mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 06:07:17 +01:00
Moved files around.
This commit is contained in:
parent
60cd869407
commit
2cd38f1306
35 changed files with 45 additions and 45 deletions
|
|
@ -1,33 +0,0 @@
|
|||
import { UseQueryOptions } from '@tanstack/react-query';
|
||||
import { useState } from 'react';
|
||||
import { useApi } from './useApi';
|
||||
import { PageResult, PageParams, PagedQueryResult } from 'lib/types';
|
||||
import { useNavigation } from '../useNavigation';
|
||||
|
||||
export function usePagedQuery<T = any>({
|
||||
queryKey,
|
||||
queryFn,
|
||||
...options
|
||||
}: Omit<UseQueryOptions, 'queryFn'> & { queryFn: (params?: object) => any }): PagedQueryResult<T> {
|
||||
const { query: queryParams } = useNavigation();
|
||||
const [params, setParams] = useState<PageParams>({
|
||||
query: '',
|
||||
page: +queryParams.page || 1,
|
||||
});
|
||||
|
||||
const { useQuery } = useApi();
|
||||
const { data, ...query } = useQuery({
|
||||
queryKey: [{ ...queryKey, ...params }],
|
||||
queryFn: () => queryFn(params as any),
|
||||
...options,
|
||||
});
|
||||
|
||||
return {
|
||||
result: data as PageResult<T>,
|
||||
query,
|
||||
params,
|
||||
setParams,
|
||||
};
|
||||
}
|
||||
|
||||
export default usePagedQuery;
|
||||
Loading…
Add table
Add a link
Reference in a new issue