"use client"; import { ReactNode } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { clearTokens, loginWithRedirect } from "@/lib/auth"; const NAV_ITEMS: { href: string; label: string; icon: string }[] = [ { href: "/admin", label: "نمای کلی", icon: "▦" }, { href: "/admin/commercial", label: "تجاری", icon: "◈" }, { href: "/admin/tenants", label: "Tenantها", icon: "🏢" }, { href: "/admin/users", label: "کاربران", icon: "👤" }, { href: "/admin/plans", label: "پلن‌ها", icon: "📦" }, { href: "/admin/features", label: "قابلیت‌ها", icon: "🧩" }, { href: "/admin/services", label: "سرویس‌ها", icon: "🛠" }, { href: "/admin/settings", label: "حساب کاربری", icon: "⚙" }, ]; function isActive(pathname: string, href: string): boolean { if (href === "/admin") return pathname === "/admin"; return pathname === href || pathname.startsWith(`${href}/`); } export function AdminShell({ children }: { children: ReactNode }) { const pathname = usePathname(); const handleLogout = () => { clearTokens(); void loginWithRedirect("/admin"); }; return (
{/* ناوبری موبایل */}
{NAV_ITEMS.map((item) => { const active = isActive(pathname, item.href); return ( {item.label} ); })}
{children}
); }