"use client"; import { useState, ReactNode } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { LayoutDashboard, Users, Building2, Shield, LogOut, Menu, X, Fingerprint, Activity, Bell, Mail, } from "lucide-react"; import { useLanguage } from "@/components/language-provider"; import { useAuth } from "@/components/auth/auth-provider"; import { RouteGuard } from "@/components/auth/route-guard"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; const navItems = [ { key: "overview", labelFa: "نمایش کلی", labelEn: "Overview", href: "/admin", icon: LayoutDashboard }, { key: "users", labelFa: "کاربران", labelEn: "Users", href: "/admin/users", icon: Users }, { key: "members", labelFa: "اعضا", labelEn: "Members", href: "/admin/members", icon: Users }, { key: "invitations", labelFa: "دعوت‌ها", labelEn: "Invitations", href: "/admin/invitations", icon: Mail }, { key: "orgs", labelFa: "سازمان\u200cها", labelEn: "Organizations", href: "/admin/organizations", icon: Building2 }, { key: "products", labelFa: "محصول‌ها", labelEn: "Products", href: "/admin/products", icon: Shield }, { key: "apps", labelFa: "اپلیکیشن‌ها", labelEn: "Applications", href: "/admin/applications", icon: Shield }, { key: "notifications", labelFa: "اعلانات", labelEn: "Notifications", href: "/admin/notifications", icon: Bell }, { key: "sessions", labelFa: "نشست\u200cها", labelEn: "Sessions", href: "/admin/sessions", icon: Activity }, { key: "events", labelFa: "رویدادهای امنیتی", labelEn: "Security Events", href: "/admin/events", icon: Activity }, { key: "security", labelFa: "امنیت", labelEn: "Security", href: "/admin/security", icon: Fingerprint }, ]; export function AdminLayout({ children, className }: { children: ReactNode; className?: string }) { const { lang, toggle, dir } = useLanguage(); const { logout } = useAuth(); const pathname = usePathname(); const [sidebarOpen, setSidebarOpen] = useState(false); const t = (fa: string, en: string) => (lang === "fa" ? fa : en); return (
{sidebarOpen && (
setSidebarOpen(false)} /> )}

{navItems.find((i) => pathname === i.href) ? t( navItems.find((i) => pathname === i.href)?.labelFa || "", navItems.find((i) => pathname === i.href)?.labelEn || "", ) : t("نمایش کلی", "Overview")}

{children}
); }