- Add SystemOverview component and related hooks;
- update Dashboard layout and introduce new UI components
This commit is contained in:
21
src/features/dashboard/hooks/useGetSystemHealth.ts
Normal file
21
src/features/dashboard/hooks/useGetSystemHealth.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
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 };
|
||||
};
|
||||
Reference in New Issue
Block a user