Skip to content

Commit

Permalink
used useQuery istead of Tanstack
Browse files Browse the repository at this point in the history
  • Loading branch information
Utkarsh-Anandani committed Dec 27, 2024
1 parent 96e3b6d commit d986e55
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/components/Facility/FacilityCover.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useQuery } from "@tanstack/react-query";
import { navigate } from "raviger";
import { useEffect } from "react";

Expand All @@ -9,7 +10,7 @@ import useAuthUser from "@/hooks/useAuthUser";

import * as Notification from "@/Utils/Notifications";
import routes from "@/Utils/request/api";
import useTanStackQueryInstead from "@/Utils/request/useQuery";
import query from "@/Utils/request/query";

interface FacilityProps {
facilityId: string;
Expand All @@ -18,19 +19,12 @@ interface FacilityProps {
export const FacilityCover = (props: FacilityProps) => {
const { facilityId } = props;

const { data: facilityData } = useTanStackQueryInstead(
routes.getPermittedFacility,
{
pathParams: {
id: facilityId,
},
onResponse: ({ res }) => {
if (!res?.ok) {
navigate("/not-found");
}
},
},
);
const { data } = useQuery({
queryKey: ["facility", facilityId],
queryFn: query(routes.getPermittedFacility, {
pathParams: { id: facilityId },
}),
});

const authUser = useAuthUser();
useEffect(() => {
Expand All @@ -52,7 +46,7 @@ export const FacilityCover = (props: FacilityProps) => {
title="Cover Image"
className="h-[90vh]"
crumbsReplacements={{
[facilityId]: { name: facilityData?.name },
[facilityId]: { name: data?.name },
}}
>
<div className="md:pt-[10vh] md:pr-[5vw] pt-[5vh]">
Expand Down

0 comments on commit d986e55

Please sign in to comment.