import TablePagination from "@/components/TablePagination"; import { Clock, Edit3, Loader2, Lock, Shield, Trash2 } from "lucide-react"; import type { UserRecord } from "@/lib/api"; import { getRoleMeta } from "@/app/users/components/user-role-config"; import { formatRelativeDate, getInitials, getServerAccessSummary, } from "@/app/users/components/user-utils"; interface ActiveUsersPanelProps { loading: boolean; items: UserRecord[]; currentUserId: string | undefined; canManageAccess: boolean; canManageRoles: boolean; mutatingKey: string | null; currentPage: number; totalPages: number; totalItems: number; startItem: number; endItem: number; onPageChange: (page: number) => void; onEditAccess: (user: UserRecord) => void; onEditRole: (user: UserRecord) => void; onDelete: (user: UserRecord) => void | Promise; } export default function ActiveUsersPanel({ loading, items, currentUserId, canManageAccess, canManageRoles, mutatingKey, currentPage, totalPages, totalItems, startItem, endItem, onPageChange, onEditAccess, onEditRole, onDelete, }: ActiveUsersPanelProps) { return (
{loading ? (
Loading users...
) : items.length === 0 ? (
No active users found.
) : ( <> {items.map((item) => { const role = getRoleMeta(item.role); const RoleIcon = role.icon; const isSelf = currentUserId === item.id; const access = getServerAccessSummary({ role: item.role, allServersAccess: item.allServersAccess, names: item.serverAssignments.map( (assignment) => assignment.server.name, ), }); const canEditAccess = canManageAccess && !(item.role === "SUPER_ADMIN" && currentUserId !== undefined); const canEditRole = canManageRoles && item.role !== "SUPER_ADMIN"; const canDeactivate = canManageRoles && item.role !== "SUPER_ADMIN" && !isSelf; return ( ); })}
User Role Server Access Status Last Login Actions
{getInitials(item.name)}

{item.name}

{item.email}

{role.label} {access.label} {item.isActive ? ( ) : null} {item.isActive ? "active" : "inactive"} {formatRelativeDate(item.lastLogin)}
{canDeactivate ? ( ) : ( )}
)}
); }