// src/api/deal/commentApi.ts
import instance from "../axiosInstance"

export async function getComments(dealId: number) {
  try {
    const { data } = await instance.get(`/comments/${dealId}`)
    return data
  } catch (error: any) {
    const message = error.response?.data?.error || "Yorumlar alınamadı"
    console.error("Yorumları alma hatası:", message)
    throw new Error(message)
  }
}

export async function postComment(dealId: number, text: string) {
  try {
    const { data } = await instance.post("/comments", { dealId, text })
    return data
  } catch (error: any) {
    const message = error.response?.data?.error || "Yorum gönderilemedi"
    console.error("Yorum gönderme hatası:", message)
    throw new Error(message)
  }
}
