import { useCallback, useEffect, useState } from "react"; import { api } from "./api.js"; interface Operator { did: string; handle: string; avatar?: string; addedAt: number; enrolledAt: number | null; passkeys: number; } export function OperatorsPanel() { const [operators, setOperators] = useState([]); const [handle, setHandle] = useState(""); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); const [confirmDid, setConfirmDid] = useState(null); const refresh = useCallback(() => { api .operators() .then((r) => setOperators(r.operators)) .catch((e) => setError(e.message)); }, []); useEffect(refresh, [refresh]); const add = async () => { setBusy(true); setError(null); try { await api.operatorAdd(handle.trim()); setHandle(""); refresh(); } catch (e) { setError((e as Error).message); } finally { setBusy(false); } }; const remove = async (did: string) => { setBusy(true); setError(null); setConfirmDid(null); try { await api.operatorRemove(did); refresh(); } catch (e) { setError((e as Error).message); } finally { setBusy(false); } }; return (

Admins

{error &&
{error}
} {operators.length === 0 && (

no admins yet. add one by handle and have them sign in using the new admin button to create a passkey.

)} {operators.map((o) => (
{o.avatar ? ( ) : ( {o.enrolledAt != null ? `enrolled ${new Date(o.enrolledAt).toLocaleDateString()}` : `added ${new Date(o.addedAt).toLocaleDateString()}`} {confirmDid === o.did ? ( ) : ( )}
))}
setHandle(e.target.value)} />

removing and re-adding an admin resets their enrollment (deletes their passkeys).

); }