File
Blob: src/client/lib/queries/site.ts
| 1 | import { queryOptions } from "@tanstack/react-query"; |
| 2 | import { api } from "@/client/lib/api"; |
| 3 | |
| 4 | export const siteQueryKey = (workspaceId: string) => ["workspace-site", workspaceId] as const; |
| 5 | export const siteRootsQueryKey = (workspaceId: string) => ["workspace-site-roots", workspaceId] as const; |
| 6 | export const sitePageStatusQueryKey = (workspaceId: string, pageId: string) => |
| 7 | ["workspace-site-page-status", workspaceId, pageId] as const; |
| 8 | |
| 9 | export const siteQueryOptions = (workspaceId: string) => |
| 10 | queryOptions({ |
| 11 | queryKey: siteQueryKey(workspaceId), |
| 12 | queryFn: () => api.site.get(workspaceId), |
| 13 | staleTime: 30_000, |
| 14 | }); |
| 15 | |
| 16 | export const siteRootsQueryOptions = (workspaceId: string) => |
| 17 | queryOptions({ |
| 18 | queryKey: siteRootsQueryKey(workspaceId), |
| 19 | queryFn: () => api.site.listRoots(workspaceId), |
| 20 | staleTime: 30_000, |
| 21 | }); |
| 22 | |
| 23 | export const sitePageStatusQueryOptions = (workspaceId: string, pageId: string) => |
| 24 | queryOptions({ |
| 25 | queryKey: sitePageStatusQueryKey(workspaceId, pageId), |
| 26 | queryFn: () => api.site.pageStatus(workspaceId, pageId), |
| 27 | staleTime: 10_000, |
| 28 | }); |