"use client"

import Link from "next/link"
import { usePathname } from "next/navigation"
import { cn } from "@/lib/utils"
import { BookOpen, Package, ShoppingBag, Users } from "lucide-react"

export function AdminNav() {
  const pathname = usePathname()

  return (
    <div className="w-64 border-r bg-muted/40 min-h-screen overflow-y-auto">
      <div className="space-y-4 py-4 px-2">
        <div className="px-4 py-2">
          <h2 className="mb-2 px-2 text-lg font-semibold tracking-tight">管理菜单</h2>
          <div className="space-y-1">
            <Link
              href="/admin"
              className={cn(
                "flex items-center rounded-md px-2 py-2 hover:bg-muted",
                pathname === "/admin" ? "bg-muted" : "transparent",
              )}
            >
              <BookOpen className="mr-2 h-4 w-4" />
              <span>控制台</span>
            </Link>
            <Link
              href="/admin/books"
              className={cn(
                "flex items-center rounded-md px-2 py-2 hover:bg-muted",
                pathname?.startsWith("/admin/books") ? "bg-muted" : "transparent",
              )}
            >
              <BookOpen className="mr-2 h-4 w-4" />
              <span>图书管理</span>
            </Link>
            <Link
              href="/admin/publishers"
              className={cn(
                "flex items-center rounded-md px-2 py-2 hover:bg-muted",
                pathname?.startsWith("/admin/publishers") ? "bg-muted" : "transparent",
              )}
            >
              <ShoppingBag className="mr-2 h-4 w-4" />
              <span>出版社管理</span>
            </Link>
            <Link
              href="/admin/orders"
              className={cn(
                "flex items-center rounded-md px-2 py-2 hover:bg-muted",
                pathname?.startsWith("/admin/orders") ? "bg-muted" : "transparent",
              )}
            >
              <Package className="mr-2 h-4 w-4" />
              <span>订单管理</span>
            </Link>
            <Link
              href="/admin/users"
              className={cn(
                "flex items-center rounded-md px-2 py-2 hover:bg-muted",
                pathname?.startsWith("/admin/users") ? "bg-muted" : "transparent",
              )}
            >
              <Users className="mr-2 h-4 w-4" />
              <span>用户管理</span>
            </Link>
          </div>
        </div>
      </div>
    </div>
  )
}
