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

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

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

export const useSubmitSuggestionMutation = () => {
  return useMutation<
    SubmitSuggestionReturn,
    BaseAxiosError,
    SubmitSuggestionTypes,
    SubmitSuggestionReturn
  >({
    mutationKey: seriesQueryKeys.submitSuggestion(),
    mutationFn: async (data) => {
      const response = await seriesApi.submitSuggestion(data);
      return response.data;
    }
  });
};
