From 806f76f76d0d0c7d3bcd74187ce3bd55eb73e918 Mon Sep 17 00:00:00 2001
From: Alberto Defendi <1369-ahl-berto@users.noreply.gitlab.inf.unibz.it>
Date: Sun, 23 May 2021 18:07:29 +0200
Subject: [PATCH] Route for NavBar.

---
 src/components/AuthUser/Dashboard/HomePage/NavBar.tsx | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/components/AuthUser/Dashboard/HomePage/NavBar.tsx b/src/components/AuthUser/Dashboard/HomePage/NavBar.tsx
index 3d61c75..e05702f 100644
--- a/src/components/AuthUser/Dashboard/HomePage/NavBar.tsx
+++ b/src/components/AuthUser/Dashboard/HomePage/NavBar.tsx
@@ -4,6 +4,8 @@ import { Tabs, Tab } from '@material-ui/core';
 import HomeIcon from '@material-ui/icons/Home';
 import ImportContactsIcon from '@material-ui/icons/ImportContacts';
 import AccountCircleIcon from '@material-ui/icons/AccountCircle';
+import { AuthRoutes } from 'api/routes';
+import { useHistory } from 'react-router-dom';
 
 const useStyles = makeStyles(() => ({
   tabs: {
@@ -29,15 +31,17 @@ const useStyles = makeStyles(() => ({
 }));
 
 export const NavBar: FC = () => {
+  const history = useHistory();
   const classes = useStyles();
 
-  const [value, setValue] = React.useState(0);
+  const [value, setValue] = React.useState<string>('');
 
   const handleChange = (
     event: React.ChangeEvent<unknown>,
-    newValue: number,
+    newValue: string,
   ): void => {
     setValue(newValue);
+    history.replace(newValue);
   };
 
   return (
@@ -51,16 +55,19 @@ export const NavBar: FC = () => {
     >
       <Tab
         label="HomePage"
+        value={`${AuthRoutes.dashboard}${AuthRoutes.home}`}
         icon={<HomeIcon className={classes.tabIcon} />}
         className={classes.tabPan}
       />
       <Tab
         label="Reservation"
+        value={`${AuthRoutes.dashboard}${AuthRoutes.reservation}`}
         icon={<ImportContactsIcon className={classes.tabIcon} />}
         className={`${classes.tabPan} ${classes.rightAlign}`}
       />
       <Tab
         label="Profile"
+        value={`${AuthRoutes.dashboard}${AuthRoutes.profile}`}
         className={classes.tabPan}
         icon={<AccountCircleIcon className={classes.tabIcon} />}
       />
-- 
GitLab