Files
leocrm/frontend/src/api/hooks.ts
T

43 lines
1.3 KiB
TypeScript
Raw Normal View History

/**
2026-07-23 17:17:32 +02:00
* hooks.ts — Re-Export Hub (Company hooks removed in Phase 1C)
*
* This file re-exports all hooks from their dedicated modules so that
* existing imports `from '@/api/hooks'` continue to work without change.
*/
2026-07-23 17:17:32 +02:00
import { useQuery } from '@tanstack/react-query';
// ── Re-exports from dedicated modules ──
export * from './types';
export * from './auth';
export * from './users';
export * from './contacts';
export * from './roles';
export * from './groups';
export * from './audit';
export * from './notifications';
export * from './plugins';
export * from './settings';
export * from './attachments';
export * from './unifiedContacts';
2026-07-23 20:00:37 +02:00
export * from './automation';
// ── Search hook (uses dynamic import, kept inline) ──
import type { SearchResult } from './search';
export type { SearchResult };
export function useGlobalSearch(query: string, entityTypes?: string[]) {
return useQuery({
queryKey: ['globalSearch', query, entityTypes],
queryFn: async (): Promise<SearchResult[]> => {
if (!query.trim()) return [];
const { search } = await import('@/api/search');
const response = await search(query, entityTypes, 20);
return response.results || [];
},
enabled: query.trim().length > 0,
staleTime: 30 * 1000,
});
}