"use client" import { useState } from "react" import { cn } from "@/lib/utils" interface ProfileImageProps { src?: string | null alt: string fallback: string size?: "sm" | "md" | "lg" className?: string } export function ProfileImage({ src, alt, fallback, size = "md", className }: ProfileImageProps) { const [imageError, setImageError] = useState(false) const [imageLoaded, setImageLoaded] = useState(false) const sizeClasses = { sm: "w-8 h-8 text-xs", md: "w-12 h-12 text-sm", lg: "w-16 h-16 text-lg" } const hasValidImage = src && src.trim() !== '' && !imageError return (
{hasValidImage ? ( <> {alt} setImageLoaded(true)} onError={() => setImageError(true)} /> {/* Fallback que se muestra mientras carga */} {!imageLoaded && (
{fallback.charAt(0).toUpperCase()}
)} ) : (
{fallback.charAt(0).toUpperCase()}
)}
) }