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 { 
  ExtensionPayoutListParams,
  ExtensionPayoutListResponse
} from '../../model/payout/types';
import { 
  useMutation,
  UseMutationOptions
} from '@tanstack/react-query';

export const extensionPayoutList = (params: ExtensionPayoutListParams) => {
  return resultify(
    axios.post<ExtensionPayoutListResponse>(API_URL_ADDITIONAL_SERVICE.extensionPayoutList(), params),
  );
};

export const useExtensionPayoutListMutation = (options?: UseMutationOptions<ExtensionPayoutListResponse, CBDCAxiosError, ExtensionPayoutListParams>) => {
  const mutation = useMutation<ExtensionPayoutListResponse, CBDCAxiosError, ExtensionPayoutListParams>({
    ...options,
    mutationFn: (params: ExtensionPayoutListParams) => extensionPayoutList(params),
  });

  return {
    ...mutation,
  };
};
