Skip to content
File

Blob: src/client/lib/queries/site.ts

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