blob: 294c250cfcbbd7592763121fee705407417d1b4c (
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
import React from 'react';
import {
AppBar,
Toolbar,
IconButton,
Typography, Avatar
} from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import AccountCircle from '@material-ui/icons/AccountCircle';
import NotificationsIcon from '@material-ui/icons/Notifications';
import HomeIcon from '@material-ui/icons/Home';
import { useAuth } from '../../hooks/useAuth';
import { useNavigate } from '../../hooks/useNavigate';
import SearchBar from './SearchBar';
const useStyles = makeStyles({
root: {
display: 'flex',
justifyContent: 'space-around',
width: '60%',
margin: 'auto'
},
logo: {
fontWeight: 'bold',
cursor: 'pointer'
},
avatar: {
width: 24,
height: 24
}
});
const Header: React.FC = () => {
const classes = useStyles();
const { user } = useAuth();
const { navigate } = useNavigate();
const handleHome = (): void => {
navigate('home');
};
const handleFeed = (): void => {
navigate('feed');
};
const handleProfile = (): void => {
if (user) navigate('profile');
else navigate('auth');
};
const handleNotifications = (): void => {
navigate('notifications');
};
return (
<AppBar position="fixed">
<Toolbar className={classes.root}>
<Typography variant="h5" className={classes.logo} onClick={handleHome}>
Which
</Typography>
<SearchBar />
<div>
<IconButton onClick={handleFeed}>
<HomeIcon />
</IconButton>
<IconButton onClick={handleNotifications}>
<NotificationsIcon />
</IconButton>
<IconButton onClick={handleProfile}>
{
user?.avatarUrl
? <Avatar className={classes.avatar} src={user?.avatarUrl} />
: <AccountCircle />
}
</IconButton>
</div>
</Toolbar>
</AppBar>
);
};
export default Header;
|