Skip to content

Commit

Permalink
Merge pull request #12634 from Expensify/ckt_refactor_workspaceFetch3
Browse files Browse the repository at this point in the history
Update WorkspacePageWithSections to use OpenWorkspaceView instead of fetchFreePlanVerifiedBankAccount
  • Loading branch information
amyevans authored Nov 11, 2022
2 parents 40e1278 + d694d97 commit e82af5f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ function verifyIdentityForBankAccount(bankAccountID, onfidoData) {
}, getVBBADataForOnyx());
}

function openWorkspaceView() {
API.read('OpenWorkspaceView');
}

export {
addPersonalBankAccount,
clearOnfidoToken,
Expand All @@ -375,6 +379,7 @@ export {
updateCompanyInformationForBankAccount,
updatePersonalInformationForBankAccount,
updatePlaidData,
openWorkspaceView,
validateBankAccount,
verifyIdentityForBankAccount,
};
12 changes: 9 additions & 3 deletions src/pages/workspace/WorkspacePageWithSections.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import networkPropTypes from '../../components/networkPropTypes';
import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView';

const propTypes = {
shouldSkipVBBACall: PropTypes.bool,

/** Information about the network from Onyx */
network: networkPropTypes.isRequired,

Expand All @@ -38,7 +40,7 @@ const propTypes = {
}).isRequired,

/** From Onyx */
/** Bank account currently in setup */
/** Bank account attached to free plan */
reimbursementAccount: reimbursementAccountPropTypes,

/** User Data from Onyx */
Expand Down Expand Up @@ -71,6 +73,7 @@ const defaultProps = {
footer: null,
guidesCallTaskID: '',
shouldUseScrollView: false,
shouldSkipVBBACall: false,
};

class WorkspacePageWithSections extends React.Component {
Expand All @@ -87,8 +90,11 @@ class WorkspacePageWithSections extends React.Component {
}

fetchData() {
const achState = lodashGet(this.props.reimbursementAccount, 'achData.state', '');
BankAccounts.fetchFreePlanVerifiedBankAccount('', achState);
if (this.props.shouldSkipVBBACall) {
return;
}

BankAccounts.openWorkspaceView();
}

render() {
Expand Down
5 changes: 3 additions & 2 deletions src/pages/workspace/reimburse/WorkspaceReimbursePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ const WorkspaceReimbursePage = props => (
headerText={props.translate('workspace.common.reimburse')}
route={props.route}
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_REIMBURSE}
shouldSkipVBBACall
>
{hasVBA => (
<WorkspaceReimburseView policy={props.policy} hasVBA={hasVBA} />
{() => (
<WorkspaceReimburseView policy={props.policy} />
)}
</WorkspacePageWithSections>
);
Expand Down
22 changes: 21 additions & 1 deletion src/pages/workspace/reimburse/WorkspaceReimburseView.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import lodashGet from 'lodash/get';
import _ from 'underscore';
Expand All @@ -17,6 +18,9 @@ import compose from '../../../libs/compose';
import * as Policy from '../../../libs/actions/Policy';
import CONST from '../../../CONST';
import Button from '../../../components/Button';
import ONYXKEYS from '../../../ONYXKEYS';
import BankAccount from '../../../libs/models/BankAccount';
import reimbursementAccountPropTypes from '../../ReimbursementAccount/reimbursementAccountPropTypes';
import getPermittedDecimalSeparator from '../../../libs/getPermittedDecimalSeparator';
import {withNetwork} from '../../../components/OnyxProvider';
import OfflineWithFeedback from '../../../components/OfflineWithFeedback';
Expand Down Expand Up @@ -49,12 +53,20 @@ const propTypes = {
lastModified: PropTypes.number,
}).isRequired,

/** From Onyx */
/** Bank account attached to free plan */
reimbursementAccount: reimbursementAccountPropTypes,

/** Information about the network */
network: networkPropTypes.isRequired,

...withLocalizePropTypes,
};

const defaultProps = {
reimbursementAccount: {},
};

class WorkspaceReimburseView extends React.Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -199,6 +211,8 @@ class WorkspaceReimburseView extends React.Component {
}

render() {
const achState = lodashGet(this.props.reimbursementAccount, 'achData.state', '');
const hasVBA = achState === BankAccount.STATE.OPEN;
return (
<>
<Section
Expand Down Expand Up @@ -267,7 +281,7 @@ class WorkspaceReimburseView extends React.Component {
</View>
</OfflineWithFeedback>
</Section>
{this.props.hasVBA ? (
{hasVBA ? (
<Section
title={this.props.translate('workspace.reimburse.fastReimbursementsHappyMembers')}
icon={Illustrations.BankUserGreen}
Expand Down Expand Up @@ -310,9 +324,15 @@ class WorkspaceReimburseView extends React.Component {
}
}

WorkspaceReimburseView.defaultProps = defaultProps;
WorkspaceReimburseView.propTypes = propTypes;

export default compose(
withLocalize,
withNetwork(),
withOnyx({
reimbursementAccount: {
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
},
}),
)(WorkspaceReimburseView);

0 comments on commit e82af5f

Please sign in to comment.