import { useState } from "react"; import { apiPost } from "../lib/api"; const CATEGORIES: { value: string; label: string }[] = [ { value: "bug", label: "Bug" }, { value: "feature", label: "Feature request" }, { value: "other", label: "Other" }, ]; function FlagIcon() { return ( ); } export function ReportIssueButton({ className }: { className?: string }) { const [open, setOpen] = useState(false); return ( <> {open && setOpen(false)} />} ); } function ReportIssueModal({ onClose }: { onClose: () => void }) { const [category, setCategory] = useState("bug"); const [subject, setSubject] = useState(""); const [description, setDescription] = useState(""); const [submitting, setSubmitting] = useState(false); const [error, setError] = useState(""); const [done, setDone] = useState(false); const handleSubmit = async () => { if (!subject.trim() || !description.trim()) { setError("Please fill in both a subject and a description."); return; } setSubmitting(true); setError(""); try { await apiPost("/api/issues", { category, subject: subject.trim(), description: description.trim(), page_context: window.location.hash || window.location.pathname, }); setDone(true); } catch (e) { setError(e instanceof Error ? e.message : "Failed to submit — please try again."); } finally { setSubmitting(false); } }; return (
e.stopPropagation()} > {done ? (

Thanks — your report was sent.

) : ( <>

Report an Issue

{CATEGORIES.map((c) => ( ))}
setSubject(e.target.value)} placeholder="Short summary of the issue" className="input text-sm" />