This commit is contained in:
2025-11-22 14:43:05 +01:00
parent 5498cf4342
commit 530218a4b8
9 changed files with 38 additions and 40 deletions
+11 -11
View File
@@ -7,7 +7,7 @@ import PdfViewer from './PdfViewer';
interface DocumentLike {
id?: string | number;
title?: string;
content_type?: string;
mime_type?: string;
filename?: string;
original_name?: string;
[key: string]: unknown;
@@ -15,7 +15,7 @@ interface DocumentLike {
interface DocumentLink {
url?: string;
contentType?: string;
mimeType?: string;
filename?: string;
}
@@ -100,8 +100,8 @@ const DocumentViewerLayout = ({
return null;
}
const normalizedContentType = (documentLink.contentType
|| document.content_type
const normalizedMimeType = (documentLink.mimeType
|| document.mime_type
|| '')
.toLowerCase();
const normalizedFilename = documentLink.filename
@@ -109,12 +109,12 @@ const DocumentViewerLayout = ({
|| document.original_name
|| '';
const fileExtension = getFileExtension(normalizedFilename);
const isImage = normalizedContentType.startsWith('image/');
const isPdf = normalizedContentType === 'application/pdf'
|| normalizedContentType === 'application/x-pdf';
const isAudio = normalizedContentType.startsWith('audio/')
const isImage = normalizedMimeType.startsWith('image/');
const isPdf = normalizedMimeType === 'application/pdf'
|| normalizedMimeType === 'application/x-pdf';
const isAudio = normalizedMimeType.startsWith('audio/')
|| AUDIO_EXTENSIONS.has(fileExtension);
const isVideo = normalizedContentType.startsWith('video/')
const isVideo = normalizedMimeType.startsWith('video/')
|| VIDEO_EXTENSIONS.has(fileExtension);
const mediaLabel = document.title
|| normalizedFilename
@@ -170,7 +170,7 @@ const DocumentViewerLayout = ({
);
}
const displayContentType = document.content_type || documentLink.contentType || 'this file type';
const displayMimeType = document.mime_type || documentLink.mimeType || 'this file type';
const displayFilename = documentLink.filename
|| document.filename
|| document.original_name
@@ -179,7 +179,7 @@ const DocumentViewerLayout = ({
return (
<div className="document-viewer__unsupported">
<div className="document-viewer__unsupported-message">
Preview is not available for {displayContentType} files.
Preview is not available for {displayMimeType} files.
</div>
<div className="document-viewer__unsupported-filename">{displayFilename}</div>
<a