diff --git a/src/pages/signin/ChooseSSOOrMagicCode.tsx b/src/pages/signin/ChooseSSOOrMagicCode.tsx index 4143c2b733e0..3895b303020b 100644 --- a/src/pages/signin/ChooseSSOOrMagicCode.tsx +++ b/src/pages/signin/ChooseSSOOrMagicCode.tsx @@ -1,100 +1,67 @@ -import React, {useEffect} from 'react'; -import {Keyboard, View} from 'react-native'; +import React from 'react'; +import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import Button from '@components/Button'; -import FormHelpMessage from '@components/FormHelpMessage'; import Text from '@components/Text'; -import useKeyboardState from '@hooks/useKeyboardState'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; -import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; -import * as Session from '@userActions/Session'; -import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type {Account, Credentials} from '@src/types/onyx'; -import {isEmptyObject} from '@src/types/utils/EmptyObject'; -import ChangeExpensifyLoginLink from './ChangeExpensifyLoginLink'; -import Terms from './Terms'; +import type {Account} from '@src/types/onyx'; +import ValidateCodeForm from './ValidateCodeForm'; type ChooseSSOOrMagicCodeOnyxProps = { - /** The credentials of the logged in person */ - credentials: OnyxEntry; - /** The details about the account that the user is signing in with */ account: OnyxEntry; }; type ChooseSSOOrMagicCodeProps = ChooseSSOOrMagicCodeOnyxProps & { - /** Function that returns whether the user is using SAML or magic codes to log in */ - setIsUsingMagicCode: (value: boolean) => void; + /** Determines if user is switched to using recovery code instead of 2fa code */ + isUsingRecoveryCode: boolean; + + /** Function to change `isUsingRecoveryCode` state when user toggles between 2fa code and recovery code */ + setIsUsingRecoveryCode: (value: boolean) => void; }; -function ChooseSSOOrMagicCode({credentials, account, setIsUsingMagicCode}: ChooseSSOOrMagicCodeProps) { +function ChooseSSOOrMagicCode({account, isUsingRecoveryCode, setIsUsingRecoveryCode}: ChooseSSOOrMagicCodeProps) { const styles = useThemeStyles(); - const {isKeyboardShown} = useKeyboardState(); const {translate} = useLocalize(); const {isOffline} = useNetwork(); const {isSmallScreenWidth} = useWindowDimensions(); - - // This view doesn't have a field for user input, so dismiss the device keyboard if shown - useEffect(() => { - if (!isKeyboardShown) { - return; - } - Keyboard.dismiss(); - }, [isKeyboardShown]); + const loginTextAfterMagicCode = isUsingRecoveryCode ? translate('validateCodeForm.enterRecoveryCode') : translate('validateCodeForm.enterAuthenticatorCode'); + const loginText = account?.requiresTwoFactorAuth ? loginTextAfterMagicCode : translate('samlSignIn.orContinueWithMagicCode'); return ( - <> - - {translate('samlSignIn.welcomeSAMLEnabled')} -