diff --git a/src/components/cases/documents-tab.tsx b/src/components/cases/documents-tab.tsx index 9eaa68e..544ec93 100644 --- a/src/components/cases/documents-tab.tsx +++ b/src/components/cases/documents-tab.tsx @@ -380,6 +380,80 @@ export function CaseDocumentsTab({ caseId }: { caseId: string }) { + + !o && closePreview()}> + + + {previewDoc?.name} + {previewUrl && ( +
+ + +
+ )} +
+
+ {previewLoading ? ( +
+ Loading preview… +
+ ) : previewUrl && previewDoc ? ( + + ) : null} +
+
+
+ + ); +} + +function PreviewBody({ url, doc }: { url: string; doc: any }) { + const mime = (doc.mime_type || "").toLowerCase(); + const name = (doc.name || "").toLowerCase(); + const isImage = mime.startsWith("image/") || /\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(name); + const isPdf = mime === "application/pdf" || name.endsWith(".pdf"); + const isText = + mime.startsWith("text/") || + /\.(txt|md|csv|json|log|xml|yml|yaml)$/i.test(name); + const isAudio = mime.startsWith("audio/") || /\.(mp3|wav|m4a|ogg)$/i.test(name); + const isVideo = mime.startsWith("video/") || /\.(mp4|webm|mov)$/i.test(name); + + if (isImage) { + return ( +
+ {doc.name} +
+ ); + } + if (isPdf || isText) { + return