"use client"; import { useEffect, useState } from "react"; import { Search, Plus, Lock } from "lucide-react"; import { api } from "@/lib/api"; export default function Support() { const [orgs, setOrgs] = useState([]); const [q, setQ] = useState(""); const [selected, setSelected] = useState(""); const [view, setView] = useState(null); const [notes, setNotes] = useState([]); const [note, setNote] = useState(""); useEffect(() => { api("/admin/organizations").then(setOrgs).catch(() => {}); }, []); async function open(orgId: string) { setSelected(orgId); api(`/admin/organizations/${orgId}/support-view`).then(setView).catch(() => {}); api(`/admin/organizations/${orgId}/notes`).then(setNotes).catch(() => setNotes([])); } async function addNote() { if (!note.trim()) return; await api(`/admin/organizations/${selected}/notes`, { method: "POST", body: JSON.stringify({ note }) }); setNote(""); api(`/admin/organizations/${selected}/notes`).then(setNotes); } const filtered = orgs.filter((o) => o.name.toLowerCase().includes(q.toLowerCase())); return (

Support View

Read-only
{/* Org list */}
setQ(e.target.value)} placeholder="Search org…" className="pl-9 pr-3 py-2 w-full rounded-lg border border-slate-200 text-sm" />
{filtered.map((o) => ( ))}
{/* Detail */}
{!view ? (
Select an organization to debug.
) : ( <>

{view.org.name}

{view.org.status} · {view.org.contact_email}

Products ({view.products.length})

{view.products.map((p: any, i: number) => ( ))}
NameSKUStatusQRs
{p.name}{p.sku}{p.status}{p.qr_count}

Recent Scans

{view.recent_scans.map((s: any, i: number) => ( ))} {view.recent_scans.length === 0 && }
TimeCodeCityDevice
{new Date(s.at).toLocaleString()}{s.code}{s.city ?? "—"}{s.device ?? "—"}
No scans.

Internal Notes

setNote(e.target.value)} placeholder="Add a debugging note…" className="flex-1 px-3 py-2 rounded-lg border border-slate-200 text-sm" />
{notes.map((n) => (
{n.note}
{n.author} · {new Date(n.at).toLocaleString()}
))} {notes.length === 0 &&

No notes.

}
)}
); }