feat(F-157): completed feature
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
'use client';
|
||||
import { useEffect } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { usePathname, useRouter } from 'next/navigation';
|
||||
import Link from 'next/link';
|
||||
import { AuthProvider, useAuth } from '@/features/auth/components/AuthProvider';
|
||||
import { topNavItems, subNavItems, type NavItem } from '@/lib/permissions';
|
||||
import { visibleNavItems, type NavItem } from '@/lib/permissions';
|
||||
import type { Role } from '@/types';
|
||||
|
||||
function NavItemRow({ item }: { item: NavItem }) {
|
||||
const pathname = window?.location?.pathname ?? '';
|
||||
const pathname = usePathname();
|
||||
const active = item.href === '/'
|
||||
? pathname === '/'
|
||||
: pathname.startsWith(item.href);
|
||||
@@ -35,7 +35,7 @@ function NavItemRow({ item }: { item: NavItem }) {
|
||||
}
|
||||
|
||||
function Sidebar({ role, email }: { role: Role; email: string }) {
|
||||
const topItems = topNavItems(role);
|
||||
const items = visibleNavItems(role);
|
||||
|
||||
return (
|
||||
<div className="w-60 bg-white border-r border-gray-200 flex flex-col h-screen sticky top-0">
|
||||
@@ -50,22 +50,9 @@ function Sidebar({ role, email }: { role: Role; email: string }) {
|
||||
|
||||
{/* Nav */}
|
||||
<nav className="flex-1 px-3 py-4 space-y-0.5 overflow-y-auto">
|
||||
{topItems.map((item) => {
|
||||
const subs = subNavItems(item.href, role);
|
||||
|
||||
return (
|
||||
<div key={item.href}>
|
||||
<NavItemRow item={item} />
|
||||
{subs.length > 0 && (
|
||||
<div className="ml-4 mt-0.5 space-y-0.5">
|
||||
{subs.map((sub) => (
|
||||
<NavItemRow key={sub.href} item={sub} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{items.map((item) => (
|
||||
<NavItemRow key={item.href} item={item} />
|
||||
))}
|
||||
</nav>
|
||||
|
||||
{/* User footer */}
|
||||
|
||||
Reference in New Issue
Block a user