import { ReactNode, useState } from "react"; import { Link, useLocation, useNavigate } from "react-router-dom"; import { useQuery } from "@tanstack/react-query"; import { commandsApi, Command } from "../api/client"; import { LayoutDashboard, Server, Settings, LogOut, Menu, X, Building2, MapPin, History, CheckCircle, XCircle, Clock, Loader2, } from "lucide-react"; import { useAuth } from "../hooks/useAuth"; import { Button } from "./Button"; interface LayoutProps { children: ReactNode; } const navItems = [ { path: "/", label: "Dashboard", icon: LayoutDashboard }, { path: "/clients", label: "Clients", icon: Building2 }, { path: "/sites", label: "Sites", icon: MapPin }, { path: "/agents", label: "Agents", icon: Server }, { path: "/settings", label: "Settings", icon: Settings }, ]; const APP_VERSION = "0.2.0"; const SERVER_VERSION = "0.1.0"; function CommandStatusIcon({ status }: { status: Command["status"] }) { const config = { pending: { icon: Clock, color: "text-amber-500" }, running: { icon: Loader2, color: "text-cyan-500 animate-spin" }, completed: { icon: CheckCircle, color: "text-emerald-500" }, failed: { icon: XCircle, color: "text-rose-500" }, }; const { icon: Icon, color } = config[status]; return ; } export function Layout({ children }: LayoutProps) { const [sidebarOpen, setSidebarOpen] = useState(false); const location = useLocation(); const navigate = useNavigate(); const { user, logout } = useAuth(); const { data: commands = [] } = useQuery({ queryKey: ["commands"], queryFn: () => commandsApi.list().then((res) => res.data), refetchInterval: 15000, }); const recentCommands = commands.slice(0, 4); const handleLogout = () => { logout(); navigate("/login"); }; return (
{/* Subtle grid pattern background */}
{/* Mobile header */}
GURURMM
{/* Mobile menu overlay with blur */}
setSidebarOpen(false)} />
{/* Sidebar - Mission Control Aesthetic */} {/* Main content area */}
{children}
); }