-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathpreview-viewer.tsx
More file actions
76 lines (67 loc) · 2.21 KB
/
preview-viewer.tsx
File metadata and controls
76 lines (67 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { DocumentPreviewData } from "@/lib/types/document-preview";
import { PreviewImageViewer } from "./preview-image-viewer";
import { PreviewPagesViewer } from "./preview-pages-viewer";
import { PreviewTextViewer } from "./preview-text-viewer";
interface PreviewViewerProps {
documentData: DocumentPreviewData;
onClose: () => void;
}
export function PreviewViewer({ documentData, onClose }: PreviewViewerProps) {
const renderViewer = () => {
// Documents with pages (PDFs, docs, slides)
if (documentData.pages && documentData.pages.length > 0) {
return (
<PreviewPagesViewer documentData={documentData} onClose={onClose} />
);
}
// Single image files
if (documentData.fileType === "image" && documentData.file) {
return (
<PreviewImageViewer documentData={documentData} onClose={onClose} />
);
}
// Plain text files
if (documentData.fileType === "text" && documentData.file) {
return (
<PreviewTextViewer documentData={documentData} onClose={onClose} />
);
}
// Excel/CSV files
if (documentData.fileType === "sheet" && documentData.sheetData) {
return (
<div className="flex h-full w-full items-center justify-center">
<div className="text-center">
<p className="text-gray-400">
Sheet preview coming soon. Please preview via a shared link.
</p>
</div>
</div>
);
}
// Notion documents (not fully supported yet)
if (documentData.fileType === "notion") {
return (
<div className="flex h-full w-full items-center justify-center">
<div className="text-center">
<p className="text-gray-400">Notion document preview coming soon</p>
</div>
</div>
);
}
// Fallback for unsupported types
return (
<div className="flex h-full w-full items-center justify-center">
<div className="text-center">
<p className="text-gray-400">
Preview not available for this document type
</p>
</div>
</div>
);
};
return (
<div className="relative h-full w-full rounded-lg bg-gray-900">
{renderViewer()}
</div>
);
}