Skip to content
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

[New Feature] - Teachers Unite sign-up flows #23063

Merged
merged 98 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
59af4db
Added Save the world route
dhairyasenjaliya Jul 18, 2023
bdbba2f
Improve Save the world route & add translate
dhairyasenjaliya Jul 18, 2023
e482d3c
Added I know a teacher route with form validation
dhairyasenjaliya Jul 18, 2023
0cba0ea
Crash fix
dhairyasenjaliya Jul 18, 2023
b077a12
Added new route for intro principal
dhairyasenjaliya Jul 18, 2023
2eb7e7c
Eslint fix
dhairyasenjaliya Jul 18, 2023
18273b7
Added Validation
dhairyasenjaliya Jul 18, 2023
65cc038
remove unused import
dhairyasenjaliya Jul 18, 2023
4910173
Added I am a teacher page
dhairyasenjaliya Jul 18, 2023
28039d6
Remove un-used import
dhairyasenjaliya Jul 18, 2023
8c44614
Added some translation
dhairyasenjaliya Jul 19, 2023
a78b3c5
Add heart icon from emojiCategory
dhairyasenjaliya Jul 19, 2023
d02e26d
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Jul 19, 2023
fb4eb11
minor improvement
dhairyasenjaliya Jul 19, 2023
63788c9
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Jul 20, 2023
830837f
change comment
dhairyasenjaliya Jul 20, 2023
d29b8f6
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Jul 21, 2023
808e54c
remove extra style
dhairyasenjaliya Jul 24, 2023
27c6006
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Jul 24, 2023
07195f7
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Jul 26, 2023
676ba3c
Added Email Icon
dhairyasenjaliya Jul 26, 2023
bc0cd90
Added Lottie animation for Save the world
dhairyasenjaliya Jul 26, 2023
abdb587
Added brand orange.800 color for saveTheWorld animation
dhairyasenjaliya Jul 26, 2023
a8f46e6
Lint fixes
dhairyasenjaliya Jul 26, 2023
146438a
lint erroe
dhairyasenjaliya Jul 26, 2023
89d9084
Lint fix
dhairyasenjaliya Jul 26, 2023
fae9b9c
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Jul 27, 2023
36fd477
Try to resolve jest-3 fail
dhairyasenjaliya Jul 27, 2023
47a8bdc
Re-add Heart Icon
dhairyasenjaliya Jul 27, 2023
7cef2e7
Re-add Heart Icon with lint fix :(
dhairyasenjaliya Jul 27, 2023
34202e5
Navigate user to exp public room
dhairyasenjaliya Jul 27, 2023
93f1581
ReferTeachersUniteVolunteer optimistic added
dhairyasenjaliya Jul 31, 2023
a8384d9
AddSchoolPrincipal action with optimistic added WIP
dhairyasenjaliya Jul 31, 2023
8d4c496
Suggested Fixes
dhairyasenjaliya Jul 31, 2023
8e2ca6e
Remove Arrow functions
dhairyasenjaliya Jul 31, 2023
4ea3dc1
Move boolean props at first
dhairyasenjaliya Jul 31, 2023
5eeabc5
CleanUp arrow functions
dhairyasenjaliya Jul 31, 2023
f243f80
Rename routes
dhairyasenjaliya Jul 31, 2023
5198685
Generate expensChat for principal intro
dhairyasenjaliya Aug 1, 2023
7dffad9
Add isPublicDomain function to check new email as per new array
dhairyasenjaliya Aug 1, 2023
4bb7e8f
Email icon size
dhairyasenjaliya Aug 1, 2023
f300baa
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 2, 2023
be8fd7d
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 3, 2023
b0c5047
remove local publicDomain function
dhairyasenjaliya Aug 3, 2023
2f5f4bb
withLocalize not needed on save the world page
dhairyasenjaliya Aug 3, 2023
c3b59e4
Remove comments & add name props to missing inputs
dhairyasenjaliya Aug 3, 2023
335d55e
Route changes and form name updated
dhairyasenjaliya Aug 3, 2023
d87a306
useLocalize hooks, route changes , arrow function usage
dhairyasenjaliya Aug 3, 2023
d97724a
added reportCreationData to AddSchoolPrincipal command
dhairyasenjaliya Aug 3, 2023
046e468
added trasnlate as per team suggested
dhairyasenjaliya Aug 3, 2023
4ca9b93
added missing translate
dhairyasenjaliya Aug 3, 2023
c19e38a
reviewed changes
dhairyasenjaliya Aug 3, 2023
fa265b3
review fixes
dhairyasenjaliya Aug 3, 2023
42e419a
cleanUp functions
dhairyasenjaliya Aug 3, 2023
bf915cd
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 7, 2023
57b51c5
Align text link
dhairyasenjaliya Aug 7, 2023
17a4c49
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 8, 2023
42e8df8
add local function to check public domain email
dhairyasenjaliya Aug 8, 2023
53bb04e
cleanup
dhairyasenjaliya Aug 8, 2023
5c25aa9
modify blockview to support embed link with subtitle
dhairyasenjaliya Aug 8, 2023
68d2caf
fix validation on know a teacher page
dhairyasenjaliya Aug 9, 2023
4644731
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 9, 2023
b6976db
rename API command name
dhairyasenjaliya Aug 9, 2023
e980776
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 11, 2023
72a2f29
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 14, 2023
d686fd4
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 16, 2023
7efe733
added policyID & public room ID for testing API command
dhairyasenjaliya Aug 16, 2023
89dfe55
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 17, 2023
ebd7a8b
removed absolute codes
dhairyasenjaliya Aug 17, 2023
1bd9630
removed absolute codes
dhairyasenjaliya Aug 17, 2023
d932788
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 19, 2023
85d36a6
PublicID & RoomID updated as per final
dhairyasenjaliya Aug 19, 2023
8d71138
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 21, 2023
f983951
Improvements
dhairyasenjaliya Aug 21, 2023
80a218d
Added validation to prevent user reffering to their own contact method
dhairyasenjaliya Aug 21, 2023
fbea500
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 22, 2023
8621ad1
Remove OptimisticExpenseChatForSchool
dhairyasenjaliya Aug 22, 2023
e3bce3a
Added condition to check reportId
dhairyasenjaliya Aug 22, 2023
9d0d80e
make last name mandatory
dhairyasenjaliya Aug 22, 2023
e5e329c
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 22, 2023
0f36fc7
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 23, 2023
1df618d
useContext on blockView fixes
dhairyasenjaliya Aug 23, 2023
2374a0e
fixes
dhairyasenjaliya Aug 23, 2023
e85c0ae
user partnerUserID instead of email/phone
dhairyasenjaliya Aug 23, 2023
e553c3f
remove unused translation
dhairyasenjaliya Aug 23, 2023
1cdbea7
Change form input name
dhairyasenjaliya Aug 24, 2023
071b1d7
Rename var
dhairyasenjaliya Aug 25, 2023
be92f39
DRY phoneLogin & validateNumber
dhairyasenjaliya Aug 28, 2023
6059c06
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 28, 2023
e4889b0
Cleanup functions
dhairyasenjaliya Aug 28, 2023
d452af3
revert loading condition
dhairyasenjaliya Aug 28, 2023
ae78c51
room name
dhairyasenjaliya Aug 28, 2023
ee9e91b
Prettier fix
dhairyasenjaliya Aug 28, 2023
a5258db
Merge branch 'main' of https://github.com/dhairyasenjaliya/Expensify …
dhairyasenjaliya Aug 28, 2023
c22085c
Change policyID
dhairyasenjaliya Aug 28, 2023
d2bfd50
limit teacher signup
dhairyasenjaliya Aug 29, 2023
dddda20
Rename Policy
dhairyasenjaliya Aug 29, 2023
3ba6d89
Added actual id's
dhairyasenjaliya Aug 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/animations/SaveTheWorld.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions assets/images/heart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2557,6 +2557,12 @@ const CONST = {
TRANSLATION_KEYS: {
ATTACHMENT: 'common.attachment',
},
TEACHERS_UNITE: {
PUBLIC_ROOM_ID: '207591744844000',
POLICY_ID: 'ABD1345ED7293535',
POLICY_NAME: 'Expensify.org / Teachers Unite!',
PUBLIC_ROOM_NAME: '#teachers-unite',
},
CUSTOM_STATUS_TYPES: {
NEVER: 'never',
THIRTY_MINUTES: 'thirtyMinutes',
Expand Down
2 changes: 2 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ const ONYXKEYS = {
SETTINGS_STATUS_SET_FORM: 'settingsStatusSetForm',
SETTINGS_STATUS_CLEAR_AFTER_FORM: 'settingsStatusClearAfterForm',
SETTINGS_STATUS_SET_CLEAR_AFTER_FORM: 'settingsStatusSetClearAfterForm',
I_KNOW_A_TEACHER_FORM: 'iKnowTeacherForm',
INTRO_SCHOOL_PRINCIPAL_FORM: 'introSchoolPrincipalForm',
},
} as const;

Expand Down
4 changes: 4 additions & 0 deletions src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ export default {
FLAG_COMMENT: `flag/:reportID/:reportActionID`,
getFlagCommentRoute: (reportID, reportActionID) => `flag/${reportID}/${reportActionID}`,
SEARCH: 'search',
SAVE_THE_WORLD: 'save-the-world',
I_KNOW_A_TEACHER: 'save-the-world/i-know-a-teacher',
INTRO_SCHOOL_PRINCIPAL: 'save-the-world/intro-school-principal',
I_AM_A_TEACHER: 'save-the-world/i-am-a-teacher',
DETAILS: 'details',
getDetailsRoute: (login) => `details?login=${encodeURIComponent(login)}`,
PROFILE: 'a/:accountID',
Expand Down
41 changes: 29 additions & 12 deletions src/components/BlockingViews/BlockingView.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const propTypes = {

/** Function to call when pressing the navigation link */
onLinkPress: PropTypes.func,

/** Whether we should embed the link with subtitle */
shouldEmbedLinkWithSubtitle: PropTypes.bool,
};

const defaultProps = {
Expand All @@ -48,10 +51,30 @@ const defaultProps = {
iconWidth: variables.iconSizeSuperLarge,
iconHeight: variables.iconSizeSuperLarge,
onLinkPress: () => Navigation.dismissModal(),
shouldEmbedLinkWithSubtitle: false,
};

function BlockingView(props) {
const {translate} = useLocalize();
function renderContent() {
return (
<>
<AutoEmailLink
style={[styles.textAlignCenter]}
text={props.subtitle}
/>
{props.shouldShowLink ? (
<TextLink
onPress={props.onLinkPress}
style={[styles.link, styles.mt2]}
>
{translate(props.linkKey)}
</TextLink>
) : null}
</>
);
}

return (
<View style={[styles.flex1, styles.alignItemsCenter, styles.justifyContentCenter, styles.ph10]}>
<Icon
Expand All @@ -61,18 +84,12 @@ function BlockingView(props) {
height={props.iconHeight}
/>
<Text style={[styles.notFoundTextHeader]}>{props.title}</Text>
<AutoEmailLink
style={[styles.textAlignCenter]}
text={props.subtitle}
/>
{props.shouldShowLink ? (
<TextLink
onPress={props.onLinkPress}
style={[styles.link, styles.mt2]}
>
{translate(props.linkKey)}
</TextLink>
) : null}

{props.shouldEmbedLinkWithSubtitle ? (
<Text style={[styles.textAlignCenter]}>{renderContent()}</Text>
) : (
<View style={[styles.alignItemsCenter, styles.justifyContentCenter]}>{renderContent()}</View>
)}
</View>
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Icon/Expensicons.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import Gear from '../../../assets/images/gear.svg';
import Globe from '../../../assets/images/globe.svg';
import GoogleLogo from '../../../assets/images/signIn/google-logo.svg';
import Hashtag from '../../../assets/images/hashtag.svg';
import Heart from '../../../assets/images/heart.svg';
import History from '../../../assets/images/history.svg';
import Hourglass from '../../../assets/images/hourglass.svg';
import ImageCropCircleMask from '../../../assets/images/image-crop-circle-mask.svg';
Expand Down Expand Up @@ -188,6 +189,7 @@ export {
Globe,
GoogleLogo,
Hashtag,
Heart,
History,
Hourglass,
ImageCropCircleMask,
Expand Down
2 changes: 2 additions & 0 deletions src/components/Icon/Illustrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import CoffeeMug from '../../../assets/images/simple-illustrations/simple-illust
import ConciergeBlue from '../../../assets/images/product-illustrations/concierge--blue.svg';
import ConciergeExclamation from '../../../assets/images/product-illustrations/concierge--exclamation.svg';
import CreditCardsBlue from '../../../assets/images/product-illustrations/credit-cards--blue.svg';
import EmailAddress from '../../../assets/images/simple-illustrations/simple-illustration__email-address.svg';
import InvoiceOrange from '../../../assets/images/product-illustrations/invoice--orange.svg';
import JewelBoxBlue from '../../../assets/images/product-illustrations/jewel-box--blue.svg';
import JewelBoxGreen from '../../../assets/images/product-illustrations/jewel-box--green.svg';
Expand Down Expand Up @@ -55,6 +56,7 @@ export {
ConciergeBlue,
ConciergeExclamation,
CreditCardsBlue,
EmailAddress,
InvoiceOrange,
JewelBoxBlue,
JewelBoxGreen,
Expand Down
3 changes: 2 additions & 1 deletion src/components/LottieAnimations.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ const Hands = require('../../assets/animations/Hands.json');
const PreferencesDJ = require('../../assets/animations/PreferencesDJ.json');
const ReviewingBankInfo = require('../../assets/animations/ReviewingBankInfo.json');
const WorkspacePlanet = require('../../assets/animations/WorkspacePlanet.json');
const SaveTheWorld = require('../../assets/animations/SaveTheWorld.json');

export {ExpensifyLounge, Fireworks, Hands, PreferencesDJ, ReviewingBankInfo, WorkspacePlanet};
export {ExpensifyLounge, Fireworks, Hands, PreferencesDJ, ReviewingBankInfo, SaveTheWorld, WorkspacePlanet};
1 change: 0 additions & 1 deletion src/components/withLocalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, {createContext, forwardRef} from 'react';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import lodashGet from 'lodash/get';

import getComponentDisplayName from '../libs/getComponentDisplayName';
import ONYXKEYS from '../ONYXKEYS';
import * as Localize from '../libs/Localize';
Expand Down
28 changes: 27 additions & 1 deletion src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ export default {
someone: 'Someone',
total: 'Total',
edit: 'Edit',
letsDoThis: `Let's do this!`,
youssef-lr marked this conversation as resolved.
Show resolved Hide resolved
letsStart: `Let's start`,
dhairyasenjaliya marked this conversation as resolved.
Show resolved Hide resolved
showMore: 'Show more',
merchant: 'Merchant',
category: 'Category',
Expand Down Expand Up @@ -371,6 +373,7 @@ export default {
draftedMessage: 'Drafted message',
listOfChatMessages: 'List of chat messages',
listOfChats: 'List of chats',
saveTheWorld: 'Save the world',
},
tabSelector: {
manual: 'Manual',
Expand Down Expand Up @@ -517,7 +520,7 @@ export default {
enteredMethodIsAlreadySubmited: 'The Entered Contact Method already exists.',
passwordRequired: 'password required.',
contactMethodRequired: 'Contact method is required.',
invalidContactMethod: 'Invalid contact method.',
invalidContactMethod: 'Invalid contact method',
},
newContactMethod: 'New contact method',
},
Expand Down Expand Up @@ -1610,6 +1613,29 @@ export default {
levelTwoResult: 'Message hidden from channel, plus anonymous warning and message is reported for review.',
levelThreeResult: 'Message removed from channel plus anonymous warning and message is reported for review.',
},
teachersUnitePage: {
teachersUnite: 'Teachers unite!',
joinExpensifyOrg: 'Join Expensify.org in eliminating injustice around the world and help teachers split their expenses for classrooms in need!',
iKnowATeacher: 'I know a teacher',
iAmATeacher: 'I am a teacher',
getInTouch: 'Excellent! Please share their information so we can get in touch with them.',
introSchoolPrincipal: 'Intro to your school principal',
schoolPrincipalVerfiyExpense:
'Expensify.org splits the cost of essential school supplies so that students from low-income households can have a better learning experience. Your principal will be asked to verify your expenses.',
principalFirstName: 'Principal first name',
principalLastName: 'Principal last name',
principalWorkEmail: 'Principal work email',
updateYourEmail: 'Update your email address',
updateEmail: 'Update email address',
contactMethods: 'Contact methods.',
schoolMailAsDefault: 'Before you move forward, please make sure to set your school email as your default contact method. You can do so in Settings > Profile > ',
error: {
enterPhoneEmail: 'Enter a valid email or phone number',
enterEmail: 'Enter an email',
enterValidEmail: 'Enter a valid email',
tryDifferentEmail: 'Please try a different email',
},
},
distance: {
addStop: 'Add stop',
address: 'Address',
Expand Down
29 changes: 28 additions & 1 deletion src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ export default {
someone: 'Alguien',
total: 'Total',
edit: 'Editar',
letsDoThis: '¡Hagámoslo!',
letsStart: 'Empecemos',
showMore: 'Mostrar más',
merchant: 'Comerciante',
category: 'Categoría',
Expand Down Expand Up @@ -370,6 +372,7 @@ export default {
draftedMessage: 'Mensaje borrador',
listOfChatMessages: 'Lista de mensajes del chat',
listOfChats: 'lista de chats',
saveTheWorld: 'Salvar el mundo',
},
tabSelector: {
manual: 'Manual',
Expand Down Expand Up @@ -517,7 +520,7 @@ export default {
enteredMethodIsAlreadySubmited: 'El método de contacto ingresado ya existe.',
passwordRequired: 'Se requiere contraseña',
contactMethodRequired: 'Se requiere método de contacto.',
invalidContactMethod: 'Método de contacto no válido.',
invalidContactMethod: 'Método de contacto no válido',
},
newContactMethod: 'Nuevo método de contacto',
},
Expand Down Expand Up @@ -2097,6 +2100,30 @@ export default {
levelTwoResult: 'Mensaje ocultado del canal, más advertencia anónima y mensaje reportado para revisión.',
levelThreeResult: 'Mensaje eliminado del canal, más advertencia anónima y mensaje reportado para revisión.',
},
teachersUnitePage: {
teachersUnite: '¡Profesores unidos!',
joinExpensifyOrg: 'Únete a Expensify.org para eliminar la injusticia en todo el mundo y ayuda a los profesores a dividir sus gastos para las aulas más necesitadas.',
iKnowATeacher: 'Yo conozco a un profesor',
iAmATeacher: 'Soy profesor',
getInTouch: '¡Excelente! Por favor, comparte su información para que podamos ponernos en contacto con ellos.',
introSchoolPrincipal: 'Introducción al director del colegio',
schoolPrincipalVerfiyExpense:
'Expensify.org divide el coste del material escolar esencial para que los estudiantes de familias con bajos ingresos puedan tener una mejor experiencia de aprendizaje. Se pedirá a tu director que verifique tus gastos.',
principalFirstName: 'Nombre del director',
principalLastName: 'Apellido del director',
principalWorkEmail: 'Correo electrónico de trabajo del director',
updateYourEmail: 'Actualiza tu dirección de correo electrónico',
updateEmail: 'Actualización de la dirección de correo electrónico',
contactMethods: 'Métodos de contacto.',
schoolMailAsDefault:
'Antes de seguir adelante, asegúrate de establecer el correo electrónico de tu colegio como método de contacto predeterminado. Puede hacerlo en Configuración > Perfil > ',
error: {
enterPhoneEmail: 'Ingrese un correo electrónico o número de teléfono válido',
enterEmail: 'Introduce un correo electrónico',
enterValidEmail: 'Introduzca un correo electrónico válido',
tryDifferentEmail: 'Por favor intenta con un e-mail diferente',
},
},
distance: {
addStop: 'Agregar parada',
address: 'Dirección',
Expand Down
45 changes: 44 additions & 1 deletion src/libs/LoginUtils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import _ from 'underscore';
import Str from 'expensify-common/lib/str';
import Onyx from 'react-native-onyx';
import {PUBLIC_DOMAINS} from 'expensify-common/lib/CONST';
import {parsePhoneNumber} from 'awesome-phonenumber';
import CONST from '../CONST';
import ONYXKEYS from '../ONYXKEYS';

Expand Down Expand Up @@ -28,4 +32,43 @@ function appendCountryCode(phone) {
return phone.startsWith('+') ? phone : `+${countryCodeByIP}${phone}`;
}

export {getPhoneNumberWithoutSpecialChars, appendCountryCode};
/**
* Check email is public domain or not
*
* @param {String} email
* @return {Boolean}
*/
function isEmailPublicDomain(email) {
const emailDomain = Str.extractEmailDomain(email);
return _.includes(PUBLIC_DOMAINS, emailDomain.toLowerCase(), false);
}

/**
* Check if number is valid
* @param {String} values
* @returns {String} - Returns valid phone number formatted
*/
function validateNumber(values) {
const parsedPhoneNumber = parsePhoneNumber(values);

if (parsedPhoneNumber.possible && Str.isValidPhone(values.slice(0))) {
return parsedPhoneNumber.number.e164 + CONST.SMS.DOMAIN;
}

return '';
}

/**
* Check number is valid and attach country code
* @param {String} partnerUserID
* @returns {String} - Returns valid phone number with country code
*/
function getPhoneLogin(partnerUserID) {
if (_.isEmpty(partnerUserID)) {
return '';
}

return appendCountryCode(getPhoneNumberWithoutSpecialChars(partnerUserID));
}

export {getPhoneNumberWithoutSpecialChars, appendCountryCode, isEmailPublicDomain, validateNumber, getPhoneLogin};
Loading
Loading