From b1d3752cecb3e5b17d7ca4741de5019262ea3009 Mon Sep 17 00:00:00 2001 From: Nathalie Kuoch Date: Thu, 16 Nov 2023 17:09:20 +0100 Subject: [PATCH] Change vbba step order --- src/CONST.ts | 2 +- src/libs/Permissions.ts | 5 +++ src/libs/actions/BankAccounts.ts | 23 ++++++++-- src/pages/ReimbursementAccount/CompanyStep.js | 6 +-- .../ReimbursementAccountPage.js | 44 +++++++++---------- 5 files changed, 51 insertions(+), 29 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 13b79179f431..0e220e316a27 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -187,8 +187,8 @@ const CONST = { STEP: { // In the order they appear in the VBA flow BANK_ACCOUNT: 'BankAccountStep', - COMPANY: 'CompanyStep', REQUESTOR: 'RequestorStep', + COMPANY: 'CompanyStep', ACH_CONTRACT: 'ACHContractStep', VALIDATION: 'ValidationStep', ENABLE: 'EnableStep', diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 43e7ef9fbbc8..05c7ee94ff60 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -38,11 +38,16 @@ function canUseLinkPreviews(): boolean { return false; } +function canUseNewVbbaFlow(): boolean { + return true; +} + export default { canUseChronos, canUseDefaultRooms, canUseCommentLinking, canUsePolicyRooms, canUseLinkPreviews, + canUseNewVbbaFlow, canUseViolations, }; diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts index 8d0c59ab8d60..11a3aace610d 100644 --- a/src/libs/actions/BankAccounts.ts +++ b/src/libs/actions/BankAccounts.ts @@ -5,6 +5,7 @@ import Navigation from '@libs/Navigation/Navigation'; import * as PlaidDataProps from '@pages/ReimbursementAccount/plaidDataPropTypes'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import Permissions from '@libs/Permissions'; import ROUTES from '@src/ROUTES'; import type PlaidBankAccount from '@src/types/onyx/PlaidBankAccount'; import type {BankAccountStep, BankAccountSubStep} from '@src/types/onyx/ReimbursementAccount'; @@ -132,6 +133,7 @@ function connectBankAccountWithPlaid(bankAccountID: number, selectedPlaidBankAcc bank?: string; plaidAccountID: string; plaidAccessToken: string; + canUseNewVbbaFlow: boolean; }; const parameters: ConnectBankAccountWithPlaidParams = { @@ -141,6 +143,7 @@ function connectBankAccountWithPlaid(bankAccountID: number, selectedPlaidBankAcc bank: selectedPlaidBankAccount.bankName, plaidAccountID: selectedPlaidBankAccount.plaidAccountID, plaidAccessToken: selectedPlaidBankAccount.plaidAccessToken, + canUseNewVbbaFlow: Permissions.canUseNewVbbaFlow(), }; API.write(commandName, parameters, getVBBADataForOnyx()); @@ -248,7 +251,10 @@ function deletePaymentBankAccount(bankAccountID: number) { * This action is called by the requestor step in the Verified Bank Account flow */ function updatePersonalInformationForBankAccount(params: RequestorStepProps) { - API.write('UpdatePersonalInformationForBankAccount', params, getVBBADataForOnyx(CONST.BANK_ACCOUNT.STEP.REQUESTOR)); + API.write('UpdatePersonalInformationForBankAccount', { + ...params, + canUseNewVbbaFlow: Permissions.canUseNewVbbaFlow(), + }, getVBBADataForOnyx(CONST.BANK_ACCOUNT.STEP.REQUESTOR)); } function validateBankAccount(bankAccountID: number, validateCode: string) { @@ -350,9 +356,16 @@ function openReimbursementAccountPage(stepToOpen: ReimbursementAccountStep, subS * Updates the bank account in the database with the company step data */ function updateCompanyInformationForBankAccount(bankAccount: BankAccountCompanyInformation, policyID: string) { - type UpdateCompanyInformationForBankAccountParams = BankAccountCompanyInformation & {policyID: string}; + type UpdateCompanyInformationForBankAccountParams = BankAccountCompanyInformation & { + policyID: string, + canUseNewVbbaFlow: boolean, + }; - const parameters: UpdateCompanyInformationForBankAccountParams = {...bankAccount, policyID}; + const parameters: UpdateCompanyInformationForBankAccountParams = { + ...bankAccount, + policyID, + canUseNewVbbaFlow: Permissions.canUseNewVbbaFlow(), + }; API.write('UpdateCompanyInformationForBankAccount', parameters, getVBBADataForOnyx(CONST.BANK_ACCOUNT.STEP.COMPANY)); } @@ -374,6 +387,7 @@ function connectBankAccountManually(bankAccountID: number, accountNumber?: strin accountNumber?: string; routingNumber?: string; plaidMask?: string; + canUseNewVbbaFlow: boolean; }; const parameters: ConnectBankAccountManuallyParams = { @@ -381,6 +395,7 @@ function connectBankAccountManually(bankAccountID: number, accountNumber?: strin accountNumber, routingNumber, plaidMask, + canUseNewVbbaFlow: Permissions.canUseNewVbbaFlow(), }; API.write('ConnectBankAccountManually', parameters, getVBBADataForOnyx(CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT)); @@ -393,11 +408,13 @@ function verifyIdentityForBankAccount(bankAccountID: number, onfidoData: OnfidoD type VerifyIdentityForBankAccountParams = { bankAccountID: number; onfidoData: string; + canUseNewVbbaFlow: boolean; }; const parameters: VerifyIdentityForBankAccountParams = { bankAccountID, onfidoData: JSON.stringify(onfidoData), + canUseNewVbbaFlow: Permissions.canUseNewVbbaFlow(), }; API.write('VerifyIdentityForBankAccount', parameters, getVBBADataForOnyx()); diff --git a/src/pages/ReimbursementAccount/CompanyStep.js b/src/pages/ReimbursementAccount/CompanyStep.js index f1d62eef89ae..5023153b07c5 100644 --- a/src/pages/ReimbursementAccount/CompanyStep.js +++ b/src/pages/ReimbursementAccount/CompanyStep.js @@ -137,9 +137,9 @@ function CompanyStep({reimbursementAccount, reimbursementAccountDraft, getDefaul BankAccounts.updateCompanyInformationForBankAccount(bankAccount, policyID); }; - const bankAccountID = lodashGet(reimbursementAccount, 'achData.bankAccountID', 0); - const shouldDisableCompanyName = Boolean(bankAccountID && getDefaultStateForField('companyName')); - const shouldDisableCompanyTaxID = Boolean(bankAccountID && getDefaultStateForField('companyTaxID')); + const shouldDisableNonEditableFields = lodashGet(reimbursementAccount, 'achData.bankAccountID', 0) && lodashGet(reimbursementAccount, 'achData.state') !== 'SETUP'; + const shouldDisableCompanyName = Boolean(shouldDisableNonEditableFields && getDefaultStateForField('companyName')) ; + const shouldDisableCompanyTaxID = Boolean(shouldDisableNonEditableFields && getDefaultStateForField('companyTaxID')); return ( ); } - if (currentStep === CONST.BANK_ACCOUNT.STEP.REQUESTOR) { - const shouldShowOnfido = this.props.onfidoToken && !achData.isOnfidoSetupComplete; + if (currentStep === CONST.BANK_ACCOUNT.STEP.COMPANY) { return ( - ); }