components/current-user-avatar.tsx
Rama main · réplica de lectura del repositorio original.
'use client'
import { IconUser as User2 } from '@tabler/icons-react'
import { useCurrentUserImage } from '@/hooks/use-current-user-image'
import { useCurrentUserName } from '@/hooks/use-current-user-name'
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
export const CurrentUserAvatar = () => {
const profileImage = useCurrentUserImage()
const name = useCurrentUserName()
const initials = name
?.split(' ')
?.map(word => word[0])
?.join('')
?.toUpperCase()
return (
<Avatar className="size-6">
{profileImage && <AvatarImage src={profileImage} alt={initials} />}
<AvatarFallback>
{initials === '?' ? (
<User2 size={16} className="text-muted-foreground" />
) : (
initials
)}
</AvatarFallback>
</Avatar>
)
}