forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Expensify#33839 from callstack-internal/pac-guerre…
…iro/refactor/migrate-validatelogin-to-typescript [TS migration] Migrate 'ValidateLogin' page to TypeScript
- Loading branch information
Showing
5 changed files
with
73 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, {useEffect} from 'react'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import * as Session from '@userActions/Session'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type {ValidateLoginPageOnyxNativeProps, ValidateLoginPageProps} from './types'; | ||
|
||
function ValidateLoginPage({ | ||
route: { | ||
params: {accountID, validateCode}, | ||
}, | ||
session, | ||
}: ValidateLoginPageProps<ValidateLoginPageOnyxNativeProps>) { | ||
useEffect(() => { | ||
if (session?.authToken) { | ||
// If already signed in, do not show the validate code if not on web, | ||
// because we don't want to block the user with the interstitial page. | ||
Navigation.goBack(); | ||
} else { | ||
Session.signInWithValidateCodeAndNavigate(Number(accountID), validateCode); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
return <FullScreenLoadingIndicator />; | ||
} | ||
|
||
ValidateLoginPage.displayName = 'ValidateLoginPage'; | ||
|
||
export default withOnyx<ValidateLoginPageProps<ValidateLoginPageOnyxNativeProps>, ValidateLoginPageOnyxNativeProps>({ | ||
session: {key: ONYXKEYS.SESSION}, | ||
})(ValidateLoginPage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type {StackScreenProps} from '@react-navigation/stack'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
import type {PublicScreensParamList} from '@libs/Navigation/types'; | ||
import type SCREENS from '@src/SCREENS'; | ||
import type {Account, Credentials, Session} from '@src/types/onyx'; | ||
|
||
type ValidateLoginPageOnyxNativeProps = { | ||
/** Session of currently logged in user */ | ||
session: OnyxEntry<Session>; | ||
}; | ||
|
||
type ValidateLoginPageOnyxProps = ValidateLoginPageOnyxNativeProps & { | ||
/** The details about the account that the user is signing in with */ | ||
account: OnyxEntry<Account>; | ||
|
||
/** The credentials of the person logging in */ | ||
credentials: OnyxEntry<Credentials>; | ||
}; | ||
|
||
type ValidateLoginPageProps<OnyxProps> = OnyxProps & StackScreenProps<PublicScreensParamList, typeof SCREENS.VALIDATE_LOGIN>; | ||
|
||
export type {ValidateLoginPageOnyxNativeProps, ValidateLoginPageOnyxProps, ValidateLoginPageProps}; |