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

export const extensionAlimtalkList = (params: ExtensionAlimtalkListParams) => {
  return resultify(
    axios.post<ExtensionAlimtalkListResponse>(API_URL.extensionAlimtalkList(), params),
  );
};

export const useExtensionAlimtalkListMutation = (options?: UseMutationOptions<ExtensionAlimtalkListResponse, CBDCAxiosError, ExtensionAlimtalkListParams>) => {
  const mutation = useMutation<ExtensionAlimtalkListResponse, CBDCAxiosError, ExtensionAlimtalkListParams>({
    ...options,
    mutationFn: (params: ExtensionAlimtalkListParams) => extensionAlimtalkList(params),
  });

  return {
    ...mutation,
  };
};
