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

export const extensionSmsResend = (params: ExtensionSmsResendParams) => {
  return resultify(
    axios.post<ExtensionSmsResendResponse>(API_URL.extensionSmsResend(), params),
  );
};

export const useExtensionSmsResendMutation = (options?: UseMutationOptions<ExtensionSmsResendResponse, CBDCAxiosError, ExtensionSmsResendParams>) => {
  const mutation = useMutation<ExtensionSmsResendResponse, CBDCAxiosError, ExtensionSmsResendParams>({
    ...options,
    mutationFn: (params: ExtensionSmsResendParams) => extensionSmsResend(params),
  });

  return {
    ...mutation,
  };
};
