forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserCard.js
More file actions
61 lines (59 loc) · 1.56 KB
/
UserCard.js
File metadata and controls
61 lines (59 loc) · 1.56 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React from 'react'
import { Badge, Box, Text, PseudoBox, Stack } from '@chakra-ui/core'
import { Trans } from '@lingui/macro'
import { useHistory } from 'react-router-dom'
import { bool, string } from 'prop-types'
export function UserCard({ userName, displayName, tfa, role }) {
const history = useHistory()
return (
<PseudoBox
width="100%"
display={{ md: 'flex' }}
alignItems="center"
onClick={() => {
history.push({
pathname: '/user',
state: { detail: userName },
})
}}
_hover={{ borderColor: 'gray.200', bg: 'gray.200' }}
p="8"
>
<Box flexShrink="0" minW="15%">
<Text mt="1" fontSize="md" fontWeight="semibold">
{displayName}
</Text>
</Box>
<Box flexShrink="0" ml={{ md: 2 }} mr={{ md: 2 }}>
<Text fontSize="md" minW="10%">
{userName}
</Text>
</Box>
{role && (
<Box flexShrink="0" ml={{ md: 2 }} mr={{ md: 2 }}>
<Stack isInline align="center">
<Badge
color="primary"
bg="transparent"
borderColor="primary"
borderWidth="1px"
>
{role}
</Badge>
{tfa !== null && (
<Badge variantColor={tfa ? 'green' : 'red'}>
<Trans>2FA</Trans>
</Badge>
)}
</Stack>
</Box>
)}
</PseudoBox>
)
}
UserCard.propTypes = {
displayName: string.isRequired,
userName: string.isRequired,
role: string,
tfa: bool,
}