From 37e5dc69c3a392f2a32347128cb3a7f663486c41 Mon Sep 17 00:00:00 2001 From: gofnnp Date: Sat, 29 Jun 2024 13:55:23 +0400 Subject: [PATCH] AW-125-feature-parameter --- src/api/resources/User.ts | 1 + .../pages/ABDesign/v1/pages/Gender/index.tsx | 7 +++++-- src/hooks/authentication/use-authentication.ts | 4 +++- src/routerComponents/ABDesign/v1/index.tsx | 2 +- src/store/index.ts | 2 ++ src/store/userConfig.ts | 10 ++++++++++ 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/api/resources/User.ts b/src/api/resources/User.ts index 3cca74a..b3252b8 100644 --- a/src/api/resources/User.ts +++ b/src/api/resources/User.ts @@ -173,6 +173,7 @@ export interface ICreateAuthorizePayload { partner?: Partial>; sign?: boolean; signDate?: string; + feature?: string; } export interface ICreateAuthorizeResponse { diff --git a/src/components/pages/ABDesign/v1/pages/Gender/index.tsx b/src/components/pages/ABDesign/v1/pages/Gender/index.tsx index fcbf23c..f46acf4 100644 --- a/src/components/pages/ABDesign/v1/pages/Gender/index.tsx +++ b/src/components/pages/ABDesign/v1/pages/Gender/index.tsx @@ -6,7 +6,7 @@ import routes from "@/routes"; import { actions, selectors } from "@/store"; import { useEffect, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; -import { useNavigate, useParams } from "react-router-dom"; +import { useLocation, useNavigate, useParams } from "react-router-dom"; import BackgroundTopBlob from "../../ui/BackgroundTopBlob"; import { useDynamicSize } from "@/hooks/useDynamicSize"; import Header from "../../components/Header"; @@ -22,6 +22,7 @@ interface IGenderPageProps { function GenderPage({ productKey }: IGenderPageProps): JSX.Element { const dispatch = useDispatch(); const navigate = useNavigate(); + const location = useLocation(); const { targetId } = useParams(); const { width: pageWidth, elementRef: pageRef } = useDynamicSize({}); const [selectedGender, setSelectedGender] = useState(null); @@ -30,9 +31,11 @@ function GenderPage({ productKey }: IGenderPageProps): JSX.Element { ); useEffect(() => { + const feature = location.pathname.replace("/v1/gender/", ""); const isShowTryApp = targetId === "i"; dispatch(actions.userConfig.addIsShowTryApp(isShowTryApp)); - }, [dispatch, targetId]); + dispatch(actions.userConfig.setFeature(feature.includes("/v1/gender") ? "" : feature)); + }, [dispatch, location.pathname, targetId]); useEffect(() => { if (privacyPolicyChecked && selectedGender) { diff --git a/src/hooks/authentication/use-authentication.ts b/src/hooks/authentication/use-authentication.ts index b2f822d..0cbeb7a 100644 --- a/src/hooks/authentication/use-authentication.ts +++ b/src/hooks/authentication/use-authentication.ts @@ -15,6 +15,7 @@ import { useDispatch, useSelector } from "react-redux"; export const useAuthentication = () => { const api = useApi(); + const feature = useSelector(selectors.selectFeature) const { i18n } = useTranslation(); const dispatch = useDispatch(); const [isLoading, setIsLoading] = useState(false); @@ -98,7 +99,8 @@ export const useAuthentication = () => { }, }, sign: checked, - signDate: dateOfCheck + signDate: dateOfCheck, + feature }) // eslint-disable-next-line react-hooks/exhaustive-deps }, [ diff --git a/src/routerComponents/ABDesign/v1/index.tsx b/src/routerComponents/ABDesign/v1/index.tsx index 1aca5c5..c3fb657 100644 --- a/src/routerComponents/ABDesign/v1/index.tsx +++ b/src/routerComponents/ABDesign/v1/index.tsx @@ -38,7 +38,7 @@ function ABDesignV1Routes() { }> }> - } /> + } /> ) { + state.feature = action.payload; + return state; + }, }, extraReducers: (builder) => builder.addCase("reset", () => initialState), }); @@ -54,4 +60,8 @@ export const selectIsForceShortPath = createSelector( (state: { userConfig: IUserConfig }) => state.userConfig.isForceShortPath, (userConfig) => userConfig ); +export const selectFeature = createSelector( + (state: { userConfig: IUserConfig }) => state.userConfig.feature, + (userConfig) => userConfig +); export default userConfigSlice.reducer;