import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; 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 { User, Settings, LogOut, Trophy } from 'lucide-react'; import { useAuth } from '@/hooks/useAuth'; import { useToast } from '@/hooks/use-toast'; export function AuthButtons() { const { user, profile, signOut } = useAuth(); const navigate = useNavigate(); const { toast } = useToast(); const [loggingOut, setLoggingOut] = useState(false); const handleSignOut = async () => { setLoggingOut(true); try { await signOut(); toast({ title: "Signed out", description: "You've been signed out successfully.", }); navigate('/'); } catch (error: any) { toast({ variant: "destructive", title: "Error signing out", description: error.message, }); } finally { setLoggingOut(false); } }; if (!user) { return ( <> ); } return (

{profile?.display_name || profile?.username}

{user.email}

navigate('/profile')}> Profile navigate('/profile#lists')}> My Lists navigate('/settings')}> Settings {loggingOut ? 'Signing out...' : 'Sign out'}
); }