-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProfile.js
80 lines (74 loc) · 2.29 KB
/
Profile.js
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import IconButton from '@material-ui/core/IconButton';
import MenuItem from '@material-ui/core/MenuItem';
import Menu from '@material-ui/core/Menu';
import Avatar from '@material-ui/core/Avatar';
import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent';
const useStyles = makeStyles((theme) => ({
// root: {
// flexGrow: 1,
// },
// menuButton: {
// marginRight: theme.spacing(2),
// },
// title: {
// flexGrow: 1,
// },
// large: {
// width: theme.spacing(20),
// height: theme.spacing(20),
// },
}));
export default function Profile() {
const classes = useStyles();
const [anchorEl, setAnchorEl] = React.useState(null);
const open = Boolean(anchorEl);
const user = JSON.parse(localStorage.getItem('user'));
const handleMenu = (event) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
const handleLogout = () => {
localStorage.removeItem("accessToken");
localStorage.removeItem("user");
window.location.href = "/";
};
return (
<div className={classes.root}>
<AppBar position="static">
<Toolbar>
<Typography variant="h6" className={classes.title}>
Profile
</Typography>
<div>
<IconButton onClick={handleMenu} color="inherit">
<Avatar src={user.avatar} />
</IconButton>
<Menu id="menu-appbar"
anchorEl={anchorEl}
open={open}
onClose={handleClose}
>
<MenuItem onClick={handleLogout}>Logout</MenuItem>
</Menu>
</div>
</Toolbar>
</AppBar>
<Card className={classes.root} variant="outlined">
<CardContent>
{/* <Avatar src={user.avatar} className={classes.large} /> */}
<Typography variant="h5">
Welcome {user.fname} {user.lname}
</Typography>
</CardContent>
</Card>
</div>
);
}