import { useState } from 'react'; interface ProfileAvatarProps { avatarUrl: string; displayName: string; } /** * Renders the user's current avatar photo, falling back to their initials when the public * profile payload carries an empty `avatarUrl` or the hosted image fails to load. */ const ProfileAvatar = ({ avatarUrl, displayName }: ProfileAvatarProps) => { const [didImageFail, setDidImageFail] = useState(false); const showPhoto = avatarUrl.length > 0 && !didImageFail; return (
{showPhoto ? (
{`${displayName}'s setDidImageFail(true)} />
) : (
{displayName.slice(0, 2).toUpperCase()}
)}
); }; export default ProfileAvatar;