({ dataSource, pagination, onEdit }: UserTableProps)
| 17 | } |
| 18 | |
| 19 | const UserTable = ({ dataSource, pagination, onEdit }: UserTableProps) => ( |
| 20 | <Table |
| 21 | rowKey='username' |
| 22 | data={dataSource} |
| 23 | columns={[ |
| 24 | { |
| 25 | colKey: 'username', |
| 26 | title: t('账户'), |
| 27 | width: 120, |
| 28 | }, |
| 29 | { |
| 30 | colKey: 'nickname', |
| 31 | title: t('昵称'), |
| 32 | width: 120, |
| 33 | }, |
| 34 | { |
| 35 | colKey: 'is_superuser', |
| 36 | title: t('超级管理员'), |
| 37 | width: 80, |
| 38 | cell: ({ row }) => (row.is_superuser |
| 39 | ? <Tag theme="success" variant='light'>是{ }</Tag> |
| 40 | : <Tag>否</Tag>), |
| 41 | }, |
| 42 | { |
| 43 | colKey: 'level', |
| 44 | title: t('级别'), |
| 45 | width: 100, |
| 46 | cell: ({ row }) => <Tag className={cn(s.userTag, s[`level-${row.level}`])}> |
| 47 | {LEVEL_CHOICES[row.level as LevelEnum]} |
| 48 | </Tag>, |
| 49 | }, |
| 50 | { |
| 51 | colKey: 'status', |
| 52 | title: t('状态'), |
| 53 | width: 80, |
| 54 | cell: ({ row }) => (row.status > StatusEnum.ACTIVE ? ( |
| 55 | <Tag>待激活</Tag> |
| 56 | ) : ( |
| 57 | <Tag theme="success" variant='light'>已激活</Tag> |
| 58 | )), |
| 59 | }, |
| 60 | { |
| 61 | colKey: 'latest_login_time', |
| 62 | title: t('最近访问时间'), |
| 63 | width: 150, |
| 64 | cell: ({ row }) => formatDateTime(row.latest_login_time), |
| 65 | }, |
| 66 | { |
| 67 | colKey: 'op', |
| 68 | title: t('操作'), |
| 69 | width: 80, |
| 70 | fixed: 'right', |
| 71 | cell: ({ row }) => ( |
| 72 | <a onClick={() => onEdit(row)}>{t('编辑')}</a> |
| 73 | ), |
| 74 | }, |
| 75 | ] as PrimaryTableCol<UserData>[]} |
| 76 | pagination={pagination} |
nothing calls this directly
no test coverage detected