'use client'; import { Text } from '@/ui/Text'; import { Bell, Command } from 'lucide-react'; import { usePathname } from 'next/navigation'; import { useCurrentSession } from '@/hooks/auth/useCurrentSession'; import { useState, useEffect } from 'react'; import { ShellHeader } from '@/ui/shell/Shell'; import { CommandModal } from './CommandModal'; import { UserPill } from '@/components/profile/UserPill'; import { Input } from '@/ui/Input'; import { Box } from '@/ui/Box'; import { IconButton } from '@/ui/IconButton'; import { useSidebar } from '@/components/layout/SidebarContext'; import { PublicTopNav } from '@/ui/PublicTopNav'; import { PublicNavLogin } from '@/ui/PublicNavLogin'; import { PublicNavSignup } from '@/ui/PublicNavSignup'; export function AppHeader() { const pathname = usePathname(); const { data: session } = useCurrentSession(); const isAuthenticated = !!session; const [isCommandOpen, setIsCommandOpen] = useState(false); const { isCollapsed } = useSidebar(); // Simple breadcrumb logic const pathSegments = pathname.split('/').filter(Boolean); const breadcrumbs = pathSegments.length > 0 ? pathSegments.map(s => s.charAt(0).toUpperCase() + s.slice(1)).join(' / ') : 'Home'; // Cmd+K Listener useEffect(() => { const down = (e: KeyboardEvent) => { if (e.key === 'k' && (e.metaKey || e.ctrlKey)) { e.preventDefault(); setIsCommandOpen((open) => !open); } }; document.addEventListener('keydown', down); return () => document.removeEventListener('keydown', down); }, []); return ( <> {/* Left: Public Navigation & Context */} {/* Public Top Navigation - Only when not authenticated */} {!isAuthenticated && ( )} {/* Context & Search - Only when authenticated */} {isAuthenticated && ( <> {breadcrumbs} {/* Command Search Trigger */} setIsCommandOpen(true)} placeholder="Search or type a command..." variant="search" width="24rem" rightElement={ K } className="cursor-pointer" /> )} {/* Right: User & Notifications */} {/* Notifications - Only when authed */} {isAuthenticated && ( )} {/* Public Login/Signup Buttons - Only when not authenticated */} {!isAuthenticated && ( <> )} {/* User Pill (Handles Auth & Menu) - Only when authenticated */} {isAuthenticated && } setIsCommandOpen(false)} /> ); }