From 639799901d19bd4ef34e85a1a2cdeabf67d56028 Mon Sep 17 00:00:00 2001 From: Kosuke Tseng Date: Tue, 4 Oct 2022 11:05:11 -0700 Subject: [PATCH 1/8] add new command --- src/libs/actions/BankAccounts.js | 36 +++++++++++++++++++ .../ReimbursementAccountPage.js | 1 + 2 files changed, 37 insertions(+) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 97193ee5ad5a..52f2d598c496 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -241,6 +241,41 @@ function validateBankAccount(bankAccountID, validateCode) { }); } +function openReimbursementAccountPage() { + const onyxData = { + optimisticData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + error: '', + loading: true, + }, + }, + ], + successData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + loading: false, + }, + }, + ], + failureData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + loading: false, + }, + }, + ], + }; + + return API.read('OpenReimbursementAccountPage', {}, onyxData); +} + /** * Updates the bank account in the database with the company step data * @@ -298,6 +333,7 @@ export { clearPersonalBankAccount, clearPlaid, clearOnfidoToken, + openReimbursementAccountPage, updatePersonalInformationForBankAccount, validateBankAccount, updateCompanyInformationForBankAccount, diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index b98889085ac8..f7ba895c3586 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -160,6 +160,7 @@ class ReimbursementAccountPage extends React.Component { // If we are trying to navigate to `/bank-account/new` and we already have a bank account then don't allow returning to `/new` BankAccounts.fetchFreePlanVerifiedBankAccount(stepToOpen !== CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT ? stepToOpen : ''); + BankAccounts.openReimbursementAccountPage(); } render() { From 36d127768a2e3fedfa2154014c352a1b919d8f70 Mon Sep 17 00:00:00 2001 From: Kosuke Tseng Date: Wed, 5 Oct 2022 10:24:34 -0700 Subject: [PATCH 2/8] get local items --- .../ReimbursementAccount/ReimbursementAccountPage.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index f7ba895c3586..f89efaeac6f9 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -18,6 +18,7 @@ import getPlaidOAuthReceivedRedirectURI from '../../libs/getPlaidOAuthReceivedRe import Text from '../../components/Text'; import {withNetwork} from '../../components/OnyxProvider'; import networkPropTypes from '../../components/networkPropTypes'; +import * as store from '../../libs/actions/ReimbursementAccount/store'; // Steps import BankAccountStep from './BankAccountStep'; @@ -158,9 +159,15 @@ class ReimbursementAccountPage extends React.Component { // We want to use the same stepToOpen variable when the network state changes because we can be redirected to a different step when the account refreshes. const stepToOpen = this.getStepToOpenFromRouteParams(); + console.log('fetchData'); // If we are trying to navigate to `/bank-account/new` and we already have a bank account then don't allow returning to `/new` BankAccounts.fetchFreePlanVerifiedBankAccount(stepToOpen !== CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT ? stepToOpen : ''); - BankAccounts.openReimbursementAccountPage(); + + + const policyID = store.getReimbursementAccountWorkspaceID() || ''; + const subStep = lodashGet(store.getReimbursementAccountInSetup(), 'subStep', ''); + + BankAccounts.openReimbursementAccountPage(policyID, subStep); } render() { From 20da5bfc956874f958d3f366098bb53e352d1c47 Mon Sep 17 00:00:00 2001 From: Kosuke Tseng Date: Wed, 12 Oct 2022 00:52:02 -0700 Subject: [PATCH 3/8] pass in params --- src/libs/actions/BankAccounts.js | 10 ++++++++-- .../ReimbursementAccount/ReimbursementAccountPage.js | 9 +++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 9cc0c9852ef1..6f1eb55d8b32 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -243,7 +243,7 @@ function validateBankAccount(bankAccountID, validateCode) { }); } -function openReimbursementAccountPage() { +function openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep) { const onyxData = { optimisticData: [ { @@ -275,7 +275,13 @@ function openReimbursementAccountPage() { ], }; - return API.read('OpenReimbursementAccountPage', {}, onyxData); + const param = { + stepToOpen, + subStep, + localCurrentStep, + }; + + return API.read('OpenReimbursementAccountPage', param, onyxData); } /** diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index f89efaeac6f9..7f86da26cbcd 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -159,15 +159,12 @@ class ReimbursementAccountPage extends React.Component { // We want to use the same stepToOpen variable when the network state changes because we can be redirected to a different step when the account refreshes. const stepToOpen = this.getStepToOpenFromRouteParams(); - console.log('fetchData'); // If we are trying to navigate to `/bank-account/new` and we already have a bank account then don't allow returning to `/new` - BankAccounts.fetchFreePlanVerifiedBankAccount(stepToOpen !== CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT ? stepToOpen : ''); + // BankAccounts.fetchFreePlanVerifiedBankAccount(stepToOpen !== CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT ? stepToOpen : ''); - - const policyID = store.getReimbursementAccountWorkspaceID() || ''; const subStep = lodashGet(store.getReimbursementAccountInSetup(), 'subStep', ''); - - BankAccounts.openReimbursementAccountPage(policyID, subStep); + const localCurrentStep = lodashGet(store.getReimbursementAccountInSetup(), 'currentStep', ''); + BankAccounts.openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep); } render() { From 24ec6eaa7368489f4a2abd8a152e9d424dd48ef7 Mon Sep 17 00:00:00 2001 From: Kosuke Tseng Date: Wed, 12 Oct 2022 01:51:45 -0700 Subject: [PATCH 4/8] remove old usage --- src/pages/ReimbursementAccount/ReimbursementAccountPage.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index 7f86da26cbcd..6ffff4c779bd 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -158,10 +158,6 @@ class ReimbursementAccountPage extends React.Component { // We can specify a step to navigate to by using route params when the component mounts. // We want to use the same stepToOpen variable when the network state changes because we can be redirected to a different step when the account refreshes. const stepToOpen = this.getStepToOpenFromRouteParams(); - - // If we are trying to navigate to `/bank-account/new` and we already have a bank account then don't allow returning to `/new` - // BankAccounts.fetchFreePlanVerifiedBankAccount(stepToOpen !== CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT ? stepToOpen : ''); - const subStep = lodashGet(store.getReimbursementAccountInSetup(), 'subStep', ''); const localCurrentStep = lodashGet(store.getReimbursementAccountInSetup(), 'currentStep', ''); BankAccounts.openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep); From 79958f7512d3fd754c71b48384d7bb22c1654927 Mon Sep 17 00:00:00 2001 From: Kosuke Tseng Date: Wed, 12 Oct 2022 09:24:03 -0700 Subject: [PATCH 5/8] update param to isBankAccountINReview --- src/libs/actions/ReimbursementAccount/setupWithdrawalAccount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/ReimbursementAccount/setupWithdrawalAccount.js b/src/libs/actions/ReimbursementAccount/setupWithdrawalAccount.js index ccdf00b7d518..9430c020ad35 100644 --- a/src/libs/actions/ReimbursementAccount/setupWithdrawalAccount.js +++ b/src/libs/actions/ReimbursementAccount/setupWithdrawalAccount.js @@ -58,7 +58,7 @@ function getNextStep(updatedACHData) { return currentStep; } - if (currentStep === CONST.BANK_ACCOUNT.STEP.VALIDATION && updatedACHData.bankAccountInReview) { + if (currentStep === CONST.BANK_ACCOUNT.STEP.VALIDATION && updatedACHData.isBankAccountInReview) { return currentStep; } From 68f70e73980049be5f4378600cb5e33126682d17 Mon Sep 17 00:00:00 2001 From: Kosuke Tseng Date: Tue, 18 Oct 2022 00:33:47 -0700 Subject: [PATCH 6/8] optimistic data --- src/libs/actions/BankAccounts.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 6f1eb55d8b32..d846c3222aee 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -250,8 +250,8 @@ function openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep) { onyxMethod: CONST.ONYX.METHOD.MERGE, key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, value: { - error: '', - loading: true, + errors: null, + isLoading: true, }, }, ], @@ -260,7 +260,7 @@ function openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep) { onyxMethod: CONST.ONYX.METHOD.MERGE, key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, value: { - loading: false, + isLoading: false, }, }, ], @@ -269,7 +269,7 @@ function openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep) { onyxMethod: CONST.ONYX.METHOD.MERGE, key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, value: { - loading: false, + isLoading: false, }, }, ], From 34f6a529f134ef541c8a1c8210f48e41ddaf5fc4 Mon Sep 17 00:00:00 2001 From: Kosuke Tseng Date: Tue, 18 Oct 2022 18:31:33 -0700 Subject: [PATCH 7/8] cleanup --- src/pages/ReimbursementAccount/ReimbursementAccountPage.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js index 6ffff4c779bd..520643cb359a 100644 --- a/src/pages/ReimbursementAccount/ReimbursementAccountPage.js +++ b/src/pages/ReimbursementAccount/ReimbursementAccountPage.js @@ -158,8 +158,9 @@ class ReimbursementAccountPage extends React.Component { // We can specify a step to navigate to by using route params when the component mounts. // We want to use the same stepToOpen variable when the network state changes because we can be redirected to a different step when the account refreshes. const stepToOpen = this.getStepToOpenFromRouteParams(); - const subStep = lodashGet(store.getReimbursementAccountInSetup(), 'subStep', ''); - const localCurrentStep = lodashGet(store.getReimbursementAccountInSetup(), 'currentStep', ''); + const reimbursementAccount = store.getReimbursementAccountInSetup(); + const subStep = reimbursementAccount.subStep || ''; + const localCurrentStep = reimbursementAccount.currentStep || ''; BankAccounts.openReimbursementAccountPage(stepToOpen, subStep, localCurrentStep); } From 206f310b1206d1073c417492784e565da76d0086 Mon Sep 17 00:00:00 2001 From: Kosuke Tseng Date: Thu, 3 Nov 2022 16:44:03 -0700 Subject: [PATCH 8/8] undo unnecessary change --- src/libs/actions/ReimbursementAccount/setupWithdrawalAccount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/ReimbursementAccount/setupWithdrawalAccount.js b/src/libs/actions/ReimbursementAccount/setupWithdrawalAccount.js index 9430c020ad35..ccdf00b7d518 100644 --- a/src/libs/actions/ReimbursementAccount/setupWithdrawalAccount.js +++ b/src/libs/actions/ReimbursementAccount/setupWithdrawalAccount.js @@ -58,7 +58,7 @@ function getNextStep(updatedACHData) { return currentStep; } - if (currentStep === CONST.BANK_ACCOUNT.STEP.VALIDATION && updatedACHData.isBankAccountInReview) { + if (currentStep === CONST.BANK_ACCOUNT.STEP.VALIDATION && updatedACHData.bankAccountInReview) { return currentStep; }