import { Button } from '@/components/ui/button'; import { FileText, Eye, Download } from 'lucide-react'; import { formatDateTime } from '@/utils/dateFormatter'; export interface DocumentData { documentId: string; name: string; fileType: string; size: string; sizeBytes?: number; uploadedBy?: string; uploadedAt: string; } interface DocumentCardProps { document: DocumentData; onPreview?: (doc: { fileName: string; fileType: string; documentId: string; fileSize?: number }) => void; onDownload?: (documentId: string) => Promise; showPreview?: boolean; testId?: string; } const canPreview = (fileType: string) => { const type = (fileType || '').toLowerCase(); return type.includes('image') || type.includes('pdf') || type.includes('jpg') || type.includes('jpeg') || type.includes('png') || type.includes('gif'); }; export function DocumentCard({ document, onPreview, onDownload, showPreview = true, testId = 'document-card' }: DocumentCardProps) { return (

{document.name}

{document.size} • Uploaded by {document.uploadedBy} on {formatDateTime(document.uploadedAt)}

{/* Preview button for images and PDFs */} {showPreview && canPreview(document.fileType) && onPreview && ( )} {/* Download button */} {onDownload && ( )}
); }