cjo93 commited on
Commit
8f17d4e
·
verified ·
1 Parent(s): 2184b19

Create src/app/dashboard/layout.tsx

Browse files
Files changed (1) hide show
  1. src/app/dashboard/layout.tsx +76 -0
src/app/dashboard/layout.tsx ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use client";
2
+
3
+ import Link from "next/link";
4
+ import { useAuth } from "@/lib/auth-context";
5
+ import { useRouter } from "next/navigation";
6
+ import { useEffect } from "react";
7
+ import { LayoutGrid, FileText, Zap, Settings, LogOut, Loader2, Terminal } from "lucide-react";
8
+
9
+ export default function DashboardLayout({ children }: { children: React.ReactNode }) {
10
+ const { user, loading, logout } = useAuth();
11
+ const router = useRouter();
12
+
13
+ // Protect Route
14
+ useEffect(() => {
15
+ if (!loading && !user) router.push("/auth/signup");
16
+ }, [user, loading, router]);
17
+
18
+ if (loading) {
19
+ return (
20
+ <div className="h-screen bg-[#050505] flex items-center justify-center">
21
+ <Loader2 className="w-5 h-5 text-amber-500 animate-spin" />
22
+ </div>
23
+ );
24
+ }
25
+
26
+ return (
27
+ <div className="flex h-screen bg-[#050505] text-white font-sans overflow-hidden">
28
+ {/* Console Sidebar */}
29
+ <aside className="w-64 border-r border-white/10 flex flex-col bg-[#0A0A0A]">
30
+ <div className="p-6 border-b border-white/10">
31
+ <Link href="/" className="font-mono text-xs text-amber-500 tracking-[0.2em] uppercase flex items-center gap-2">
32
+ <Terminal className="w-3 h-3" />
33
+ Defrag // OS
34
+ </Link>
35
+ </div>
36
+
37
+ <nav className="flex-1 p-4 space-y-1">
38
+ {[
39
+ { name: "Overview", icon: LayoutGrid, href: "/dashboard" },
40
+ { name: "Blueprints", icon: FileText, href: "/dashboard/blueprints" },
41
+ { name: "API Keys", icon: Zap, href: "/dashboard/keys" },
42
+ { name: "Settings", icon: Settings, href: "/dashboard/settings" },
43
+ ].map((item) => (
44
+ <Link
45
+ key={item.name}
46
+ href={item.href}
47
+ 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"
48
+ >
49
+ <item.icon className="w-4 h-4" />
50
+ {item.name}
51
+ </Link>
52
+ ))}
53
+ </nav>
54
+
55
+ <div className="p-4 border-t border-white/10">
56
+ <button
57
+ onClick={() => logout()}
58
+ 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"
59
+ >
60
+ <LogOut className="w-4 h-4" /> Terminate
61
+ </button>
62
+ </div>
63
+ </aside>
64
+
65
+ {/* Main Viewport */}
66
+ <main className="flex-1 overflow-y-auto bg-[#050505] relative">
67
+ {/* Background Grid */}
68
+ <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" />
69
+
70
+ <div className="p-8 relative z-10 max-w-6xl mx-auto">
71
+ {children}
72
+ </div>
73
+ </main>
74
+ </div>
75
+ );
76
+ }