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

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

export const useExtensionAlimtalkDetailMutation = (options?: UseMutationOptions<ExtensionAlimtalkDetailResponse, CBDCAxiosError, ExtensionAlimtalkDetailParams>) => {
  const mutation = useMutation<ExtensionAlimtalkDetailResponse, CBDCAxiosError, ExtensionAlimtalkDetailParams>({
    ...options,
    mutationFn: (params: ExtensionAlimtalkDetailParams) => extensionAlimtalkDetail(params),
  });

  return {
    ...mutation,
  };
};
