fix(13-03): dynamic import PreviewModal to prevent SSR DOMMatrix crash

react-pdf calls new DOMMatrix() at module level — static import causes
500 on document page during SSR. Same pattern as PdfViewer/PdfViewerWrapper.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Chandler Copeland
2026-03-21 17:25:14 -06:00
parent 3f4ca5a8e5
commit 72f7d20bac

View File

@@ -1,7 +1,11 @@
'use client'; 'use client';
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import { useRouter } from 'next/navigation'; import { useRouter } from 'next/navigation';
import { PreviewModal } from './PreviewModal'; import dynamic from 'next/dynamic';
// PreviewModal imports react-pdf which calls new DOMMatrix() at module level —
// must be loaded client-only to avoid SSR crash, same pattern as PdfViewer.
const PreviewModal = dynamic(() => import('./PreviewModal').then(m => m.PreviewModal), { ssr: false });
interface PreparePanelProps { interface PreparePanelProps {
docId: string; docId: string;