From 930fc6e543db95178b9668ade7d7e22afd646038 Mon Sep 17 00:00:00 2001 From: Francois Laithier Date: Wed, 13 Nov 2024 16:33:40 -0800 Subject: [PATCH] Re-add removed `route` param --- .../settings/Security/TwoFactorAuth/Steps/CodesStep.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx b/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx index 56bb7e0c52ab..e104397a7936 100644 --- a/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx +++ b/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx @@ -1,3 +1,5 @@ +import type {RouteProp} from '@react-navigation/native'; +import {useRoute} from '@react-navigation/native'; import React, {useEffect, useMemo, useState} from 'react'; import {ActivityIndicator, View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; @@ -19,7 +21,7 @@ import {READ_COMMANDS} from '@libs/API/types'; import Clipboard from '@libs/Clipboard'; import * as ErrorUtils from '@libs/ErrorUtils'; import localFileDownload from '@libs/localFileDownload'; -import type {BackToParams} from '@libs/Navigation/types'; +import type {BackToParams, SettingsNavigatorParamList} from '@libs/Navigation/types'; import StepWrapper from '@pages/settings/Security/TwoFactorAuth/StepWrapper/StepWrapper'; import useTwoFactorAuthContext from '@pages/settings/Security/TwoFactorAuth/TwoFactorAuthContext/useTwoFactorAuth'; import * as Session from '@userActions/Session'; @@ -27,6 +29,7 @@ import * as TwoFactorAuthActions from '@userActions/TwoFactorAuthActions'; import * as User from '@userActions/User'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import type SCREENS from '@src/SCREENS'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; type CodesStepProps = BackToParams; @@ -46,6 +49,7 @@ function CodesStep({backTo}: CodesStepProps) { const isUserValidated = user?.validated; const contactMethod = account?.primaryLogin ?? ''; + const route = useRoute>(); const loginData = useMemo(() => loginList?.[contactMethod], [loginList, contactMethod]); const validateLoginError = ErrorUtils.getEarliestErrorField(loginData, 'validateLogin'); @@ -73,7 +77,7 @@ function CodesStep({backTo}: CodesStepProps) { }} // When the 2FA code step is open from Xero flow, we don't need to pass backTo because we build the necessary root route // from the backTo param in the route (in getMatchingRootRouteForRHPRoute) and goBack will not need a fallbackRoute. - onBackButtonPress={() => TwoFactorAuthActions.quitAndNavigateBack(route.params.forwardTo?.includes(READ_COMMANDS.CONNECT_POLICY_TO_XERO) ? '' : backTo)} + onBackButtonPress={() => TwoFactorAuthActions.quitAndNavigateBack(route?.params?.forwardTo?.includes(READ_COMMANDS.CONNECT_POLICY_TO_XERO) ? '' : backTo)} > {!!isUserValidated && (