-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TS migration] Migrate 'ValidateLogin' page to TypeScript #33839
Changes from 4 commits
e5cd46f
14f8bb5
e53425b
1e9d72e
670a3e1
9719184
51a21e5
2d65ac5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type {StackScreenProps} from '@react-navigation/stack'; | ||
import React, {useEffect} from 'react'; | ||
import {OnyxEntry, withOnyx} from 'react-native-onyx'; | ||
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import type {AuthScreensParamList} from '@libs/Navigation/types'; | ||
import * as Session from '@userActions/Session'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import SCREENS from '@src/SCREENS'; | ||
import type {Session as SessionType} from '@src/types/onyx'; | ||
|
||
type ValidateLoginPageOnyxProps = { | ||
session: OnyxEntry<SessionType>; | ||
}; | ||
|
||
type ValidateLoginPageProps = ValidateLoginPageOnyxProps & StackScreenProps<AuthScreensParamList, typeof SCREENS.VALIDATE_LOGIN>; | ||
|
||
function ValidateLoginPage({ | ||
route: { | ||
params: {accountID = '', validateCode = ''}, | ||
}, | ||
session, | ||
}: ValidateLoginPageProps) { | ||
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, ValidateLoginPageOnyxProps>({ | ||
session: {key: ONYXKEYS.SESSION}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Credentials were removed, please test the component carefully on native There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @blazejkustra There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And honestly I don't know how to test this component on the native side because it seems this page is only used on web 🤷 |
||
})(ValidateLoginPage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ValidateLoginPage has platform specific implementations, create types.ts file with a shared type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! 👍