import { useState } from "react"; import type { ConfigEntry } from "../types"; interface Props { entries: [string, ConfigEntry][]; onEdit: (key: string, entry: ConfigEntry) => void; onDelete: (key: string, scope: string) => void; addToast: (msg: string, type: "success" | "error") => void; } export default function ConfigTable({ entries, onEdit, onDelete, addToast }: Props) { const [revealed, setRevealed] = useState>(new Set()); const toggle = (key: string) => { setRevealed((prev) => { const next = new Set(prev); next.has(key) ? next.delete(key) : next.add(key); return next; }); }; const copy = (value: string) => { navigator.clipboard.writeText(value); addToast("Copied to clipboard", "success"); }; const fmtTime = (iso: string) => { try { const d = new Date(iso); return d.toLocaleDateString(undefined, { month: "short", day: "numeric" }) + " " + d.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" }); } catch { return iso; } }; if (entries.length === 0) { return (

No configuration keys found

Add your first key to get started

); } return (
{entries.map(([key, entry]) => { const show = revealed.has(key); const displayVal = show ? entry.value : "•".repeat(Math.min(entry.value.length || 8, 24)); return ( ); })}
Key Value Scope Flags Updated Actions
{key}
{displayVal}
{entry.scope}
{entry.secret && ( secret )} {entry.env === false && ( no-env )}
{fmtTime(entry.updated_at)}
); }