import { useState } from "react"; import { adminSetSiteAdmin } from "~/fns/admin"; import type { getAdminOverview } from "~/fns/admin"; import { useAction } from "~/hooks/use-action"; import { Button } from "~/ui/Button"; import { ErrorBanner } from "~/ui/Callout"; import { Panel } from "~/ui/Panel"; import { TextLink } from "~/ui/TextLink"; type Admins = Awaited>["siteAdmins"]; const INPUT = "rounded-md border border-kumo-line bg-kumo-base px-2 py-1 text-kumo-strong"; /** Site admins, with grant and revoke. Revoking here (not in the database) also revokes their site-admin deploy tokens. */ export function SiteAdmins({ admins }: { admins: Admins }) { const [name, setName] = useState(""); const action = useAction(adminSetSiteAdmin); return (
{ event.preventDefault(); const target = name.trim(); if (!target || !window.confirm(`Make ${target} a site admin? They can see and change everything.`)) return; await action.run({ data: { name: target, admin: true } }); setName(""); }} > setName(event.target.value)} />
    {admins.map((admin) => (
  • {admin.name}
  • ))}
); }