mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-07 08:23:55 +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
23 lines
756 B
TypeScript
23 lines
756 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { CustomFields } from 'ontime-types';
|
|
|
|
import { queryRefetchInterval } from '../../ontimeConfig';
|
|
import { CUSTOM_FIELDS } from '../api/constants';
|
|
import { getCustomFields } from '../api/customFields';
|
|
|
|
const placeholder: CustomFields = {};
|
|
|
|
export default function useCustomFields() {
|
|
const { data, status, isFetching, isError, refetch } = useQuery({
|
|
queryKey: CUSTOM_FIELDS,
|
|
queryFn: getCustomFields,
|
|
placeholderData: (previousData, _previousQuery) => previousData,
|
|
retry: 5,
|
|
retryDelay: (attempt) => attempt * 2500,
|
|
refetchInterval: queryRefetchInterval,
|
|
networkMode: 'always',
|
|
});
|
|
|
|
return { data: data ?? placeholder, status, isFetching, isError, refetch };
|
|
}
|