New goals page. Upgraded prisma.
This commit is contained in:
17
src/components/hooks/queries/useResultQuery.ts
Normal file
17
src/components/hooks/queries/useResultQuery.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useApi } from '@/components/hooks';
|
||||
import { UseQueryOptions, QueryKey } from '@tanstack/react-query';
|
||||
|
||||
export function useResultQuery<T>(
|
||||
type: string,
|
||||
params?: { [key: string]: any },
|
||||
options?: Omit<UseQueryOptions<T, Error, T, QueryKey>, 'queryKey' | 'queryFn'>,
|
||||
) {
|
||||
const { post, useQuery } = useApi();
|
||||
|
||||
return useQuery<T>({
|
||||
queryKey: ['reports', type, params],
|
||||
queryFn: () => post(`/reports/${type}`, params),
|
||||
enabled: !!type,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user