Files
sofa/hooks/use-system-health.ts
T
jakeandClaude Opus 4.6 59e9dd6775 Add SWR for system health and command palette search fetching
Replace manual fetch/useState/useEffect patterns with SWR hooks in
system health section and command palette search, gaining automatic
caching, request deduplication, and stale-while-revalidate.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 12:24:23 -05:00

20 lines
492 B
TypeScript

import useSWR from "swr";
import type { SystemHealthData } from "@/lib/services/system-health";
import { fetcher } from "@/lib/swr/fetcher";
export function useSystemHealth() {
const { data, error, isLoading, isValidating, mutate } =
useSWR<SystemHealthData>("/api/admin/system-health", fetcher, {
revalidateOnFocus: true,
dedupingInterval: 10_000,
});
return {
data: data ?? null,
error,
isLoading,
isValidating,
refresh: () => mutate(),
};
}