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

export const extensionSmsDetail = (params: ExtensionSmsDetailParams) => {
  return resultify(
    axios.post<ExtensionSmsDetailResponse>(API_URL.extensionSmsDetail(), params),
  );
};

export const useExtensionSmsListMutation = (options?: UseMutationOptions<ExtensionSmsDetailResponse, CBDCAxiosError, ExtensionSmsDetailParams>) => {
  const mutation = useMutation<ExtensionSmsDetailResponse, CBDCAxiosError, ExtensionSmsDetailParams>({
    ...options,
    mutationFn: (params: ExtensionSmsDetailParams) => extensionSmsDetail(params),
  });

  return {
    ...mutation,
  };
};
