diff --git a/src/components/ui/ResourceViewer.tsx b/src/components/ui/ResourceViewer.tsx index db06b29..0a8d76d 100644 --- a/src/components/ui/ResourceViewer.tsx +++ b/src/components/ui/ResourceViewer.tsx @@ -1,13 +1,18 @@ 'use client' +import dynamic from 'next/dynamic' import Image from 'next/image' import type { ResourceDTO } from '@/lib/api/types' +// Même stratégie que PdfSection : react-pdf a besoin de `window`. +const PdfViewer = dynamic(() => import('@/components/sections/pdf/PdfViewer'), { ssr: false }) + // Mirrors C# ResourceType enum — backend may serialize as int OR as string name const IMAGES = new Set([0, 2, 'Image', 'ImageUrl']) const VIDEOS = new Set([1, 3, 'Video', 'VideoUrl']) const AUDIOS = new Set([4, 'Audio']) const VIDEO_URLS = new Set([3, 'VideoUrl']) +const PDFS = new Set([5, 'PDF']) /** An absent type falls back to image rendering below — treat it as an image here too. */ export function isImageResource(type: unknown): boolean { @@ -81,6 +86,16 @@ export default function ResourceViewer({ resource, alt = '', objectFit = 'contai ) } + // PDF — sans ce cas, un PDF tombait dans le rendu image ci-dessous et + // s'affichait en image cassée. Même défaut que celui corrigé pour la vidéo. + if (t !== undefined && PDFS.has(t as never)) { + return ( +