From aa90ad5b4c8fc0670533a4cbe3e24c7c9b57a286 Mon Sep 17 00:00:00 2001 From: Noufal Rahim <120470585+noufalrahim@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:28:15 +0530 Subject: [PATCH] fix: Removed useQuery from wrapper (#8716) Co-authored-by: Khavin Shankar --- .../Facility/LocationManagement.tsx | 196 ++++++++++-------- 1 file changed, 110 insertions(+), 86 deletions(-) diff --git a/src/Components/Facility/LocationManagement.tsx b/src/Components/Facility/LocationManagement.tsx index 8df40d9c5f2..1aaf57b7233 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"; import Loading from "@/Components/Common/Loading"; interface Props { @@ -223,97 +224,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 + +
+
+ +
+ + +
-
-); + ); +};