import { useQuery } from '@tanstack/react-query' import type { BrokerEventsData } from '@/shared/api' import { type BrokerEventsQuery, getBrokerEvents } from '../api/brokerEventApi' export function useBrokerEvents(accountId: string | undefined, query: BrokerEventsQuery) { const { from, to, types } = query return useQuery({ queryKey: ['broker', 'events', accountId, from, to, types], enabled: Boolean(accountId), queryFn: async () => (await getBrokerEvents(accountId!, { from, to, types })).data, staleTime: 300_000, retry: 2, refetchOnWindowFocus: false, }) }