Skip to content

Commit

Permalink
Merge pull request #5803 from Expensify/yuwen-betterSteps
Browse files Browse the repository at this point in the history
Don't dismiss the Reimbursement Account Page after validating a withdrawal account

(cherry picked from commit 27b23b5)
  • Loading branch information
luacmartins authored and OSBotify committed Oct 13, 2021
1 parent 44929d6 commit 4a89a32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 1 addition & 8 deletions src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import * as API from '../API';
import BankAccount from '../models/BankAccount';
import Growl from '../Growl';
import {translateLocal} from '../translate';
import Navigation from '../Navigation/Navigation';

/**
* List of bank accounts. This data should not be stored in Onyx since it contains unmasked PANs.
Expand Down Expand Up @@ -574,7 +573,6 @@ function validateBankAccount(bankAccountID, validateCode) {
API.BankAccount_Validate({bankAccountID, validateCode})
.then((response) => {
if (response.jsonCode === 200) {
Growl.show('Bank Account successfully validated!', CONST.GROWL.SUCCESS, 5000);
Onyx.set(ONYXKEYS.REIMBURSEMENT_ACCOUNT_DRAFT, null);
API.User_IsUsingExpensifyCard()
.then(({isUsingExpensifyCard}) => {
Expand All @@ -584,12 +582,7 @@ function validateBankAccount(bankAccountID, validateCode) {
achData: {state: BankAccount.STATE.OPEN},
};

if (isUsingExpensifyCard) {
Navigation.dismissModal();
} else {
reimbursementAccount.achData.currentStep = CONST.BANK_ACCOUNT.STEP.ENABLE;
}

reimbursementAccount.achData.currentStep = CONST.BANK_ACCOUNT.STEP.ENABLE;
Onyx.merge(ONYXKEYS.USER, {isUsingExpensifyCard});
Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, reimbursementAccount);
});
Expand Down
9 changes: 8 additions & 1 deletion src/pages/ReimbursementAccount/ReimbursementAccountForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import reimbursementAccountPropTypes from './reimbursementAccountPropTypes';
import compose from '../../libs/compose';
import ONYXKEYS from '../../ONYXKEYS';
import FormAlertWithSubmitButton from '../../components/FormAlertWithSubmitButton';
import CONST from '../../CONST';

const propTypes = {
/** ACH data for the withdrawal account actively being set up */
Expand All @@ -34,6 +35,12 @@ class ReimbursementAccountForm extends React.Component {
// @TODO once all validation errors show in multiples we can remove this check
|| lodashGet(this.props, 'reimbursementAccount.error', '').length > 0;

const currentStep = lodashGet(
this.props,
'reimbursementAccount.achData.currentStep',
CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT,
);

return (
<ScrollView
style={[styles.w100, styles.flex1]}
Expand All @@ -47,7 +54,7 @@ class ReimbursementAccountForm extends React.Component {
</View>
<FormAlertWithSubmitButton
isAlertVisible={isErrorVisible}
buttonText={this.props.translate('common.saveAndContinue')}
buttonText={currentStep === CONST.BANK_ACCOUNT.STEP.VALIDATION ? this.props.translate('validationStep.buttonText') : this.props.translate('common.saveAndContinue')}
onSubmit={this.props.onSubmit}
onFixTheErrorsLinkPressed={() => {
this.form.scrollTo({y: 0, animated: true});
Expand Down

0 comments on commit 4a89a32

Please sign in to comment.