From 1f41e899c733bd0eae2d9e8692b3a0a76c94b9d7 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Tue, 1 Aug 2023 22:34:02 +0200 Subject: [PATCH] Updated the Header.jsx --- .../Dashboard/components/Header/Header.jsx | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/states/Dashboard/components/Header/Header.jsx b/src/states/Dashboard/components/Header/Header.jsx index 22cb24e..0e212af 100644 --- a/src/states/Dashboard/components/Header/Header.jsx +++ b/src/states/Dashboard/components/Header/Header.jsx @@ -1,17 +1,36 @@ import {AppBar, IconButton, Toolbar, Typography} from "@mui/material"; import {Menu} from "@mui/icons-material"; +import {useContext, useEffect} from "react"; +import {projectSidebar, sidebar} from "@/common/routes/index.jsx"; +import {useLocation} from "react-router-dom"; +import {ProjectContext} from "@/states/Dashboard/contexts/Project"; -const drawerWidth = 240; +const drawerWidth = 260; + +export const Header = ({toggleOpen}) => { + const location = useLocation(); + const {currentProject} = useContext(ProjectContext); + + useEffect(() => { + document.title = "LicenseAPI - " + getTitleByPath(); + }, [location]); + + const getTitleByPath = () => { + const route = [...sidebar, ...projectSidebar].find((route) => location.pathname + .replace(currentProject?.id, ":projectId").startsWith(route.path) && route.path !== "/"); + if (route) return route.name; + return "Startseite"; + } -export const Header = () => { return ( - + - {}} + - Home + {getTitleByPath()} )