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

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

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

export const useGetSeriesWithGroup = () => {
  return useMutation<
  PostGetSeriesList,
    BaseAxiosError,
    { token: string; group: string },
    PostGetSeriesList
  >({
    mutationKey: seriesQueryKeys.getSeriesWithGroup(),
    mutationFn: async (variables) => {
      const response = await seriesApi.getSeriesWithGroup(variables.token, variables.group);
      return response.data;
    }
  });
};
