diff --git a/app/(protected)/layout.tsx b/app/(protected)/layout.tsx index d7cc8be..1978f5b 100644 --- a/app/(protected)/layout.tsx +++ b/app/(protected)/layout.tsx @@ -13,7 +13,7 @@ export default async function ProtectedLayout({ if (!session) redirect('/login') return ( -
+
( - - - -) -const IconList = () => ( - - - -) -const IconCheck = () => ( - - - -) -const IconChart = () => ( - - - -) -const IconSettings = () => ( - - - - -) -const IconUsers = () => ( - - - -) -const IconPlus = () => ( - - - -) -const IconLogout = () => ( - - - -) -const IconUser = () => ( - - - -) +const IconGrid = () => +const IconList = () => +const IconCheck = () => +const IconChart = () => +const IconSettings = () => +const IconUsers = () => +const IconPlus = () => +const IconLogout = () => +const IconUser = () => const NAV_ITEMS: Record = { reporter: [ @@ -94,6 +68,12 @@ const NAV_ITEMS: Record = { ], } +const EXACT_ROOTS = ['/reporter', '/supervisor', '/management', '/capa-owner', '/admin', '/report', '/account'] + +function isActivePath(href: string, pathname: string): boolean { + return EXACT_ROOTS.includes(href) ? pathname === href : pathname.startsWith(href) +} + function initials(name: string): string { return name .split(' ') @@ -107,23 +87,19 @@ function useNavItems(role: string): NavItem[] { return NAV_ITEMS[role] ?? NAV_ITEMS.reporter } -function NavLink({ item, pathname }: { item: NavItem; pathname: string }) { - // Exact match for root-level single-page roles, prefix match otherwise - const exactRoots = ['/reporter', '/supervisor', '/management', '/capa-owner', '/admin', '/report', '/account'] - const isActive = exactRoots.includes(item.href) - ? pathname === item.href - : pathname.startsWith(item.href) +const LINK_BASE = 'flex items-center gap-3 px-3 py-2 text-sm border-l-2 transition-colors' +const LINK_ACTIVE = 'border-accent text-accent-700 font-extrabold bg-accent-100/50' +const LINK_IDLE = 'border-transparent text-ink/70 font-medium hover:bg-ink/7 hover:text-ink' +function NavLink({ item, pathname }: { item: NavItem; pathname: string }) { + const active = isActivePath(item.href, pathname) return ( - {item.icon} + {item.icon} {item.label} ) @@ -143,86 +119,78 @@ export function Sidebar({ role, userName, userEmail }: SidebarProps) { const displayName = userName || userEmail || 'User' const roleLabel = role.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase()) + const accountActive = pathname === '/account' return ( <> {/* Desktop sidebar */} -