// adapters/requests/dealCreateAdapter.ts
import type { DealDraft } from "../../models/DealDraft"

export function mapDealDraftToCreateRequest(draft: DealDraft): FormData {
  const fd = new FormData()

  fd.append("title", draft.title)
  if (draft.description) fd.append("description", draft.description)
  if (draft.url) fd.append("url", draft.url)

  if (draft.price != null) fd.append("price", String(draft.price))


if (draft.customCompany) fd.append("sellerName", draft.customCompany)

  // files
  ;(draft.images ?? []).slice(0, 5).forEach((f) => {
    fd.append("images", f) // field adı backend'deki upload.array("images", 5) ile aynı
  })

  return fd
}
