diff --git a/webui/src/states/Root/components/Header/Header.jsx b/webui/src/states/Root/components/Header/Header.jsx new file mode 100644 index 0000000..dd367b8 --- /dev/null +++ b/webui/src/states/Root/components/Header/Header.jsx @@ -0,0 +1,44 @@ +import {AppBar, Avatar, IconButton, Stack, Toolbar, Tooltip, Typography} from "@mui/material"; +import {Menu as MenuIcon} from "@mui/icons-material"; +import {useEffect} from "react"; +import {sidebar} from "@/common/routes/server.jsx"; +import {useLocation} from "react-router-dom"; +import {t} from "i18next"; + +const drawerWidth = 240; + +export const Header = ({toggleOpen}) => { + const location = useLocation(); + + const retrieveUsername = () => atob(localStorage.getItem("token")).split(":")[0]; + + useEffect(() => { + document.title = "MCDash - " + getTitleByPath(); + }, [location]); + + const getTitleByPath = () => { + const route = sidebar.find((route) => location.pathname.startsWith(route.path) && route.path !== "/"); + if (route) return route.name(); + return t("nav.server"); + } + + + return ( + + + + + + + {getTitleByPath()} + + + + + + + + + ) +} \ No newline at end of file