From 4dc824b202d158ff775c55da30c4e63a438ae3b6 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Wed, 6 Aug 2025 03:14:36 +0000 Subject: [PATCH] Add authentication state to header and show user menu when logged in cgen-742fab4556884a23a6e31f28dd1e94f0 --- client/components/Layout.tsx | 110 ++++++++++++++++++++++++++++++----- 1 file changed, 96 insertions(+), 14 deletions(-) diff --git a/client/components/Layout.tsx b/client/components/Layout.tsx index 1f6b15fd..9e706eb4 100644 --- a/client/components/Layout.tsx +++ b/client/components/Layout.tsx @@ -2,6 +2,16 @@ import { Link, useLocation } from "react-router-dom"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import SupabaseStatus from "./SupabaseStatus"; +import { useAuth } from "@/contexts/AuthContext"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; +import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; +import { User, Settings, LogOut, Bell } from "lucide-react"; interface LayoutProps { children: React.ReactNode; @@ -9,6 +19,7 @@ interface LayoutProps { export default function Layout({ children }: LayoutProps) { const location = useLocation(); + const { user, profile, signOut, loading } = useAuth(); const navigation = [ { name: "Home", href: "/" }, @@ -61,21 +72,92 @@ export default function Layout({ children }: LayoutProps) { ))} - {/* CTA */} + {/* Auth Section */}
- - + {!loading && ( + <> + {user && profile ? ( + // Logged in user menu +
+ + + + + + +
+
+

+ {profile.full_name || profile.username} +

+

+ {profile.email} +

+
+
+ + + + + Dashboard + + + + + + Profile Settings + + + + signOut()} + > + + Sign out + +
+
+
+ ) : ( + // Not logged in - show sign in/join buttons + <> + + + + )} + + )}