"use client"; import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { useEffect, useState } from "react"; import { useAuth, roleAtLeast } from "@/lib/auth"; const NAV = [ { href: "/", label: "Dashboard", icon: "▦", min: "readonly" as const }, { href: "/tasks", label: "Tasks", icon: "✦", min: "readonly" as const }, { href: "/inventory", label: "Vessels", icon: "▤", min: "readonly" as const }, { href: "/mcp", label: "MCP Servers", icon: "⚇", min: "readonly" as const }, { href: "/rules", label: "Rules", icon: "☰", min: "support" as const }, { href: "/models", label: "Models", icon: "◈", min: "admin" as const }, { href: "/users", label: "Users", icon: "♟", min: "admin" as const }, ]; export default function AppShell({ children }: { children: React.ReactNode }) { const { user, loading, logout } = useAuth(); const router = useRouter(); const pathname = usePathname(); const [navOpen, setNavOpen] = useState(false); useEffect(() => { if (!loading && !user) router.replace("/login"); }, [loading, user, router]); // Close the mobile drawer on navigation. useEffect(() => { setNavOpen(false); }, [pathname]); if (loading || !user) { return (
Loading…
); } const sidebar = ( <>
A
Agentic OS
troubleshooting
{user.full_name || user.email}
{user.role}
); return (
{/* Mobile top bar */}
Agentic OS
{/* Mobile drawer */} {navOpen && (
setNavOpen(false)}>
)} {/* Desktop sidebar */}
{children}
); }