Files
meditation-admin/components/Sidebar.tsx
T
2026-06-03 08:54:20 +03:30

61 lines
2.0 KiB
TypeScript

"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { NAV } from "@/lib/nav";
import { cn } from "@/lib/utils";
import { Logo } from "./Logo";
export function Sidebar({ onNavigate }: { onNavigate?: () => void }) {
const pathname = usePathname();
return (
<nav className="flex h-full flex-col gap-1 overflow-y-auto p-4">
<div className="mb-4 flex items-center gap-2 px-2">
<span className="flex h-10 w-10 items-center justify-center rounded-xl bg-primary-soft">
<Logo className="h-7 w-7 text-primary" />
</span>
<div className="flex flex-col leading-tight">
<span className="font-bold text-foreground">آرام جان</span>
<span className="text-[11px] text-muted">پنل مدیریت</span>
</div>
</div>
{NAV.map((section) => {
const Icon = section.icon;
return (
<div key={section.label} className="mb-1">
<div className="flex items-center gap-2 px-3 py-1.5 text-xs font-semibold text-muted">
<Icon className="h-4 w-4" />
{section.label}
</div>
<div className="flex flex-col">
{section.items.map((item) => {
const active =
pathname === item.href ||
(item.href !== "/dashboard" &&
pathname?.startsWith(item.href));
return (
<Link
key={item.href}
href={item.href}
onClick={onNavigate}
className={cn(
"mr-6 rounded-lg px-3 py-2 text-sm transition",
active
? "bg-primary text-white"
: "text-foreground hover:bg-surface-muted",
)}
>
{item.label}
</Link>
);
})}
</div>
</div>
);
})}
</nav>
);
}