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

export const extensionArsDetail = (params: ExtensionArsDetailParams) => {
  return resultify(
    axios.post<ExtensionArsDetailResponse>(API_URL.extensionArsDetail(), params),
  );
};

export const useExtensionArsDetailMutation = (options?: UseMutationOptions<ExtensionArsDetailResponse, CBDCAxiosError, ExtensionArsDetailParams>) => {
  const mutation = useMutation<ExtensionArsDetailResponse, CBDCAxiosError, ExtensionArsDetailParams>({
    ...options,
    mutationFn: (params: ExtensionArsDetailParams) => extensionArsDetail(params),
  });

  return {
    ...mutation,
  };
};
