From 0a8abef8c9539da6c48d29aceb95c3293ae3c617 Mon Sep 17 00:00:00 2001 From: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> Date: Fri, 22 Sep 2023 21:38:53 +0530 Subject: [PATCH] Fix Ambulance Phone Number validation in Shifting --- src/Components/Patient/ShiftCreate.tsx | 11 +++++++++-- src/Utils/utils.ts | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Components/Patient/ShiftCreate.tsx b/src/Components/Patient/ShiftCreate.tsx index e8e89ebc59c..fb15039a2ea 100644 --- a/src/Components/Patient/ShiftCreate.tsx +++ b/src/Components/Patient/ShiftCreate.tsx @@ -145,6 +145,11 @@ export const ShiftCreate = (props: patientShiftProps) => { errors: action.errors, }; } + case "set_field": + return { + form: { ...state.form, [action.name]: action.value }, + errors: { ...state.errors, [action.name]: action.error }, + }; default: return state; } @@ -188,8 +193,10 @@ export const ShiftCreate = (props: patientShiftProps) => { const handleFormFieldChange = (event: FieldChangeEvent) => { dispatch({ - type: "set_form", - form: { ...state.form, [event.name]: event.value }, + type: "set_field", + name: event.name, + value: event.value, + error: "", }); }; diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index 4c29d5105f3..1c702e75e86 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -253,6 +253,8 @@ export interface CountryData { } export const parsePhoneNumber = (phoneNumber: string, countryCode?: string) => { + if (!phoneNumber) return ""; + if (phoneNumber === "+91") return ""; const phoneCodes: Record = phoneCodesJson; let parsedNumber = phoneNumber.replace(/[-+() ]/g, ""); if (countryCode && phoneCodes[countryCode]) {