Updated realtime data fetch.

This commit is contained in:
Mike Cao 2024-08-20 23:58:20 -07:00
parent 04e0b33622
commit e35c11c3d6
9 changed files with 126 additions and 87 deletions

View file

@ -1,15 +1,13 @@
import { RealtimeData } from 'lib/types';
import { useApi } from './useApi';
import { REALTIME_INTERVAL } from 'lib/constants';
import { useTimezone } from '../useTimezone';
export function useRealtime(websiteId: string) {
const { get, useQuery } = useApi();
const { timezone } = useTimezone();
const { data, isLoading, error } = useQuery<RealtimeData>({
queryKey: ['realtime', websiteId],
queryFn: async () => {
return get(`/realtime/${websiteId}`, { timezone });
return get(`/realtime/${websiteId}`);
},
enabled: !!websiteId,
refetchInterval: REALTIME_INTERVAL,