blob: 73d93633a1b10f62773ebea097bfb7b1c9abb67b (
plain)
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
|
import React from 'react';
import { useHistory } from 'react-router-dom';
import { makeStyles } from '@material-ui/core/styles';
import VerifiedIcon from '@material-ui/icons/CheckCircleOutline';
import { Avatar, CardHeader } from '@material-ui/core/';
import { User } from 'which-types';
interface PropTypes {
user: User;
info?: string | JSX.Element
}
const useStyles = makeStyles(theme => ({
root: {
display: 'flex',
alignItems: 'center'
},
verified: {
marginLeft: theme.spacing(0.5),
width: theme.spacing(2),
height: theme.spacing(2)
},
avatar: {
cursor: 'pointer'
}
}));
const UserStrip: React.FC<PropTypes> = ({ user, info }) => {
const classes = useStyles();
const history = useHistory();
const { username, avatarUrl, verified } = user;
const handleNavigate = () => {
history.push(`/profile/${username}`);
};
const avatar = (
<Avatar
src={avatarUrl}
alt={username[0].toUpperCase()}
onClick={handleNavigate}
className={classes.avatar}
/>
);
const title = (
<div className={classes.root}>
{username}
{verified && <VerifiedIcon color="primary" className={classes.verified} />}
</div>
);
return <CardHeader avatar={avatar} title={title} subheader={info} />;
};
export default UserStrip;
|