mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 20:57:17 +01:00
17 lines
526 B
TypeScript
17 lines
526 B
TypeScript
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 };
|
|
}
|