import { useState } from 'react' import type { Question } from '../types/quiz' import { ProgressBar } from './ProgressBar' interface QuestionScreenProps { question: Question current: number total: number onAnswer: (answer: string | string[]) => void } export function QuestionScreen({ question, current, total, onAnswer }: QuestionScreenProps) { const [selected, setSelected] = useState([]) const [textValue, setTextValue] = useState('') const handleSingleSelect = (optionId: string) => { setSelected([optionId]) setTimeout(() => onAnswer(optionId), 400) } const handleMultiToggle = (optionId: string) => { setSelected(prev => prev.includes(optionId) ? prev.filter(id => id !== optionId) : [...prev, optionId] ) } const handleMultiSubmit = () => { if (selected.length > 0) onAnswer(selected) } const handleTextSubmit = () => { if (textValue.trim()) onAnswer(textValue.trim()) } return (

{question.text}

{/* Single choice */} {question.type === 'single' && (
{question.options.map(opt => ( ))}
)} {/* Multi choice */} {question.type === 'multi' && ( <>
{question.options.map(opt => ( ))}
)} {/* Image cards */} {question.type === 'image_cards' && (
{question.options.map(opt => ( ))}
)} {/* Text input */} {question.type === 'text_input' && ( <> setTextValue(e.target.value)} onKeyDown={e => e.key === 'Enter' && handleTextSubmit()} placeholder={question.placeholder || ''} className="w-full px-3.5 py-3 text-[15px] bg-(--color-bg-card) border border-(--color-border) rounded-lg text-(--color-text-primary) outline-none transition-colors focus:border-(--color-accent) placeholder:text-(--color-text-tertiary)" autoFocus />
)}
) }