Skip to content

Commit

Permalink
Merge pull request #3863 from thematters/feat/sign-up-lang
Browse files Browse the repository at this point in the history
fix(signup): pass langauge to sign up mutations
  • Loading branch information
robertu7 authored Oct 5, 2023
2 parents c81b856 + 6a7c242 commit 4b235d7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/components/Forms/EmailLoginForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ export const EmailLoginForm: React.FC<FormProps> = ({
try {
setIsSubmitting(true)
const { data } = await login({
variables: { input: { email, passwordOrCode: password } },
variables: {
input: { email, passwordOrCode: password, language: lang },
},
})

const token = data?.emailLogin.token || ''
Expand Down
6 changes: 2 additions & 4 deletions src/components/Forms/WalletAuthForm/Connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const Connect: React.FC<FormProps> = ({
if (isLogin) {
// confirm auth
const { data: loginData } = await walletLogin({
variables,
variables: { input: { ...variables.input, language: lang } },
})

const token = loginData?.walletLogin.token || ''
Expand All @@ -216,9 +216,7 @@ const Connect: React.FC<FormProps> = ({
}

if (isConnect) {
await addWalletLogin({
variables: variables,
})
await addWalletLogin({ variables })

toast.success({
message: (
Expand Down
6 changes: 4 additions & 2 deletions src/views/Callback/LoginCallback.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useEffect, useState } from 'react'
import { useContext, useEffect, useState } from 'react'

import {
COOKIE_LANGUAGE,
COOKIE_TOKEN_NAME,
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'

Expand All @@ -19,6 +19,7 @@ const LoginCallback = () => {
showToast: false,
})

const { lang } = useContext(LanguageContext)
const [hasError, setHasError] = useState(false)
const { getQuery } = useRoute()
const email = getQuery('email')
Expand All @@ -32,6 +33,7 @@ const LoginCallback = () => {
input: {
email,
passwordOrCode: code,
language: lang,
},
},
})
Expand Down
12 changes: 10 additions & 2 deletions src/views/Callback/SocialCallback.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react'
import { useContext, useEffect, useState } from 'react'

import {
COOKIE_LANGUAGE,
Expand All @@ -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,
Expand All @@ -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')
Expand Down Expand Up @@ -73,6 +80,7 @@ const SocialCallback = ({ type }: Props) => {
nonce: localNonce,
codeVerifier: localCodeVerifier,
authorizationCode: code,
language: lang,
},
},
})
Expand Down

1 comment on commit 4b235d7

@vercel
Copy link

@vercel vercel bot commented on 4b235d7 Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.