mirror of
https://github.com/documenso/documenso.git
synced 2025-11-15 09:12:02 +10:00
fix: unbreak pdf viewer
This commit is contained in:
@ -153,7 +153,7 @@ export const EditDocumentForm = ({
|
|||||||
gradient
|
gradient
|
||||||
>
|
>
|
||||||
<CardContent className="p-2">
|
<CardContent className="p-2">
|
||||||
<LazyPDFViewer documentData={documentData} />
|
<LazyPDFViewer key={documentData.id} documentData={documentData} />
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|||||||
@ -91,7 +91,7 @@ export default async function DocumentPage({ params }: DocumentPageProps) {
|
|||||||
|
|
||||||
{document.status === InternalDocumentStatus.COMPLETED && (
|
{document.status === InternalDocumentStatus.COMPLETED && (
|
||||||
<div className="mx-auto mt-12 max-w-2xl">
|
<div className="mx-auto mt-12 max-w-2xl">
|
||||||
<LazyPDFViewer documentData={documentData} />
|
<LazyPDFViewer key={documentData.id} documentData={documentData} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -74,7 +74,7 @@ export default async function SigningPage({ params: { token } }: SigningPageProp
|
|||||||
gradient
|
gradient
|
||||||
>
|
>
|
||||||
<CardContent className="p-2">
|
<CardContent className="p-2">
|
||||||
<LazyPDFViewer documentData={documentData} />
|
<LazyPDFViewer key={documentData.id} documentData={documentData} />
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|||||||
@ -66,6 +66,8 @@ export const PDFViewer = ({
|
|||||||
const [numPages, setNumPages] = useState(0);
|
const [numPages, setNumPages] = useState(0);
|
||||||
const [pdfError, setPdfError] = useState(false);
|
const [pdfError, setPdfError] = useState(false);
|
||||||
|
|
||||||
|
const isLoading = isDocumentBytesLoading || !documentBytes;
|
||||||
|
|
||||||
const onDocumentLoaded = (doc: LoadedPDFDocument) => {
|
const onDocumentLoaded = (doc: LoadedPDFDocument) => {
|
||||||
setNumPages(doc.numPages);
|
setNumPages(doc.numPages);
|
||||||
onDocumentLoad?.(doc);
|
onDocumentLoad?.(doc);
|
||||||
@ -153,13 +155,17 @@ export const PDFViewer = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={$el} className={cn('overflow-hidden', className)} {...props}>
|
<div ref={$el} className={cn('overflow-hidden', className)} {...props}>
|
||||||
{isDocumentBytesLoading ? (
|
{isLoading ? (
|
||||||
<div className={cn('h-[80vh] max-h-[60rem] w-full overflow-hidden rounded')}>
|
<div
|
||||||
|
className={cn(
|
||||||
|
'flex h-[80vh] max-h-[60rem] w-full flex-col items-center justify-center overflow-hidden rounded',
|
||||||
|
)}
|
||||||
|
>
|
||||||
<PDFLoader />
|
<PDFLoader />
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<PDFDocument
|
<PDFDocument
|
||||||
file={documentBytes}
|
file={documentBytes.buffer}
|
||||||
className={cn('w-full overflow-hidden rounded', {
|
className={cn('w-full overflow-hidden rounded', {
|
||||||
'h-[80vh] max-h-[60rem]': numPages === 0,
|
'h-[80vh] max-h-[60rem]': numPages === 0,
|
||||||
})}
|
})}
|
||||||
|
|||||||
Reference in New Issue
Block a user