Skip to content

Commit

Permalink
Merge pull request #54585 from Expensify/revert-52082-fix/51491-walle…
Browse files Browse the repository at this point in the history
…t-page

Revert "fix wallet phone validation page"

(cherry picked from commit d649ce2)

(CP triggered by jasperhuangg)
  • Loading branch information
neil-marcellini authored and OSBotify committed Dec 26, 2024
1 parent 8f04fbf commit 82153a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
6 changes: 1 addition & 5 deletions src/libs/GetPhysicalCardUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {Str} from 'expensify-common';
import type {OnyxEntry} from 'react-native-onyx';
import ROUTES from '@src/ROUTES';
import type {Route} from '@src/ROUTES';
Expand All @@ -7,19 +6,16 @@ import type {LoginList, PrivatePersonalDetails} from '@src/types/onyx';
import * as LoginUtils from './LoginUtils';
import Navigation from './Navigation/Navigation';
import * as PersonalDetailsUtils from './PersonalDetailsUtils';
import * as PhoneNumberUtils from './PhoneNumber';
import * as UserUtils from './UserUtils';

function getCurrentRoute(domain: string, privatePersonalDetails: OnyxEntry<PrivatePersonalDetails>): Route {
const {legalFirstName, legalLastName, phoneNumber} = privatePersonalDetails ?? {};
const address = PersonalDetailsUtils.getCurrentAddress(privatePersonalDetails);
const phoneNumberWithCountryCode = LoginUtils.appendCountryCode(phoneNumber ?? '');
const parsedPhoneNumber = PhoneNumberUtils.parsePhoneNumber(phoneNumberWithCountryCode);

if (!legalFirstName && !legalLastName) {
return ROUTES.SETTINGS_WALLET_CARD_GET_PHYSICAL_NAME.getRoute(domain);
}
if (!phoneNumber || !parsedPhoneNumber.possible || !Str.isValidE164Phone(phoneNumberWithCountryCode.slice(0))) {
if (!phoneNumber || !LoginUtils.validateNumber(phoneNumber)) {
return ROUTES.SETTINGS_WALLET_CARD_GET_PHYSICAL_PHONE.getRoute(domain);
}
if (!(address?.street && address?.city && address?.state && address?.country && address?.zip)) {
Expand Down
14 changes: 3 additions & 11 deletions src/pages/settings/Wallet/Card/GetPhysicalCardPhone.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {Str} from 'expensify-common';
import React from 'react';
import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
Expand All @@ -9,8 +8,6 @@ import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as LoginUtils from '@libs/LoginUtils';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import * as PhoneNumberUtils from '@libs/PhoneNumber';
import * as ValidationUtils from '@libs/ValidationUtils';
import type {SettingsNavigatorParamList} from '@navigation/types';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -43,17 +40,12 @@ function GetPhysicalCardPhone({

const errors: OnValidateResult = {};

if (!ValidationUtils.isRequiredFulfilled(phoneNumberToValidate)) {
if (!LoginUtils.validateNumber(phoneNumberToValidate)) {
errors.phoneNumber = translate('common.error.phoneNumber');
} else if (!phoneNumberToValidate) {
errors.phoneNumber = translate('common.error.fieldRequired');
}

const phoneNumberWithCountryCode = LoginUtils.appendCountryCode(phoneNumberToValidate);
const parsedPhoneNumber = PhoneNumberUtils.parsePhoneNumber(phoneNumberWithCountryCode);

if (!parsedPhoneNumber.possible || !Str.isValidE164Phone(phoneNumberWithCountryCode.slice(0))) {
errors.phoneNumber = translate('bankAccount.error.phoneNumber');
}

return errors;
};

Expand Down

0 comments on commit 82153a6

Please sign in to comment.