1
1
/**
2
2
* AI Assistance Disclosure:
3
- * Tool: GitHub Copilot (model: Claude 3.5 Sonnet), date: 2025-09-15
3
+ * Tool: GitHub Copilot (model: Claude Sonnet 4 ), date: 2025-09-15
4
4
* Purpose: To create a reusable navigation bar component for the PeerPrep application.
5
5
* Author Review: I validated correctness, security, and performance of the code.
6
6
* I modified the styling to match the application's theme.
9
9
"use client" ;
10
10
11
11
import Link from "next/link" ;
12
- import { useState } from "react " ;
12
+ import { usePathname } from "next/navigation " ;
13
13
import { useRouter } from "next/navigation" ;
14
14
import { Button } from "@/components/ui/button" ;
15
15
import { User , LogOut , ChevronDown } from "lucide-react" ;
@@ -26,7 +26,7 @@ import {
26
26
} from "@/components/ui/dropdown-menu" ;
27
27
28
28
export default function Navbar ( ) {
29
- const [ activeTab , setActiveTab ] = useState ( "Dashboard" ) ;
29
+ const pathname = usePathname ( ) ;
30
30
const { user, setUser } = useUser ( ) ;
31
31
const router = useRouter ( ) ;
32
32
@@ -75,9 +75,8 @@ export default function Navbar() {
75
75
< Link
76
76
key = { item . name }
77
77
href = { item . href }
78
- onClick = { ( ) => setActiveTab ( item . name ) }
79
78
className = { `px-3 py-2 text-sm font-medium transition-colors ${
80
- activeTab === item . name
79
+ pathname . startsWith ( item . href )
81
80
? "text-blue-600 border-b-2 border-blue-600"
82
81
: "text-gray-600 hover:text-blue-600"
83
82
} `}
0 commit comments