import { Link, Outlet, useLocation } from "@remix-run/react"; import { LayoutDashboard, ClipboardList, Store, Users, Package, Tags, Ticket, LayoutGrid, Landmark, LayoutTemplate, Bell, Activity, MessageSquareWarning, ScrollText, ArrowRight, ShieldCheck, Loader2, } from "lucide-react"; import type { LucideIcon } from "lucide-react"; import { useRequireAdmin } from "~/hooks/useRequireAdmin"; interface NavItem { label: string; to: string; icon: LucideIcon; exact?: boolean; soon?: boolean; // planned but not built yet } const NAV: NavItem[] = [ { label: "نمای کلی", to: "/admin", icon: LayoutDashboard, exact: true }, { label: "سفارشها", to: "/admin/orders", icon: ClipboardList }, { label: "فروشگاهها", to: "/admin/sellers", icon: Store }, { label: "کاربران", to: "/admin/users", icon: Users }, { label: "محصولات", to: "/admin/products", icon: Package }, { label: "ویژگیها", to: "/admin/catalog", icon: Tags }, { label: "تخفیفها", to: "/admin/discounts", icon: Ticket }, { label: "مجموعهها", to: "/admin/collections", icon: LayoutGrid }, { label: "دفتر مالی", to: "/admin/ledger", icon: Landmark }, { label: "صفحه اصلی", to: "/admin/homepage", icon: LayoutTemplate }, { label: "اعلانها", to: "/admin/notifications", icon: Bell }, { label: "سلامت AI", to: "/admin/ai-health", icon: Activity }, { label: "مدیریت محتوا", to: "/admin/moderation", icon: MessageSquareWarning }, { label: "گزارش فعالیت", to: "/admin/audit", icon: ScrollText }, ]; export default function AdminLayout() { const location = useLocation(); const { isLoading, isAdmin } = useRequireAdmin(); const isActive = (item: NavItem) => item.exact ? location.pathname === item.to : location.pathname.startsWith(item.to); if (isLoading || !isAdmin) { return (
پنل مدیریت