Skip to content

Commit f2a28fb

Browse files
committed
change approach
1 parent 1cc4625 commit f2a28fb

3 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/pages/ReimbursementAccount/ReimbursementAccountVerifyAccountPage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import Navigation from '@libs/Navigation/Navigation';
23
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
34
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
45
import VerifyAccountPageBase from '@pages/settings/VerifyAccountPageBase';
@@ -13,7 +14,9 @@ function ReimbursementAccountVerifyAccountPage({route}: ReimbursementAccountVeri
1314
return (
1415
<VerifyAccountPageBase
1516
navigateBackTo={ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute(policyID, '', backTo)}
16-
navigateForwardTo={ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute(policyID, '', backTo, CONST.BANK_ACCOUNT.STEP.COUNTRY)}
17+
handleClose={() => {
18+
Navigation.goBack(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute(policyID, '', backTo, CONST.BANK_ACCOUNT.STEP.COUNTRY), {compareParams: false});
19+
}}
1720
/>
1821
);
1922
}

src/pages/ReimbursementAccount/VerifiedBankAccountFlowEntryPoint.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function VerifiedBankAccountFlowEntryPoint({
153153
const handleConnectManually = () => {
154154
if (!isAccountValidated) {
155155
setReimbursementAccountOptionPressed(CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL);
156-
Navigation.navigate(ROUTES.BANK_ACCOUNT_VERIFY_ACCOUNT.getRoute(policyID, backTo), {forceReplace: true});
156+
Navigation.navigate(ROUTES.BANK_ACCOUNT_VERIFY_ACCOUNT.getRoute(policyID, backTo));
157157
return;
158158
}
159159

@@ -173,7 +173,7 @@ function VerifiedBankAccountFlowEntryPoint({
173173

174174
if (!isAccountValidated) {
175175
setReimbursementAccountOptionPressed(CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID);
176-
Navigation.navigate(ROUTES.BANK_ACCOUNT_VERIFY_ACCOUNT.getRoute(policyID, backTo), {forceReplace: true});
176+
Navigation.navigate(ROUTES.BANK_ACCOUNT_VERIFY_ACCOUNT.getRoute(policyID, backTo));
177177
return;
178178
}
179179

src/pages/settings/VerifyAccountPageBase.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import ONYXKEYS from '@src/ONYXKEYS';
1313
import type {Route} from '@src/ROUTES';
1414
import {isEmptyObject} from '@src/types/utils/EmptyObject';
1515

16-
type VerifyAccountPageBaseProps = {navigateBackTo?: Route; navigateForwardTo?: Route};
16+
type VerifyAccountPageBaseProps = {navigateBackTo?: Route; navigateForwardTo?: Route; handleClose?: () => void};
1717

1818
/**
1919
* This is a base page as RHP for account verification. The back & forward url logic should be handled on per case basis in higher component.
2020
*/
21-
function VerifyAccountPageBase({navigateBackTo, navigateForwardTo}: VerifyAccountPageBaseProps) {
21+
function VerifyAccountPageBase({navigateBackTo, navigateForwardTo, handleClose}: VerifyAccountPageBaseProps) {
2222
const styles = useThemeStyles();
2323
const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
2424
const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true});
@@ -40,7 +40,7 @@ function VerifyAccountPageBase({navigateBackTo, navigateForwardTo}: VerifyAccoun
4040
[loginList, contactMethod, formatPhoneNumber],
4141
);
4242

43-
const handleClose = useCallback(() => {
43+
const handleCloseFallback = useCallback(() => {
4444
Navigation.goBack(navigateBackTo);
4545
}, [navigateBackTo]);
4646

@@ -49,13 +49,14 @@ function VerifyAccountPageBase({navigateBackTo, navigateForwardTo}: VerifyAccoun
4949
if (!isUserValidated) {
5050
return;
5151
}
52-
5352
if (navigateForwardTo) {
5453
Navigation.navigate(navigateForwardTo, {forceReplace: true});
55-
} else {
54+
} else if (handleClose) {
5655
handleClose();
56+
} else {
57+
handleCloseFallback();
5758
}
58-
}, [isUserValidated, navigateForwardTo, handleClose]);
59+
}, [isUserValidated, navigateForwardTo, handleCloseFallback, handleClose]);
5960

6061
// Once user is validated or the modal is dismissed, we don't want to show empty content.
6162
if (isUserValidated) {
@@ -84,7 +85,7 @@ function VerifyAccountPageBase({navigateBackTo, navigateForwardTo}: VerifyAccoun
8485
handleSubmitForm={handleSubmitForm}
8586
validateError={!isEmptyObject(validateLoginError) ? validateLoginError : getLatestErrorField(loginData, 'validateCodeSent')}
8687
clearError={() => clearContactMethodErrors(contactMethod, !isEmptyObject(validateLoginError) ? 'validateLogin' : 'validateCodeSent')}
87-
onClose={handleClose}
88+
onClose={handleCloseFallback}
8889
/>
8990
);
9091
}

0 commit comments

Comments
 (0)