Skip to content

Commit

Permalink
Merge pull request #11466 from Expensify/nat-onf
Browse files Browse the repository at this point in the history
Fix onfido flow

(cherry picked from commit 204d780)
  • Loading branch information
madmax330 authored and OSBotify committed Sep 30, 2022
1 parent 2e8f8cd commit 8c1fdd2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function updatePlaidData(plaidData) {
Onyx.merge(ONYXKEYS.PLAID_DATA, plaidData);
}

function clearOnfido() {
function clearOnfidoToken() {
Onyx.merge(ONYXKEYS.ONFIDO_TOKEN, '');
}

Expand Down Expand Up @@ -265,7 +265,7 @@ export {
deletePaymentBankAccount,
clearPersonalBankAccount,
clearPlaid,
clearOnfido,
clearOnfidoToken,
updatePersonalInformationForBankAccount,
validateBankAccount,
connectBankAccountWithPlaid,
Expand Down
5 changes: 4 additions & 1 deletion src/pages/ReimbursementAccount/ACHContractStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ class ACHContractStep extends React.Component {
title={this.props.translate('beneficialOwnersStep.additionalInformation')}
stepCounter={{step: 4, total: 5}}
onCloseButtonPress={Navigation.dismissModal}
onBackButtonPress={() => BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.REQUESTOR)}
onBackButtonPress={() => {
BankAccounts.clearOnfidoToken();
BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.REQUESTOR);
}}
shouldShowGetAssistanceButton
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_BANK_ACCOUNT}
shouldShowBackButton
Expand Down
18 changes: 16 additions & 2 deletions src/pages/ReimbursementAccount/RequestorStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,20 @@ class RequestorStep extends React.Component {
BankAccounts.updatePersonalInformationForBankAccount(payload);
}

submitOnfidoVerification() {
if (!this.validate()) {
return;
}

const payload = {
bankAccountID: ReimbursementAccountUtils.getDefaultStateForField(this.props, 'bankAccountID', 0),
...this.state,
dob: moment(this.state.dob).format(CONST.DATE.MOMENT_FORMAT_STRING),
};

BankAccounts.setupWithdrawalAccount(payload);
}

render() {
const achData = this.props.reimbursementAccount.achData;
const shouldShowOnfido = achData.useOnfido && this.props.onfidoToken && !this.state.isOnfidoSetupComplete;
Expand All @@ -161,7 +175,7 @@ class RequestorStep extends React.Component {
shouldShowBackButton
onBackButtonPress={() => {
if (shouldShowOnfido) {
BankAccounts.clearOnfido();
BankAccounts.clearOnfidoToken();
} else {
BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.COMPANY);
}
Expand All @@ -185,7 +199,7 @@ class RequestorStep extends React.Component {
this.setState({
onfidoData,
isOnfidoSetupComplete: true,
}, this.submit);
}, this.submitOnfidoVerification);
}}
/>
</ScrollView>
Expand Down

0 comments on commit 8c1fdd2

Please sign in to comment.