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

Fix blank screen when showing the WorkspaceResetBankAccount modal #14726

Merged
merged 18 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function resetFreePlanBankAccount(bankAccountID) {
{
optimisticData: [
{
onyxMethod: 'set',
onyxMethod: CONST.ONYX.METHOD.SET,
key: ONYXKEYS.ONFIDO_TOKEN,
value: '',
},
Expand All @@ -44,12 +44,31 @@ function resetFreePlanBankAccount(bankAccountID) {
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
value: ReimbursementAccountProps.reimbursementAccountDefaultProps,
},
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
value: {isLoading: true},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a note for myself and reviewers, adding isLoading here caused this side effect: #15114

#15114 (comment)

},
{
onyxMethod: CONST.ONYX.METHOD.SET,
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT_DRAFT,
value: {},
},
],
successData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
value: {isLoading: false},
},
],
failureData: [
{
onyxMethod: CONST.ONYX.METHOD.MERGE,
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
value: {isLoading: false},
},
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comma

});
}

Expand Down
19 changes: 17 additions & 2 deletions src/pages/ReimbursementAccount/ContinueBankAccountSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ import ScreenWrapper from '../../components/ScreenWrapper';
import Section from '../../components/Section';
import Text from '../../components/Text';
import withPolicy from '../workspace/withPolicy';
import * as ReimbursementAccountProps from './reimbursementAccountPropTypes';
import WorkspaceResetBankAccountModal from '../workspace/WorkspaceResetBankAccountModal';
import * as BankAccounts from '../../libs/actions/BankAccounts';

const propTypes = {
/** Bank account currently in setup */
reimbursementAccount: ReimbursementAccountProps.reimbursementAccountPropTypes.isRequired,

/** Callback to continue to the next step of the setup */
continue: PropTypes.func.isRequired,

/** Callback to start over the setup */
/** Callback to reset the bank account */
startOver: PropTypes.func.isRequired,

/** Policy values needed in the component */
Expand Down Expand Up @@ -67,13 +73,22 @@ const ContinueBankAccountSetup = props => (
<MenuItem
title={props.translate('workspace.bankAccount.startOver')}
icon={Expensicons.RotateLeft}
onPress={props.startOver}
onPress={() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be on same line

BankAccounts.requestResetFreePlanBankAccount();
}}
shouldShowRightIcon
wrapperStyle={[styles.cardMenuItem]}
/>
</Section>
</ScrollView>
</FullPageNotFoundView>

{props.reimbursementAccount.shouldShowResetModal && (
<WorkspaceResetBankAccountModal
reimbursementAccount={props.reimbursementAccount}
onConfirm={props.startOver}
/>
)}
</ScreenWrapper>
);

Expand Down
12 changes: 2 additions & 10 deletions src/pages/ReimbursementAccount/ReimbursementAccountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import EnableStep from './EnableStep';
import ROUTES from '../../ROUTES';
import HeaderWithCloseButton from '../../components/HeaderWithCloseButton';
import * as ReimbursementAccountProps from './reimbursementAccountPropTypes';
import WorkspaceResetBankAccountModal from '../workspace/WorkspaceResetBankAccountModal';
import reimbursementAccountDraftPropTypes from './ReimbursementAccountDraftPropTypes';
import * as ReimbursementAccountUtils from '../../libs/ReimbursementAccountUtils';

Expand Down Expand Up @@ -276,17 +275,10 @@ class ReimbursementAccountPage extends React.Component {
return (
<View>
<ContinueBankAccountSetup
reimbursementAccount={this.props.reimbursementAccount}
continue={this.continue}
startOver={() => {
BankAccounts.requestResetFreePlanBankAccount();
}}
startOver={() => this.setState({shouldHideContinueSetupButton: true})}
/>
{this.props.reimbursementAccount.shouldShowResetModal && (
<WorkspaceResetBankAccountModal
reimbursementAccount={this.props.reimbursementAccount}
onConfirm={() => this.setState({shouldHideContinueSetupButton: true})}
/>
)}
</View>
);
}
Expand Down
6 changes: 2 additions & 4 deletions src/pages/workspace/WorkspaceResetBankAccountModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const propTypes = {
};

const defaultProps = {
onConfirm: null,
onConfirm: () => {},
};

const WorkspaceResetBankAccountModal = (props) => {
Expand All @@ -47,9 +47,7 @@ const WorkspaceResetBankAccountModal = (props) => {
onCancel={BankAccounts.cancelResetFreePlanBankAccount}
onConfirm={() => {
BankAccounts.resetFreePlanBankAccount(bankAccountID);
if (props.onConfirm) {
props.onConfirm();
}
props.onConfirm();
}}
shouldShowCancelButton
isVisible
Expand Down