import axios from 'axios';
import { API_URL_ADDITIONAL_SERVICE } from '@/shared/api/api-url-additional-service';
import { resultify } from '@/shared/lib/resultify';
import { CBDCAxiosError } from '@/shared/@types/error';
import { 
  ExtensionPayoutExcelParams,
  ExtensionPayoutExcelResponse
} from '../../model/payout/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';

export const extensionPayoutExcel = (params: ExtensionPayoutExcelParams) => {
  return resultify(
    axios.post<ExtensionPayoutExcelResponse>(API_URL_ADDITIONAL_SERVICE.extensionPayoutExcel(), params),
  );
};

export const useExtensionPayoutExcelMutation = (options?: UseMutationOptions<ExtensionPayoutExcelResponse, CBDCAxiosError, ExtensionPayoutExcelParams>) => {
  const mutation = useMutation<ExtensionPayoutExcelResponse, CBDCAxiosError, ExtensionPayoutExcelParams>({
    ...options,
    mutationFn: (params: ExtensionPayoutExcelParams) => extensionPayoutExcel(params),
  });

  return {
    ...mutation,
  };
};
