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 { 
  ExtensionArsResendParams,
  ExtensionArsResendResponse
} from '../../model/ars/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';

export const extensionArsResend = (params: ExtensionArsResendParams) => {
  return resultify(
    axios.post<ExtensionArsResendResponse>(API_URL_ADDITIONAL_SERVICE.extensionArsResend(), params),
  );
};

export const useExtensionArsResendMutation = (options?: UseMutationOptions<ExtensionArsResendResponse, CBDCAxiosError, ExtensionArsResendParams>) => {
  const mutation = useMutation<ExtensionArsResendResponse, CBDCAxiosError, ExtensionArsResendParams>({
    ...options,
    mutationFn: (params: ExtensionArsResendParams) => extensionArsResend(params),
  });

  return {
    ...mutation,
  };
};
