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 NotificationBell from "@/components/notifications/NotificationBell"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Sheet, SheetClose, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger, } from "@/components/ui/sheet"; import { User, Settings, LogOut, Sparkles, UserCircle, Menu, } from "lucide-react"; interface LayoutProps { children: React.ReactNode; hideFooter?: boolean; } export default function CodeLayout({ children, hideFooter }: LayoutProps) { const location = useLocation(); const { user, profile, roles, signOut, loading, profileComplete } = useAuth(); const isOwner = Array.isArray(roles) && roles.includes("owner"); const navigation = [ { name: "Home", href: "/" }, { name: "Realms", href: "/realms" }, { name: "Get Started", href: "/onboarding" }, { name: "Engage", href: "/engage" }, { name: "Roadmap", href: "/roadmap" }, { name: "Developers", href: "/developers" }, { name: "Opportunities", href: "/opportunities" }, { name: "About", href: "/about" }, { name: "Contact", href: "/contact" }, ]; const userNavigation = [ { name: "Dashboard", href: "/dashboard" }, { name: "Realms", href: "/realms" }, { name: "Feed", href: "/feed" }, { name: "Engage", href: "/engage" }, { name: "Roadmap", href: "/roadmap" }, { name: "Developers", href: "/developers" }, { name: "Opportunities", href: "/opportunities" }, { name: "Home", href: "/" }, { name: "About", href: "/about" }, { name: "Contact", href: "/contact" }, ]; const passportHref = profile?.username ? `/passport/${profile.username}` : "/passport/me"; const navItems = user ? userNavigation : navigation; const scrollToTop = () => { window.scrollTo({ top: 0, behavior: "smooth" }); }; return (
{/* Logo */}
AeThex Logo AeThex
{/* Navigation */} {/* Auth Section */}
Navigate AeThex Access any section without leaving your flow.
{loading ? (
) : user ? ( <> Go to Dashboard View Profile Account Settings ) : ( <> Join AeThex Sign In )}
{!loading && ( <> {user ? ( // Logged in - always show Dashboard button; show avatar menu if profile exists
{!profileComplete && ( )} {!profile && ( )} {profile && (

{profile.full_name || profile.username}

{profile.email}

Dashboard My Profile AeThex Passport Account Settings {isOwner && ( Admin Panel )} signOut()} > Sign out
)}
) : ( // Not logged in - show sign in/join buttons <> )} )}
{children}
{!hideFooter && ( )} {/* Supabase Configuration Status */}
); }