-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
131 additions
and
81 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 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
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
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
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,73 @@ | ||
import type {StackScreenProps} from '@react-navigation/stack'; | ||
import React, {useCallback, useEffect, useRef} from 'react'; | ||
import {View} from 'react-native'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
import type {AnimatedTextInputRef} from '@components/RNTextInput'; | ||
import ScreenWrapper from '@components/ScreenWrapper'; | ||
import Text from '@components/Text'; | ||
import ValidateCodeForm from '@components/ValidateCodeActionModal/ValidateCodeForm'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as ErrorUtils from '@libs/ErrorUtils'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; | ||
import * as User from '@userActions/User'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import ROUTES from '@src/ROUTES'; | ||
import type SCREENS from '@src/SCREENS'; | ||
|
||
type VerifyAccountPageProps = StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.PROFILE.NEW_CONTACT_METHOD>; | ||
|
||
function VerifyAccountPage({route}: VerifyAccountPageProps) { | ||
const [account] = useOnyx(ONYXKEYS.ACCOUNT); | ||
const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST); | ||
const [pendingContactAction] = useOnyx(ONYXKEYS.PENDING_CONTACT_ACTION); | ||
const contactMethod = account?.primaryLogin ?? ''; | ||
const themeStyles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
const loginInputRef = useRef<AnimatedTextInputRef>(null); | ||
const loginData = loginList?.[pendingContactAction?.contactMethod ?? contactMethod]; | ||
const validateLoginError = ErrorUtils.getEarliestErrorField(loginData, 'validateLogin'); | ||
|
||
const [validateCodeAction] = useOnyx(ONYXKEYS.VALIDATE_ACTION_CODE); | ||
|
||
const navigateBackTo = route?.params?.backTo ?? ROUTES.SETTINGS_WALLET; | ||
|
||
useEffect(() => () => User.clearUnvalidatedNewContactMethodAction(), []); | ||
|
||
const handleSubmitForm = useCallback( | ||
(submitCode: string) => { | ||
User.validateSecondaryLogin(loginList, contactMethod ?? '', submitCode); | ||
Navigation.navigate(navigateBackTo); | ||
}, | ||
[loginList, contactMethod, navigateBackTo], | ||
); | ||
|
||
return ( | ||
<ScreenWrapper | ||
onEntryTransitionEnd={() => loginInputRef.current?.focus()} | ||
includeSafeAreaPaddingBottom={false} | ||
shouldEnableMaxHeight | ||
testID={VerifyAccountPage.displayName} | ||
> | ||
<HeaderWithBackButton | ||
title={translate('contacts.validateAccount')} | ||
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_ADD_BANK_ACCOUNT)} | ||
/> | ||
<View style={[themeStyles.ph5, themeStyles.mt3, themeStyles.mb7]}> | ||
<Text style={[themeStyles.mb3]}>{translate('contacts.featureRequiresValidate')}</Text> | ||
<ValidateCodeForm | ||
validateCodeAction={validateCodeAction} | ||
validateError={validateLoginError} | ||
handleSubmitForm={handleSubmitForm} | ||
clearError={() => {}} | ||
/> | ||
</View> | ||
</ScreenWrapper> | ||
); | ||
} | ||
|
||
VerifyAccountPage.displayName = 'VerifyAccountPage'; | ||
|
||
export default VerifyAccountPage; |
Pay someone flow triggers the verify account modal but we still want to stay on Report Central Pane. So, this was removed here. #52456