MSP-3104 create RoleList
This commit is contained in:
1 parent
25bd7c6224
commit
5cb5fe8231
3 files changed
+60
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import { Descriptions, Spin } from 'antd'
|
||||
|
||||
import { RoleListProps } from '@components/RoleList/role-list.type.ts'
|
||||
|
||||
import roleApi from '@services/roleService.ts'
|
||||
|
||||
import './role-list.scss'
|
||||
|
||||
|
||||
const RoleList = ({ userRoles }: RoleListProps) => {
|
||||
const { data: roles = [], isLoading, isError } = roleApi.useGetAllRolesQuery()
|
||||
const roleIds = new Set(userRoles)
|
||||
|
||||
if (isError) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<Descriptions layout="vertical" className="role-list">
|
||||
<Descriptions.Item label="Список ролей">
|
||||
{isLoading ? (
|
||||
<Spin className="spin" />
|
||||
) : (
|
||||
<ul>
|
||||
{roles.map((roleData) => {
|
||||
if (roleIds.has(roleData.id) && roleData.name) {
|
||||
return <li key={roleData.id}>{roleData.name}</li>
|
||||
}
|
||||
return null
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
)
|
||||
}
|
||||
|
||||
export default RoleList
|
||||
@@ -0,0 +1,19 @@
|
||||
@import "src/constants/style/styleConst";
|
||||
|
||||
.role-list {
|
||||
.ant-descriptions-item-label {
|
||||
font-size: $text-size-header2;
|
||||
}
|
||||
|
||||
.spin {
|
||||
position: initial;
|
||||
}
|
||||
|
||||
ul, li {
|
||||
list-style-position: inside
|
||||
}
|
||||
|
||||
li {
|
||||
font-size: $text-size
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export type RoleListProps = {
|
||||
userRoles: number[]
|
||||
}
|
||||
Reference in new issue
Block a user