import { useQuery } from 'react-query';

import { timeTrackingKeys } from '../queries';
import {
  type CategorizedHoursListFilters,
  getCategorizedHoursCategoryCounts,
} from '../services';

export const useGetCategorizedHoursCategoryCounts = (
  filters: CategorizedHoursListFilters,
  enabled = true,
) =>
  useQuery({
    queryKey: timeTrackingKeys.categorizedHours.categoryCounts(filters),
    queryFn: () => getCategorizedHoursCategoryCounts(filters),
    select: response => response.data,
    enabled,
    keepPreviousData: true,
  });
