blob: 29754c9ded86503ae1b3cde233b7b4ba57bd1176 (
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
|
import React from 'react';
import { useHistory } from 'react-router-dom';
import { Avatar as AvatarBase } from '@material-ui/core';
import { User } from 'which-types';
interface PropTypes {
user?: User;
className?: string;
}
const Avatar: React.FC<PropTypes> = ({ user, className }) => {
const history = useHistory();
const handleClick = () => {
if (user) history.push(`/profile/${user.username}`);
};
return (
<AvatarBase
src={user?.avatarUrl}
onClick={handleClick}
className={className}
style={{ cursor: 'pointer' }}
/>
);
};
export default Avatar;
|