From 412bc42588525300ce568dd8d1eedc56b3ca20fb Mon Sep 17 00:00:00 2001 From: Getabalew Date: Tue, 22 Oct 2024 19:01:47 +0300 Subject: [PATCH 01/13] fix: reuse validate-code-action-moda in wallet settings page --- .../settings/Wallet/VerifyAccountPage.tsx | 55 +++++++------------ 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/src/pages/settings/Wallet/VerifyAccountPage.tsx b/src/pages/settings/Wallet/VerifyAccountPage.tsx index 0755ff3a932b..0b828323ad4e 100644 --- a/src/pages/settings/Wallet/VerifyAccountPage.tsx +++ b/src/pages/settings/Wallet/VerifyAccountPage.tsx @@ -1,15 +1,8 @@ import type {StackScreenProps} from '@react-navigation/stack'; -import React, {useCallback, useEffect, useRef} from 'react'; -import {View} from 'react-native'; +import React, {useCallback, useEffect, useState} from 'react'; import {useOnyx} from 'react-native-onyx'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import type {AnimatedTextInputRef} from '@components/RNTextInput'; -import ScreenWrapper from '@components/ScreenWrapper'; -import Text from '@components/Text'; -import ValidateCodeForm from '@components/ValidateCodeActionModal/ValidateCodeForm'; import useLocalize from '@hooks/useLocalize'; import useSafePaddingBottomStyle from '@hooks/useSafePaddingBottomStyle'; -import useThemeStyles from '@hooks/useThemeStyles'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; @@ -17,6 +10,7 @@ import * as User from '@userActions/User'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; +import ValidateCodeActionModal from "@components/ValidateCodeActionModal"; type VerifyAccountPageProps = StackScreenProps; @@ -24,16 +18,11 @@ function VerifyAccountPage({route}: VerifyAccountPageProps) { const [account] = useOnyx(ONYXKEYS.ACCOUNT); const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST); const contactMethod = account?.primaryLogin ?? ''; - const themeStyles = useThemeStyles(); const {translate} = useLocalize(); - const safePaddingBottomStyle = useSafePaddingBottomStyle(); - const loginInputRef = useRef(null); const loginData = loginList?.[contactMethod]; - const styles = useThemeStyles(); const validateLoginError = ErrorUtils.getEarliestErrorField(loginData, 'validateLogin'); const [isUserValidated] = useOnyx(ONYXKEYS.USER, {selector: (user) => !!user?.validated}); - - const [validateCodeAction] = useOnyx(ONYXKEYS.VALIDATE_ACTION_CODE); + const [isValidateCodeActionModalVisible, setIsValidateCodeActionModalVisible] = useState(true); const navigateBackTo = route?.params?.backTo ?? ROUTES.SETTINGS_WALLET; @@ -55,31 +44,25 @@ function VerifyAccountPage({route}: VerifyAccountPageProps) { return; } Navigation.navigate(navigateBackTo); + setIsValidateCodeActionModalVisible(false); }, [isUserValidated, navigateBackTo]); return ( - loginInputRef.current?.focus()} - includeSafeAreaPaddingBottom={false} - shouldEnableMaxHeight - testID={VerifyAccountPage.displayName} - > - Navigation.goBack(ROUTES.SETTINGS_WALLET)} - /> - - {translate('contacts.featureRequiresValidate')} - User.requestValidateCodeAction()} - validateCodeAction={validateCodeAction} - validateError={validateLoginError} - handleSubmitForm={handleSubmitForm} - clearError={clearError} - buttonStyles={[styles.justifyContentEnd, styles.flex1, safePaddingBottomStyle]} - /> - - + User.requestValidateCodeAction()} + handleSubmitForm={handleSubmitForm} + validateError={validateLoginError} + isVisible={isValidateCodeActionModalVisible} + title={translate('contacts.validateAccount')} + description={translate('contacts.featureRequiresValidate')} + onClose={() => { + setIsValidateCodeActionModalVisible(false) + if (!isUserValidated) { + Navigation.navigate(ROUTES.SETTINGS_WALLET); + } + }} + clearError={clearError} + /> ); } From 240e285261395b0c88bfd8cf76c4b2f784b03dc4 Mon Sep 17 00:00:00 2001 From: Getabalew Date: Tue, 22 Oct 2024 19:07:26 +0300 Subject: [PATCH 02/13] fix: lint --- src/pages/settings/Wallet/VerifyAccountPage.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/settings/Wallet/VerifyAccountPage.tsx b/src/pages/settings/Wallet/VerifyAccountPage.tsx index 0b828323ad4e..0d7673b7b918 100644 --- a/src/pages/settings/Wallet/VerifyAccountPage.tsx +++ b/src/pages/settings/Wallet/VerifyAccountPage.tsx @@ -1,8 +1,8 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useCallback, useEffect, useState} from 'react'; import {useOnyx} from 'react-native-onyx'; +import ValidateCodeActionModal from '@components/ValidateCodeActionModal'; import useLocalize from '@hooks/useLocalize'; -import useSafePaddingBottomStyle from '@hooks/useSafePaddingBottomStyle'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; @@ -10,7 +10,6 @@ import * as User from '@userActions/User'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; -import ValidateCodeActionModal from "@components/ValidateCodeActionModal"; type VerifyAccountPageProps = StackScreenProps; @@ -56,7 +55,7 @@ function VerifyAccountPage({route}: VerifyAccountPageProps) { title={translate('contacts.validateAccount')} description={translate('contacts.featureRequiresValidate')} onClose={() => { - setIsValidateCodeActionModalVisible(false) + setIsValidateCodeActionModalVisible(false); if (!isUserValidated) { Navigation.navigate(ROUTES.SETTINGS_WALLET); } From 2ef718aaa8fe4530e9014927010772ca386856c0 Mon Sep 17 00:00:00 2001 From: Getabalew Date: Tue, 22 Oct 2024 20:17:08 +0300 Subject: [PATCH 03/13] fix: unvalidated copilot not navigating to magic code modal --- src/ROUTES.ts | 5 ++++- src/libs/Navigation/types.ts | 1 + .../Security/AddDelegate/ConfirmDelegatePage.tsx | 10 +++++++++- .../Security/AddDelegate/DelegateMagicCodeModal.tsx | 4 +++- src/pages/settings/Security/SecuritySettingsPage.tsx | 3 +++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index cf15013fed9b..cf0f620dcbf9 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -148,7 +148,10 @@ const ROUTES = { }, SETTINGS_DELEGATE_CONFIRM: { route: 'settings/security/delegate/:login/role/:role/confirm', - getRoute: (login: string, role: string) => `settings/security/delegate/${encodeURIComponent(login)}/role/${role}/confirm` as const, + getRoute: (login: string, role: string, showValidateActionModal?: boolean) => { + const validateActionModalParam = showValidateActionModal ? `?showValidateActionModal=true` : ''; + return `settings/security/delegate/${encodeURIComponent(login)}/role/${role}/confirm${validateActionModalParam}` as const + } }, SETTINGS_ABOUT: 'settings/about', SETTINGS_APP_DOWNLOAD_LINKS: 'settings/about/app-download-links', diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 0aa6e7474329..377805a184ec 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -752,6 +752,7 @@ type SettingsNavigatorParamList = { [SCREENS.SETTINGS.DELEGATE.DELEGATE_CONFIRM]: { login: string; role: string; + showValidateActionModal?: boolean; }; [SCREENS.SETTINGS.REPORT_CARD_LOST_OR_DAMAGED]: { /** cardID of selected card */ diff --git a/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx b/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx index c769734688c6..47b8e70570bb 100644 --- a/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx +++ b/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx @@ -27,9 +27,10 @@ function ConfirmDelegatePage({route}: ConfirmDelegatePageProps) { const styles = useThemeStyles(); const login = route.params.login; const role = route.params.role as ValueOf; + const showValidateActionModal = route.params.showValidateActionModal; const {isOffline} = useNetwork(); - const [isValidateCodeActionModalVisible, setIsValidateCodeActionModalVisible] = useState(false); + const [isValidateCodeActionModalVisible, setIsValidateCodeActionModalVisible] = useState(showValidateActionModal ?? false); const personalDetails = PersonalDetailsUtils.getPersonalDetailByEmail(login); const avatarIcon = personalDetails?.avatar ?? FallbackAvatar; @@ -77,6 +78,13 @@ function ConfirmDelegatePage({route}: ConfirmDelegatePageProps) { { + if (!showValidateActionModal) { + return; + } + + Navigation.navigate(ROUTES.SETTINGS_SECURITY); + }} /> )} diff --git a/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx b/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx index 64b8d27dfd73..dd54aa5b9404 100644 --- a/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx +++ b/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx @@ -14,9 +14,10 @@ import ROUTES from '@src/ROUTES'; type DelegateMagicCodeModalProps = { login: string; role: ValueOf; + onClose?: () => void; }; -function DelegateMagicCodeModal({login, role}: DelegateMagicCodeModalProps) { +function DelegateMagicCodeModal({login, role, onClose}: DelegateMagicCodeModalProps) { const {translate} = useLocalize(); const [account] = useOnyx(ONYXKEYS.ACCOUNT); const [isValidateCodeActionModalVisible, setIsValidateCodeActionModalVisible] = useState(true); @@ -34,6 +35,7 @@ function DelegateMagicCodeModal({login, role}: DelegateMagicCodeModalProps) { }, [login, currentDelegate, role]); const onBackButtonPress = () => { + onClose?.(); setIsValidateCodeActionModalVisible(false); }; diff --git a/src/pages/settings/Security/SecuritySettingsPage.tsx b/src/pages/settings/Security/SecuritySettingsPage.tsx index 88908dbdc1d6..42352594db7a 100644 --- a/src/pages/settings/Security/SecuritySettingsPage.tsx +++ b/src/pages/settings/Security/SecuritySettingsPage.tsx @@ -151,7 +151,10 @@ function SecuritySettingsPage() { } if (pendingFields?.role && !pendingFields?.email) { Navigation.navigate(ROUTES.SETTINGS_UPDATE_DELEGATE_ROLE.getRoute(email, role)); + return; } + + Navigation.navigate(ROUTES.SETTINGS_DELEGATE_CONFIRM.getRoute(email, role, true)); }; const formattedEmail = formatPhoneNumber(email); From f226c894d653eab6d2d24b0e08dc4edf0021430c Mon Sep 17 00:00:00 2001 From: Getabalew Date: Tue, 22 Oct 2024 20:33:05 +0300 Subject: [PATCH 04/13] fix: lint --- src/ROUTES.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index cf0f620dcbf9..5ed6afd3b034 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -150,8 +150,8 @@ const ROUTES = { route: 'settings/security/delegate/:login/role/:role/confirm', getRoute: (login: string, role: string, showValidateActionModal?: boolean) => { const validateActionModalParam = showValidateActionModal ? `?showValidateActionModal=true` : ''; - return `settings/security/delegate/${encodeURIComponent(login)}/role/${role}/confirm${validateActionModalParam}` as const - } + return `settings/security/delegate/${encodeURIComponent(login)}/role/${role}/confirm${validateActionModalParam}` as const; + }, }, SETTINGS_ABOUT: 'settings/about', SETTINGS_APP_DOWNLOAD_LINKS: 'settings/about/app-download-links', From 1adf30391373d78d5a69f5105d702bc7c21460d7 Mon Sep 17 00:00:00 2001 From: Getabalew Date: Tue, 22 Oct 2024 21:15:36 +0300 Subject: [PATCH 05/13] fix: duplicate magic code call --- src/components/ValidateAccountMessage.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/components/ValidateAccountMessage.tsx b/src/components/ValidateAccountMessage.tsx index d9810e859bfa..add6f9cb5d70 100644 --- a/src/components/ValidateAccountMessage.tsx +++ b/src/components/ValidateAccountMessage.tsx @@ -44,9 +44,6 @@ function ValidateAccountMessage({backTo}: ValidateAccountMessageProps) { onPress={() => { const loginName = loginNames?.at(0); const login = loginList?.[loginName ?? ''] ?? {}; - if (!login?.validatedDate && !login?.validateCodeSent) { - User.requestContactMethodValidateCode(loginName ?? ''); - } Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHOD_DETAILS.getRoute(login?.partnerUserID ?? loginNames?.at(0) ?? '', backTo)); }} From 50996795e82d8ea430708e4e25aa016213b4ac28 Mon Sep 17 00:00:00 2001 From: Getabalew Date: Tue, 22 Oct 2024 22:29:11 +0300 Subject: [PATCH 06/13] fix: duplicate form submission --- .../ValidateCodeForm/BaseValidateCodeForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx b/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx index 9207b9158051..c7e14798dd8e 100644 --- a/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx +++ b/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx @@ -174,6 +174,7 @@ function BaseValidateCodeForm({ } setFormError({}); + console.log('calling addNewContactMethod 2') handleSubmitForm(validateCode); }, [validateCode, handleSubmitForm]); @@ -232,7 +233,6 @@ function BaseValidateCodeForm({ onPress={validateAndSubmitForm} style={[styles.mt4]} success - pressOnEnter large isLoading={account?.isLoading} /> From 4948a3ae2c8fbb5bd758fa905bbe6bfc67af7b77 Mon Sep 17 00:00:00 2001 From: Getabalew Date: Tue, 22 Oct 2024 22:33:37 +0300 Subject: [PATCH 07/13] fix: lint --- .../ValidateCodeForm/BaseValidateCodeForm.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx b/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx index c7e14798dd8e..02121ce26906 100644 --- a/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx +++ b/src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx @@ -174,7 +174,6 @@ function BaseValidateCodeForm({ } setFormError({}); - console.log('calling addNewContactMethod 2') handleSubmitForm(validateCode); }, [validateCode, handleSubmitForm]); From 719f970841872aa8b8e4ac119e2a33048597603d Mon Sep 17 00:00:00 2001 From: Getabalew Date: Tue, 22 Oct 2024 22:34:02 +0300 Subject: [PATCH 08/13] fix: lint --- src/components/ValidateAccountMessage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/ValidateAccountMessage.tsx b/src/components/ValidateAccountMessage.tsx index add6f9cb5d70..d27e2704af3c 100644 --- a/src/components/ValidateAccountMessage.tsx +++ b/src/components/ValidateAccountMessage.tsx @@ -7,7 +7,6 @@ import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; import variables from '@styles/variables'; import * as Session from '@userActions/Session'; -import * as User from '@userActions/User'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import Icon from './Icon'; From 373832e7def33968fbd4faeee9bef43a07c18ce0 Mon Sep 17 00:00:00 2001 From: Getabalew Date: Wed, 23 Oct 2024 00:31:50 +0300 Subject: [PATCH 09/13] fix: use the correct type for showValidateActionModal --- src/libs/Navigation/types.ts | 2 +- src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 377805a184ec..db92328b7a51 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -752,7 +752,7 @@ type SettingsNavigatorParamList = { [SCREENS.SETTINGS.DELEGATE.DELEGATE_CONFIRM]: { login: string; role: string; - showValidateActionModal?: boolean; + showValidateActionModal?: string; }; [SCREENS.SETTINGS.REPORT_CARD_LOST_OR_DAMAGED]: { /** cardID of selected card */ diff --git a/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx b/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx index 47b8e70570bb..ea9a1da690e8 100644 --- a/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx +++ b/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx @@ -27,7 +27,7 @@ function ConfirmDelegatePage({route}: ConfirmDelegatePageProps) { const styles = useThemeStyles(); const login = route.params.login; const role = route.params.role as ValueOf; - const showValidateActionModal = route.params.showValidateActionModal; + const showValidateActionModal = route.params.showValidateActionModal === 'true'; const {isOffline} = useNetwork(); const [isValidateCodeActionModalVisible, setIsValidateCodeActionModalVisible] = useState(showValidateActionModal ?? false); From e02c563b385a5155012071339aba3bda84ae1887 Mon Sep 17 00:00:00 2001 From: Getabalew Date: Wed, 23 Oct 2024 01:02:16 +0300 Subject: [PATCH 10/13] fix: navigation back issues --- src/components/SettlementButton/index.tsx | 2 +- src/pages/settings/Wallet/VerifyAccountPage.tsx | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/SettlementButton/index.tsx b/src/components/SettlementButton/index.tsx index d1d0ff8ccb71..4c3c9adf8ef1 100644 --- a/src/components/SettlementButton/index.tsx +++ b/src/components/SettlementButton/index.tsx @@ -191,7 +191,7 @@ function SettlementButton({ if (iouPaymentType === CONST.IOU.PAYMENT_TYPE.EXPENSIFY || iouPaymentType === CONST.IOU.PAYMENT_TYPE.VBBA) { if (!isUserValidated) { - Navigation.navigate(ROUTES.SETTINGS_WALLET_VERIFY_ACCOUNT.getRoute(ROUTES.SETTINGS_ADD_BANK_ACCOUNT)); + Navigation.navigate(ROUTES.SETTINGS_WALLET_VERIFY_ACCOUNT.route); return; } triggerKYCFlow(event, iouPaymentType); diff --git a/src/pages/settings/Wallet/VerifyAccountPage.tsx b/src/pages/settings/Wallet/VerifyAccountPage.tsx index 0d7673b7b918..4bb4acce3db3 100644 --- a/src/pages/settings/Wallet/VerifyAccountPage.tsx +++ b/src/pages/settings/Wallet/VerifyAccountPage.tsx @@ -23,7 +23,7 @@ function VerifyAccountPage({route}: VerifyAccountPageProps) { const [isUserValidated] = useOnyx(ONYXKEYS.USER, {selector: (user) => !!user?.validated}); const [isValidateCodeActionModalVisible, setIsValidateCodeActionModalVisible] = useState(true); - const navigateBackTo = route?.params?.backTo ?? ROUTES.SETTINGS_WALLET; + const navigateBackTo = route?.params?.backTo; useEffect(() => () => User.clearUnvalidatedNewContactMethodAction(), []); @@ -42,13 +42,19 @@ function VerifyAccountPage({route}: VerifyAccountPageProps) { if (!isUserValidated) { return; } - Navigation.navigate(navigateBackTo); + setIsValidateCodeActionModalVisible(false); + + if(!navigateBackTo) { + return; + } + + Navigation.navigate(navigateBackTo); }, [isUserValidated, navigateBackTo]); return ( User.requestValidateCodeAction()} + sendValidateCode={() => {}} handleSubmitForm={handleSubmitForm} validateError={validateLoginError} isVisible={isValidateCodeActionModalVisible} @@ -56,7 +62,7 @@ function VerifyAccountPage({route}: VerifyAccountPageProps) { description={translate('contacts.featureRequiresValidate')} onClose={() => { setIsValidateCodeActionModalVisible(false); - if (!isUserValidated) { + if (!isUserValidated && navigateBackTo) { Navigation.navigate(ROUTES.SETTINGS_WALLET); } }} From dfc51a3e54fd55ff13dbd0e862300c7f7511395e Mon Sep 17 00:00:00 2001 From: Getabalew Date: Wed, 23 Oct 2024 01:04:47 +0300 Subject: [PATCH 11/13] fix: lint --- src/pages/settings/Wallet/VerifyAccountPage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/settings/Wallet/VerifyAccountPage.tsx b/src/pages/settings/Wallet/VerifyAccountPage.tsx index 4bb4acce3db3..367de4a50c1d 100644 --- a/src/pages/settings/Wallet/VerifyAccountPage.tsx +++ b/src/pages/settings/Wallet/VerifyAccountPage.tsx @@ -42,13 +42,13 @@ function VerifyAccountPage({route}: VerifyAccountPageProps) { if (!isUserValidated) { return; } - + setIsValidateCodeActionModalVisible(false); - if(!navigateBackTo) { + if (!navigateBackTo) { return; } - + Navigation.navigate(navigateBackTo); }, [isUserValidated, navigateBackTo]); @@ -62,7 +62,7 @@ function VerifyAccountPage({route}: VerifyAccountPageProps) { description={translate('contacts.featureRequiresValidate')} onClose={() => { setIsValidateCodeActionModalVisible(false); - if (!isUserValidated && navigateBackTo) { + if (!isUserValidated && navigateBackTo) { Navigation.navigate(ROUTES.SETTINGS_WALLET); } }} From ea374a8ca6d5c474b3224687c88c6e7e11442362 Mon Sep 17 00:00:00 2001 From: Getabalew Date: Wed, 23 Oct 2024 02:06:25 +0300 Subject: [PATCH 12/13] fix: navigation back issues --- .../settings/Wallet/VerifyAccountPage.tsx | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/pages/settings/Wallet/VerifyAccountPage.tsx b/src/pages/settings/Wallet/VerifyAccountPage.tsx index 367de4a50c1d..b3f6264440af 100644 --- a/src/pages/settings/Wallet/VerifyAccountPage.tsx +++ b/src/pages/settings/Wallet/VerifyAccountPage.tsx @@ -52,20 +52,27 @@ function VerifyAccountPage({route}: VerifyAccountPageProps) { Navigation.navigate(navigateBackTo); }, [isUserValidated, navigateBackTo]); + useEffect(() => { + if (isValidateCodeActionModalVisible) { + return; + } + + if (!isUserValidated && navigateBackTo) { + Navigation.navigate(ROUTES.SETTINGS_WALLET); + } else if (!navigateBackTo) { + Navigation.goBack(); + } + }, [isValidateCodeActionModalVisible]); + return ( {}} + sendValidateCode={() => User.requestValidateCodeAction()} handleSubmitForm={handleSubmitForm} validateError={validateLoginError} isVisible={isValidateCodeActionModalVisible} title={translate('contacts.validateAccount')} description={translate('contacts.featureRequiresValidate')} - onClose={() => { - setIsValidateCodeActionModalVisible(false); - if (!isUserValidated && navigateBackTo) { - Navigation.navigate(ROUTES.SETTINGS_WALLET); - } - }} + onClose={() => setIsValidateCodeActionModalVisible(false)} clearError={clearError} /> ); From 9c7c9d9e3b9379e1f0722c7f60665dc23480611e Mon Sep 17 00:00:00 2001 From: Getabalew Date: Wed, 23 Oct 2024 02:08:57 +0300 Subject: [PATCH 13/13] fix: lint --- src/pages/settings/Wallet/VerifyAccountPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/settings/Wallet/VerifyAccountPage.tsx b/src/pages/settings/Wallet/VerifyAccountPage.tsx index b3f6264440af..a3b51ef0de17 100644 --- a/src/pages/settings/Wallet/VerifyAccountPage.tsx +++ b/src/pages/settings/Wallet/VerifyAccountPage.tsx @@ -62,7 +62,7 @@ function VerifyAccountPage({route}: VerifyAccountPageProps) { } else if (!navigateBackTo) { Navigation.goBack(); } - }, [isValidateCodeActionModalVisible]); + }, [isValidateCodeActionModalVisible, isUserValidated, navigateBackTo]); return (