feat(monitor/frontend): useSnapshot hook (single bootstrap, no refetch)

This commit is contained in:
CarterPerez-dev 2026-05-02 05:33:53 -04:00
parent 4216de3435
commit 6aa3efacd6
1 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,21 @@
// ©AngelaMos | 2026
// snapshot.ts
import { useQuery } from '@tanstack/react-query'
import { apiClient } from '@/core/api'
export type Snapshot = Record<string, unknown>
export const SNAPSHOT_KEY = ['snapshot'] as const
export function useSnapshot() {
return useQuery({
queryKey: SNAPSHOT_KEY,
queryFn: async (): Promise<Snapshot> => {
const res = await apiClient.get<Snapshot>('/v1/snapshot')
return res.data
},
staleTime: Number.POSITIVE_INFINITY,
gcTime: Number.POSITIVE_INFINITY,
})
}