import apiClient from "@/lib/axiosClient";
import { API_ENDPOINTS } from "@/lib/apiEndpoints";
import type { GiftListResponse } from "@/types/live";

export async function fetchGifts(
  userId: string | number,
  page: number,
): Promise<GiftListResponse> {
  const { data } = await apiClient.post(API_ENDPOINTS.GIFT.GET, {
    user_id: userId,
    page_no: page,
  });
  return data;
}

export async function sendGiftAPI(params: {
  userId: string | number;
  giftId: number;
  channelId: string;
  price: number;
}): Promise<{ status: number; message: string }> {
  const formData = new FormData();
  formData.append("user_id", String(params.userId));
  formData.append("gift_id", String(params.giftId));
  formData.append("channel_id", params.channelId);
  formData.append("content_id", "");
  formData.append("price", String(params.price));
  const { data } = await apiClient.post(API_ENDPOINTS.GIFT.SEND, formData);
  return data;
}
