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

export const extensionArsList = (params: ExtensionArsListParams) => {
  return resultify(
    axios.post<ExtensionArsListResponse>(API_URL_ADDITIONAL_SERVICE.extensionArsList(), params),
  );
};

export const useExtensionArsListMutation = (options?: UseMutationOptions<ExtensionArsListResponse, CBDCAxiosError, ExtensionArsListParams>) => {
  const mutation = useMutation<ExtensionArsListResponse, CBDCAxiosError, ExtensionArsListParams>({
    ...options,
    mutationFn: (params: ExtensionArsListParams) => extensionArsList(params),
  });

  return {
    ...mutation,
  };
};
