aboutsummaryrefslogtreecommitdiff
path: root/src/components/hooks/queries/useReportQuery.ts
blob: 6973e2d344c483b3009b8b89ca970b2409b0fdc2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { useApi } from '../useApi';
import { useModified } from '../useModified';

export function useReportQuery(reportId: string) {
  const { get, useQuery } = useApi();
  const { modified } = useModified(`report:${reportId}`);

  return useQuery({
    queryKey: ['report', { reportId, modified }],
    queryFn: () => {
      return get(`/reports/${reportId}`);
    },
    enabled: !!reportId,
  });
}