From c9a6f71b82c61e3797651675e259ab3dcf653964 Mon Sep 17 00:00:00 2001 From: Daniil Chemerkin Date: Mon, 6 May 2024 21:42:06 +0000 Subject: [PATCH] Develop --- src/api/resources/User.ts | 1 + src/components/App/index.tsx | 3 ++- src/components/PaymentPage/results/SuccessPage/index.tsx | 2 +- src/hooks/authentication/use-authentication.ts | 8 +++++++- src/types.ts | 8 ++++++++ 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/api/resources/User.ts b/src/api/resources/User.ts index 34e5e88..17fd629 100644 --- a/src/api/resources/User.ts +++ b/src/api/resources/User.ts @@ -174,6 +174,7 @@ export interface ICreateAuthorizePayload { export interface ICreateAuthorizeResponse { token: string; + userId?: string; } export const createAuthorizeRequest = (data: ICreateAuthorizePayload): Request => { diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx index 2d70791..019d905 100755 --- a/src/components/App/index.tsx +++ b/src/components/App/index.tsx @@ -228,7 +228,8 @@ function App(): JSX.Element { return dispatch(actions.status.update("lead")); } })(); - }, [dispatch, api, token, user]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [dispatch, api, token]); useEffect(() => { async function getApng() { diff --git a/src/components/PaymentPage/results/SuccessPage/index.tsx b/src/components/PaymentPage/results/SuccessPage/index.tsx index 59966ed..6a9b04e 100644 --- a/src/components/PaymentPage/results/SuccessPage/index.tsx +++ b/src/components/PaymentPage/results/SuccessPage/index.tsx @@ -13,7 +13,7 @@ function PaymentSuccessPage(): JSX.Element { const dispatch = useDispatch(); const handleNext = () => { dispatch(actions.status.update("subscribed")); - navigate(routes.client.home()); + navigate(routes.client.addReport()); }; return ( diff --git a/src/hooks/authentication/use-authentication.ts b/src/hooks/authentication/use-authentication.ts index ced36ca..fbf89db 100644 --- a/src/hooks/authentication/use-authentication.ts +++ b/src/hooks/authentication/use-authentication.ts @@ -114,7 +114,13 @@ export const useAuthentication = () => { try { setIsLoading(true); const payload = getAuthorizationPayload(email, source); - const { token } = await api.authorization(payload); + const { token, userId } = await api.authorization(payload); + if (userId?.length && !!window.ym) { + window.ym(95799066, 'userParams', { + UserID: userId + }) + window.ym(95799066, 'setUserID', userId); + } const { user } = await api.getUser({ token }); signUp(token, user); setToken(token); diff --git a/src/types.ts b/src/types.ts index c664802..6adc00a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -22,3 +22,11 @@ export interface SignupForm { } export type UserStatus = "lead" | "registred" | "subscribed" | "unsubscribed"; + +declare global { + interface Window { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ym: any; + } +} +