Skip to content

Commit

Permalink
feat: move static methods out of the NewContactMethodPage component
Browse files Browse the repository at this point in the history
  • Loading branch information
allroundexperts committed Jun 24, 2023
1 parent 66f1c15 commit a455bfd
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/pages/settings/Profile/Contacts/NewContactMethodPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,34 @@ const defaultProps = {
loginList: {},
};

function NewContactMethodPage(props) {
const loginInputRef = useRef(null);
const getPhoneLogin = (phoneOrEmail) => {
if (_.isEmpty(phoneOrEmail)) {
return '';
}

const getPhoneLogin = (phoneOrEmail) => {
if (_.isEmpty(phoneOrEmail)) {
return '';
}
return LoginUtils.appendCountryCode(LoginUtils.getPhoneNumberWithoutSpecialChars(phoneOrEmail));
};

return LoginUtils.appendCountryCode(LoginUtils.getPhoneNumberWithoutSpecialChars(phoneOrEmail));
};
const validateNumber = (values) => {
const parsedPhoneNumber = parsePhoneNumber(values);

const validateNumber = (values) => {
const parsedPhoneNumber = parsePhoneNumber(values);
if (parsedPhoneNumber.possible) {
return parsedPhoneNumber.number.e164 + CONST.SMS.DOMAIN;
}

if (parsedPhoneNumber.possible) {
return parsedPhoneNumber.number.e164 + CONST.SMS.DOMAIN;
}
return '';
};

return '';
};
const addNewContactMethod = (values) => {
const phoneLogin = getPhoneLogin(values.phoneOrEmail);
const validateIfnumber = validateNumber(phoneLogin);
const submitDetail = (validateIfnumber || values.phoneOrEmail).trim().toLowerCase();

User.addNewContactMethodAndNavigate(submitDetail, values.password);
};

function NewContactMethodPage(props) {
const loginInputRef = useRef(null);

const validate = React.useCallback(
(values) => {
Expand Down Expand Up @@ -107,14 +115,6 @@ function NewContactMethodPage(props) {
[],
);

const addNewContactMethod = (values) => {
const phoneLogin = getPhoneLogin(values.phoneOrEmail);
const validateIfnumber = validateNumber(phoneLogin);
const submitDetail = (validateIfnumber || values.phoneOrEmail).trim().toLowerCase();

User.addNewContactMethodAndNavigate(submitDetail, values.password);
};

return (
<ScreenWrapper
onEntryTransitionEnd={() => {
Expand Down

0 comments on commit a455bfd

Please sign in to comment.