import { format } from 'date-fns'
import { Image, FileText, Film, Music, File, Download } from 'lucide-react'
const typeIcons = {
image: Image,
document: FileText,
video: Film,
audio: Music,
}
const formatFileSize = (bytes) => {
if (!bytes) return '—'
if (bytes < 1024) return `${bytes} B`
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`
}
export default function AssetCard({ asset, onClick }) {
const TypeIcon = typeIcons[asset.type] || File
const isImage = asset.type === 'image'
return (
onClick?.(asset)}
className="bg-white rounded-xl border border-border overflow-hidden card-hover cursor-pointer group"
>
{/* Thumbnail */}
{isImage && asset.url ? (

{
e.target.style.display = 'none'
e.target.nextSibling.style.display = 'flex'
}}
/>
) : null}
{asset.fileType || asset.type}
{/* Hover overlay */}
{/* Info */}
{asset.name}
{formatFileSize(asset.size)}
{asset.createdAt && (
{format(new Date(asset.createdAt), 'MMM d')}
)}
{asset.tags && asset.tags.length > 0 && (
{asset.tags.slice(0, 3).map((tag) => (
{tag}
))}
{asset.tags.length > 3 && (
+{asset.tags.length - 3}
)}
)}
)
}