'use client'; import { GeneratedQuestion, QuestionType } from '@/types/quiz'; import { Card } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Checkbox } from '@/components/ui/checkbox'; import { cn } from '@/lib/utils'; export interface QuestionCardProps { question: GeneratedQuestion; questionTypes: QuestionType[]; onEdit?: (question: GeneratedQuestion) => void; onDuplicate?: (question: GeneratedQuestion) => void; onPreview?: (question: GeneratedQuestion) => void; onRemove?: (questionId: string) => void; isSelected?: boolean; onSelect?: (questionId: string, selected: boolean) => void; onDragStart?: (questionId: string) => void; onDragEnd?: () => void; onDragOver?: (e: React.DragEvent) => void; onDrop?: (questionId: string) => void; isDragging?: boolean; isEditing?: boolean; className?: string; } export default function QuestionCard({ question, questionTypes, onEdit, onDuplicate, onPreview, onRemove, isSelected = false, onSelect, onDragStart, onDragEnd, onDragOver, onDrop, isDragging = false, isEditing = false, className = '', }: QuestionCardProps) { const questionType = questionTypes.find(t => t.id === question.type); const handleSelect = () => { if (onSelect) { onSelect(question.id, !isSelected); } }; const handleDragStart = (e: React.DragEvent) => { e.dataTransfer.setData('text/plain', question.id); if (onDragStart) { onDragStart(question.id); } }; const handleDragEnd = () => { if (onDragEnd) { onDragEnd(); } }; const handleDragOver = (e: React.DragEvent) => { e.preventDefault(); if (onDragOver) { onDragOver(e); } }; const handleDrop = (e: React.DragEvent) => { e.preventDefault(); const draggedId = e.dataTransfer.getData('text/plain'); if (onDrop && draggedId !== question.id) { onDrop(question.id); } }; return (
{/* Drag Handle */}
{/* Selection Checkbox */} {onSelect && ( )} {/* Question Content */}
{questionType?.name || 'Unknown Type'} {question.points} pts {new Date(question.createdAt).toLocaleDateString()}

{question.stem}

{/* Display Options */} {question.content && question.content.Options && (
{Object.entries(question.content.Options).map(([key, value]) => (
{key}) {value as string}
))}
)} {/* Display Answer */} {question.content && question.content.Answer && (
Answer: {question.content.Answer}
)}
{/* Action Buttons */}
{onEdit && ( )} {onDuplicate && ( )} {onPreview && ( )} {onRemove && ( )}
); }