-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Merge account feature fixes - Part 1 #59911
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c55c163
first phase of fixes
allroundexperts be860ff
fix type errors
allroundexperts 7517dd8
auth error
allroundexperts c5bdc95
change error message
allroundexperts 793f855
refactor key names
allroundexperts c378cc1
Merge branch 'main' into feat-47073-1
allroundexperts 9d5dbe2
handle comment
allroundexperts 624a213
fix lint errors
allroundexperts 0a182b7
remove the un-used usememo
allroundexperts 80a0efd
Merge branch 'main' into feat-47073-1
allroundexperts 49d0a8a
no redirect after clicking send again button
allroundexperts 7b2e73d
add w-100 to validate page description
allroundexperts 37264ec
Merge branch 'main' into feat-47073-1
allroundexperts 33caa59
remove mobile exfy changes
allroundexperts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import {useFocusEffect, useRoute} from '@react-navigation/native'; | ||
| import {useFocusEffect, useNavigation, useRoute} from '@react-navigation/native'; | ||
| import {Str} from 'expensify-common'; | ||
| import React, {useCallback, useRef, useState} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import React, {useCallback, useEffect, useRef, useState} from 'react'; | ||
| import {InteractionManager, View} from 'react-native'; | ||
| import {useOnyx} from 'react-native-onyx'; | ||
| import type {ValueOf} from 'type-fest'; | ||
| import CheckboxWithLabel from '@components/CheckboxWithLabel'; | ||
|
|
@@ -16,11 +16,10 @@ import TextInput from '@components/TextInput'; | |
| import useLocalize from '@hooks/useLocalize'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {addErrorMessage, getLatestErrorMessage} from '@libs/ErrorUtils'; | ||
| import {appendCountryCode, getPhoneNumberWithoutSpecialChars} from '@libs/LoginUtils'; | ||
| import {getPhoneLogin, validateNumber} from '@libs/LoginUtils'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types'; | ||
| import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; | ||
| import {parsePhoneNumber} from '@libs/PhoneNumber'; | ||
| import {isNumericWithSpecialChars} from '@libs/ValidationUtils'; | ||
| import {clearGetValidateCodeForAccountMerge, requestValidationCodeForAccountMerge} from '@userActions/MergeAccounts'; | ||
| import CONST from '@src/CONST'; | ||
|
|
@@ -52,6 +51,7 @@ const getValidateCodeErrorKey = (err: string): ValueOf<typeof CONST.MERGE_ACCOUN | |
|
|
||
| function AccountDetailsPage() { | ||
| const formRef = useRef<FormRef>(null); | ||
| const navigation = useNavigation(); | ||
| const [userEmailOrPhone] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.email, canBeMissing: true}); | ||
| const [getValidateCodeForAccountMerge] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.getValidateCodeForAccountMerge, canBeMissing: true}); | ||
| const {params} = useRoute<PlatformStackRouteProp<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.MERGE_ACCOUNTS.ACCOUNT_DETAILS>>(); | ||
|
|
@@ -67,30 +67,38 @@ function AccountDetailsPage() { | |
|
|
||
| useFocusEffect( | ||
| useCallback(() => { | ||
| if (!validateCodeSent || !email) { | ||
| return; | ||
| } | ||
| const task = InteractionManager.runAfterInteractions(() => { | ||
| if (!validateCodeSent || !email) { | ||
| return; | ||
| } | ||
|
|
||
| return Navigation.navigate(ROUTES.SETTINGS_MERGE_ACCOUNTS_MAGIC_CODE.getRoute(email)); | ||
|
Contributor
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. Came from this issue |
||
| }); | ||
|
|
||
| return Navigation.navigate(ROUTES.SETTINGS_MERGE_ACCOUNTS_MAGIC_CODE.getRoute(email)); | ||
| return () => task.cancel(); | ||
|
allroundexperts marked this conversation as resolved.
|
||
| }, [validateCodeSent, email]), | ||
| ); | ||
|
|
||
| useFocusEffect( | ||
| useCallback(() => { | ||
| if (!errorKey || !email) { | ||
| return; | ||
| } | ||
| return Navigation.navigate(ROUTES.SETTINGS_MERGE_ACCOUNTS_RESULT.getRoute(email, errorKey)); | ||
| const task = InteractionManager.runAfterInteractions(() => { | ||
| if (!errorKey || !email) { | ||
| return; | ||
| } | ||
| return Navigation.navigate(ROUTES.SETTINGS_MERGE_ACCOUNTS_RESULT.getRoute(email, errorKey)); | ||
| }); | ||
|
|
||
| return () => task.cancel(); | ||
| }, [errorKey, email]), | ||
| ); | ||
|
|
||
| useFocusEffect( | ||
| useCallback(() => { | ||
| return () => { | ||
| clearGetValidateCodeForAccountMerge(); | ||
| }; | ||
| }, []), | ||
| ); | ||
| useEffect(() => { | ||
| const unsubscribe = navigation.addListener('blur', () => { | ||
| clearGetValidateCodeForAccountMerge(); | ||
| }); | ||
|
|
||
| return unsubscribe; | ||
| }, [navigation]); | ||
|
|
||
| const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.MERGE_ACCOUNT_DETAILS_FORM>): Errors => { | ||
| const errors = {}; | ||
|
|
@@ -99,11 +107,13 @@ function AccountDetailsPage() { | |
|
|
||
| if (!login) { | ||
| addErrorMessage(errors, INPUT_IDS.PHONE_OR_EMAIL, translate('common.pleaseEnterEmailOrPhoneNumber')); | ||
| } else if (login.trim() === userEmailOrPhone) { | ||
| addErrorMessage(errors, INPUT_IDS.PHONE_OR_EMAIL, translate('common.error.email')); | ||
|
allroundexperts marked this conversation as resolved.
allroundexperts marked this conversation as resolved.
|
||
| } else { | ||
| const phoneLogin = appendCountryCode(getPhoneNumberWithoutSpecialChars(login)); | ||
| const parsedPhoneNumber = parsePhoneNumber(phoneLogin); | ||
| const phoneLogin = getPhoneLogin(login); | ||
| const validateIfNumber = validateNumber(phoneLogin); | ||
|
|
||
| if (!Str.isValidEmail(login) && !parsedPhoneNumber.possible) { | ||
| if (!Str.isValidEmail(login) && !validateIfNumber) { | ||
| if (isNumericWithSpecialChars(login)) { | ||
| addErrorMessage(errors, INPUT_IDS.PHONE_OR_EMAIL, translate('common.error.phoneNumber')); | ||
| } else { | ||
|
|
||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.