From eb4b183fcfbcce82e4277c84dc1aeb1a62a2e480 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 21 Mar 2024 11:29:12 +0700 Subject: [PATCH 1/3] feature: Add validation flow to bank account set up --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/libs/actions/User.ts | 7 +++++++ src/pages/ReimbursementAccount/BankAccountStep.js | 15 +++++++++++++++ 4 files changed, 24 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index 29618b083bd5..60c051a289b1 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1413,6 +1413,7 @@ export default { validateAccountError: { phrase1: 'Hold up! We need you to validate your account first. To do so, ', phrase2: 'sign back in with a magic code', + phrase3: 'o verifique la cuenta aquí', }, hasPhoneLoginError: 'To add a verified bank account please ensure your primary login is a valid email and try again. You can add your phone number as a secondary login.', hasBeenThrottledError: 'There was an error adding your bank account. Please wait a few minutes and try again.', diff --git a/src/languages/es.ts b/src/languages/es.ts index 874921ee911a..811bfd2031d4 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1432,6 +1432,7 @@ export default { validateAccountError: { phrase1: '¡Un momento! Primero necesitas validar tu cuenta. Para hacerlo, ', phrase2: 'vuelve a iniciar sesión con un código mágico', + phrase3: '', }, hasPhoneLoginError: 'Para añadir una cuenta bancaria verificada, asegúrate de que tu nombre de usuario principal sea un correo electrónico válido y vuelve a intentarlo. Puedes añadir tu número de teléfono como nombre de usuario secundario.', diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 2d23edfba93f..e2bc4791d465 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -390,6 +390,13 @@ function validateSecondaryLogin(contactMethod: string, validateCode: string) { isLoading: true, }, }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.USER, + value: { + validated: true, + }, + }, ]; const successData: OnyxUpdate[] = [ { diff --git a/src/pages/ReimbursementAccount/BankAccountStep.js b/src/pages/ReimbursementAccount/BankAccountStep.js index e8aacadc6e1a..0ebcb1fe891e 100644 --- a/src/pages/ReimbursementAccount/BankAccountStep.js +++ b/src/pages/ReimbursementAccount/BankAccountStep.js @@ -20,6 +20,7 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import compose from '@libs/compose'; import getPlaidDesktopMessage from '@libs/getPlaidDesktopMessage'; +import Navigation from '@libs/Navigation/Navigation'; import variables from '@styles/variables'; import * as BankAccounts from '@userActions/BankAccounts'; import * as Link from '@userActions/Link'; @@ -83,6 +84,7 @@ function BankAccountStep(props) { props.policyID, ROUTES.WORKSPACE_INITIAL.getRoute(props.policyID), )}`; + const loginNames = _.keys(props.loginList); const removeExistingBankAccountDetails = () => { const bankAccountData = { @@ -180,6 +182,16 @@ function BankAccountStep(props) { > {props.translate('bankAccount.validateAccountError.phrase2')} + { + const login = props.loginList[loginNames[0]]; + + Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHOD_DETAILS.getRoute(login.partnerUserID || loginNames[0])); + }} + > + {props.translate('bankAccount.validateAccountError.phrase3')} + . @@ -221,5 +233,8 @@ export default compose( isPlaidDisabled: { key: ONYXKEYS.IS_PLAID_DISABLED, }, + loginList: { + key: ONYXKEYS.LOGIN_LIST, + }, }), )(BankAccountStep); From 9c6468fb447594ca2b9cb2efdac0421c392ab64b Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 20 May 2024 13:53:20 +0700 Subject: [PATCH 2/3] edit translation key --- src/languages/en.ts | 5 +++-- src/languages/es.ts | 3 ++- src/libs/actions/User.ts | 16 +++++++++------- .../ReimbursementAccount/BankAccountStep.tsx | 3 ++- .../Contacts/ContactMethodDetailsPage.tsx | 8 -------- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index cef3fb35ff5f..73b1dcf49e5a 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1509,8 +1509,9 @@ export default { checkHelpLine: 'Your routing number and account number can be found on a check for the account.', validateAccountError: { phrase1: 'Hold up! We need you to validate your account first. To do so, ', - phrase2: 'sign back in with a magic code', - phrase3: 'o verifique la cuenta aquí', + phrase2: 'sign back in with a magic code ', + phrase3: 'or ', + phrase4: 'verify the account here', }, hasPhoneLoginError: 'To add a verified bank account please ensure your primary login is a valid email and try again. You can add your phone number as a secondary login.', hasBeenThrottledError: 'There was an error adding your bank account. Please wait a few minutes and try again.', diff --git a/src/languages/es.ts b/src/languages/es.ts index d1c707019e02..42fe6333e63d 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1526,7 +1526,8 @@ export default { validateAccountError: { phrase1: '¡Un momento! Primero necesitas validar tu cuenta. Para hacerlo, ', phrase2: 'vuelve a iniciar sesión con un código mágico', - phrase3: '', + phrase3: 'o', + phrase4: 'verifique la cuenta aquí', }, hasPhoneLoginError: 'Para añadir una cuenta bancaria verificada, asegúrate de que tu nombre de usuario principal sea un correo electrónico válido y vuelve a intentarlo. Puedes añadir tu número de teléfono como nombre de usuario secundario.', diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 81e89c1224b8..8c9d4391bb46 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -22,6 +22,7 @@ import type { ValidateSecondaryLoginParams, } from '@libs/API/parameters'; import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; +import DateUtils from '@libs/DateUtils'; import * as ErrorUtils from '@libs/ErrorUtils'; import Log from '@libs/Log'; import Navigation from '@libs/Navigation/Navigation'; @@ -392,13 +393,6 @@ function validateSecondaryLogin(contactMethod: string, validateCode: string) { isLoading: true, }, }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.USER, - value: { - validated: true, - }, - }, ]; const successData: OnyxUpdate[] = [ { @@ -406,6 +400,7 @@ function validateSecondaryLogin(contactMethod: string, validateCode: string) { key: ONYXKEYS.LOGIN_LIST, value: { [contactMethod]: { + validatedDate: DateUtils.getDBTime(), pendingFields: { validateLogin: null, }, @@ -420,6 +415,13 @@ function validateSecondaryLogin(contactMethod: string, validateCode: string) { key: ONYXKEYS.ACCOUNT, value: {isLoading: false}, }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.USER, + value: { + validated: true, + }, + }, ]; const failureData: OnyxUpdate[] = [ diff --git a/src/pages/ReimbursementAccount/BankAccountStep.tsx b/src/pages/ReimbursementAccount/BankAccountStep.tsx index ca1b48590521..71b832214d80 100644 --- a/src/pages/ReimbursementAccount/BankAccountStep.tsx +++ b/src/pages/ReimbursementAccount/BankAccountStep.tsx @@ -184,6 +184,7 @@ function BankAccountStep({ > {translate('bankAccount.validateAccountError.phrase2')} + {translate('bankAccount.validateAccountError.phrase3')} { @@ -192,7 +193,7 @@ function BankAccountStep({ Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHOD_DETAILS.getRoute(login?.partnerUserID ?? loginNames?.[0])); }} > - {translate('bankAccount.validateAccountError.phrase3')} + {translate('bankAccount.validateAccountError.phrase4')} . diff --git a/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.tsx b/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.tsx index 8aaeb7151563..8aedb68e2ad8 100644 --- a/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.tsx +++ b/src/pages/settings/Profile/Contacts/ContactMethodDetailsPage.tsx @@ -23,7 +23,6 @@ import {canUseTouchScreen} from '@libs/DeviceCapabilities'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; -import * as Session from '@userActions/Session'; import * as User from '@userActions/User'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -156,13 +155,6 @@ function ContactMethodDetailsPage({route}: ContactMethodDetailsPageProps) { return; } - // If the selected contactMethod is the current session['login'] and the account is unvalidated, - // the current authToken is invalid after the successful magic code verification. - // So we need to sign out the user and redirect to the sign in page. - if (isDefaultContactMethod) { - Session.signOutAndRedirectToSignIn(); - return; - } // Navigate to methods page on successful magic code verification // validatedDate property is responsible to decide the status of the magic code verification Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS.route); From 392252f79e42a1640318fc77ee3ba4bf1fc84774 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 6 Jun 2024 14:44:52 +0700 Subject: [PATCH 3/3] update translation --- src/languages/en.ts | 2 +- src/languages/es.ts | 2 +- src/pages/ReimbursementAccount/BankAccountStep.tsx | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 7dc0cfa34bce..0d564b4daeca 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1550,7 +1550,7 @@ export default { phrase1: 'Hold up! We need you to validate your account first. To do so, ', phrase2: 'sign back in with a magic code ', phrase3: 'or ', - phrase4: 'verify the account here', + phrase4: 'verify your account here', }, hasPhoneLoginError: 'To add a verified bank account please ensure your primary login is a valid email and try again. You can add your phone number as a secondary login.', hasBeenThrottledError: 'There was an error adding your bank account. Please wait a few minutes and try again.', diff --git a/src/languages/es.ts b/src/languages/es.ts index d5475f76bcfb..3883af1c1e97 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1567,7 +1567,7 @@ export default { phrase1: '¡Un momento! Primero necesitas validar tu cuenta. Para hacerlo, ', phrase2: 'vuelve a iniciar sesión con un código mágico', phrase3: 'o', - phrase4: 'verifique la cuenta aquí', + phrase4: 'verifique tu cuenta aquí', }, hasPhoneLoginError: 'Para añadir una cuenta bancaria verificada, asegúrate de que tu nombre de usuario principal sea un correo electrónico válido y vuelve a intentarlo. Puedes añadir tu número de teléfono como nombre de usuario secundario.', diff --git a/src/pages/ReimbursementAccount/BankAccountStep.tsx b/src/pages/ReimbursementAccount/BankAccountStep.tsx index 71b832214d80..71de41be9ff1 100644 --- a/src/pages/ReimbursementAccount/BankAccountStep.tsx +++ b/src/pages/ReimbursementAccount/BankAccountStep.tsx @@ -189,7 +189,6 @@ function BankAccountStep({ fontSize={variables.fontSizeLabel} onPress={() => { const login = loginList?.[loginNames?.[0]] ?? {}; - Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHOD_DETAILS.getRoute(login?.partnerUserID ?? loginNames?.[0])); }} >