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

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

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

  return {
    ...mutation,
  };
};
