Skip to content
File

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

typescript15 lines
1import { queryOptions } from "@tanstack/react-query";
2import { api } from "@/client/lib/api";
3 
4export const searchQueryOptions = (workspaceId: string | null, query: string) =>
5 queryOptions({
6 queryKey: ["search", workspaceId, query] as const,
7 queryFn: () => {
8 if (!workspaceId) return [];
9 return api.search(workspaceId, query);
10 },
11 enabled: !!workspaceId && query.trim().length >= 3,
12 staleTime: 30_000,
13 placeholderData: (prev) => prev,
14 });