Skip to content

Commit 3c002cc

Browse files
remove unnecessary changes
1 parent a9cc6e0 commit 3c002cc

4 files changed

Lines changed: 11 additions & 14 deletions

File tree

src/pages/TeachersUnite/KnowATeacherPage.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ function KnowATeacherPage() {
2626
const {translate} = useLocalize();
2727
const {isProduction} = useEnvironment();
2828
const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true});
29-
const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: true});
3029

3130
/**
3231
* Submit form to pass firstName, partnerUserID and lastName
3332
*/
3433
const onSubmit = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.I_KNOW_A_TEACHER_FORM>) => {
35-
const phoneLogin = getPhoneLogin(values.partnerUserID, countryCode);
34+
const phoneLogin = getPhoneLogin(values.partnerUserID);
3635
const validateIfNumber = validateNumber(phoneLogin);
3736
const contactMethod = (validateIfNumber || values.partnerUserID).trim().toLowerCase();
3837
const firstName = values.firstName.trim();
@@ -49,7 +48,7 @@ function KnowATeacherPage() {
4948
const validate = useCallback(
5049
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.I_KNOW_A_TEACHER_FORM>) => {
5150
const errors = getFieldRequiredErrors(values, [INPUT_IDS.FIRST_NAME, INPUT_IDS.LAST_NAME]);
52-
const phoneLogin = getPhoneLogin(values.partnerUserID, countryCode);
51+
const phoneLogin = getPhoneLogin(values.partnerUserID);
5352
const validateIfNumber = validateNumber(phoneLogin);
5453

5554
if (!isValidDisplayName(values.firstName)) {
@@ -88,7 +87,7 @@ function KnowATeacherPage() {
8887

8988
return errors;
9089
},
91-
[loginList, translate, countryCode],
90+
[loginList, translate],
9291
);
9392

9493
return (

src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,24 @@ function NewContactMethodPage({route}: NewContactMethodPageProps) {
3333
const {translate} = useLocalize();
3434
const loginInputRef = useRef<AnimatedTextInputRef>(null);
3535
const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST, {canBeMissing: true});
36-
const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: true});
3736

3837
const navigateBackTo = route?.params?.backTo;
3938

4039
const handleValidateMagicCode = useCallback(
4140
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.NEW_CONTACT_METHOD_FORM>) => {
42-
const phoneLogin = getPhoneLogin(values.phoneOrEmail, countryCode);
41+
const phoneLogin = getPhoneLogin(values.phoneOrEmail);
4342
const validateIfNumber = validateNumber(phoneLogin);
4443
const submitDetail = (validateIfNumber || values.phoneOrEmail).trim().toLowerCase();
4544
resetValidateActionCodeSent();
4645
addPendingContactMethod(submitDetail);
4746
Navigation.navigate(ROUTES.SETTINGS_NEW_CONTACT_METHOD_CONFIRM_MAGIC_CODE.getRoute(submitDetail, navigateBackTo));
4847
},
49-
[countryCode, navigateBackTo],
48+
[navigateBackTo],
5049
);
5150

5251
const validate = useCallback(
5352
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.NEW_CONTACT_METHOD_FORM>): Errors => {
54-
const phoneLogin = getPhoneLogin(values.phoneOrEmail, countryCode);
53+
const phoneLogin = getPhoneLogin(values.phoneOrEmail);
5554
const validateIfNumber = validateNumber(phoneLogin);
5655

5756
const errors = {};
@@ -83,7 +82,7 @@ function NewContactMethodPage({route}: NewContactMethodPageProps) {
8382
// the loginList gets updated, causing this function to run again.
8483
// https://github.com/Expensify/App/issues/20610
8584
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
86-
[translate, countryCode],
85+
[translate],
8786
);
8887

8988
const onBackButtonPress = useCallback(() => {

src/pages/settings/Security/MergeAccounts/AccountDetailsPage.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ function AccountDetailsPage() {
7272
const {params} = useRoute<PlatformStackRouteProp<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.MERGE_ACCOUNTS.ACCOUNT_DETAILS>>();
7373
const [email, setEmail] = useState(params?.email ?? '');
7474
const {inputCallbackRef} = useAutoFocusInput();
75-
const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: true});
7675
const validateCodeSent = getValidateCodeForAccountMerge?.validateCodeSent;
7776
const latestError = getLatestErrorMessage(getValidateCodeForAccountMerge);
7877
const errorKey = getValidateCodeErrorKey(latestError);
@@ -145,7 +144,7 @@ function AccountDetailsPage() {
145144
} else if (login.trim() === userEmailOrPhone) {
146145
addErrorMessage(errors, INPUT_IDS.PHONE_OR_EMAIL, translate('common.error.email'));
147146
} else {
148-
const phoneLogin = getPhoneLogin(login, countryCode);
147+
const phoneLogin = getPhoneLogin(login);
149148
const validateIfNumber = validateNumber(phoneLogin);
150149

151150
if (!Str.isValidEmail(login) && !validateIfNumber) {

tests/unit/LoginUtilsTest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,17 @@ describe('LoginUtils', () => {
7979
describe('getPhoneLogin', () => {
8080
it('Should return valid phone number with country code if provided phone number is valid and with country code', () => {
8181
const givenPhone = '+12345678901';
82-
const parsedPhone = LoginUtils.getPhoneLogin(givenPhone, 1);
82+
const parsedPhone = LoginUtils.getPhoneLogin(givenPhone);
8383
expect(parsedPhone).toBe('+12345678901');
8484
});
8585
it('Should return valid phone number with country code if provided phone number is valid and without country code', () => {
8686
const givenPhone = '2345678901';
87-
const parsedPhone = LoginUtils.getPhoneLogin(givenPhone, 1);
87+
const parsedPhone = LoginUtils.getPhoneLogin(givenPhone);
8888
expect(parsedPhone).toBe('+12345678901');
8989
});
9090
it('Should return empty string if provided phone number is empty', () => {
9191
const givenPhone = '';
92-
const parsedPhone = LoginUtils.getPhoneLogin(givenPhone, 1);
92+
const parsedPhone = LoginUtils.getPhoneLogin(givenPhone);
9393
expect(parsedPhone).toBe('');
9494
});
9595
});

0 commit comments

Comments
 (0)