mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-08 08:53:51 +00:00
01c2ef4c4d
* refactor: rename settings panel * style: typo * style: fix blackout position * fix: offset time in time-to-end * refactor: operator is protected * style: tweaks to pincode * refactor: close params editor on submit * refactor: same navigation in all pages * refactor: use cached response
21 lines
745 B
TypeScript
21 lines
745 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
|
|
import { queryRefetchIntervalSlow } from '../../ontimeConfig';
|
|
import { PROJECT_DATA } from '../api/constants';
|
|
import { getProjectData } from '../api/project';
|
|
import { projectDataPlaceholder } from '../models/ProjectData';
|
|
|
|
export default function useProjectData() {
|
|
const { data, status, isFetching, isError, refetch } = useQuery({
|
|
queryKey: PROJECT_DATA,
|
|
queryFn: getProjectData,
|
|
placeholderData: (previousData, _previousQuery) => previousData,
|
|
retry: 5,
|
|
retryDelay: (attempt) => attempt * 2500,
|
|
refetchInterval: queryRefetchIntervalSlow,
|
|
networkMode: 'always',
|
|
});
|
|
|
|
return { data: data ?? projectDataPlaceholder, status, isFetching, isError, refetch };
|
|
}
|