aboutsummaryrefslogtreecommitdiff
path: root/src/components/Header
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-08-07 22:53:53 +0300
committereug-vs <eug-vs@keemail.me>2020-08-08 08:28:55 +0300
commitb124be4d5067570a8f5db4813d45e1bf49d95f56 (patch)
tree3c57342af821f7ce1b4ad4be733f7e4c4738ddf6 /src/components/Header
parent5ba6455b2aa6c75c336628bda59e70b46e3b1d6b (diff)
downloadwhich-ui-b124be4d5067570a8f5db4813d45e1bf49d95f56.tar.gz
feat: support routing in Header
Diffstat (limited to 'src/components/Header')
-rw-r--r--src/components/Header/Header.tsx19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx
index 41aeec7..ef5f9fb 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,10 +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';
+import urls from '../../pages/urls';
+
const useStyles = makeStyles(theme => ({
mobile: {
@@ -40,28 +42,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(urls.home);
};
const handleFeed = (): void => {
- navigate('feed');
+ history.push(urls.feed)
};
const handleProfile = (): void => {
- if (user) navigate('profile');
- else navigate('auth');
+ if (user) history.push(urls.profile(user.username));
+ else history.push(urls.login);
};
const handleNotifications = (): void => {
- navigate('notifications');
+ history.push(urls.notifications);
};
const FeedButton = (