Renamed query hooks. Fixed conversion bugs.
This commit is contained in:
19
src/components/hooks/queries/useRealtimeQuery.ts
Normal file
19
src/components/hooks/queries/useRealtimeQuery.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { useTimezone } from '@/components/hooks/useTimezone';
|
||||
import { REALTIME_INTERVAL } from '@/lib/constants';
|
||||
import { RealtimeData } from '@/lib/types';
|
||||
import { useApi } from '../useApi';
|
||||
|
||||
export function useRealtimeQuery(websiteId: string) {
|
||||
const { get, useQuery } = useApi();
|
||||
const { timezone } = useTimezone();
|
||||
const { data, isLoading, error } = useQuery<RealtimeData>({
|
||||
queryKey: ['realtime', { websiteId, timezone }],
|
||||
queryFn: async () => {
|
||||
return get(`/realtime/${websiteId}`, { timezone });
|
||||
},
|
||||
enabled: !!websiteId,
|
||||
refetchInterval: REALTIME_INTERVAL,
|
||||
});
|
||||
|
||||
return { data, isLoading, error };
|
||||
}
|
||||
Reference in New Issue
Block a user