diff --git a/src/components/RoleList/index.tsx b/src/components/RoleList/index.tsx new file mode 100644 index 0000000..8aab52c --- /dev/null +++ b/src/components/RoleList/index.tsx @@ -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 ( + + + {isLoading ? ( + + ) : ( +
    + {roles.map((roleData) => { + if (roleIds.has(roleData.id) && roleData.name) { + return
  • {roleData.name}
  • + } + return null + })} +
+ )} +
+
+ ) +} + +export default RoleList diff --git a/src/components/RoleList/role-list.scss b/src/components/RoleList/role-list.scss new file mode 100644 index 0000000..a233d42 --- /dev/null +++ b/src/components/RoleList/role-list.scss @@ -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 + } +} diff --git a/src/components/RoleList/role-list.type.ts b/src/components/RoleList/role-list.type.ts new file mode 100644 index 0000000..a4c2d36 --- /dev/null +++ b/src/components/RoleList/role-list.type.ts @@ -0,0 +1,3 @@ +export type RoleListProps = { + userRoles: number[] +}