Skip to content

Commit 6491854

Browse files
committed
feat: set active menu sidebar user
1 parent 77d60cb commit 6491854

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/app/[locale]/(public)/(user)/layout.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import { Separator } from "@/components/ui/Separator";
77
import { Link } from "@/lib/navigation";
88
import { useAuthUser } from "@/components/hooks/UseAuthUser";
99
import ProtectedRoute from "@/components/layout/ProtectedRoute";
10+
import { usePathname } from "@/lib/navigation";
1011

1112
interface UserLayoutProps {
1213
children: React.ReactNode;
1314
}
1415

1516
export default function UserLayout({ children }: UserLayoutProps) {
1617
const { user } = useAuthUser();
18+
const pathname = usePathname();
1719

1820
return (
1921
<ProtectedRoute>
@@ -33,11 +35,24 @@ export default function UserLayout({ children }: UserLayoutProps) {
3335

3436
<Separator />
3537

38+
{/* TODO: Refactor to use constant list for better maintainability
39+
Should create a navigationItems array with { href, label, icon, isActive }
40+
instead of hardcoding each link with pathname checks */}
3641
<nav className="flex flex-col gap-3 text-sm">
37-
<Link href="/my-events" className="flex items-center gap-2 text-gray-800 transition hover:text-blue-600">
42+
<Link
43+
href="/my-events"
44+
className={`flex items-center gap-2 transition hover:text-blue-600 ${
45+
pathname.includes("/my-events") ? "text-hmc-base-blue" : "text-foreground"
46+
}`}
47+
>
3848
<Calendar1 size={16} /> My Events
3949
</Link>
40-
<Link href="/profile" className="flex items-center gap-2 text-gray-800 transition hover:text-blue-600">
50+
<Link
51+
href="/profile"
52+
className={`flex items-center gap-2 transition hover:text-blue-600 ${
53+
pathname.includes("/profile") ? "text-hmc-base-blue" : "text-foreground"
54+
}`}
55+
>
4156
<User size={16} /> Profil
4257
</Link>
4358
</nav>

0 commit comments

Comments
 (0)