"use client"; import Image from 'next/image'; import Link from 'next/link'; import { usePathname, useRouter } from 'next/navigation'; import { LogOut, Settings, User } from 'lucide-react'; import { cn } from '@/lib/utils'; import { NotificationBell } from '@/components/notifications/notification-bell'; import { Avatar, AvatarFallback } from '@/components/ui/avatar'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { useDataProvider } from '@/lib/demo/data-provider-context'; import { useAuthStore } from '@/stores/auth'; import { getNavItems } from './nav-items'; export function TopBar() { const router = useRouter(); const pathname = usePathname(); const { basePath } = useDataProvider(); const user = useAuthStore((s) => s.user); const navItems = getNavItems(basePath).filter((item) => item.label !== 'Settings'); const initials = user ? `${user.first_name?.[0] ?? ''}${user.last_name?.[0] ?? ''}`.toUpperCase() || 'U' : 'U'; const handleLogout = async () => { try { await fetch('/api/auth/logout', { method: 'POST' }); } catch { // Continue with redirect even if the API call fails } if (basePath.startsWith('/demo')) { router.push('/demo'); } else { router.push('/login'); } }; return (
{/* Logo */} Casera Casera {/* Desktop nav links */} {/* Right section */}
router.push(`${basePath}/settings/profile`)}> Profile router.push(`${basePath}/settings`)}> Settings Sign out
); }