From b9b0ed0ca7c1089884d2ae32b19ed72c01c100b6 Mon Sep 17 00:00:00 2001
From: Saikiran Patil <84263946+saikiranpatil@users.noreply.github.com>
Date: Wed, 18 Dec 2024 10:39:55 +0530
Subject: [PATCH] changed useTanstackuseQuery to useQuery

---
 .../Facility/LocationManagement.tsx           | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/components/Facility/LocationManagement.tsx b/src/components/Facility/LocationManagement.tsx
index 1fe0551b4d3..e9c1323142f 100644
--- a/src/components/Facility/LocationManagement.tsx
+++ b/src/components/Facility/LocationManagement.tsx
@@ -1,3 +1,4 @@
+import { useQuery } from "@tanstack/react-query";
 import { useState } from "react";
 
 import RecordMeta from "@/CAREUI/display/RecordMeta";
@@ -19,6 +20,7 @@ import useAuthUser from "@/hooks/useAuthUser";
 import AuthorizeFor, { NonReadOnlyUsers } from "@/Utils/AuthorizeFor";
 import * as Notification from "@/Utils/Notifications";
 import routes from "@/Utils/request/api";
+import query from "@/Utils/request/query";
 import request from "@/Utils/request/request";
 import useTanStackQueryInstead from "@/Utils/request/useQuery";
 
@@ -45,19 +47,16 @@ export default function LocationManagement({ facilityId }: Props) {
     name: "",
     id: "",
   });
-  const [facilityMiddleware, setFacilityMiddleware] = useState<
-    string | undefined
-  >(undefined);
 
-  useTanStackQueryInstead(routes.getPermittedFacility, {
-    pathParams: { id: facilityId },
-    onResponse: (res) => {
-      if (res.data) {
-        setFacilityMiddleware(res.data?.middleware_address);
-      }
-    },
+  const { data } = useQuery({
+    queryKey: [routes.getPermittedFacility.path, facilityId],
+    queryFn: query(routes.getPermittedFacility, {
+      pathParams: { id: facilityId },
+    }),
   });
 
+  const facilityMiddleware = data?.middleware_address;
+
   const closeDeleteFailModal = () => {
     setShowDeleteFailModal({ ...showDeleteFailModal, open: false });
   };