mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-07 15:29:10 +00:00
18 lines
550 B
TypeScript
18 lines
550 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { OntimeReport } from 'ontime-types';
|
|
import { MILLIS_PER_HOUR } from 'ontime-utils';
|
|
|
|
import { REPORT } from '../api/constants';
|
|
import { fetchReport } from '../api/report';
|
|
|
|
export default function useReport() {
|
|
const { data, refetch } = useQuery<OntimeReport>({
|
|
queryKey: REPORT,
|
|
queryFn: ({ signal }) => fetchReport({ signal }),
|
|
placeholderData: (previousData, _previousQuery) => previousData,
|
|
staleTime: MILLIS_PER_HOUR,
|
|
});
|
|
|
|
return { data: data ?? {}, refetch };
|
|
}
|