'use client'; import Link from 'next/link'; import { Avatar, AvatarFallback, AvatarImage, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui'; import { useAuth } from '@/components/context'; import { useRouter } from 'next/navigation'; import { signOut } from '@/lib/actions'; import { User } from 'lucide-react'; const AvatarDropdown = () => { const { profile, avatarUrl, isLoading, refreshUserData } = useAuth(); const router = useRouter(); const handleSignOut = async () => { const result = await signOut(); if (result?.success) { await refreshUserData(); router.push('/sign-in'); } }; const getInitials = (name: string | null | undefined): string => { if (!name) return ''; return name .split(' ') .map((n) => n[0]) .join('') .toUpperCase(); }; return ( {avatarUrl ? ( ) : ( {profile?.full_name ? ( getInitials(profile.full_name) ) : ( )} )} {profile?.full_name} Edit profile ); }; export default AvatarDropdown;