Skip to content

Commit

Permalink
Merge pull request Expensify#30433 from Pujan92/fix/30024
Browse files Browse the repository at this point in the history
Fix: Wallet - Once after login, debit card page exits without open
  • Loading branch information
bondydaa authored Oct 30, 2023
2 parents 592317f + 94f6b4f commit e6dad7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/libs/actions/PaymentMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ function clearDebitCardFormErrorAndSubmit() {
Onyx.set(ONYXKEYS.FORMS.ADD_DEBIT_CARD_FORM, {
isLoading: false,
errors: undefined,
setupComplete: true,
setupComplete: false,
});
}

Expand Down
11 changes: 7 additions & 4 deletions src/pages/settings/Wallet/AddDebitCardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,15 @@ function DebitCardPage(props) {
const prevFormDataSetupComplete = usePrevious(props.formData.setupComplete);
const nameOnCardRef = useRef(null);

/**
* Reset the form values on the mount and unmount so that old errors don't show when this form is displayed again.
*/
useEffect(() => {
PaymentMethods.clearDebitCardFormErrorAndSubmit();

return () => {
PaymentMethods.clearDebitCardFormErrorAndSubmit();
};
}, []);

useEffect(() => {
Expand All @@ -56,10 +63,6 @@ function DebitCardPage(props) {
}

PaymentMethods.continueSetup();

return () => {
PaymentMethods.clearDebitCardFormErrorAndSubmit();
};
}, [prevFormDataSetupComplete, props.formData.setupComplete]);

/**
Expand Down

0 comments on commit e6dad7a

Please sign in to comment.