Skip to content

Commit

Permalink
refactored handlSearch
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahendar0701 committed Dec 7, 2024
1 parent 89956a6 commit 1ee55dd
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/components/Facility/DischargedPatientsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,21 @@ const DischargedPatientsList = ({

const handleSearch = useCallback(
(key: string, value: string) => {
const isValidPhoneNumber = (val: string) =>
val.length >= 13 || val === "";

const updatedQuery = {
phone_number:
key === "phone_number"
? value.length >= 13 || value === ""
? value
: undefined
key === "phone_number" && isValidPhoneNumber(value)
? value
: undefined,
name: key === "name" ? value : undefined,
patient_no: key === "patient_no" ? value : undefined,
emergency_phone_number:
key === "emergency_contact_number"
? value.length >= 13 || value === ""
? value
: undefined
key === "emergency_contact_number" && isValidPhoneNumber(value)
? value
: undefined,
};

updateQuery(updatedQuery);
},
[updateQuery],
Expand Down

0 comments on commit 1ee55dd

Please sign in to comment.