'use client';

import Link from 'next/link';
import { usePathname } from 'next/navigation';

const LINKS = [
  { href: '/admin', label: 'Overview', exact: true },
  { href: '/admin/users', label: 'Users', exact: false },
  { href: '/admin/tunnels', label: 'Tunnels', exact: false },
  { href: '/admin/reserved', label: 'Reserved', exact: false },
  { href: '/admin/audit', label: 'Audit Log', exact: false },
];

export function AdminNav() {
  const pathname = usePathname();
  return (
    <nav className="admin-nav">
      {LINKS.map((l) => {
        const active = l.exact
          ? pathname === l.href
          : pathname === l.href || pathname.startsWith(`${l.href}/`);
        return (
          <Link
            key={l.href}
            href={l.href}
            className={active ? 'admin-nav-link active' : 'admin-nav-link'}
          >
            {l.label}
          </Link>
        );
      })}
    </nav>
  );
}
