import React from 'react'; import { TrashIcon, ArrowDownTrayIcon, EyeIcon, } from '@heroicons/react/24/outline'; import { Attachment } from '../../entities/Attachment'; import FileIcon from './Icons/FileIcon'; interface AttachmentCardProps { attachment: Attachment; taskUid: string; onDelete: (attachment: Attachment) => void; onDownload: (attachment: Attachment) => void; onPreview: (attachment: Attachment) => void; isPreviewOpen: boolean; } const AttachmentCard: React.FC = ({ attachment, onDelete, onDownload, onPreview, }) => { const isImage = attachment.mime_type.startsWith('image/'); const isPdf = attachment.mime_type === 'application/pdf'; const canPreview = isImage || isPdf; const formatFileSize = (bytes: number): string => { if (bytes < 1024) return `${bytes} B`; if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; }; return (
{/* Preview/Icon Area */}
canPreview && onPreview(attachment)} > {isImage && attachment.file_url ? ( {attachment.original_filename} ) : isPdf ? (
PDF
) : ( )} {/* Action buttons overlay - visible on hover */}
{canPreview && ( )}
{/* File Info Area */}

{attachment.original_filename}

{formatFileSize(attachment.file_size)}

{/* Date */}

{new Date(attachment.created_at).toLocaleDateString()}

); }; export default AttachmentCard;