From 626ef41b373a8f7e66e2b41d7d83df3ed082c489 Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Thu, 26 Dec 2024 09:53:13 -0800 Subject: [PATCH] Revert "fix wallet phone validation page" --- src/libs/GetPhysicalCardUtils.ts | 6 +----- .../settings/Wallet/Card/GetPhysicalCardPhone.tsx | 14 +++----------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/libs/GetPhysicalCardUtils.ts b/src/libs/GetPhysicalCardUtils.ts index 9ed192b09233..8dc46204db3c 100644 --- a/src/libs/GetPhysicalCardUtils.ts +++ b/src/libs/GetPhysicalCardUtils.ts @@ -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'; @@ -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): 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)) { diff --git a/src/pages/settings/Wallet/Card/GetPhysicalCardPhone.tsx b/src/pages/settings/Wallet/Card/GetPhysicalCardPhone.tsx index 075bc4a3ff5c..bcb3fe646fff 100644 --- a/src/pages/settings/Wallet/Card/GetPhysicalCardPhone.tsx +++ b/src/pages/settings/Wallet/Card/GetPhysicalCardPhone.tsx @@ -1,4 +1,3 @@ -import {Str} from 'expensify-common'; import React from 'react'; import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; @@ -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'; @@ -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; };