From 5f0e0a81dd772a4d29132f4b29781d98e2402d1d Mon Sep 17 00:00:00 2001 From: Jacobjohnjeevan Date: Thu, 17 Oct 2024 12:50:32 +0530 Subject: [PATCH] CNS: filter by locations changes --- src/Components/Common/LocationSelect.tsx | 8 ++++++++ src/Components/Facility/CentralNursingStation.tsx | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/Components/Common/LocationSelect.tsx b/src/Components/Common/LocationSelect.tsx index cf8a4e2d6b8..cb1b7514ac0 100644 --- a/src/Components/Common/LocationSelect.tsx +++ b/src/Components/Common/LocationSelect.tsx @@ -15,6 +15,8 @@ interface LocationSelectProps { selected: string | string[] | null; setSelected: (selected: string | string[] | null) => void; errorClassName?: string; + bedIsOccupied?: boolean; + disableOnOneOrFewer?: boolean; } export const LocationSelect = (props: LocationSelectProps) => { @@ -23,6 +25,8 @@ export const LocationSelect = (props: LocationSelectProps) => { { query: { limit: 14, + bed_is_occupied: + props.bedIsOccupied === undefined ? undefined : !props.bedIsOccupied, }, pathParams: { facility_external_id: props.facilityId, @@ -31,6 +35,10 @@ export const LocationSelect = (props: LocationSelectProps) => { }, ); + if (props.disableOnOneOrFewer && data && data.count <= 1) { + props = { ...props, disabled: true }; + } + return props.multiple ? (