'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { Bell, LogOut, Settings, User, Calendar } from 'lucide-react'; import { useToast } from '@/hooks/use-toast'; interface DashboardHeaderProps { user: { userId: string; email: string; role: 'user' | 'admin'; }; } export function DashboardHeader({ user }: DashboardHeaderProps) { const router = useRouter(); const { toast } = useToast(); const [isLoggingOut, setIsLoggingOut] = useState(false); const handleLogout = async () => { setIsLoggingOut(true); try { await fetch('/api/auth/logout', { method: 'POST', }); toast({ title: 'Logged out successfully', description: 'See you next time!', }); router.push('/login'); router.refresh(); } catch (error) { toast({ title: 'Logout failed', description: 'Please try again', variant: 'destructive', }); } finally { setIsLoggingOut(false); } }; return (

TT Booking

{user.role === 'admin' && ( Admin )}
{user.role === 'admin' && ( )}
{user.email.split('@')[0]}
); }