mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-07 00:13:53 +00:00
b6507c27a6
* create report service * write report from runtimeState * use in UI * clear report * update types * clear all from settings menu * rearence rightclik menu * refactor styling * also report roll events * ontime/under time is same colour * refactor reporter * add target to ontime-refetch * remove menu * fectch only on message from server * memo useGetEventReport * refactor * use staleTime * dont add to menu yet * implement review * clear all from menu * fix merge * start end show * combine test for the go button text and action * add report to menu * extract csv utility * report management * unneeded async * small refacort of triggerReportEntry --------- Co-authored-by: Carlos Valente <carlosvalente@pm.me>
21 lines
608 B
TypeScript
21 lines
608 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: fetchReport,
|
|
placeholderData: (previousData, _previousQuery) => previousData,
|
|
retry: 5,
|
|
retryDelay: (attempt) => attempt * 2500,
|
|
networkMode: 'always',
|
|
staleTime: MILLIS_PER_HOUR,
|
|
});
|
|
|
|
return { data: data ?? {}, refetch };
|
|
}
|