+ {/* Sign In Button for unauthenticated users */}
+ {!isAuthenticated && (
+
+
+
+
+
+ )}
+
{/* LAYER 1: The Content (Text + Button) */}
@@ -13,9 +42,9 @@ export function Home() {
Build databases faster.
diff --git a/src/components/WorkStation.tsx b/src/components/WorkStation.tsx
index c4a0968..a02cbc2 100644
--- a/src/components/WorkStation.tsx
+++ b/src/components/WorkStation.tsx
@@ -1,5 +1,5 @@
import { useRef, useState, useEffect } from "react";
-import { useParams } from "react-router-dom";
+import { useParams, useNavigate } from "react-router-dom";
import "../index.css";
import { Toaster, toast } from "sonner";
@@ -16,7 +16,12 @@ import {
Share2,
Sparkles,
Wand2,
- Loader2
+ Loader2,
+ Bot,
+ User,
+ LogOut,
+ Settings,
+ FolderKanban
} from "lucide-react";
// Components
@@ -28,10 +33,21 @@ import GenerateModal from "./GenerateModel";
import { NotFound } from "./NotFound"; // Import your 404 component
import AssistantPanel from "./assistant/AssistantPanel";
import AssistantButton from "./assistant/AssistantButton";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger
+} from "./ui/dropdown-menu";
+import { Avatar, AvatarFallback } from "./ui/avatar";
// Store & Libs
import { useDBStore } from "../store/dbStore";
import { useAssistantStore } from "../store/assistantStore";
+import { useAIChatStore } from "../store/aiChatStore";
+import { useAuthStore } from "../store/authStore";
import { saveProject as saveLocal, importProject } from "../lib/projectIO";
import { getLayoutedElements } from '../utils/layout';
import { ProjectCompiler } from "../lib/compiler";
@@ -40,6 +56,7 @@ import { useProjectSave } from "@/hooks/useProjectSave";
function WorkStation() {
const { projectId } = useParams(); // Get Project ID from URL
+ const navigate = useNavigate();
// --- STORE STATE ---
const addTable = useDBStore((s) => s.addTable);
@@ -62,6 +79,9 @@ function WorkStation() {
// --- AI CHAT STATE ---
const { isChatOpen, isSplitView, toggleChat } = useAIChatStore();
+ // --- AUTH STATE ---
+ const { user, signOut } = useAuthStore();
+
// --- LOCAL STATE ---
const [snipOpen, setSnipOpen] = useState(false);
const [generateOpen, setGenerateOpen] = useState(false);
@@ -72,7 +92,29 @@ function WorkStation() {
const [isSaving, setIsSaving] = useState(false);
// Hook for auto-saving (now local only)
- useProjectSave(projectId || '');
+ useProjectSave(projectId || '');
+
+ // Handle sign out
+ const handleSignOut = async () => {
+ await signOut();
+ toast.success("Signed out successfully");
+ navigate('/login');
+ };
+
+ // Get user initials for avatar
+ const getUserInitials = () => {
+ if (!user) return 'U';
+ if (user.user_metadata?.full_name) {
+ const names = user.user_metadata.full_name.split(' ');
+ return names.length > 1
+ ? `${names[0][0]}${names[1][0]}`.toUpperCase()
+ : names[0][0].toUpperCase();
+ }
+ if (user.email) {
+ return user.email[0].toUpperCase();
+ }
+ return 'U';
+ };
/* -------------------------------------------------------
1. INITIALIZATION (No cloud loading)
@@ -403,6 +445,52 @@ useEffect(() => {
{/* Top Right: Inspector */}
+ {/* User Menu */}
+
+
+
+
+
+
+
+
+ {user?.user_metadata?.full_name || 'User'}
+
+
+ {user?.email}
+
+
+
+
+
+
+ My Projects
+
+
+
+ Settings
+
+
+
+
+ Sign out
+
+
+
+
{/* AI Chat Toggle Button */}