blob: f02adc3177abd83a56fb5b94014e1b9bf70ff3ad (
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
60
61
62
63
64
65
|
import React from 'react';
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;
navigate: (prefix: string, id: string) => void;
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, navigate }) => {
const classes = useStyles();
const {
username,
avatarUrl,
verified
} = user;
const handleNavigate = () => {
navigate('profile', user._id);
};
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;
|