From d996fff0db769ca2fb3ab7f5d6e0adeae3c0ba15 Mon Sep 17 00:00:00 2001 From: Theis Gaedigk Date: Wed, 27 May 2026 10:14:51 +0200 Subject: [PATCH] fixed sidebar navigation --- frontend/src/components/Sidebar.tsx | 43 +++++++++++++---------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsx index dd1792b..30b7018 100644 --- a/frontend/src/components/Sidebar.tsx +++ b/frontend/src/components/Sidebar.tsx @@ -3,16 +3,18 @@ import { Button, Typography } from "@mui/joy"; import InventoryIcon from "@mui/icons-material/Inventory"; import AddBoxIcon from "@mui/icons-material/AddBox"; import AccountBoxIcon from "@mui/icons-material/AccountBox"; -import { useNavigate } from "@tanstack/react-router"; -import { useState } from "react"; +import { useNavigate, useMatchRoute } from "@tanstack/react-router"; export const Sidebar = () => { const { t } = useTranslation(); const navigate = useNavigate(); - const currentURL = window.location.href; - const [currentPage, setCurrentPage] = useState( - currentURL.substring(currentURL.lastIndexOf("/") + 1), - ); + const matchRoute = useMatchRoute(); + + const btnClass = + "h-11 w-full justify-start! rounded-2xl px-4 text-left text-sm font-semibold text-slate-700 transition hover:bg-white/80 hover:text-[#0b6bcb] [&_.MuiButton-startDecorator]:mr-3! [&_.MuiButton-startDecorator]:ml-0!"; + + const variant = (to: string) => + !!matchRoute({ to, fuzzy: false }) ? "soft" : "plain"; return (