import { useQuery } from '@tanstack/react-query';

import { seriesQueryKeys } from '../series-query-keys';
import { seriesApi, type PostGetSeriesGroups } from '../series-api';

import type { BaseAxiosError } from '../../../../types';

export const useGetSeriesGroups = (enabled: boolean) => {
  return useQuery<PostGetSeriesGroups, BaseAxiosError>({
    queryKey: seriesQueryKeys.getSeriesGroups(),
    queryFn: async () => {
      const response = await seriesApi.getSeriesGroups();
      return response.data;
    },
    enabled
  });
};
