import axios from 'axios';
import { API_URL_ADDITIONAL_SERVICE } from '@/shared/api/api-url-additional-service';
import { resultify } from '@/shared/lib/resultify';
import { CBDCAxiosError } from '@/shared/@types/error';
import { 
  ExtensionPayoutDetailParams,
  ExtensionPayoutDetailResponse
} from '../../model/payout/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';

export const extensionPayoutDetail = (params: ExtensionPayoutDetailParams) => {
  return resultify(
    axios.post<ExtensionPayoutDetailResponse>(API_URL_ADDITIONAL_SERVICE.extensionPayoutDetail(), params),
  );
};

export const useExtensionPayoutDetailMutation = (options?: UseMutationOptions<ExtensionPayoutDetailResponse, CBDCAxiosError, ExtensionPayoutDetailParams>) => {
  const mutation = useMutation<ExtensionPayoutDetailResponse, CBDCAxiosError, ExtensionPayoutDetailParams>({
    ...options,
    mutationFn: (params: ExtensionPayoutDetailParams) => extensionPayoutDetail(params),
  });

  return {
    ...mutation,
  };
};
