diff --git a/frontend/package-lock.json b/frontend/package-lock.json index eb2ea54481defa733fc7e513a6c5f774f0b3a58d..c5066b34f00d5603035839ff6d8bb88032c13174 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -33,7 +33,7 @@ "i18next": "^21.3.3", "i18next-browser-languagedetector": "^6.1.2", "i18next-http-backend": "^1.3.1", - "libphonenumber-js": "^1.9.35", + "libphonenumber-js": "^1.10.28", "lodash": "^4.17.21", "react": "^17.0.2", "react-cookie": "^4.1.1", @@ -15086,9 +15086,9 @@ } }, "node_modules/libphonenumber-js": { - "version": "1.9.39", - "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.9.39.tgz", - "integrity": "sha512-TxYz/Ii7mjkocKGKmFHhsTAvvcxr4AY3yUlZzZ2z7HC4DPRrNlzJ9n32/SMogqsyFOXLMXQPCkCInNRbiVaEPA==" + "version": "1.10.28", + "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.28.tgz", + "integrity": "sha512-1eAgjLrZA0+2Wgw4hs+4Q/kEBycxQo8ZLYnmOvZ3AlM8ImAVAJgDPlZtISLEzD1vunc2q8s2Pn7XwB7I8U3Kzw==" }, "node_modules/lines-and-columns": { "version": "1.1.6", @@ -35325,9 +35325,9 @@ } }, "libphonenumber-js": { - "version": "1.9.39", - "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.9.39.tgz", - "integrity": "sha512-TxYz/Ii7mjkocKGKmFHhsTAvvcxr4AY3yUlZzZ2z7HC4DPRrNlzJ9n32/SMogqsyFOXLMXQPCkCInNRbiVaEPA==" + "version": "1.10.28", + "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.28.tgz", + "integrity": "sha512-1eAgjLrZA0+2Wgw4hs+4Q/kEBycxQo8ZLYnmOvZ3AlM8ImAVAJgDPlZtISLEzD1vunc2q8s2Pn7XwB7I8U3Kzw==" }, "lines-and-columns": { "version": "1.1.6", diff --git a/frontend/package.json b/frontend/package.json index b541ee4be02d55bef09dd7f3fcfa95fc5f043d69..045374b2a09dbf1c820e303969c9d133914d3fcc 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -28,7 +28,7 @@ "i18next": "^21.3.3", "i18next-browser-languagedetector": "^6.1.2", "i18next-http-backend": "^1.3.1", - "libphonenumber-js": "^1.9.35", + "libphonenumber-js": "^1.10.28", "lodash": "^4.17.21", "react": "^17.0.2", "react-cookie": "^4.1.1", diff --git a/frontend/src/routes/guest/register/index.tsx b/frontend/src/routes/guest/register/index.tsx index b7a2d0932ed4b283daf0e6dbb2a8e56fe8a77006..639c5e96acf6cbcfc2428f2b82b0c47355304a2b 100644 --- a/frontend/src/routes/guest/register/index.tsx +++ b/frontend/src/routes/guest/register/index.tsx @@ -5,6 +5,7 @@ import { CountryCode, getCountries, getCountryCallingCode, + parsePhoneNumber, } from 'libphonenumber-js' import format from 'date-fns/format' import parse from 'date-fns/parse' @@ -236,9 +237,8 @@ export default function GuestRegister() { const payload: any = { person: {}, } - payload.person.private_mobile = `+${getCountryCallingCode( - registerData.mobilePhoneCountry as CountryCode - )}${registerData.mobilePhone}` + const parsedPhone = parsePhoneNumber(registerData.mobilePhone, registerData.mobilePhoneCountry as CountryCode) + payload.person.private_mobile = parsedPhone.format('E.164') if (initialGuestData !== null) { // Only include the fields if they have actually changed. Could also send them back to the diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index 681f6757998646ca1bc997b9de329c3298077053..77036843972653540141db395a42c12d79c50129 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -9,7 +9,7 @@ import { Consent, FetchedConsent, } from 'interfaces' -import { isValidPhoneNumber, parsePhoneNumber } from 'libphonenumber-js' +import { isValidPhoneNumber, parsePhoneNumber } from 'libphonenumber-js/mobile' import parse from 'date-fns/parse' import { parseInt } from 'lodash'