el.xwx.moe/hooks/store/dashboardData.tsx

20 lines
457 B
TypeScript
Raw Normal View History

import { useQuery } from "@tanstack/react-query";
2024-08-14 15:44:07 -05:00
import { useSession } from "next-auth/react";
const useDashboardData = () => {
2024-08-14 15:44:07 -05:00
const { status } = useSession();
return useQuery({
queryKey: ["dashboardData"],
2024-09-09 23:09:33 -05:00
queryFn: async () => {
const response = await fetch("/api/v2/dashboard");
const data = await response.json();
2024-09-09 23:09:33 -05:00
return data.data;
},
2024-08-14 15:44:07 -05:00
enabled: status === "authenticated",
});
};
export { useDashboardData };