mirror of
https://github.com/Sea-Haven-Industries/proposal-system.git
synced 2026-10-07 16:18:57 +00:00
19 lines
636 B
TypeScript
19 lines
636 B
TypeScript
|
|
// Sites domain — TanStack Query hooks + query keys (the only public surface).
|
||
|
|
import { useQuery } from '@tanstack/react-query';
|
||
|
|
import { sitesApi } from './api';
|
||
|
|
|
||
|
|
export const sitesKeys = {
|
||
|
|
all: ['sites'] as const,
|
||
|
|
search: (query: string) => [...sitesKeys.all, 'search', query] as const,
|
||
|
|
};
|
||
|
|
|
||
|
|
/** Site autocomplete (ProposalFormPage). Call with the debounced input;
|
||
|
|
* disabled below 2 characters, matching current page behavior. */
|
||
|
|
export function useSiteSearch(query: string) {
|
||
|
|
return useQuery({
|
||
|
|
queryKey: sitesKeys.search(query),
|
||
|
|
queryFn: () => sitesApi.search(query),
|
||
|
|
enabled: query.trim().length >= 2,
|
||
|
|
});
|
||
|
|
}
|