From 2d65ac513755b23727e8c1f88c8e77505c4992ef Mon Sep 17 00:00:00 2001 From: Pedro Guerreiro Date: Wed, 17 Jan 2024 10:53:42 +0000 Subject: [PATCH] refactor(typescript): apply pull request feedback --- src/pages/ValidateLoginPage/index.tsx | 2 +- src/pages/ValidateLoginPage/index.website.tsx | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pages/ValidateLoginPage/index.tsx b/src/pages/ValidateLoginPage/index.tsx index 1af5000ed801..7e79216a129d 100644 --- a/src/pages/ValidateLoginPage/index.tsx +++ b/src/pages/ValidateLoginPage/index.tsx @@ -8,7 +8,7 @@ import type {ValidateLoginPageOnyxNativeProps, ValidateLoginPageProps} from './t function ValidateLoginPage({ route: { - params: {accountID = '', validateCode = ''}, + params: {accountID, validateCode}, }, session, }: ValidateLoginPageProps) { diff --git a/src/pages/ValidateLoginPage/index.website.tsx b/src/pages/ValidateLoginPage/index.website.tsx index 3fe994e20644..08f0a64d1a0d 100644 --- a/src/pages/ValidateLoginPage/index.website.tsx +++ b/src/pages/ValidateLoginPage/index.website.tsx @@ -10,11 +10,16 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {ValidateLoginPageOnyxProps, ValidateLoginPageProps} from './types'; -function ValidateLoginPage({account, credentials, route, session}: ValidateLoginPageProps) { +function ValidateLoginPage({ + account, + credentials, + route: { + params: {accountID, validateCode}, + }, + session, +}: ValidateLoginPageProps) { const login = credentials?.login; const autoAuthState = session?.autoAuthState ?? CONST.AUTO_AUTH_STATE.NOT_STARTED; - const accountID = Number(route?.params.accountID) ?? -1; - const validateCode = route.params.validateCode ?? ''; const isSignedIn = !!session?.authToken; const is2FARequired = !!account?.requiresTwoFactorAuth; const cachedAccountID = credentials?.accountID; @@ -32,7 +37,7 @@ function ValidateLoginPage({account, credentials, route, session}: ValidateLogin } // The user has initiated the sign in process on the same browser, in another tab. - Session.signInWithValidateCode(accountID, validateCode); + Session.signInWithValidateCode(Number(accountID), validateCode); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -52,7 +57,7 @@ function ValidateLoginPage({account, credentials, route, session}: ValidateLogin {autoAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && isSignedIn && } {autoAuthState === CONST.AUTO_AUTH_STATE.NOT_STARTED && ( )}