import axios from 'axios';
import { API_URL_ADDITIONAL_SERVICE } from '@/shared/api/api-url-additional-service';
import { resultify } from '@/shared/lib/resultify';
import { NiceAxiosError } from '@/shared/@types/error';
import {
  ExtensionArsResendParams,
  ExtensionArsResendResponse
} from '../../model/ars/types';
import {
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';
import { getHeaderUserAgent } from '@/shared/constants/url';

export const extensionArsResend = (params: ExtensionArsResendParams) => {
  let headerOptions = {
    menuId: 52,
    apiType: 'UPDATE'
  };
  let options = {
    headers: {
      'X-User-Agent': getHeaderUserAgent(headerOptions)
    }
  };
  return resultify(
    axios.post<ExtensionArsResendResponse>(API_URL_ADDITIONAL_SERVICE.extensionArsResend(), params, options),
  );
};

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

  return {
    ...mutation,
  };
};
