Skip to content

Commit

Permalink
navigate to forward to
Browse files Browse the repository at this point in the history
  • Loading branch information
rushatgabhane committed Jun 20, 2024
1 parent c844340 commit 5799a37
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React from 'react';
import ConfirmationPage from '@components/ConfirmationPage';
import LottieAnimations from '@components/LottieAnimations';
import useLocalize from '@hooks/useLocalize';
import type {BackToParams} from '@libs/Navigation/types';
import type {BackToAndForwardToParms} from '@libs/Navigation/types';
import Navigation from '@navigation/Navigation';
import StepWrapper from '@pages/settings/Security/TwoFactorAuth/StepWrapper/StepWrapper';
import useTwoFactorAuthContext from '@pages/settings/Security/TwoFactorAuth/TwoFactorAuthContext/useTwoFactorAuth';
import * as TwoFactorAuthActions from '@userActions/TwoFactorAuthActions';
import CONST from '@src/CONST';

function SuccessStep({backTo}: BackToParams) {
function SuccessStep({backTo, forwardTo}: BackToAndForwardToParms) {
const {setStep} = useTwoFactorAuthContext();

const {translate} = useLocalize();
Expand All @@ -31,6 +31,10 @@ function SuccessStep({backTo}: BackToParams) {
onButtonPress={() => {
TwoFactorAuthActions.clearTwoFactorAuthData();
setStep(CONST.TWO_FACTOR_AUTH_STEPS.ENABLED);
if (forwardTo) {
Navigation.navigate(forwardTo);
return;
}
if (backTo) {
Navigation.navigate(backTo);
}
Expand Down
11 changes: 9 additions & 2 deletions src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ type TwoFactorAuthStepProps = BaseTwoFactorAuthFormOnyxProps;

function TwoFactorAuthSteps({account}: TwoFactorAuthStepProps) {
const route = useRoute<RouteProp<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.TWO_FACTOR_AUTH>>();
const backTo = route.params?.backTo ?? '';
const backTo = route.params?.backTo;
const forwardTo = route.params?.forwardTo;

const [currentStep, setCurrentStep] = useState<TwoFactorAuthStep>(CONST.TWO_FACTOR_AUTH_STEPS.CODES);

const {setAnimationDirection} = useAnimatedStepContext();
Expand Down Expand Up @@ -59,7 +61,12 @@ function TwoFactorAuthSteps({account}: TwoFactorAuthStepProps) {
case CONST.TWO_FACTOR_AUTH_STEPS.VERIFY:
return <VerifyStep />;
case CONST.TWO_FACTOR_AUTH_STEPS.SUCCESS:
return <SuccessStep backTo={backTo} />;
return (
<SuccessStep
backTo={backTo}
forwardTo={forwardTo}
/>
);
case CONST.TWO_FACTOR_AUTH_STEPS.ENABLED:
return <EnabledStep />;
case CONST.TWO_FACTOR_AUTH_STEPS.DISABLED:
Expand Down

0 comments on commit 5799a37

Please sign in to comment.