// src/api/deal/createDeal.ts
import instance from "../axiosInstance"
import { endpoints } from "@shared/contracts"

const { deals } = endpoints

export async function createDeal(formData: FormData) {
  try {
    const { data } = await instance.post("/deals", formData, {
      headers: { "Content-Type": "multipart/form-data" },
    })
    return deals.dealCreateResponseSchema.parse(data)
  } catch (error: any) {
    const message = error.response?.data?.error || "Fırsat eklenemedi"
    console.error("Fırsat oluşturma hatası:", message)
    throw new Error(message)
  }
}
