mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-10 01:43:43 +00:00
c075f73752
* feat: create loader component * fix: prevent stale data in forms
21 lines
693 B
TypeScript
21 lines
693 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
|
|
import { queryRefetchIntervalSlow } from '../../ontimeConfig';
|
|
import { VIEW_SETTINGS } from '../api/apiConstants';
|
|
import { getView } from '../api/ontimeApi';
|
|
import { viewsSettingsPlaceholder } from '../models/ViewSettings.type';
|
|
|
|
export default function useViewSettings() {
|
|
const { data, status, isFetching, isError, refetch } = useQuery({
|
|
queryKey: VIEW_SETTINGS,
|
|
queryFn: getView,
|
|
placeholderData: viewsSettingsPlaceholder,
|
|
retry: 5,
|
|
retryDelay: (attempt) => attempt * 2500,
|
|
refetchInterval: queryRefetchIntervalSlow,
|
|
networkMode: 'always',
|
|
});
|
|
|
|
return { data, status, isError, refetch, isFetching };
|
|
}
|