From 5799a37ad353e8124023ac7fd7b4ff979f312400 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 20 Jun 2024 04:55:20 +0300 Subject: [PATCH] navigate to forward to --- .../Security/TwoFactorAuth/Steps/SuccessStep.tsx | 8 ++++++-- .../Security/TwoFactorAuth/TwoFactorAuthSteps.tsx | 11 +++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/pages/settings/Security/TwoFactorAuth/Steps/SuccessStep.tsx b/src/pages/settings/Security/TwoFactorAuth/Steps/SuccessStep.tsx index 5e92fb8649ef..82fe40c53a64 100644 --- a/src/pages/settings/Security/TwoFactorAuth/Steps/SuccessStep.tsx +++ b/src/pages/settings/Security/TwoFactorAuth/Steps/SuccessStep.tsx @@ -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(); @@ -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); } diff --git a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.tsx b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.tsx index c8f2c357f05f..db2c35983f65 100644 --- a/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.tsx +++ b/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.tsx @@ -22,7 +22,9 @@ type TwoFactorAuthStepProps = BaseTwoFactorAuthFormOnyxProps; function TwoFactorAuthSteps({account}: TwoFactorAuthStepProps) { const route = useRoute>(); - const backTo = route.params?.backTo ?? ''; + const backTo = route.params?.backTo; + const forwardTo = route.params?.forwardTo; + const [currentStep, setCurrentStep] = useState(CONST.TWO_FACTOR_AUTH_STEPS.CODES); const {setAnimationDirection} = useAnimatedStepContext(); @@ -59,7 +61,12 @@ function TwoFactorAuthSteps({account}: TwoFactorAuthStepProps) { case CONST.TWO_FACTOR_AUTH_STEPS.VERIFY: return ; case CONST.TWO_FACTOR_AUTH_STEPS.SUCCESS: - return ; + return ( + + ); case CONST.TWO_FACTOR_AUTH_STEPS.ENABLED: return ; case CONST.TWO_FACTOR_AUTH_STEPS.DISABLED: