import { useState, useCallback } from 'react'; interface Props { question: string; options: string[]; number: number; total: number; onAnswer: (answer: string) => void; } export default function QuestionPanel({ question, options, number, total, onAnswer }: Props) { const [selected, setSelected] = useState(null); const [custom, setCustom] = useState(''); const handleConfirm = useCallback(() => { const answer = selected === '__custom__' ? custom.trim() : (selected || custom.trim()); if (!answer) return; onAnswer(answer); setSelected(null); setCustom(''); }, [selected, custom, onAnswer]); return (
{/* Pink/white panel */}
{/* Header */}
Question {number} of {total} {Math.round((number / total) * 100)}%
{/* Progress bar */}
{/* Question */}

{question}

{/* Options */}
{options.map((opt, i) => ( ))} {/* Custom answer */}
{selected === '__custom__' && (
setCustom(e.target.value)} placeholder="Type your answer..." className="w-full bg-white border border-slate-200 rounded-lg px-3 py-2 text-sm text-slate-700 placeholder-slate-400 outline-none focus:border-pink-300 focus:ring-2 focus:ring-pink-100" />
)}
{/* Confirm button */}
); }