import { Questionnaire } from '@/types'; import { useScopedI18n } from '@/locales/client'; interface AnswerListProps { questions: Questionnaire['questions']; answers: string[]; // array of selected option values in order renderOptions: (id: number) => { id: number; content: string; value: string }[]; } export function AnswerList({ questions, answers, renderOptions }: AnswerListProps) { const t = useScopedI18n('common'); if (!questions || questions.length === 0) return null; return (

{t('answerList.title')}

{questions.map((q, idx) => { const selectedValue = answers[idx]; const optionContent = selectedValue !== undefined ? (() => { const opts = renderOptions(q.id) || []; const found = opts.find(o => String(o.value) === String(selectedValue)); return found ? found.content : `${t('answerList.option')} ${selectedValue}`; })() : t('answerList.unanswered'); return (
{idx + 1}. {q.content} {selectedValue !== undefined ? `${optionContent}` : t('answerList.unanswered')}
); })}
); }