22 lines
588 B
TypeScript
22 lines
588 B
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
import { cambase } from "../../../app/config";
|
|
|
|
const fetchSystemHealth = async () => {
|
|
const response = await fetch(`${cambase}/api/system-health`);
|
|
if (!response.ok) throw new Error("Network response was not ok");
|
|
return response.json();
|
|
};
|
|
|
|
export const useGetSystemHealth = () => {
|
|
const systemHealthQuery = useQuery({
|
|
queryKey: ["systemHealth"],
|
|
queryFn: fetchSystemHealth,
|
|
refetchInterval: 60000,
|
|
refetchOnWindowFocus: false,
|
|
retry: false,
|
|
staleTime: 30000,
|
|
});
|
|
|
|
return { systemHealthQuery };
|
|
};
|