'use client'
import type { AnswerValue, Question, QuestionOption } from '@/lib/form-engine.types'
import { RadioGroup } from './widgets/radio-group'
import { CheckboxGroup } from './widgets/checkbox-group'
import { TextAreaField } from './widgets/text-area-field'
import { TextShortField } from './widgets/text-short-field'
interface QuestionRendererProps {
question: Question
value: AnswerValue
onChange: (value: AnswerValue) => void
error?: string
}
const YES_NO_OPTIONS: QuestionOption[] = [
{ value: 'true', label: 'Sí' },
{ value: 'false', label: 'No' },
]
export function QuestionRenderer({ question, value, onChange, error }: QuestionRendererProps) {
const { code, type, prompt, required, max_select, options } = question
const legend = (
<>
{code} · {prompt}
>
)
if (type === 'single_choice' && options) {
return (
)
}
if (type === 'multiple_choice' && options) {
return (
)
}
// yes_no resuelto con el RadioGroup existente — dos opciones fijas, sin widget nuevo.
if (type === 'yes_no') {
return (
)
}
if (type === 'text_short') {
return (
)
}
if (type === 'text_long') {
return (
)
}
return null
}