All files / src/hooks/queries useWebsiteQueries.ts

100% Statements 4/4
100% Branches 4/4
100% Functions 4/4
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21          3x   1x           3x   1x          
import { useQuery } from "@tanstack/react-query";
import { websiteApi } from "../../lib/api";
import { queryKeys } from "../../lib/query-keys";
 
export function useWebsiteSettings(proId: string | null) {
	return useQuery({
		queryKey: queryKeys.website.settings(proId ?? ""),
		queryFn: () => websiteApi.getSettings(proId as string),
		enabled: !!proId,
	});
}
 
export function useWebsiteTemplates(proId: string | null) {
	return useQuery({
		queryKey: queryKeys.website.templates(proId ?? ""),
		queryFn: () => websiteApi.getTemplates(proId as string),
		enabled: !!proId,
		staleTime: 1000 * 60 * 60, // 1 hour - templates rarely change
	});
}