Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CNS: filter by locations changes #8812

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading