function OptionLabel({ opt }) { const images = Array.isArray(opt.images) ? opt.images : []; return ( {images.length > 0 ? ( {images.map((src) => ( ))} ) : null} {opt.label} ); } export default function QuestionField({ question, value, otherValue, onChange, onOtherChange }) { if (!question) return null; if (question.type === 'number') { return (
onChange(e.target.value === '' ? '' : Number(e.target.value))} />
); } if (question.type === 'single') { return (
{question.label} *
{question.options.map((opt) => ( ))}
{question.otherField && value === 'others' && ( onOtherChange(e.target.value)} /> )}
); } const selected = Array.isArray(value) ? value : []; return (
{question.label} *

Multiple answers can be selected

{question.options.map((opt) => { const checked = selected.includes(opt.value); return ( ); })}
{question.otherField && selected.includes('others') && ( onOtherChange(e.target.value)} /> )}
); }