mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-30 07:06:39 +08:00
### What problem does this PR solve? Feat: Capitalize the first letter of the team's role #2834 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
77 lines
1.9 KiB
TypeScript
77 lines
1.9 KiB
TypeScript
import { useListTenantUser } from '@/hooks/user-setting-hooks';
|
|
import { ITenantUser } from '@/interfaces/database/user-setting';
|
|
import { formatDate } from '@/utils/date';
|
|
import { DeleteOutlined } from '@ant-design/icons';
|
|
import type { TableProps } from 'antd';
|
|
import { Button, Table, Tag } from 'antd';
|
|
import { upperFirst } from 'lodash';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { TenantRole } from '../constants';
|
|
import { useHandleDeleteUser } from './hooks';
|
|
|
|
const ColorMap = {
|
|
[TenantRole.Normal]: 'green',
|
|
[TenantRole.Invite]: 'orange',
|
|
[TenantRole.Owner]: 'red',
|
|
};
|
|
|
|
const UserTable = () => {
|
|
const { data, loading } = useListTenantUser();
|
|
const { handleDeleteTenantUser } = useHandleDeleteUser();
|
|
const { t } = useTranslation();
|
|
|
|
const columns: TableProps<ITenantUser>['columns'] = [
|
|
{
|
|
title: t('common.name'),
|
|
dataIndex: 'nickname',
|
|
key: 'nickname',
|
|
},
|
|
{
|
|
title: t('setting.email'),
|
|
dataIndex: 'email',
|
|
key: 'email',
|
|
},
|
|
{
|
|
title: t('setting.role'),
|
|
dataIndex: 'role',
|
|
key: 'role',
|
|
render(value, { role }) {
|
|
return (
|
|
<Tag color={ColorMap[role as keyof typeof ColorMap]}>
|
|
{upperFirst(role)}
|
|
</Tag>
|
|
);
|
|
},
|
|
},
|
|
{
|
|
title: t('setting.updateDate'),
|
|
dataIndex: 'update_date',
|
|
key: 'update_date',
|
|
render(value) {
|
|
return formatDate(value);
|
|
},
|
|
},
|
|
{
|
|
title: t('common.action'),
|
|
key: 'action',
|
|
render: (_, record) => (
|
|
<Button type="text" onClick={handleDeleteTenantUser(record.user_id)}>
|
|
<DeleteOutlined size={20} />
|
|
</Button>
|
|
),
|
|
},
|
|
];
|
|
|
|
return (
|
|
<Table<ITenantUser>
|
|
rowKey={'user_id'}
|
|
columns={columns}
|
|
dataSource={data}
|
|
loading={loading}
|
|
pagination={false}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default UserTable;
|