import { useState } from 'react' import type { Question } from '@/types/questions' import { QuestionType, isInputButtonsQuestion } from '@/types/questions' import { Card, CardContent } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { Badge } from '@/components/ui/badge' import { Edit, Trash2, FileText, Type } from 'lucide-react' import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from '@/components/ui/alert-dialog' interface TestQuestionsManagerProps { questions: Question[] onChange: (questions: Question[]) => void onEdit: (question: Question, index: number) => void disabled?: boolean } export function TestQuestionsManager({ questions, onChange, onEdit, disabled = false, }: TestQuestionsManagerProps) { const [questionToDelete, setQuestionToDelete] = useState<{ question: Question index: number } | null>(null) const handleDelete = (question: Question, index: number) => { setQuestionToDelete({ question, index }) } const confirmDelete = () => { if (questionToDelete) { const newQuestions = questions.filter((_, i) => i !== questionToDelete.index) onChange(newQuestions) setQuestionToDelete(null) } } const getQuestionPreview = (question: Question): string => { if (question.text) return question.text if (question.image) return '📷 Image question' return `Word: ${question.word}` } const getQuestionTypeLabel = (type: QuestionType): string => { switch (type) { case QuestionType.SIMPLE: return 'Simple' case QuestionType.INPUT_BUTTONS: return 'Input Buttons' default: return type } } const getQuestionTypeColor = (type: QuestionType): string => { switch (type) { case QuestionType.SIMPLE: return 'bg-blue-500' case QuestionType.INPUT_BUTTONS: return 'bg-green-500' default: return 'bg-gray-500' } } return (
{questions.length} question{questions.length !== 1 ? 's' : ''} in this test
No questions yet. Add your first question to get started.
{question.word}
{getQuestionPreview(question)}