// Public read-only garden data layer: the unauthenticated /full payload behind a // share token. Shares the FullGarden shape with the editor's own load, so the // public page can reuse toEditorObject / toEditorPlanting and GardenCanvas. import { queryOptions, useQuery } from '@tanstack/react-query' import { api } from './api' import { fullGardenSchema, type FullGarden } from './objects' export function publicGardenQueryOptions(token: string) { return queryOptions({ queryKey: ['public-garden', token] as const, queryFn: async (): Promise => fullGardenSchema.parse(await api.get(`/public/gardens/${encodeURIComponent(token)}`)), // A disabled/rotated token is a 404, not a transient failure — don't retry. retry: false, staleTime: 30_000, }) } export function usePublicGarden(token: string) { return useQuery(publicGardenQueryOptions(token)) }