Skip to content

Commit

Permalink
Show only ventilator in link assets to bed (#6146)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashesh3 authored Aug 25, 2023
1 parent 8c988b3 commit 2f86fde
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
12 changes: 10 additions & 2 deletions src/Components/Common/AssetSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ interface AssetSelectProps {
facility?: string;
is_working?: boolean;
in_use_by_consultation?: boolean;
is_permanent?: boolean;
is_permanent?: boolean | null;
multiple?: boolean;
AssetType?: number;
asset_class?: string;
showAll?: boolean;
showNOptions?: number;
freeText?: boolean;
Expand All @@ -34,20 +35,27 @@ export const AssetSelect = (props: AssetSelectProps) => {
className = "",
freeText = false,
errors = "",
asset_class = "",
} = props;

const dispatchAction: any = useDispatch();

const AssetSearch = useCallback(
async (text: string) => {
const params = {
const params: Partial<AssetSelectProps> & {
limit: number;
offset: number;
search_text: string;
asset_class: string;
} = {
limit: 50,
offset: 0,
search_text: text,
facility,
is_working,
in_use_by_consultation,
is_permanent,
asset_class,
};

const res = await dispatchAction(listAssets(params));
Expand Down
20 changes: 13 additions & 7 deletions src/Components/Facility/Consultations/Beds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ import { useDispatch } from "react-redux";
import dayjs from "../../../Utils/dayjs";
import { AssetSelect } from "../../Common/AssetSelect.js";
import DialogModal from "../../Common/Dialog.js";
import AssetsList from "../../Assets/AssetsList.js";
import { Link } from "raviger";
import { AssetData, assetClassProps } from "../../Assets/AssetTypes.js";
import {
AssetClass,
AssetData,
assetClassProps,
} from "../../Assets/AssetTypes.js";
import Chip from "../../../CAREUI/display/Chip.js";

interface BedsProps {
Expand Down Expand Up @@ -229,6 +232,7 @@ const Beds = (props: BedsProps) => {
setSelected={setAssets}
selected={assets}
multiple={true}
asset_class={AssetClass.VENTILATOR}
facility={facilityId}
in_use_by_consultation={false}
is_permanent={false}
Expand Down Expand Up @@ -271,11 +275,13 @@ const Beds = (props: BedsProps) => {
{bed?.bed_object?.name}
{bed?.assets_objects && bed.assets_objects.length > 0 && (
<span
className={` bg-primary-500 font-semibold text-white ml-2 h-6 cursor-pointer rounded-md px-2 text-xs`}
onClick={() => setShowBedDetails(bed)}
>
{bed.assets_objects.length}
</span>
className={
" ml-2 h-6 cursor-pointer rounded-md bg-primary-500 px-2 text-xs font-semibold text-white"
}
onClick={() => setShowBedDetails(bed)}
>
{bed.assets_objects.length}
</span>
)}
</div>
<div className="bg-primary-100 py-2 text-center">
Expand Down

0 comments on commit 2f86fde

Please sign in to comment.