Skip to content

Commit

Permalink
Fix: hide Monitors without a patient checkbox filter is not toggling (o…
Browse files Browse the repository at this point in the history
…hcnetwork#6992)

* fix: hide Monitors without a patient checkbox filter is not toggling state

* remove state variable isBedOccupied

* fix typo

* fix boolean qParam being string

* fix loading state and bugs

* fix initial state

---------

Co-authored-by: rithviknishad <[email protected]>
  • Loading branch information
GokulramGHV and rithviknishad authored Jan 8, 2024
1 parent 7f6cc0c commit 37b451a
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/Components/Facility/CentralNursingStation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export default function CentralNursingStation({ facilityId }: Props) {
offset: (qParams.page ? qParams.page - 1 : 0) * PER_PAGE_LIMIT,
asset_class: "HL7MONITOR",
ordering: qParams.ordering || "bed__name",
bed_is_occupied: qParams.bed_is_occupied ?? true,
bed_is_occupied:
(qParams.hide_monitors_without_patient ?? "true") === "true",
},
});

Expand Down Expand Up @@ -149,19 +150,12 @@ export default function CentralNursingStation({ facilityId }: Props) {
errorClassName="hidden"
/>
<CheckBoxFormField
name="bed_is_occupied"
name="hide_monitors_without_patient"
label="Hide Monitors without Patient"
value={
qParams.bed_is_occupied === "true" ||
qParams.bed_is_occupied === undefined
}
onChange={({ name, value }) => {
if (value) {
updateQuery({ [name]: value });
} else {
removeFilter(name);
}
}}
value={JSON.parse(
qParams.hide_monitors_without_patient ?? true
)}
onChange={(e) => updateQuery({ [e.name]: e.value })}
labelClassName="text-sm"
errorClassName="hidden"
/>
Expand Down Expand Up @@ -197,7 +191,7 @@ export default function CentralNursingStation({ facilityId }: Props) {
</div>
}
>
{data === undefined ? (
{data === undefined || query.loading ? (
<Loading />
) : data.length === 0 ? (
<div className="flex h-[80vh] w-full items-center justify-center text-center text-black">
Expand Down

0 comments on commit 37b451a

Please sign in to comment.