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

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

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

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