aboutsummaryrefslogtreecommitdiff
path: root/src/components/Header/Header.tsx
diff options
context:
space:
mode:
authorEugene Sokolov <eug-vs@keemail.me>2020-08-08 11:28:07 +0300
committerGitHub <noreply@github.com>2020-08-08 11:28:07 +0300
commit70d533d2bcbaa689d3de6ecb532997cd68a7a842 (patch)
tree0199ab8a91f3e1bd5df0865c10695dde20a5303f /src/components/Header/Header.tsx
parent84eaed2f29ac370eea7c4a7ded6fb3d4661c9679 (diff)
parent104c658fc411536e09931191721411de448f964f (diff)
downloadwhich-ui-70d533d2bcbaa689d3de6ecb532997cd68a7a842.tar.gz
Merge pull request #72 from which-ecosystem/feat/routing
Add basic routing
Diffstat (limited to 'src/components/Header/Header.tsx')
-rw-r--r--src/components/Header/Header.tsx18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx
index 41aeec7..5aa66ba 100644
--- a/src/components/Header/Header.tsx
+++ b/src/components/Header/Header.tsx
@@ -1,4 +1,5 @@
import React from 'react';
+import { useHistory } from 'react-router-dom';
import {
AppBar,
Toolbar,
@@ -11,11 +12,11 @@ import { makeStyles, useTheme } 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 { useAuth } from '../../hooks/useAuth';
import SearchBar from './SearchBar';
+
const useStyles = makeStyles(theme => ({
mobile: {
top: 'auto',
@@ -40,28 +41,29 @@ const useStyles = makeStyles(theme => ({
}
}));
+
const Header: React.FC = () => {
const classes = useStyles();
const { user } = useAuth();
- const { navigate } = useNavigate();
const theme = useTheme();
+ const history = useHistory();
const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
const handleHome = (): void => {
- navigate('home');
+ history.push('/');
};
const handleFeed = (): void => {
- navigate('feed');
+ history.push('/feed');
};
const handleProfile = (): void => {
- if (user) navigate('profile');
- else navigate('auth');
+ if (user) history.push(`/profile/${user.username}`);
+ else history.push('/login');
};
const handleNotifications = (): void => {
- navigate('notifications');
+ history.push('/notifications');
};
const FeedButton = (