"use client"; import { useState } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { Button } from "@/components/ui/button"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Badge } from "@/components/ui/badge"; import { Bell, Settings, LogOut, User, Menu, X, Shield } from "lucide-react"; import { useAuth } from "@/contexts/auth-context"; const navigation = [ { name: "Project Builder", href: "/project-builder" }, { name: "Templates", href: "/templates" }, { name: "Features", href: "/features" }, { name: "Business Context", href: "/business-context" }, { name: "Architecture", href: "/architecture" }, ]; export function Header() { const [mobileMenuOpen, setMobileMenuOpen] = useState(false); const [isLoggingOut, setIsLoggingOut] = useState(false); const pathname = usePathname(); const { user, logout, isAdmin } = useAuth(); // Handle logout with loading state const handleLogout = async () => { try { setIsLoggingOut(true); await logout(); } catch (error) { console.error('Logout failed:', error); setIsLoggingOut(false); } }; // Define routes where the header should not be shown const noHeaderRoutes = ["/signin", "/signup"]; if (noHeaderRoutes.includes(pathname)) { return null; } return (
{/* Logo */}
C
Codenuk
{/* Desktop Navigation */} {/* Right side */}
{/* While loading, don't show sign-in or user menu to avoid flicker */} {!user ? ( ) : ( <> {/* Notifications */} )} {/* User Menu - Only show when user is authenticated */} {user && user.email && (

{user.name || user.email || "User"}

{user.email || "No email"}

{isAdmin && ( Admin )}
Profile Settings {isLoggingOut ? "Logging out..." : "Log out"}
)} {/* Mobile menu button */}
{/* Mobile Navigation */} {mobileMenuOpen && (
)}
); }