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 }); };