diff --git a/apps/web/src/components/dashboard/DashboardHeader.tsx b/apps/web/src/components/dashboard/DashboardHeader.tsx index 4597f67..9ba3929 100644 --- a/apps/web/src/components/dashboard/DashboardHeader.tsx +++ b/apps/web/src/components/dashboard/DashboardHeader.tsx @@ -1,4 +1,4 @@ -import { useRouter } from "@tanstack/react-router"; +import { useLocation, useRouter } from "@tanstack/react-router"; import type { LucideIcon } from "lucide-react"; import { ArrowLeft, @@ -51,7 +51,8 @@ const menuItems: readonly MenuItem[] = [ export function DashboardHeader() { const router = useRouter(); - const pathname = router.state.location.pathname; + const location = useLocation(); + const pathname = location.pathname; const getHeaderTitle = () => { const menuItem = menuItems.find((item) => item.url === pathname); diff --git a/apps/web/src/routes/dashboard.tsx b/apps/web/src/routes/dashboard.tsx index 2f42508..6ba685b 100644 --- a/apps/web/src/routes/dashboard.tsx +++ b/apps/web/src/routes/dashboard.tsx @@ -1,4 +1,9 @@ -import { createFileRoute, Link, Outlet } from "@tanstack/react-router"; +import { + createFileRoute, + Link, + Outlet, + useMatchRoute, +} from "@tanstack/react-router"; import type { LucideIcon } from "lucide-react"; import { ArrowLeft, @@ -84,6 +89,7 @@ const menuItems: readonly MenuItem[] = [ function RouteComponent() { + const matchRoute = useMatchRoute(); const loaderData = Route.useLoaderData(); if (!loaderData.hasAccess) { return ( @@ -132,16 +138,19 @@ function RouteComponent() { - {menuItems.map((item) => ( - - - - - {item.title} - - - - ))} + {menuItems.map((item) => { + const isActive = !!matchRoute({ to: item.url, fuzzy: false }); + return ( + + + + + {item.title} + + + + ); + })}