From 6a7c242f95eccaaf647db53090f90d9f72d722b1 Mon Sep 17 00:00:00 2001 From: robertu <4065233+robertu7@users.noreply.github.com> Date: Wed, 4 Oct 2023 17:35:24 +0700 Subject: [PATCH] fix(signup): pass langauge to sign up mutations refs: - 202309-product#ZN-0032 --- src/components/Forms/EmailLoginForm/index.tsx | 4 +++- src/components/Forms/WalletAuthForm/Connect.tsx | 6 ++---- src/views/Callback/LoginCallback.tsx | 6 ++++-- src/views/Callback/SocialCallback.tsx | 12 ++++++++++-- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/components/Forms/EmailLoginForm/index.tsx b/src/components/Forms/EmailLoginForm/index.tsx index 69928f0421..dbcc288f42 100644 --- a/src/components/Forms/EmailLoginForm/index.tsx +++ b/src/components/Forms/EmailLoginForm/index.tsx @@ -127,7 +127,9 @@ export const EmailLoginForm: React.FC = ({ try { setIsSubmitting(true) const { data } = await login({ - variables: { input: { email, passwordOrCode: password } }, + variables: { + input: { email, passwordOrCode: password, language: lang }, + }, }) const token = data?.emailLogin.token || '' diff --git a/src/components/Forms/WalletAuthForm/Connect.tsx b/src/components/Forms/WalletAuthForm/Connect.tsx index 17af650390..1d4d41277f 100644 --- a/src/components/Forms/WalletAuthForm/Connect.tsx +++ b/src/components/Forms/WalletAuthForm/Connect.tsx @@ -189,7 +189,7 @@ const Connect: React.FC = ({ if (isLogin) { // confirm auth const { data: loginData } = await walletLogin({ - variables, + variables: { input: { ...variables.input, language: lang } }, }) const token = loginData?.walletLogin.token || '' @@ -216,9 +216,7 @@ const Connect: React.FC = ({ } if (isConnect) { - await addWalletLogin({ - variables: variables, - }) + await addWalletLogin({ variables }) toast.success({ message: ( diff --git a/src/views/Callback/LoginCallback.tsx b/src/views/Callback/LoginCallback.tsx index 096e8af96b..0c23bda9a3 100644 --- a/src/views/Callback/LoginCallback.tsx +++ b/src/views/Callback/LoginCallback.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react' +import { useContext, useEffect, useState } from 'react' import { COOKIE_LANGUAGE, @@ -6,7 +6,7 @@ import { COOKIE_USER_GROUP, } from '~/common/enums' import { redirectToTarget, setCookies } from '~/common/utils' -import { useMutation, useRoute } from '~/components' +import { LanguageContext, useMutation, useRoute } from '~/components' import { EMAIL_LOGIN } from '~/components/GQL/mutations/emailLogin' import { EmailLoginMutation } from '~/gql/graphql' @@ -19,6 +19,7 @@ const LoginCallback = () => { showToast: false, }) + const { lang } = useContext(LanguageContext) const [hasError, setHasError] = useState(false) const { getQuery } = useRoute() const email = getQuery('email') @@ -32,6 +33,7 @@ const LoginCallback = () => { input: { email, passwordOrCode: code, + language: lang, }, }, }) diff --git a/src/views/Callback/SocialCallback.tsx b/src/views/Callback/SocialCallback.tsx index e84efbb55f..3fe28f7f76 100644 --- a/src/views/Callback/SocialCallback.tsx +++ b/src/views/Callback/SocialCallback.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react' +import { useContext, useEffect, useState } from 'react' import { COOKIE_LANGUAGE, @@ -14,7 +14,12 @@ import { OAUTH_TYPE, } from '~/common/enums' import { analytics, setCookies, storage } from '~/common/utils' -import { getErrorCodes, useMutation, useRoute } from '~/components' +import { + getErrorCodes, + LanguageContext, + useMutation, + useRoute, +} from '~/components' import { AddSocialLoginMutation, SocialAccountType, @@ -41,6 +46,8 @@ const SocialCallback = ({ type }: Props) => { showToast: false, } ) + const { lang } = useContext(LanguageContext) + const [hasError, setHasError] = useState(false) const { getQuery } = useRoute() const state = getQuery('state') @@ -73,6 +80,7 @@ const SocialCallback = ({ type }: Props) => { nonce: localNonce, codeVerifier: localCodeVerifier, authorizationCode: code, + language: lang, }, }, })