mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-05 15:33:59 +00:00
21 lines
699 B
TypeScript
21 lines
699 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
|
|
import { queryRefetchIntervalSlow } from '../../ontimeConfig';
|
|
import { PROJECT_DATA } from '../api/apiConstants';
|
|
import { getProjectData } from '../api/projectDataApi';
|
|
import { projectDataPlaceholder } from '../models/ProjectData';
|
|
|
|
export default function useProjectData() {
|
|
const { data, status, isFetching, isError, refetch } = useQuery({
|
|
queryKey: PROJECT_DATA,
|
|
queryFn: getProjectData,
|
|
placeholderData: projectDataPlaceholder,
|
|
retry: 5,
|
|
retryDelay: (attempt) => attempt * 2500,
|
|
refetchInterval: queryRefetchIntervalSlow,
|
|
networkMode: 'always',
|
|
});
|
|
|
|
return { data, status, isFetching, isError, refetch };
|
|
}
|