{EYE_OPEN_SCALE.map((x: any) => (
Date: Wed, 20 Sep 2023 03:47:48 +0530
Subject: [PATCH 4/6] Medibase Search: Skip showing selected option search
results when query is present (#6284)
* fixes #6283; skip showing selected option in medibase search
* fix onblur
---
src/Components/Form/FormFields/Autocomplete.tsx | 1 +
src/Components/Medicine/MedibaseAutocompleteFormField.tsx | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/Components/Form/FormFields/Autocomplete.tsx b/src/Components/Form/FormFields/Autocomplete.tsx
index dcf3ab5e8b6..bbc60643faf 100644
--- a/src/Components/Form/FormFields/Autocomplete.tsx
+++ b/src/Components/Form/FormFields/Autocomplete.tsx
@@ -157,6 +157,7 @@ export const Autocomplete = (props: AutocompleteProps) => {
placeholder={props.placeholder ?? "Select"}
displayValue={(value: any) => value?.label || ""}
onChange={(event) => setQuery(event.target.value.toLowerCase())}
+ onBlur={() => value && setQuery("")}
autoComplete="off"
/>
diff --git a/src/Components/Medicine/MedibaseAutocompleteFormField.tsx b/src/Components/Medicine/MedibaseAutocompleteFormField.tsx
index 337546691f9..2b5612f6f32 100644
--- a/src/Components/Medicine/MedibaseAutocompleteFormField.tsx
+++ b/src/Components/Medicine/MedibaseAutocompleteFormField.tsx
@@ -49,7 +49,7 @@ export default function MedibaseAutocompleteFormField(
value={field.value}
required
onChange={field.handleChange}
- options={options(field.value && [field.value])}
+ options={options(field.value && !query && [field.value])}
optionLabel={(option) => option.name.toUpperCase()}
optionDescription={(option) => }
optionValue={(option) => option}
From 4c8b840977c3766469cd9dc8332df1c288a37585 Mon Sep 17 00:00:00 2001
From: print-Sathvik <113630200+print-Sathvik@users.noreply.github.com>
Date: Wed, 20 Sep 2023 03:50:37 +0530
Subject: [PATCH 5/6] Remove libphonenumber js (#6222)
* Replaced libphonenumber-js with custom functions
* used PhoneNumberValidator to validate
* Fixed asset import cypress test
---
package-lock.json | 6 -
package.json | 1 -
src/Common/constants.tsx | 132 ++++++++++++++++-
src/Common/static/countryPhoneAndFlags.json | 54 +++----
src/Components/ExternalResult/ResultList.tsx | 4 +-
src/Components/Facility/AssetCreate.tsx | 5 +-
src/Components/Facility/FacilityCard.tsx | 9 +-
src/Components/Facility/FacilityCreate.tsx | 20 +--
.../Form/FormFields/PhoneNumberFormField.tsx | 50 ++-----
src/Components/Patient/ManagePatients.tsx | 8 +-
src/Components/Patient/PatientRegister.tsx | 45 +++---
src/Components/Patient/ShiftCreate.tsx | 23 +--
src/Components/Resource/ResourceCreate.tsx | 16 +-
src/Components/Shifting/ListFilter.tsx | 11 +-
.../Shifting/ShiftDetailsUpdate.tsx | 9 +-
src/Components/Users/UserAdd.tsx | 41 +++---
src/Components/Users/UserFilter.tsx | 10 +-
src/Components/Users/UserProfile.tsx | 28 ++--
src/Utils/utils.ts | 139 +++++++++++++++++-
19 files changed, 425 insertions(+), 186 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index db11b8c5220..6f655932fd7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -32,7 +32,6 @@
"events": "^3.3.0",
"i18next": "^23.2.7",
"i18next-browser-languagedetector": "^7.1.0",
- "libphonenumber-js": "^1.10.37",
"lodash": "^4.17.21",
"postcss-loader": "^7.3.3",
"qrcode.react": "^3.1.0",
@@ -12079,11 +12078,6 @@
"node": ">= 0.8.0"
}
},
- "node_modules/libphonenumber-js": {
- "version": "1.10.37",
- "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.37.tgz",
- "integrity": "sha512-Z10PCaOCiAxbUxLyR31DNeeNugSVP6iv/m7UrSKS5JHziEMApJtgku4e9Q69pzzSC9LnQiM09sqsGf2ticZnMw=="
- },
"node_modules/lilconfig": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz",
diff --git a/package.json b/package.json
index 2e894f22288..8ade8c604be 100644
--- a/package.json
+++ b/package.json
@@ -72,7 +72,6 @@
"events": "^3.3.0",
"i18next": "^23.2.7",
"i18next-browser-languagedetector": "^7.1.0",
- "libphonenumber-js": "^1.10.37",
"lodash": "^4.17.21",
"postcss-loader": "^7.3.3",
"qrcode.react": "^3.1.0",
diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx
index c696beb1f15..f64a9fa27ae 100644
--- a/src/Common/constants.tsx
+++ b/src/Common/constants.tsx
@@ -1,9 +1,9 @@
import { IConfig } from "./hooks/useConfig";
import { PatientCategory } from "../Components/Facility/models";
import { SortOption } from "../Components/Common/SortDropdown";
-import { parsePhoneNumberFromString } from "libphonenumber-js";
import { dateQueryString } from "../Utils/utils";
import { IconName } from "../CAREUI/icons/CareIcon";
+import { PhoneNumberValidator } from "../Components/Form/FieldValidators";
export const RESULTS_PER_PAGE_LIMIT = 14;
export const PAGINATION_LIMIT = 36;
@@ -938,13 +938,12 @@ export const XLSXAssetImportSchema = {
prop: "support_phone",
type: String,
parse: (phone: number | string) => {
- const parsed = parsePhoneNumberFromString(String(phone), "IN");
-
- if (!parsed?.isValid()) {
+ phone = "+91" + String(phone);
+ if (!PhoneNumberValidator(["support"])(phone) === undefined) {
throw new Error("Invalid Support Phone Number");
}
- return parsed?.format("E.164");
+ return phone ? phone : undefined;
},
required: true,
},
@@ -1001,3 +1000,126 @@ export const XLSXAssetImportSchema = {
},
},
};
+
+export const AREACODES: Record = {
+ CA: [
+ "403",
+ "587",
+ "250",
+ "604",
+ "778",
+ "204",
+ "431",
+ "506",
+ "709",
+ "867",
+ "902",
+ "226",
+ "249",
+ "289",
+ "343",
+ "365",
+ "416",
+ "437",
+ "519",
+ "613",
+ "647",
+ "705",
+ "807",
+ "902",
+ "418",
+ "438",
+ "450",
+ "514",
+ "579",
+ "581",
+ "819",
+ "306",
+ "639",
+ "867",
+ ],
+ JM: ["658", "876"],
+ PR: ["787", "939"],
+ DO: ["809", "829"],
+ RE: ["262", "263", "692", "693"],
+ YT: ["269", "639"],
+ CC: ["89162"],
+ CX: ["89164"],
+ BQ: ["9"],
+ KZ: ["6", "7"],
+ SJ: ["79"],
+};
+
+export const IN_LANDLINE_AREA_CODES = [
+ "11",
+ "22",
+ "33",
+ "44",
+ "20",
+ "40",
+ "79",
+ "80",
+ "120",
+ "124",
+ "129",
+ "135",
+ "141",
+ "160",
+ "161",
+ "172",
+ "175",
+ "181",
+ "183",
+ "233",
+ "240",
+ "241",
+ "250",
+ "251",
+ "253",
+ "257",
+ "260",
+ "261",
+ "265",
+ "343",
+ "413",
+ "422",
+ "431",
+ "435",
+ "452",
+ "462",
+ "471",
+ "474",
+ "477",
+ "478",
+ "481",
+ "484",
+ "485",
+ "487",
+ "490",
+ "497",
+ "512",
+ "522",
+ "532",
+ "542",
+ "551",
+ "562",
+ "581",
+ "591",
+ "621",
+ "612",
+ "641",
+ "657",
+ "712",
+ "721",
+ "724",
+ "751",
+ "761",
+ "821",
+ "824",
+ "831",
+ "836",
+ "866",
+ "870",
+ "891",
+ "4822",
+];
diff --git a/src/Common/static/countryPhoneAndFlags.json b/src/Common/static/countryPhoneAndFlags.json
index 9b2ea40427d..87d963444b5 100644
--- a/src/Common/static/countryPhoneAndFlags.json
+++ b/src/Common/static/countryPhoneAndFlags.json
@@ -2,20 +2,20 @@
"AD": { "flag": "๐ฆ๐ฉ", "name": "Andorra", "code": "376" },
"AE": { "flag": "๐ฆ๐ช", "name": "United Arab Emirates", "code": "971" },
"AF": { "flag": "๐ฆ๐ซ", "name": "Afghanistan", "code": "93" },
- "AG": { "flag": "๐ฆ๐ฌ", "name": "Antigua & Barbuda", "code": "+1-268" },
- "AI": { "flag": "๐ฆ๐ฎ", "name": "Anguilla", "code": "+1-264" },
+ "AG": { "flag": "๐ฆ๐ฌ", "name": "Antigua & Barbuda", "code": "1-268" },
+ "AI": { "flag": "๐ฆ๐ฎ", "name": "Anguilla", "code": "1-264" },
"AL": { "flag": "๐ฆ๐ฑ", "name": "Albania", "code": "355" },
"AM": { "flag": "๐ฆ๐ฒ", "name": "Armenia", "code": "374" },
"AO": { "flag": "๐ฆ๐ด", "name": "Angola", "code": "244" },
"AR": { "flag": "๐ฆ๐ท", "name": "Argentina", "code": "54" },
- "AS": { "flag": "๐ฆ๐ธ", "name": "American Samoa", "code": "+1-684" },
+ "AS": { "flag": "๐ฆ๐ธ", "name": "American Samoa", "code": "1-684" },
"AT": { "flag": "๐ฆ๐น", "name": "Austria", "code": "43" },
"AU": { "flag": "๐ฆ๐บ", "name": "Australia", "code": "61" },
"AW": { "flag": "๐ฆ๐ผ", "name": "Aruba", "code": "297" },
- "AX": { "flag": "๐ฆ๐ฝ", "name": "ร
land Islands", "code": "+358-18" },
+ "AX": { "flag": "๐ฆ๐ฝ", "name": "ร
land Islands", "code": "358-18" },
"AZ": { "flag": "๐ฆ๐ฟ", "name": "Azerbaijan", "code": "994" },
"BA": { "flag": "๐ง๐ฆ", "name": "Bosnia & Herzegovina", "code": "387" },
- "BB": { "flag": "๐ง๐ง", "name": "Barbados", "code": "+1-246" },
+ "BB": { "flag": "๐ง๐ง", "name": "Barbados", "code": "1-246" },
"BD": { "flag": "๐ง๐ฉ", "name": "Bangladesh", "code": "880" },
"BE": { "flag": "๐ง๐ช", "name": "Belgium", "code": "32" },
"BF": { "flag": "๐ง๐ซ", "name": "Burkina Faso", "code": "226" },
@@ -24,12 +24,12 @@
"BI": { "flag": "๐ง๐ฎ", "name": "Burundi", "code": "257" },
"BJ": { "flag": "๐ง๐ฏ", "name": "Benin", "code": "229" },
"BL": { "flag": "๐ง๐ฑ", "name": "St. Barthรฉlemy", "code": "590" },
- "BM": { "flag": "๐ง๐ฒ", "name": "Bermuda", "code": "+1-441" },
+ "BM": { "flag": "๐ง๐ฒ", "name": "Bermuda", "code": "1-441" },
"BN": { "flag": "๐ง๐ณ", "name": "Brunei", "code": "673" },
"BO": { "flag": "๐ง๐ด", "name": "Bolivia", "code": "591" },
"BQ": { "flag": "๐ง๐ถ", "name": "Caribbean Netherlands", "code": "599" },
"BR": { "flag": "๐ง๐ท", "name": "Brazil", "code": "55" },
- "BS": { "flag": "๐ง๐ธ", "name": "Bahamas", "code": "+1-242" },
+ "BS": { "flag": "๐ง๐ธ", "name": "Bahamas", "code": "1-242" },
"BT": { "flag": "๐ง๐น", "name": "Bhutan", "code": "975" },
"BW": { "flag": "๐ง๐ผ", "name": "Botswana", "code": "267" },
"BY": { "flag": "๐ง๐พ", "name": "Belarus", "code": "375" },
@@ -56,11 +56,11 @@
"DE": { "flag": "๐ฉ๐ช", "name": "Germany", "code": "49" },
"DJ": { "flag": "๐ฉ๐ฏ", "name": "Djibouti", "code": "253" },
"DK": { "flag": "๐ฉ๐ฐ", "name": "Denmark", "code": "45" },
- "DM": { "flag": "๐ฉ๐ฒ", "name": "Dominica", "code": "+1-767" },
+ "DM": { "flag": "๐ฉ๐ฒ", "name": "Dominica", "code": "1-767" },
"DO": {
"flag": "๐ฉ๐ด",
"name": "Dominican Republic",
- "code": "+1-809 and 1-829"
+ "code": "1"
},
"DZ": { "flag": "๐ฉ๐ฟ", "name": "Algeria", "code": "213" },
"EC": { "flag": "๐ช๐จ", "name": "Ecuador", "code": "593" },
@@ -78,10 +78,10 @@
"FR": { "flag": "๐ซ๐ท", "name": "France", "code": "33" },
"GA": { "flag": "๐ฌ๐ฆ", "name": "Gabon", "code": "241" },
"GB": { "flag": "๐ฌ๐ง", "name": "United Kingdom", "code": "44" },
- "GD": { "flag": "๐ฌ๐ฉ", "name": "Grenada", "code": "+1-473" },
+ "GD": { "flag": "๐ฌ๐ฉ", "name": "Grenada", "code": "1-473" },
"GE": { "flag": "๐ฌ๐ช", "name": "Georgia", "code": "995" },
"GF": { "flag": "๐ฌ๐ซ", "name": "French Guiana", "code": "594" },
- "GG": { "flag": "๐ฌ๐ฌ", "name": "Guernsey", "code": "+44-1481" },
+ "GG": { "flag": "๐ฌ๐ฌ", "name": "Guernsey", "code": "44-1481" },
"GH": { "flag": "๐ฌ๐ญ", "name": "Ghana", "code": "233" },
"GI": { "flag": "๐ฌ๐ฎ", "name": "Gibraltar", "code": "350" },
"GL": { "flag": "๐ฌ๐ฑ", "name": "Greenland", "code": "299" },
@@ -91,7 +91,7 @@
"GQ": { "flag": "๐ฌ๐ถ", "name": "Equatorial Guinea", "code": "240" },
"GR": { "flag": "๐ฌ๐ท", "name": "Greece", "code": "30" },
"GT": { "flag": "๐ฌ๐น", "name": "Guatemala", "code": "502" },
- "GU": { "flag": "๐ฌ๐บ", "name": "Guam", "code": "+1-671" },
+ "GU": { "flag": "๐ฌ๐บ", "name": "Guam", "code": "1-671" },
"GW": { "flag": "๐ฌ๐ผ", "name": "Guinea-Bissau", "code": "245" },
"GY": { "flag": "๐ฌ๐พ", "name": "Guyana", "code": "592" },
"HK": { "flag": "๐ญ๐ฐ", "name": "Hong Kong SAR China", "code": "852" },
@@ -103,7 +103,7 @@
"ID": { "flag": "๐ฎ๐ฉ", "name": "Indonesia", "code": "62" },
"IE": { "flag": "๐ฎ๐ช", "name": "Ireland", "code": "353" },
"IL": { "flag": "๐ฎ๐ฑ", "name": "Israel", "code": "972" },
- "IM": { "flag": "๐ฎ๐ฒ", "name": "Isle of Man", "code": "+44-1624" },
+ "IM": { "flag": "๐ฎ๐ฒ", "name": "Isle of Man", "code": "44-1624" },
"IN": { "flag": "๐ฎ๐ณ", "name": "India", "code": "91" },
"IO": {
"flag": "๐ฎ๐ด",
@@ -114,8 +114,8 @@
"IR": { "flag": "๐ฎ๐ท", "name": "Iran", "code": "98" },
"IS": { "flag": "๐ฎ๐ธ", "name": "Iceland", "code": "354" },
"IT": { "flag": "๐ฎ๐น", "name": "Italy", "code": "39" },
- "JE": { "flag": "๐ฏ๐ช", "name": "Jersey", "code": "+44-1534" },
- "JM": { "flag": "๐ฏ๐ฒ", "name": "Jamaica", "code": "+1-876" },
+ "JE": { "flag": "๐ฏ๐ช", "name": "Jersey", "code": "44-1534" },
+ "JM": { "flag": "๐ฏ๐ฒ", "name": "Jamaica", "code": "1" },
"JO": { "flag": "๐ฏ๐ด", "name": "Jordan", "code": "962" },
"JP": { "flag": "๐ฏ๐ต", "name": "Japan", "code": "81" },
"KE": { "flag": "๐ฐ๐ช", "name": "Kenya", "code": "254" },
@@ -123,15 +123,15 @@
"KH": { "flag": "๐ฐ๐ญ", "name": "Cambodia", "code": "855" },
"KI": { "flag": "๐ฐ๐ฎ", "name": "Kiribati", "code": "686" },
"KM": { "flag": "๐ฐ๐ฒ", "name": "Comoros", "code": "269" },
- "KN": { "flag": "๐ฐ๐ณ", "name": "St. Kitts & Nevis", "code": "+1-869" },
+ "KN": { "flag": "๐ฐ๐ณ", "name": "St. Kitts & Nevis", "code": "1-869" },
"KP": { "flag": "๐ฐ๐ต", "name": "North Korea", "code": "850" },
"KR": { "flag": "๐ฐ๐ท", "name": "South Korea", "code": "82" },
"KW": { "flag": "๐ฐ๐ผ", "name": "Kuwait", "code": "965" },
- "KY": { "flag": "๐ฐ๐พ", "name": "Cayman Islands", "code": "+1-345" },
+ "KY": { "flag": "๐ฐ๐พ", "name": "Cayman Islands", "code": "1-345" },
"KZ": { "flag": "๐ฐ๐ฟ", "name": "Kazakhstan", "code": "7" },
"LA": { "flag": "๐ฑ๐ฆ", "name": "Laos", "code": "856" },
"LB": { "flag": "๐ฑ๐ง", "name": "Lebanon", "code": "961" },
- "LC": { "flag": "๐ฑ๐จ", "name": "St. Lucia", "code": "+1-758" },
+ "LC": { "flag": "๐ฑ๐จ", "name": "St. Lucia", "code": "1-758" },
"LI": { "flag": "๐ฑ๐ฎ", "name": "Liechtenstein", "code": "423" },
"LK": { "flag": "๐ฑ๐ฐ", "name": "Sri Lanka", "code": "94" },
"LR": { "flag": "๐ฑ๐ท", "name": "Liberia", "code": "231" },
@@ -152,10 +152,10 @@
"MM": { "flag": "๐ฒ๐ฒ", "name": "Myanmar (Burma)", "code": "95" },
"MN": { "flag": "๐ฒ๐ณ", "name": "Mongolia", "code": "976" },
"MO": { "flag": "๐ฒ๐ด", "name": "Macao SAR China", "code": "853" },
- "MP": { "flag": "๐ฒ๐ต", "name": "Northern Mariana Islands", "code": "+1-670" },
+ "MP": { "flag": "๐ฒ๐ต", "name": "Northern Mariana Islands", "code": "1-670" },
"MQ": { "flag": "๐ฒ๐ถ", "name": "Martinique", "code": "596" },
"MR": { "flag": "๐ฒ๐ท", "name": "Mauritania", "code": "222" },
- "MS": { "flag": "๐ฒ๐ธ", "name": "Montserrat", "code": "+1-664" },
+ "MS": { "flag": "๐ฒ๐ธ", "name": "Montserrat", "code": "1-664" },
"MT": { "flag": "๐ฒ๐น", "name": "Malta", "code": "356" },
"MU": { "flag": "๐ฒ๐บ", "name": "Mauritius", "code": "230" },
"MV": { "flag": "๐ฒ๐ป", "name": "Maldives", "code": "960" },
@@ -185,7 +185,7 @@
"PL": { "flag": "๐ต๐ฑ", "name": "Poland", "code": "48" },
"PM": { "flag": "๐ต๐ฒ", "name": "St. Pierre & Miquelon", "code": "508" },
"PN": { "flag": "๐ต๐ณ", "name": "Pitcairn Islands", "code": "870" },
- "PR": { "flag": "๐ต๐ท", "name": "Puerto Rico", "code": "+1-787 and 1-939" },
+ "PR": { "flag": "๐ต๐ท", "name": "Puerto Rico", "code": "1" },
"PS": { "flag": "๐ต๐ธ", "name": "Palestinian Territories", "code": "970" },
"PT": { "flag": "๐ต๐น", "name": "Portugal", "code": "351" },
"PW": { "flag": "๐ต๐ผ", "name": "Palau", "code": "680" },
@@ -214,10 +214,10 @@
"SS": { "flag": "๐ธ๐ธ", "name": "South Sudan", "code": "211" },
"ST": { "flag": "๐ธ๐น", "name": "Sรฃo Tomรฉ & Prรญncipe", "code": "239" },
"SV": { "flag": "๐ธ๐ป", "name": "El Salvador", "code": "503" },
- "SX": { "flag": "๐ธ๐ฝ", "name": "Sint Maarten", "code": "599" },
+ "SX": { "flag": "๐ธ๐ฝ", "name": "Sint Maarten", "code": "1-721" },
"SY": { "flag": "๐ธ๐พ", "name": "Syria", "code": "963" },
"SZ": { "flag": "๐ธ๐ฟ", "name": "Eswatini", "code": "268" },
- "TC": { "flag": "๐น๐จ", "name": "Turks & Caicos Islands", "code": "+1-649" },
+ "TC": { "flag": "๐น๐จ", "name": "Turks & Caicos Islands", "code": "1-649" },
"TD": { "flag": "๐น๐ฉ", "name": "Chad", "code": "235" },
"TG": { "flag": "๐น๐ฌ", "name": "Togo", "code": "228" },
"TH": { "flag": "๐น๐ญ", "name": "Thailand", "code": "66" },
@@ -228,7 +228,7 @@
"TN": { "flag": "๐น๐ณ", "name": "Tunisia", "code": "216" },
"TO": { "flag": "๐น๐ด", "name": "Tonga", "code": "676" },
"TR": { "flag": "๐น๐ท", "name": "Turkey", "code": "90" },
- "TT": { "flag": "๐น๐น", "name": "Trinidad & Tobago", "code": "+1-868" },
+ "TT": { "flag": "๐น๐น", "name": "Trinidad & Tobago", "code": "1-868" },
"TV": { "flag": "๐น๐ป", "name": "Tuvalu", "code": "688" },
"TW": { "flag": "๐น๐ผ", "name": "Taiwan", "code": "886" },
"TZ": { "flag": "๐น๐ฟ", "name": "Tanzania", "code": "255" },
@@ -239,10 +239,10 @@
"UY": { "flag": "๐บ๐พ", "name": "Uruguay", "code": "598" },
"UZ": { "flag": "๐บ๐ฟ", "name": "Uzbekistan", "code": "998" },
"VA": { "flag": "๐ป๐ฆ", "name": "Vatican City", "code": "379" },
- "VC": { "flag": "๐ป๐จ", "name": "St. Vincent & Grenadines", "code": "+1-784" },
+ "VC": { "flag": "๐ป๐จ", "name": "St. Vincent & Grenadines", "code": "1-784" },
"VE": { "flag": "๐ป๐ช", "name": "Venezuela", "code": "58" },
- "VG": { "flag": "๐ป๐ฌ", "name": "British Virgin Islands", "code": "+1-284" },
- "VI": { "flag": "๐ป๐ฎ", "name": "U.S. Virgin Islands", "code": "+1-340" },
+ "VG": { "flag": "๐ป๐ฌ", "name": "British Virgin Islands", "code": "1-284" },
+ "VI": { "flag": "๐ป๐ฎ", "name": "U.S. Virgin Islands", "code": "1-340" },
"VN": { "flag": "๐ป๐ณ", "name": "Vietnam", "code": "84" },
"VU": { "flag": "๐ป๐บ", "name": "Vanuatu", "code": "678" },
"WF": { "flag": "๐ผ๐ซ", "name": "Wallis & Futuna", "code": "681" },
diff --git a/src/Components/ExternalResult/ResultList.tsx b/src/Components/ExternalResult/ResultList.tsx
index 18de6f29134..74fbf8430b0 100644
--- a/src/Components/ExternalResult/ResultList.tsx
+++ b/src/Components/ExternalResult/ResultList.tsx
@@ -6,7 +6,7 @@ import { externalResultList } from "../../Redux/actions";
import ListFilter from "./ListFilter";
import FacilitiesSelectDialogue from "./FacilitiesSelectDialogue";
import { FacilityModel } from "../Facility/models";
-import parsePhoneNumberFromString from "libphonenumber-js";
+import { parsePhoneNumber } from "../../Utils/utils";
import SearchInput from "../Form/SearchInput";
import useFilters from "../../Common/hooks/useFilters";
import CareIcon from "../../CAREUI/icons/CareIcon";
@@ -65,7 +65,7 @@ export default function ResultList() {
page: qParams.page || 1,
name: qParams.name || "",
mobile_number: qParams.mobile_number
- ? parsePhoneNumberFromString(qParams.mobile_number)?.format("E.164")
+ ? parsePhoneNumber(qParams.mobile_number) ?? ""
: "",
wards: qParams.wards || undefined,
local_bodies: qParams.local_bodies || undefined,
diff --git a/src/Components/Facility/AssetCreate.tsx b/src/Components/Facility/AssetCreate.tsx
index 1e6eead5242..156d738857a 100644
--- a/src/Components/Facility/AssetCreate.tsx
+++ b/src/Components/Facility/AssetCreate.tsx
@@ -30,13 +30,12 @@ import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
import TextFormField from "../Form/FormFields/TextFormField";
import { navigate } from "raviger";
-import { parsePhoneNumberFromString } from "libphonenumber-js";
import { parseQueryParams } from "../../Utils/primitives";
import useAppHistory from "../../Common/hooks/useAppHistory";
import { useDispatch } from "react-redux";
import useVisibility from "../../Utils/useVisibility";
import { validateEmailAddress } from "../../Common/validation";
-import { dateQueryString } from "../../Utils/utils.js";
+import { dateQueryString, parsePhoneNumber } from "../../Utils/utils.js";
import dayjs from "../../Utils/dayjs";
import DateInputV2 from "../Common/DateInputV2.js";
@@ -341,7 +340,7 @@ const AssetCreate = (props: AssetProps) => {
support_email: support_email,
support_phone: support_phone.startsWith("1800")
? support_phone
- : parsePhoneNumberFromString(support_phone)?.format("E.164"),
+ : parsePhoneNumber(support_phone),
qr_code_id: qrCodeId !== "" ? qrCodeId : null,
manufacturer: manufacturer,
warranty_amc_end_of_validity: warranty_amc_end_of_validity
diff --git a/src/Components/Facility/FacilityCard.tsx b/src/Components/Facility/FacilityCard.tsx
index e66fc4f3cc2..43e515cec93 100644
--- a/src/Components/Facility/FacilityCard.tsx
+++ b/src/Components/Facility/FacilityCard.tsx
@@ -9,7 +9,7 @@ import ButtonV2, { Cancel, Submit } from "../Common/components/ButtonV2";
import * as Notification from "../../Utils/Notifications.js";
import Chip from "../../CAREUI/display/Chip";
import CareIcon from "../../CAREUI/icons/CareIcon";
-import { parsePhoneNumber } from "libphonenumber-js";
+import { formatPhoneNumber, parsePhoneNumber } from "../../Utils/utils";
import DialogModal from "../Common/Dialog";
import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
import useConfig from "../../Common/hooks/useConfig";
@@ -147,10 +147,9 @@ export const FacilityCard = (props: { facility: any; userType: any }) => {
href={`tel:${facility.phone_number}`}
className="text-sm font-semibold tracking-wider"
>
- {parsePhoneNumber(
- facility.phone_number as string,
- "IN"
- ).formatInternational() || "-"}
+ {formatPhoneNumber(
+ parsePhoneNumber(facility.phone_number as string) ?? "-"
+ )}
diff --git a/src/Components/Facility/FacilityCreate.tsx b/src/Components/Facility/FacilityCreate.tsx
index d1243daaf1d..e742caefb82 100644
--- a/src/Components/Facility/FacilityCreate.tsx
+++ b/src/Components/Facility/FacilityCreate.tsx
@@ -26,7 +26,11 @@ import {
listDoctor,
updateFacility,
} from "../../Redux/actions";
-import { getPincodeDetails, includesIgnoreCase } from "../../Utils/utils";
+import {
+ getPincodeDetails,
+ includesIgnoreCase,
+ parsePhoneNumber,
+} from "../../Utils/utils";
import {
phonePreg,
validateLatitude,
@@ -51,11 +55,11 @@ import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
import TextFormField from "../Form/FormFields/TextFormField";
import { navigate } from "raviger";
-import { parsePhoneNumberFromString } from "libphonenumber-js";
import useAppHistory from "../../Common/hooks/useAppHistory";
import useConfig from "../../Common/hooks/useConfig";
import { useDispatch } from "react-redux";
import { useTranslation } from "react-i18next";
+import { PhoneNumberValidator } from "../Form/FieldValidators.js";
const Loading = lazy(() => import("../Common/Loading"));
@@ -434,11 +438,11 @@ export const FacilityCreate = (props: FacilityProps) => {
return;
case "phone_number":
// eslint-disable-next-line no-case-declarations
- const phoneNumber = parsePhoneNumberFromString(state.form[field]);
+ const phoneNumber = state.form[field];
if (
- !state.form[field] ||
- !phoneNumber?.isPossible() ||
- !phonePreg(String(phoneNumber?.number))
+ !phoneNumber ||
+ !PhoneNumberValidator()(phoneNumber) === undefined ||
+ !phonePreg(phoneNumber)
) {
errors[field] = t("invalid_phone_number");
invalidForm = true;
@@ -488,9 +492,7 @@ export const FacilityCreate = (props: FacilityProps) => {
kasp_empanelled: JSON.parse(state.form.kasp_empanelled),
latitude: state.form.latitude || null,
longitude: state.form.longitude || null,
- phone_number: parsePhoneNumberFromString(
- state.form.phone_number
- )?.format("E.164"),
+ phone_number: parsePhoneNumber(state.form.phone_number),
oxygen_capacity: state.form.oxygen_capacity
? state.form.oxygen_capacity
: 0,
diff --git a/src/Components/Form/FormFields/PhoneNumberFormField.tsx b/src/Components/Form/FormFields/PhoneNumberFormField.tsx
index 64c93c51500..6aa70f801de 100644
--- a/src/Components/Form/FormFields/PhoneNumberFormField.tsx
+++ b/src/Components/Form/FormFields/PhoneNumberFormField.tsx
@@ -1,12 +1,13 @@
import { FormFieldBaseProps, useFormFieldPropsResolver } from "./Utils";
import FormField from "./FormField";
+import { useEffect, useMemo, useState } from "react";
import {
- AsYouType,
- isValidPhoneNumber,
+ classNames,
parsePhoneNumber,
-} from "libphonenumber-js";
-import { useMemo, useState } from "react";
-import { classNames } from "../../../Utils/utils";
+ formatPhoneNumber as formatPhoneNumberUtil,
+ getCountryCode,
+ CountryData,
+} from "../../../Utils/utils";
import phoneCodesJson from "../../../Common/static/countryPhoneAndFlags.json";
import {
FieldError,
@@ -15,12 +16,6 @@ import {
} from "../FieldValidators";
import CareIcon from "../../../CAREUI/icons/CareIcon";
-interface CountryData {
- flag: string;
- name: string;
- code: string;
-}
-
const phoneCodes: Record