{title}
{subtitle &&{subtitle}
}"use client"; import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { useEffect, useState } from "react"; import { LayoutDashboard, Trophy, ShoppingBag, Users, ReceiptText, Image as ImageIcon, Frame as FrameIcon, Smile, Medal, MessageSquare, LogOut, Menu, X, Loader2, } from "lucide-react"; import { clearAuth, isAuthed } from "@/lib/api"; const NAV = [ { href: "/", label: "داشبورد", icon: LayoutDashboard }, { href: "/tournaments", label: "تورنومنتها", icon: Trophy }, { href: "/shop", label: "فروشگاه", icon: ShoppingBag }, { href: "/users", label: "کاربران", icon: Users }, { href: "/transactions", label: "تراکنشها", icon: ReceiptText }, { href: "/carpets", label: "فرشها", icon: ImageIcon }, { href: "/frames", label: "قابها", icon: FrameIcon }, { href: "/avatars", label: "شخصیتها", icon: Smile }, { href: "/rank-tiers", label: "رتبهها", icon: Medal }, { href: "/chat", label: "چت", icon: MessageSquare }, ]; export default function Shell({ title, subtitle, children, }: { title: string; subtitle?: string; children: React.ReactNode; }) { const pathname = usePathname(); const router = useRouter(); const [ready, setReady] = useState(false); const [open, setOpen] = useState(false); useEffect(() => { if (!isAuthed()) { router.replace("/login"); } else { setReady(true); } }, [router]); // با تغییرِ مسیر، منوی موبایل را ببند. useEffect(() => { setOpen(false); }, [pathname]); if (!ready) { return (
{subtitle}
}