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

export const emptyTokenAddSendCode = (params: EmptyTokenAddSendCodeParams) => {
  return resultify(
    axios.post<EmptyTokenAddSendCodeResponse>(API_URL.emptyTokenFindSendCode(), params),
  );
};

export const useEmptyTokenAddSendCodeMutation = (options?: UseMutationOptions<EmptyTokenAddSendCodeResponse, NiceAxiosError, EmptyTokenAddSendCodeParams>) => {
  const mutation = useMutation<EmptyTokenAddSendCodeResponse, NiceAxiosError, EmptyTokenAddSendCodeParams>({
    ...options,
    mutationFn: (params: EmptyTokenAddSendCodeParams) => emptyTokenAddSendCode(params),
  });

  return {
    ...mutation,
  };
};
