"use client";

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

export default function AdminSidebarNav({ links }: { links: { href: string; label: string }[] }) {
  const pathname = usePathname();

  return (
    <>
      {links.map((l) => {
        const active = l.href === "/iv-manage-84x2" ? pathname === "/iv-manage-84x2" : pathname === l.href || pathname.startsWith(`${l.href}/`);
        return (
          <Link
            key={l.href}
            href={l.href}
            className={`block rounded-md px-3 py-2 text-sm font-medium ${
              active ? "bg-rose-700 text-white" : "text-stone-600 hover:bg-rose-50 hover:text-rose-800"
            }`}
          >
            {l.label}
          </Link>
        );
      })}
    </>
  );
}
