This repository has no description
670 B
27 lines
1import { useQuery } from '@tanstack/react-query';
2import { getMyCollections } from '../dal';
3import { collectionKeys } from '../collectionKeys';
4
5interface Props {
6 query: string;
7 params?: {
8 limit?: number;
9 };
10}
11
12export default function useCollectionSearch(props: Props) {
13 // TODO: replace with infinite suspense query
14 const collections = useQuery({
15 queryKey: collectionKeys.search(props.query),
16 queryFn: () =>
17 getMyCollections({
18 limit: props.params?.limit ?? 10,
19 sortBy: 'updatedAt',
20 sortOrder: 'desc',
21 searchText: props.query || undefined,
22 }),
23 enabled: !!props.query,
24 });
25
26 return collections;
27}