import axios from 'axios';
import { API_URL } from '@/shared/api/urls';
import { resultify } from '@/shared/lib/resultify';
import { CBDCAxiosError } from '@/shared/@types/error';
import { 
  ExtensionArsDownloadExcelParams,
  ExtensionArsDownloadExcelResponse
} from '../model/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';

export const extensionArsDownloadExcel = (params: ExtensionArsDownloadExcelParams) => {
  return resultify(
    axios.post<ExtensionArsDownloadExcelResponse>(API_URL.extensionArsDownloadExcel(), params),
  );
};

export const useExtensionArsDownloadExcelMutation = (options?: UseMutationOptions<ExtensionArsDownloadExcelResponse, CBDCAxiosError, ExtensionArsDownloadExcelParams>) => {
  const mutation = useMutation<ExtensionArsDownloadExcelResponse, CBDCAxiosError, ExtensionArsDownloadExcelParams>({
    ...options,
    mutationFn: (params: ExtensionArsDownloadExcelParams) => extensionArsDownloadExcel(params),
  });

  return {
    ...mutation,
  };
};
