import { Link, Outlet, useLocation } from "@remix-run/react"; import { LayoutDashboard, ClipboardList, Store, Users, Package, Landmark, 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, soon: true }, { label: "فروشگاهها", to: "/admin/sellers", icon: Store, soon: true }, { label: "کاربران", to: "/admin/users", icon: Users, soon: true }, { label: "محصولات", to: "/admin/products", icon: Package, soon: true }, { label: "دفتر مالی", to: "/admin/ledger", icon: Landmark, soon: true }, ]; 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 (
پنل مدیریت