-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathUserCard.js
More file actions
33 lines (31 loc) · 948 Bytes
/
UserCard.js
File metadata and controls
33 lines (31 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import React from 'react'
import { Badge, Flex, Text } from '@chakra-ui/react'
import { any, string } from 'prop-types'
export function UserCard({ userName, displayName, role, children, ...props }) {
return (
<Flex px="2" py="3" align="center" rounded="md" mb="2" borderColor="black" borderWidth="1px" {...props}>
{children}
<Text fontSize="lg" fontWeight="bold" wordBreak="break-all" ml={{ md: '1rem' }}>
{displayName} ({userName})
</Text>
{role && (
<Badge
ml="auto"
variant="solid"
bg={role === 'USER' ? 'primary' : role === 'ADMIN' ? 'info' : role === 'PENDING' ? 'strong' : 'weak'}
pt={1}
mr={{ md: '1rem' }}
justifySelf={{ base: 'start', md: 'end' }}
>
{role}
</Badge>
)}
</Flex>
)
}
UserCard.propTypes = {
userName: string.isRequired,
displayName: string,
role: string,
children: any,
}