import { Link, Outlet, useLocation } from "@remix-run/react"; import { LayoutDashboard, ClipboardList, Store, Users, Package, 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/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 (
); } const NavLinks = ({ onNavigate }: { onNavigate?: () => void }) => ( <> {NAV.map((n) => { const active = isActive(n); const cls = `flex items-center gap-3 px-3.5 py-3 rounded-xl text-[14.5px] font-semibold transition-colors ${ active ? "bg-BLACK text-white" : "text-BLACK2 hover:bg-WHITE2" } ${n.soon ? "opacity-45 cursor-not-allowed" : ""}`; const inner = ( <> {n.label} {n.soon && ( به‌زودی )} ); return n.soon ? (
{inner}
) : ( {inner} ); })} بازگشت به سایت ); return (
{/* Desktop sidebar */} {/* Mobile top bar + horizontal nav */}

پنل مدیریت

{NAV.map((n) => { const active = isActive(n); const cls = `whitespace-nowrap px-3 py-1.5 rounded-full text-[13px] font-semibold ${ active ? "bg-BLACK text-white" : "bg-WHITE2 text-BLACK2" } ${n.soon ? "opacity-45" : ""}`; return n.soon ? ( {n.label} ) : ( {n.label} ); })}
); }