diff --git a/src/Components/Facility/LocationManagement.tsx b/src/Components/Facility/LocationManagement.tsx index 83bf335aff2..d40852d940f 100644 --- a/src/Components/Facility/LocationManagement.tsx +++ b/src/Components/Facility/LocationManagement.tsx @@ -13,6 +13,7 @@ import ConfirmDialog from "../Common/ConfirmDialog"; import DialogModal from "../Common/Dialog"; import Uptime from "../Common/Uptime"; import useAuthUser from "../../Common/hooks/useAuthUser"; +import useQuery from "../../Utils/request/useQuery"; const Loading = lazy(() => import("../Common/Loading")); @@ -224,97 +225,120 @@ const Location = ({ disabled, setShowDeletePopup, facilityId, -}: LocationProps) => ( -
-
-
-
-

- {name} -

-
-

- {location_type} +}: LocationProps) => { + const { loading, data } = useQuery(routes.listFacilityBeds, { + query: { + facility: facilityId, + location: id, + }, + }); + + const totalBeds = data?.count ?? 0; + + if (loading) { + return ; + } + + return ( +

+
+
+
+

+ {name}

+
+

+ {location_type} +

+
-
-

- {description || "-"} -

-

- Middleware Address: -

-

- {middleware_address || "-"} -

- - Middleware Uptime -

- } - centerInfoPanel - /> -
- - - - Manage Beds - -
-
- - - Edit - -
-
- - setShowDeletePopup({ open: true, name: name ?? "", id: id ?? "" }) - } + {description || "-"} +

+

+ Middleware Address: +

+

- - Delete - + {middleware_address || "-"} +

+ + Middleware Uptime +

+ } + centerInfoPanel + />
-
-
- - + + Manage Beds + + + {totalBeds} + + +
+
+ + + Edit + +
+
+ + setShowDeletePopup({ open: true, name: name ?? "", id: id ?? "" }) + } + > + + Delete + +
+
+ +
+ + +
-
-); + ); +};