Skip to content

Commit

Permalink
Re-add removed route param
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisl committed Nov 14, 2024
1 parent 826e8eb commit 930fc6e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -19,14 +21,15 @@ 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';
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;
Expand All @@ -46,6 +49,7 @@ function CodesStep({backTo}: CodesStepProps) {

const isUserValidated = user?.validated;
const contactMethod = account?.primaryLogin ?? '';
const route = useRoute<RouteProp<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.TWO_FACTOR_AUTH>>();

const loginData = useMemo(() => loginList?.[contactMethod], [loginList, contactMethod]);
const validateLoginError = ErrorUtils.getEarliestErrorField(loginData, 'validateLogin');
Expand Down Expand Up @@ -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)}
>
<ScrollView contentContainerStyle={styles.flexGrow1}>
{!!isUserValidated && (
Expand Down

0 comments on commit 930fc6e

Please sign in to comment.