import { useState } from 'preact/hooks'; import { Clipboard, RefreshCw, Trash2, UserCheck, UserX } from 'lucide-preact'; import type { AdminInvite, AdminUser } from '@/lib/types'; interface AdminPageProps { currentUserId: string; users: AdminUser[]; invites: AdminInvite[]; onRefresh: () => void; onCreateInvite: (hours: number) => Promise; onDeleteAllInvites: () => Promise; onToggleUserStatus: (userId: string, currentStatus: string) => Promise; onDeleteUser: (userId: string) => Promise; onRevokeInvite: (code: string) => Promise; } export default function AdminPage(props: AdminPageProps) { const [inviteHours, setInviteHours] = useState(168); const [page, setPage] = useState(1); const pageSize = 20; const formatExpiresAt = (x?: string) => (x ? new Date(x).toLocaleString() : '-'); const totalPages = Math.max(1, Math.ceil(props.invites.length / pageSize)); const safePage = Math.min(page, totalPages); const pagedInvites = props.invites.slice((safePage - 1) * pageSize, safePage * pageSize); return (

Users

{props.users.map((user) => ( ))}
Email Name Role Status Actions
{user.email} {user.name || '-'} {user.role} {user.status}
{user.role !== 'admin' && ( )}

Invites

setInviteHours(Number((e.currentTarget as HTMLInputElement).value || 168))} /> hours
{pagedInvites.map((invite) => ( ))}
Code Status Expires At Actions
{invite.code} {invite.status} {formatExpiresAt(invite.expiresAt)}
{invite.status === 'active' && ( )}
{safePage} / {totalPages}
); }