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

export const businessMemberInfo = (params: BusinessMemberInfoParams) => {
  return resultify(
    axios.post<BusinessMemberInfoResponse>(API_URL.businessMemberInfo(), params),
  );
};

export const useBusinessMemberInfoMutation = (options?: UseMutationOptions<BusinessMemberInfoResponse, CBDCAxiosError, BusinessMemberInfoParams>) => {
  const mutation = useMutation<BusinessMemberInfoResponse, CBDCAxiosError, BusinessMemberInfoParams>({
    ...options,
    mutationFn: (params: BusinessMemberInfoParams) => businessMemberInfo(params),
  });

  return {
    ...mutation,
  };
};
