"use client"; import Image from "next/image"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { BookOpen, Calendar, FileText, GraduationCap, LayoutDashboard, Megaphone, MessageSquareQuote, Newspaper, Scale, Tags, Users, ClipboardList, BarChart3, } from "lucide-react"; import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarRail, } from "@/components/ui/sidebar"; import { Avatar, AvatarFallback } from "@/components/ui/avatar"; import { LogoutButton } from "@/components/organisms/admin/LogoutButton"; import { isAdminEntityEnabled } from "@/lib/admin/disabled-entities"; const NAV_GROUPS = [ { label: "نمای کلی", items: [{ href: "/mstcontroller", label: "داشبورد", icon: LayoutDashboard, exact: true }], }, { label: "محتوا", items: [ { href: "/mstcontroller/courses", label: "دوره ها", icon: BookOpen, entity: "courses" }, { href: "/mstcontroller/course-categories", label: "دسته بندی دوره ها", icon: Tags, entity: "course-categories", }, { href: "/mstcontroller/course-tags", label: "تگ های دوره", icon: Tags, entity: "course-tags", }, { href: "/mstcontroller/programs", label: "برنامه ها", icon: GraduationCap, entity: "programs" }, { href: "/mstcontroller/events", label: "رویدادها", icon: Calendar, entity: "events" }, { href: "/mstcontroller/articles", label: "مقالات", icon: Newspaper, entity: "articles" }, { href: "/mstcontroller/topics", label: "موضوعات", icon: Tags, entity: "topics" }, ], }, { label: "جامعه", items: [ { href: "/mstcontroller/faculty", label: "اساتید", icon: Users, entity: "faculty" }, { href: "/mstcontroller/alumni", label: "دانش آموختگان", icon: MessageSquareQuote, entity: "alumni" }, ], }, { label: "سایت", items: [ { href: "/mstcontroller/banners", label: "بنرهای کمپین", icon: Megaphone, entity: "banners" }, { href: "/mstcontroller/stats", label: "آمار", icon: BarChart3, entity: "stats" }, { href: "/mstcontroller/testimonials", label: "نظرات", icon: FileText, entity: "testimonials" }, { href: "/mstcontroller/legal", label: "صفحات قانونی", icon: Scale, entity: "legal" }, ], }, { label: "درخواست ها", items: [{ href: "/mstcontroller/registrations", label: "برگ ثبت نام", icon: ClipboardList }], }, ] as const; function isActive(pathname: string, href: string, exact?: boolean) { if (exact) return pathname === href; return pathname === href || pathname.startsWith(`${href}/`); } export function AdminSidebar({ userName }: { userName: string }) { const pathname = usePathname(); const initials = userName .split(/\s+/) .filter(Boolean) .slice(0, 2) .map((part) => part[0]) .join(""); return ( } className="data-active:bg-sidebar-accent" >
پنل مدیریت آموزش آزاد دانشگاه صنعتی امیرکبیر
{NAV_GROUPS.map((group) => { const items = group.items.filter( (item) => !("entity" in item) || isAdminEntityEnabled(item.entity), ); if (items.length === 0) return null; return ( {group.label} {items.map((item) => { const Icon = item.icon; const active = isActive( pathname, item.href, "exact" in item ? item.exact : false, ); return ( } > {item.label} ); })} ); })}
{initials || "اد"}

{userName}

مدیر محتوا

); }