File
Blob: src/client/lib/queries/search.ts
| 1 | import { queryOptions } from "@tanstack/react-query"; |
| 2 | import { api } from "@/client/lib/api"; |
| 3 | |
| 4 | export 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 | }); |