Skip to content

Commit

Permalink
Fix Ambulance Phone Number validation in Shifting (#6332)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashesh3 authored Sep 22, 2023
1 parent fee0648 commit b2076e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Components/Patient/ShiftCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -188,8 +193,10 @@ export const ShiftCreate = (props: patientShiftProps) => {

const handleFormFieldChange = (event: FieldChangeEvent<unknown>) => {
dispatch({
type: "set_form",
form: { ...state.form, [event.name]: event.value },
type: "set_field",
name: event.name,
value: event.value,
error: "",
});
};

Expand Down
2 changes: 2 additions & 0 deletions src/Utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ export interface CountryData {
}

export const parsePhoneNumber = (phoneNumber: string, countryCode?: string) => {
if (!phoneNumber) return "";
if (phoneNumber === "+91") return "";
const phoneCodes: Record<string, CountryData> = phoneCodesJson;
let parsedNumber = phoneNumber.replace(/[-+() ]/g, "");
if (countryCode && phoneCodes[countryCode]) {
Expand Down

0 comments on commit b2076e3

Please sign in to comment.