From 99df6d735deffdf05cbf1a433bbcc2b1f7cd1acf Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Wed, 22 Feb 2023 17:54:37 -0800 Subject: [PATCH 01/25] Show error in workspace's bank account page --- .../resetFreePlanBankAccount.js | 50 ++++++---- src/pages/ReimbursementAccount/EnableStep.js | 92 ++++++++++++------- 2 files changed, 90 insertions(+), 52 deletions(-) diff --git a/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.js b/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.js index 94799fa6b3c6..98121d5db910 100644 --- a/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.js +++ b/src/libs/actions/ReimbursementAccount/resetFreePlanBankAccount.js @@ -24,6 +24,26 @@ function resetFreePlanBankAccount(bankAccountID) { }, { optimisticData: [ + // This bank account is present in ONYXKEYS.BANK_ACCOUNT_LIST + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.BANK_ACCOUNT_LIST, + value: {[bankAccountID]: {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE}}, + }, + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + value: {shouldShowResetModal: false}, + }, + + // TODO: What is this loading state? doesn't seem to be used + // { + // onyxMethod: CONST.ONYX.METHOD.MERGE, + // key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + // value: {isLoading: true}, + // }, + ], + successData: [ { onyxMethod: CONST.ONYX.METHOD.SET, key: ONYXKEYS.ONFIDO_TOKEN, @@ -44,30 +64,26 @@ function resetFreePlanBankAccount(bankAccountID) { key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, value: ReimbursementAccountProps.reimbursementAccountDefaultProps, }, - { - onyxMethod: CONST.ONYX.METHOD.MERGE, - key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, - value: {isLoading: true}, - }, { onyxMethod: CONST.ONYX.METHOD.SET, key: ONYXKEYS.REIMBURSEMENT_ACCOUNT_DRAFT, value: {}, }, - ], - successData: [ - { - onyxMethod: CONST.ONYX.METHOD.MERGE, - key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, - value: {isLoading: false}, - }, + + // TODO: What is this loading state? doesn't seem to be used + // { + // onyxMethod: CONST.ONYX.METHOD.MERGE, + // key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + // value: {isLoading: false}, + // }, ], failureData: [ - { - onyxMethod: CONST.ONYX.METHOD.MERGE, - key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, - value: {isLoading: false}, - }, + // TODO: What is this loading state? doesn't seem to be used + // { + // onyxMethod: CONST.ONYX.METHOD.MERGE, + // key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, + // value: {isLoading: false}, + // }, ], }); } diff --git a/src/pages/ReimbursementAccount/EnableStep.js b/src/pages/ReimbursementAccount/EnableStep.js index b8b7dd1a029f..c6b2fb21a941 100644 --- a/src/pages/ReimbursementAccount/EnableStep.js +++ b/src/pages/ReimbursementAccount/EnableStep.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import {ScrollView} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import lodashGet from 'lodash/get'; @@ -13,6 +14,8 @@ import CONST from '../../CONST'; import Button from '../../components/Button'; import * as Expensicons from '../../components/Icon/Expensicons'; import MenuItem from '../../components/MenuItem'; +import OfflineWithFeedback from '../../components/OfflineWithFeedback'; +import bankAccountPropTypes from '../../components/bankAccountPropTypes'; import getBankIcon from '../../components/Icon/BankIcons'; import * as ReimbursementAccountProps from './reimbursementAccountPropTypes'; import userPropTypes from '../settings/userPropTypes'; @@ -23,11 +26,15 @@ import * as User from '../../libs/actions/User'; import ScreenWrapper from '../../components/ScreenWrapper'; import * as BankAccounts from '../../libs/actions/ReimbursementAccount'; import WorkspaceResetBankAccountModal from '../workspace/WorkspaceResetBankAccountModal'; +import * as PaymentMethods from '../../libs/actions/PaymentMethods'; const propTypes = { /** Bank account currently in setup */ reimbursementAccount: ReimbursementAccountProps.reimbursementAccountPropTypes.isRequired, + /** List of bank accounts */ + bankAccountList: PropTypes.objectOf(bankAccountPropTypes).isRequired, + /* Onyx Props */ user: userPropTypes.isRequired, @@ -45,6 +52,8 @@ const EnableStep = (props) => { : ''; const bankName = achData.addressName; + const errors = lodashGet(props.bankAccountList, [achData.bankAccountID, 'errors'], {}); + const pendingAction = lodashGet(props.bankAccountList, [achData.bankAccountID, 'pendingAction'], {}); return ( { title={!isUsingExpensifyCard ? props.translate('workspace.bankAccount.oneMoreThing') : props.translate('workspace.bankAccount.allSet')} icon={!isUsingExpensifyCard ? Illustrations.ConciergeNew : Illustrations.ThumbsUpStars} > - - - {!isUsingExpensifyCard - ? props.translate('workspace.bankAccount.accountDescriptionNoCards') - : props.translate('workspace.bankAccount.accountDescriptionWithCards')} - - {!isUsingExpensifyCard && ( -