"use client"; import { Button, Checkbox, Input, Label, RadioGroup, RadioGroupItem, Slider, Textarea, } from "@mdxui/primitives"; import { Plus, X } from "lucide-react"; import type { QuestionOption, SurveyQuestion } from "./types"; interface QuestionPreviewProps { question: SurveyQuestion; onUpdate: (questionId: string, updates: Partial) => void; readOnly: boolean; } export function QuestionPreview({ question, onUpdate, readOnly, }: QuestionPreviewProps) { const handleAddOption = () => { const newOption: QuestionOption = { id: crypto.randomUUID(), label: `Option ${(question.options?.length || 0) + 1}`, value: `option-${(question.options?.length || 0) + 1}`, }; onUpdate(question.id, { options: [...(question.options || []), newOption], }); }; const handleUpdateOption = (optionId: string, label: string) => { onUpdate(question.id, { options: question.options?.map((opt) => opt.id === optionId ? { ...opt, label, value: label.toLowerCase().replace(/\s+/g, "-") } : opt, ), }); }; const handleRemoveOption = (optionId: string) => { onUpdate(question.id, { options: question.options?.filter((opt) => opt.id !== optionId), }); }; switch (question.type) { case "text": case "email": case "url": case "number": return ( ); case "textarea": return (