mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-07 00:13:53 +00:00
7e3aaa8c30
* style: consistent casing on menu * refactor: bundle demo from code * feat: allow uploading custom views
22 lines
721 B
TypeScript
22 lines
721 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { type CustomViewsListResponse } from 'ontime-types';
|
|
|
|
import { queryRefetchIntervalSlow } from '../../ontimeConfig';
|
|
import { CUSTOM_VIEWS } from '../api/constants';
|
|
import { getCustomViews } from '../api/customViews';
|
|
|
|
const placeholderCustomViews: CustomViewsListResponse = {
|
|
views: [],
|
|
};
|
|
|
|
export default function useCustomViews() {
|
|
const { data, status, refetch } = useQuery({
|
|
queryKey: CUSTOM_VIEWS,
|
|
queryFn: ({ signal }) => getCustomViews({ signal }),
|
|
placeholderData: (previousData, _previousQuery) => previousData,
|
|
refetchInterval: queryRefetchIntervalSlow,
|
|
});
|
|
|
|
return { data: data ?? placeholderCustomViews, status, refetch };
|
|
}
|