From ff51f27b4cee07d7c835d37fbaeddbd96f6a40ea Mon Sep 17 00:00:00 2001 From: Maria D'Costa Date: Tue, 13 Sep 2022 10:05:20 +0100 Subject: [PATCH 1/2] Add helper method to build Onyx data for VBBA setup --- src/libs/actions/BankAccounts.js | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 43b8b7d2c056..3ba9b9f88ec7 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -41,6 +41,48 @@ function clearPlaid() { Onyx.set(ONYXKEYS.PLAID_LINK_TOKEN, ''); } +/** + * Helper method to build the Onyx data required during setup of a Verified Business Bank Account + * + * @returns {Object} + */ +function getVBBADataForOnyx() { + return { + optimisticData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isLoading: true, + errors: null, + }, + }, + ], + successData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isLoading: false, + errors: null, + }, + }, + ], + failureData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: { + isLoading: false, + errors: { + [DateUtils.getMicroseconds()]: Localize.translateLocal('paymentsPage.addBankAccountFailure'), + }, + }, + }, + ], + }; +} + /** * Adds a bank account via Plaid * From 1999128c0a8c86042e936878af78360db6d547e9 Mon Sep 17 00:00:00 2001 From: Maria D'Costa Date: Tue, 13 Sep 2022 11:22:33 +0100 Subject: [PATCH 2/2] Fix lint errors --- src/libs/actions/BankAccounts.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/BankAccounts.js b/src/libs/actions/BankAccounts.js index 3ba9b9f88ec7..d2242b028962 100644 --- a/src/libs/actions/BankAccounts.js +++ b/src/libs/actions/BankAccounts.js @@ -3,6 +3,7 @@ import CONST from '../../CONST'; import * as API from '../API'; import ONYXKEYS from '../../ONYXKEYS'; import * as Localize from '../Localize'; +import DateUtils from '../DateUtils'; export { setupWithdrawalAccount, @@ -43,9 +44,11 @@ function clearPlaid() { /** * Helper method to build the Onyx data required during setup of a Verified Business Bank Account - * + * * @returns {Object} */ +// We'll remove the below once this function is used by the VBBA commands that are yet to be implemented +/* eslint-disable no-unused-vars */ function getVBBADataForOnyx() { return { optimisticData: [