UNPKG

@dbs-portal/module-identity

Version:

Identity management module for user and role management

47 lines 3 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; /** * User List Component */ import React from 'react'; import { Table, Button, Space, Tag, Avatar } from 'antd'; import { UserOutlined, EditOutlined, DeleteOutlined, LockOutlined, UnlockOutlined } from '@ant-design/icons'; export const UserList = ({ users, loading = false, onEdit, onDelete, onLock, onUnlock }) => { const columns = [ { title: 'User', key: 'user', render: (_, record) => (_jsxs(Space, { children: [_jsx(Avatar, { src: record.avatar, icon: _jsx(UserOutlined, {}), size: "small" }), _jsxs("div", { children: [_jsx("div", { className: "font-medium", children: record.displayName || record.userName }), _jsx("div", { className: "text-sm text-gray-500", children: record.email })] })] })), }, { title: 'Status', key: 'status', render: (_, record) => (_jsxs(Space, { direction: "vertical", size: "small", children: [_jsx(Tag, { color: record.isActive ? 'green' : 'red', children: record.isActive ? 'Active' : 'Inactive' }), record.emailConfirmed && _jsx(Tag, { color: "blue", children: "Email Verified" }), record.twoFactorEnabled && _jsx(Tag, { color: "purple", children: "2FA" }), record.lockoutEnd && new Date(record.lockoutEnd) > new Date() && (_jsx(Tag, { color: "orange", children: "Locked" }))] })), }, { title: 'Roles', dataIndex: 'roles', key: 'roles', render: (roles) => (_jsx(Space, { wrap: true, children: roles.map(role => (_jsx(Tag, { children: role }, role))) })), }, { title: 'Last Login', dataIndex: 'lastLoginAt', key: 'lastLoginAt', render: (date) => date ? new Date(date).toLocaleDateString() : 'Never', }, { title: 'Actions', key: 'actions', render: (_, record) => { const isLocked = record.lockoutEnd && new Date(record.lockoutEnd) > new Date(); return (_jsxs(Space, { children: [onEdit && (_jsx(Button, { type: "text", icon: _jsx(EditOutlined, {}), onClick: () => onEdit(record), title: "Edit User" })), isLocked ? (onUnlock && (_jsx(Button, { type: "text", icon: _jsx(UnlockOutlined, {}), onClick: () => onUnlock(record), title: "Unlock User" }))) : (onLock && (_jsx(Button, { type: "text", icon: _jsx(LockOutlined, {}), onClick: () => onLock(record), title: "Lock User" }))), onDelete && (_jsx(Button, { type: "text", danger: true, icon: _jsx(DeleteOutlined, {}), onClick: () => onDelete(record), title: "Delete User" }))] })); }, }, ]; return (_jsx(Table, { columns: columns, dataSource: users, loading: loading, rowKey: "id", pagination: { showSizeChanger: true, showQuickJumper: true, showTotal: (total, range) => `${range[0]}-${range[1]} of ${total} users`, } })); }; //# sourceMappingURL=UserList.js.map