fixes to admin/products

This commit is contained in:
2026-01-09 10:18:32 -05:00
parent ae86fe6867
commit c509cb6cd0
9 changed files with 1061 additions and 368 deletions
+8 -18
View File
@@ -125,55 +125,45 @@ export default function AdminLayout({
const router = useRouter();
const pathname = usePathname();
// Where to send people back after login
const next = useMemo(
() => encodeURIComponent(pathname || "/admin"),
[pathname]
);
/**
* ✅ AUTH GUARD
* Redirects happen in useEffect (NOT during render)
*/
useEffect(() => {
if (loading) return;
// Not logged in
if (!user) {
router.replace(`/login?next=${next}`);
return;
}
// Logged in but not admin
if (user.role !== "ADMIN") {
router.replace("/");
}
}, [loading, user, router, next]);
// While loading OR redirecting, render nothing
if (loading) return null;
if (!user) return null;
if (user.role !== "ADMIN") return null;
return (
<div className="flex min-h-screen bg-black text-zinc-50">
// ✅ prevent browser-level horizontal scroll from any wide children
<div className="flex min-h-screen bg-black text-zinc-50 overflow-x-hidden">
<AdminLeftNavigation
collapsed={collapsed}
onToggleCollapsed={() => setCollapsed((v) => !v)}
groups={navGroups}
/>
{/* Main column */}
<div className="flex min-h-screen flex-1 flex-col">
{/* Top bar */}
{/* ✅ min-w-0 is the critical fix: lets the main column shrink */}
<div className="flex min-h-screen flex-1 min-w-0 flex-col">
<header className="flex items-center justify-between border-b border-zinc-900 bg-zinc-950/70 px-4 py-3">
<div>
<p className="text-xs uppercase tracking-[0.18em] text-zinc-500">
Admin
</p>
<p className="text-sm text-zinc-200">
Battl Builders Control Panel
</p>
<p className="text-sm text-zinc-200">Battl Control Panel</p>
</div>
<div className="flex items-center gap-3">
@@ -186,11 +176,11 @@ export default function AdminLayout({
</div>
</header>
{/* Content */}
<main className="flex w-full flex-1 flex-col px-4 py-6">
{/* ✅ min-w-0 here prevents table min-width from widening the page */}
<main className="flex w-full flex-1 min-w-0 flex-col px-4 py-6">
{children}
</main>
</div>
</div>
);
}
}