mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
34 lines
755 B
TypeScript
34 lines
755 B
TypeScript
import React from 'react';
|
|
|
|
interface MatchCardImageProps {
|
|
imageUrl: string;
|
|
alt: string;
|
|
className?: string;
|
|
}
|
|
|
|
/**
|
|
* Reusable image component for discovery match cards
|
|
* Handles image loading errors gracefully
|
|
*/
|
|
export const MatchCardImage: React.FC<MatchCardImageProps> = ({ imageUrl, alt, className }) => {
|
|
const [imageError, setImageError] = React.useState(false);
|
|
|
|
if (imageError) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div className={`w-full h-48 bg-muted overflow-hidden ${className || ''}`}>
|
|
<img
|
|
src={imageUrl}
|
|
alt={alt}
|
|
className="w-full h-full object-cover"
|
|
loading="lazy"
|
|
onError={() => setImageError(true)}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default React.memo(MatchCardImage);
|