Skip to content

Commit

Permalink
CNS: filter by locations changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacobjeevan committed Oct 17, 2024
1 parent cafe126 commit 5f0e0a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Components/Common/LocationSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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,
Expand All @@ -31,6 +35,10 @@ export const LocationSelect = (props: LocationSelectProps) => {
},
);

if (props.disableOnOneOrFewer && data && data.count <= 1) {
props = { ...props, disabled: true };
}

return props.multiple ? (
<AutocompleteMultiSelectFormField
name={props.name}
Expand Down
4 changes: 4 additions & 0 deletions src/Components/Facility/CentralNursingStation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ export default function CentralNursingStation({ facilityId }: Props) {
facilityId={facilityId}
errors=""
errorClassName="hidden"
bedIsOccupied={JSON.parse(
qParams.monitors_without_patient ?? "false",
)}
disableOnOneOrFewer
/>
</div>
</div>
Expand Down

0 comments on commit 5f0e0a8

Please sign in to comment.