import Link from "next/link"; import { KeyRound } from "lucide-react"; import { requireAdmin } from "@/lib/session"; import { getAllowlistCounts, listAllowlist, str } from "@/lib/queries/admin"; import { adminEmails } from "@/lib/access"; import { formatNumber } from "@/lib/format"; import { PageHeader } from "@/components/ui/page-header"; import { Badge } from "@/components/ui/badge"; import { Alert } from "@/components/ui/alert"; import { EmptyState } from "@/components/ui/empty-state"; import { Stat, StatGrid } from "@/components/ui/stat"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { DateCell, Mono, Panel, SearchForm } from "@/components/admin/primitives"; import { AddEmailsDialog, RemoveAllowButton, ResendInviteButton } from "@/components/admin/access-controls"; export const dynamic = "force-dynamic"; function StatusBadgeFor({ status, banned }: { status: "account" | "invited" | "pending"; banned: boolean | null }) { if (status === "account") { return banned ? ( account banned ) : ( account created ); } if (status === "invited") return ( invited ); return ( pending ); } export default async function AdminAccessPage({ searchParams }: { searchParams: Promise> }) { await requireAdmin(); const sp = await searchParams; const q = str(sp.q); const [rows, counts] = await Promise.all([listAllowlist({ q: q || undefined }), getAllowlistCounts()]); return ( <> > } /> {adminEmails.length ? ( {adminEmails.length === 1 ? "This address" : "These addresses"} can always sign up and {adminEmails.length === 1 ? "is" : "are"} created with the admin role, whether or not {adminEmails.length === 1 ? "it is" : "they are"} listed below: {adminEmails.map((e, i) => ( {i > 0 ? ", " : null} {e} ))} . Run pnpm db:seed to add them to the list and promote existing accounts. ) : ( Without it, only addresses on this list can sign up and nobody is promoted to admin automatically. Set ADMIN_EMAILS in the web environment and run pnpm db:seed. )} {rows.length === 0 ? ( } compact /> ) : ( Email Note Status Invited by Invited Added Actions {rows.map((r) => ( {r.userId ? ( {r.email} ) : ( {r.email} )} {r.accountEmail && r.accountEmail.toLowerCase() !== r.email ? account now {r.accountEmail} : null} {r.note ?? —} {r.invitedByUserId ? ( {r.invitedByEmail ?? r.invitedByUserId} ) : ( seed )} {r.status !== "account" ? : null} ))} )} > ); }