blob: 1a5bd1c537f673aa477c00f4127e9be33bc4e0d5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import { REALTIME_INTERVAL } from '@/lib/constants';
import type { RealtimeData } from '@/lib/types';
import { useApi } from '../useApi';
export function useRealtimeQuery(websiteId: string) {
const { get, useQuery } = useApi();
const { data, isLoading, error } = useQuery<RealtimeData>({
queryKey: ['realtime', { websiteId }],
queryFn: async () => {
return get(`/realtime/${websiteId}`);
},
enabled: !!websiteId,
refetchInterval: REALTIME_INTERVAL,
});
return { data, isLoading, error };
}
|