forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Expensify#10967 from Expensify/maria-refactor-veri…
…fy-identity-for-bank-account [Refactor] Use new API Command: VerifyIdentityForBankAccount
- Loading branch information
Showing
3 changed files
with
109 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import React from 'react'; | ||
import {ScrollView} from 'react-native'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import PropTypes from 'prop-types'; | ||
import styles from '../../styles/styles'; | ||
import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; | ||
import * as BankAccounts from '../../libs/actions/BankAccounts'; | ||
import Onfido from '../../components/Onfido'; | ||
import compose from '../../libs/compose'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
import * as ReimbursementAccountUtils from '../../libs/ReimbursementAccountUtils'; | ||
import Growl from '../../libs/Growl'; | ||
import reimbursementAccountPropTypes from './reimbursementAccountPropTypes'; | ||
import CONST from '../../CONST'; | ||
|
||
const propTypes = { | ||
/** Bank account currently in setup */ | ||
/* eslint-disable-next-line react/no-unused-prop-types */ | ||
reimbursementAccount: reimbursementAccountPropTypes.isRequired, | ||
onfidoToken: PropTypes.string, | ||
onComplete: PropTypes.func.isRequired, | ||
...withLocalizePropTypes, | ||
}; | ||
|
||
const defaultProps = { | ||
onfidoToken: '', | ||
}; | ||
|
||
class RequestorOnfidoStep extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.submit = this.submit.bind(this); | ||
} | ||
|
||
submit(onfidoData) { | ||
BankAccounts.verifyIdentityForBankAccount( | ||
ReimbursementAccountUtils.getDefaultStateForField(this.props, 'bankAccountID', 0), | ||
onfidoData, | ||
); | ||
this.props.onComplete(); | ||
} | ||
|
||
render() { | ||
return ( | ||
<ScrollView contentContainerStyle={styles.flex1}> | ||
<Onfido | ||
sdkToken={this.props.onfidoToken} | ||
onUserExit={() => { | ||
// We're taking the user back to the company step. They will need to come back to the requestor step to make the Onfido flow appear again. | ||
BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.COMPANY); | ||
}} | ||
onError={() => { | ||
// In case of any unexpected error we log it to the server, show a growl, and return the user back to the company step so they can try again. | ||
Growl.error(this.props.translate('onfidoStep.genericError'), 10000); | ||
BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.COMPANY); | ||
}} | ||
onSuccess={(onfidoData) => { | ||
this.submit(onfidoData); | ||
}} | ||
/> | ||
</ScrollView> | ||
); | ||
} | ||
} | ||
|
||
RequestorOnfidoStep.propTypes = propTypes; | ||
RequestorOnfidoStep.defaultProps = defaultProps; | ||
|
||
export default compose( | ||
withLocalize, | ||
withOnyx({ | ||
reimbursementAccount: { | ||
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT, | ||
}, | ||
onfidoToken: { | ||
key: ONYXKEYS.ONFIDO_TOKEN, | ||
}, | ||
reimbursementAccountDraft: { | ||
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT_DRAFT, | ||
}, | ||
}), | ||
)(RequestorOnfidoStep); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters