import { useState } from "react"; import { FileIcon, Download, Copy, Check, Eye } from "lucide-react"; import EvidencePreviewModal, { getPreviewType } from "./EvidencePreviewModal"; interface Evidence { id: string; test_id: string; file_name: string; sha256_hash: string; uploaded_by: string | null; uploaded_at: string; download_url?: string; } interface EvidenceListProps { evidences: Evidence[]; onDownload: (evidenceId: string) => void; } export default function EvidenceList({ evidences, onDownload }: EvidenceListProps) { const [copiedHash, setCopiedHash] = useState(null); const [preview, setPreview] = useState(null); const formatDate = (dateStr: string) => new Date(dateStr).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", }); const copyHash = async (hash: string) => { await navigator.clipboard.writeText(hash); setCopiedHash(hash); setTimeout(() => setCopiedHash(null), 2000); }; if (evidences.length === 0) { return (

No evidence files uploaded yet

); } return ( <>
{evidences.map((evidence) => { const previewType = getPreviewType(evidence.file_name); const canPreview = previewType !== null; return (

{evidence.file_name}

Uploaded {formatDate(evidence.uploaded_at)}

{/* Action buttons */}
{canPreview && ( )}
{/* SHA256 Hash */}
SHA256: {evidence.sha256_hash}
); })}
{/* Preview modal */} {preview && ( setPreview(null)} onDownload={() => { onDownload(preview.id); setPreview(null); }} /> )} ); }