All files / src/components user-profile.tsx

100% Statements 7/7
90% Branches 9/10
100% Functions 2/2
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28      3x 17x     17x 17x 14x     17x                              
import { Avatar, AvatarFallback, AvatarImage } from '@/components/avatar';
import { useOptimisticProfile } from '@/hooks/use-optimistic-profile';
 
export const UserProfile = () => {
  const { userProfile, isProfileLoading } = useOptimisticProfile();
 
  // Get the first character of the name for avatar fallback
  const getAvatarFallback = () => {
    if (!userProfile?.name) return 'U';
    return userProfile.name.charAt(0).toUpperCase();
  };
 
  return (
    <div className="flex items-center gap-3 pl-[43px]">
      <Avatar className="w-8 h-8">
        <AvatarImage
          src={userProfile?.avatar || '/api/placeholder/32/32'}
          alt={`${userProfile?.name || 'User'} avatar`}
        />
        <AvatarFallback>{getAvatarFallback()}</AvatarFallback>
      </Avatar>
      <div className="text-sm text-foreground">
        {isProfileLoading ? 'Loading...' : userProfile?.name || 'Guest'}
      </div>
    </div>
  );
};