| "use client"; |
|
|
| import Link from "next/link"; |
| import { useAuth } from "@/lib/auth-context"; |
| import { useRouter } from "next/navigation"; |
| import { useEffect } from "react"; |
| import { LayoutGrid, FileText, Zap, Settings, LogOut, Loader2, Terminal } from "lucide-react"; |
|
|
| export default function DashboardLayout({ children }: { children: React.ReactNode }) { |
| const { user, loading, logout } = useAuth(); |
| const router = useRouter(); |
|
|
| |
| useEffect(() => { |
| if (!loading && !user) router.push("/auth/signup"); |
| }, [user, loading, router]); |
|
|
| if (loading) { |
| return ( |
| <div className="h-screen bg-[#050505] flex items-center justify-center"> |
| <Loader2 className="w-5 h-5 text-amber-500 animate-spin" /> |
| </div> |
| ); |
| } |
|
|
| return ( |
| <div className="flex h-screen bg-[#050505] text-white font-sans overflow-hidden"> |
| {/* Console Sidebar */} |
| <aside className="w-64 border-r border-white/10 flex flex-col bg-[#0A0A0A]"> |
| <div className="p-6 border-b border-white/10"> |
| <Link href="/" className="font-mono text-xs text-amber-500 tracking-[0.2em] uppercase flex items-center gap-2"> |
| <Terminal className="w-3 h-3" /> |
| Defrag // OS |
| </Link> |
| </div> |
| |
| <nav className="flex-1 p-4 space-y-1"> |
| {[ |
| { name: "Overview", icon: LayoutGrid, href: "/dashboard" }, |
| { name: "Blueprints", icon: FileText, href: "/dashboard/blueprints" }, |
| { name: "API Keys", icon: Zap, href: "/dashboard/keys" }, |
| { name: "Settings", icon: Settings, href: "/dashboard/settings" }, |
| ].map((item) => ( |
| <Link |
| key={item.name} |
| href={item.href} |
| className="flex items-center gap-3 px-4 py-3 text-xs text-white/60 hover:text-white hover:bg-white/5 border-l-2 border-transparent hover:border-amber-500 transition-all font-mono uppercase tracking-wide rounded-r-md" |
| > |
| <item.icon className="w-4 h-4" /> |
| {item.name} |
| </Link> |
| ))} |
| </nav> |
| |
| <div className="p-4 border-t border-white/10"> |
| <button |
| onClick={() => logout()} |
| className="flex items-center gap-3 w-full px-4 py-3 text-xs text-red-400/60 hover:text-red-400 hover:bg-red-900/10 transition-all font-mono uppercase tracking-wide rounded-md" |
| > |
| <LogOut className="w-4 h-4" /> Terminate |
| </button> |
| </div> |
| </aside> |
| |
| {/* Main Viewport */} |
| <main className="flex-1 overflow-y-auto bg-[#050505] relative"> |
| {/* Background Grid */} |
| <div className="absolute inset-0 bg-[linear-gradient(rgba(255,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(255,255,255,0.02)_1px,transparent_1px)] bg-[size:32px_32px] pointer-events-none" /> |
| |
| <div className="p-8 relative z-10 max-w-6xl mx-auto"> |
| {children} |
| </div> |
| </main> |
| </div> |
| ); |
| } |