"use client" import { useState } from "react" import { motion, AnimatePresence } from "framer-motion" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select" import { X, Bug, Loader2, CheckCircle } from "lucide-react" interface BugReportModalProps { open: boolean onClose: () => void } export function BugReportModal({ open, onClose }: BugReportModalProps) { const [title, setTitle] = useState("") const [description, setDescription] = useState("") const [severity, setSeverity] = useState("medium") const [loading, setLoading] = useState(false) const [submitted, setSubmitted] = useState(false) const [error, setError] = useState("") const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError("") setLoading(true) try { const res = await fetch("/api/bug-reports", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ title, description, severity, page_url: window.location.href, }), }) if (res.ok) { setSubmitted(true) setTitle("") setDescription("") setSeverity("medium") } else { const data = await res.json().catch(() => ({})) setError(data.error || "Failed to submit bug report.") } } catch { setError("Connection error. Please try again.") } finally { setLoading(false) } } const handleClose = () => { setSubmitted(false) setError("") onClose() } return ( {open && (
{submitted ? (

Bug Report Submitted

Thank you for your report. The development team will investigate.

) : ( <>

Report a Bug

Help us improve the system

{error && (
{error}
)}
setTitle(e.target.value)} placeholder="Brief description of the issue" required className="w-full rounded-lg border border-[#D4D8CC] dark:border-[#333333] bg-white dark:bg-[#1E1E1E] px-3 py-2 text-sm text-[#2D3020] dark:text-white placeholder-[#8A9078] focus:border-[#C84B4B] focus:outline-none focus:ring-1 focus:ring-[#C84B4B]" />