From fa047e5e513bd313fd4477a3b3f85c16c4a8cf56 Mon Sep 17 00:00:00 2001 From: leandrofars Date: Sun, 9 Jun 2024 14:30:17 -0300 Subject: [PATCH] feat(frontend): side-nav show what tab the user is in --- frontend/src/layouts/dashboard/side-nav.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/src/layouts/dashboard/side-nav.js b/frontend/src/layouts/dashboard/side-nav.js index 865fa20..d67d4d5 100644 --- a/frontend/src/layouts/dashboard/side-nav.js +++ b/frontend/src/layouts/dashboard/side-nav.js @@ -24,6 +24,19 @@ export const SideNav = (props) => { const pathname = usePathname(); const lgUp = useMediaQuery((theme) => theme.breakpoints.up('lg')); + const isItemActive = (currentPath, itemPath) => { + if (currentPath === itemPath) { + return true; + } + + if (currentPath.includes(itemPath) && itemPath !== '/') { + return true; + } + + return false; + //TODO: test frontend with color of the landing page + } + const content = ( { }} > {items.map((item) => { - const active = item.path ? (pathname === item.path) : false; + const active = isItemActive(pathname, item.path); return (