Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update WorkspacePageWithSections to use OpenWorkspaceView instead of fetchFreePlanVerifiedBankAccount #12634

Merged
merged 5 commits into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ function verifyIdentityForBankAccount(bankAccountID, onfidoData) {
}, getVBBADataForOnyx());
}

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

export {
addPersonalBankAccount,
connectBankAccountManually,
Expand All @@ -333,6 +337,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);