"use client"; import { useEffect, useState } from "react"; import { api } from "./api"; import { USE_STATES } from "@/lib/content/schema"; export function OwnerPanel({ toolId }: { toolId: string }) { const [n, setN] = useState(null); const [projects, setProjects] = useState([]); const [all, setAll] = useState<{ slug: string; name: string }[]>([]); const [msg, setMsg] = useState(""); useEffect(() => { api(`/api/admin/owner/${toolId}`).then((r) => { setN(r.note ?? { use_state: "candidate", cluster_compat: "unknown", priority: "medium", deployment_urls: [], custom_tags: [] }); setProjects(r.projects); }); api("/api/admin/projects").then(setAll); }, [toolId]); if (!n) return null; const set = (k: string, v: any) => setN((x: any) => ({ ...x, [k]: v })); async function save() { setMsg(""); try { await api(`/api/admin/owner/${toolId}`, { method: "PUT", body: JSON.stringify({ use_state: n.useState ?? n.use_state, rating: n.rating ?? null, notes: n.notes ?? null, cluster_compat: n.clusterCompat ?? n.cluster_compat, priority: n.priority, subscription_status: n.subscriptionStatus ?? n.subscription_status ?? null, deployment_urls: n.deploymentUrls ?? n.deployment_urls ?? [], custom_tags: n.customTags ?? n.custom_tags ?? [], review_at: n.reviewAt ?? n.review_at ?? null, projects }) }); setMsg("Saved (private)."); } catch (e) { setMsg((e as Error).message); } } const g = (a: string, b: string) => n[a] ?? n[b]; return (

Owner notes private