export interface DecisionAnswerBody {
  choice: string
}

/** Same-origin POST — proxied server-side by /api/collector/decisions/:id/answer. */
export async function postDecisionAnswer(itemId: string, body: DecisionAnswerBody): Promise<void> {
  const res = await fetch(`/api/collector/decisions/${encodeURIComponent(itemId)}/answer`, {
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    body: JSON.stringify(body),
  })
  if (!res.ok) {
    throw new Error(`decision answer failed: HTTP ${res.status}`)
  }
}
