"use client" import { useState } from "react" import type { Question, QuestionOption } from "@/lib/types" import { Card, CardContent, CardFooter, CardHeader, CardTitle } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group" import { Label } from "@/components/ui/label" import { Loader2 } from "lucide-react" interface QuestionCardProps { question: Question onAnswerSubmit: (questionId: string, answerIndex: number) => void isLoading: boolean } export function QuestionCard({ question, onAnswerSubmit, isLoading }: QuestionCardProps) { const [selectedOptionIndex, setSelectedOptionIndex] = useState(null) const handleSubmit = () => { if (selectedOptionIndex !== null) { onAnswerSubmit(question.id, selectedOptionIndex) setSelectedOptionIndex(null) // Reset selection after submission } } return ( Question {question.id}

{question.text}

setSelectedOptionIndex(Number.parseInt(value))} value={selectedOptionIndex !== null ? String(selectedOptionIndex) : ""} className="space-y-3" > {question.options.map((option: QuestionOption, index: number) => (
))}
) }