Skip to content

Commit

Permalink
Merge pull request #658 from techmatters/gian_CHI-2873
Browse files Browse the repository at this point in the history
chore: remove hyphens from phone numbers [CHI-2873]
  • Loading branch information
GPaoloni authored Jul 29, 2024
2 parents 9901e08 + d2eabba commit ea8eb4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions functions/getProfileFlagsForIdentifier.protected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,19 @@ const getContactValueFromWebchat = (trigger: ChatTrigger) => {
return preEngagementData.contactIdentifier;
};

const trimSpaces = (s: string) => s.replace(' ', '');

/**
* IMPORTANT: keep up to date with flex-plugins/plugin-hrm-form/src/utils/task
*/
const trimSpaces = (s: string) => s.replaceAll(' ', '');
const trimHyphens = (s: string) => s.replaceAll('-', '');
const phoneNumberStandardization = (s: string) =>
[trimSpaces, trimHyphens].reduce((accum, f) => f(accum), s);
type TransformIdentifierFunction = (c: string) => string;
const channelTransformations: { [k: string]: TransformIdentifierFunction[] } = {
voice: [trimSpaces],
sms: [trimSpaces],
whatsapp: [(s) => s.replace('whatsapp:', ''), trimSpaces],
modica: [(s) => s.replace('modica:', ''), trimSpaces],
voice: [phoneNumberStandardization],
sms: [phoneNumberStandardization],
whatsapp: [(s) => s.replace('whatsapp:', ''), phoneNumberStandardization],
modica: [(s) => s.replace('modica:', ''), phoneNumberStandardization],
facebook: [(s) => s.replace('messenger:', '')],
instagram: [],
line: [],
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// "incremental": true, /* Enable incremental compilation */
"target": "ES2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"lib": ["ES2020", "DOM"], /* Specify library files to be included in the compilation. */
"lib": ["ES2021", "DOM"], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
Expand Down

0 comments on commit ea8eb4b

Please sign in to comment.