"use client"; import type React from "react"; import { useEffect, useMemo, useState } from "react"; import { usePathname, useRouter } from "next/navigation"; import AdminLeftNavigation, { type AdminNavGroup, } from "@/components/AdminLeftNavigation"; import { useAuth } from "@/context/AuthContext"; import { LayoutDashboard, Download, Layers, Boxes, Store, Users, Settings, Mail, Wand2, FolderKanban, Shield, } from "lucide-react"; const navGroups: AdminNavGroup[] = [ { label: "Overview", icon: , items: [ { label: "Dashboard", href: "/admin", icon: , }, ], }, { label: "Catalog", icon: , items: [ { label: "Products", href: "/admin/products", icon: , }, { label: "Platforms", href: "/admin/platforms", icon: , }, ], }, { label: "Data Ops", icon: , items: [ { label: "Imports", href: "/admin/import-status", icon: , }, { label: "Mappings", href: "/admin/mapping", icon: , }, { label: "Enrichment", href: "/admin/enrichment", icon: , }, ], }, { label: "Growth & Comms", icon: , items: [ { label: "Beta Invites", href: "/admin/beta-invites", icon: , }, { label: "List Emails", href: "/admin/email", icon: , }, { label: "Send an Email", href: "/admin/email/send", icon: , }, ], }, { label: "Access & Config", icon: , items: [ { label: "Users", href: "/admin/users", icon: , }, { label: "Merchants", href: "/admin/merchants", icon: , }, { label: "Settings", href: "/admin/settings", icon: , }, ], }, ]; export default function AdminLayout({ children, }: { children: React.ReactNode; }) { const [collapsed, setCollapsed] = useState(false); const { user, loading } = useAuth(); const router = useRouter(); const pathname = usePathname(); const next = useMemo( () => encodeURIComponent(pathname || "/admin"), [pathname] ); useEffect(() => { if (loading) return; if (!user) { router.replace(`/login?next=${next}`); return; } if (user.role !== "ADMIN") { router.replace("/"); } }, [loading, user, router, next]); if (loading) return null; if (!user) return null; if (user.role !== "ADMIN") return null; return ( // ✅ prevent browser-level horizontal scroll from any wide children
setCollapsed((v) => !v)} groups={navGroups} /> {/* ✅ min-w-0 is the critical fix: lets the main column shrink */}

Admin

Battl Control Panel

Internal • v0.1
ADMIN
{/* ✅ min-w-0 here prevents table min-width from widening the page */}
{children}
); }