From 6aa3efacd6d9ed79896bcf682d01185108dce73d Mon Sep 17 00:00:00 2001 From: CarterPerez-dev Date: Sat, 2 May 2026 05:33:53 -0400 Subject: [PATCH] feat(monitor/frontend): useSnapshot hook (single bootstrap, no refetch) --- .../frontend/src/api/snapshot.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 PROJECTS/advanced/monitor-the-situation-dashboard/frontend/src/api/snapshot.ts diff --git a/PROJECTS/advanced/monitor-the-situation-dashboard/frontend/src/api/snapshot.ts b/PROJECTS/advanced/monitor-the-situation-dashboard/frontend/src/api/snapshot.ts new file mode 100644 index 00000000..3c4365da --- /dev/null +++ b/PROJECTS/advanced/monitor-the-situation-dashboard/frontend/src/api/snapshot.ts @@ -0,0 +1,21 @@ +// ©AngelaMos | 2026 +// snapshot.ts + +import { useQuery } from '@tanstack/react-query' +import { apiClient } from '@/core/api' + +export type Snapshot = Record + +export const SNAPSHOT_KEY = ['snapshot'] as const + +export function useSnapshot() { + return useQuery({ + queryKey: SNAPSHOT_KEY, + queryFn: async (): Promise => { + const res = await apiClient.get('/v1/snapshot') + return res.data + }, + staleTime: Number.POSITIVE_INFINITY, + gcTime: Number.POSITIVE_INFINITY, + }) +}