import { useQuery, type UseQueryResult } from "@tanstack/react-query"; import { dashboardApi } from "@/domain/dashboard/api/dashboard-api"; import type { DispatcherPage } from "@/domain/dashboard/types/dashboard-dispatcher-page"; import type { DispatcherWorkloadRow } from "@/domain/dashboard/types/dashboard-workload"; import type { DashboardRangeKey } from "@/domain/dashboard/types/dashboard-range"; import { dashboardRangeParams } from "@/domain/dashboard/utils/dashboard-range-utils"; import { queryKeys } from "@/infra/query-key/query-key"; export function useDashboardWorkload( range: DashboardRangeKey, page = 1, dispatcherId: string | null = null, enabled = true, ): UseQueryResult, Error> { return useQuery({ queryKey: queryKeys.dashboard.workload(range, page, dispatcherId), queryFn: () => dashboardApi.getWorkload(dashboardRangeParams(range), page, dispatcherId ?? undefined), staleTime: 60 * 1000, enabled, }); }