Fix react-pdf for prod build (#15)

Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675)

Reviewed-on: cerc-io/testnet-onboarding-app#15
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Co-committed-by: Nabarun <nabarun@deepstacksoft.com>
This commit is contained in:
Nabarun 2024-08-08 12:58:57 +00:00 committed by nabarun
parent 989251dc58
commit 74542a56a5
3 changed files with 28 additions and 7 deletions

21
public/pdf.worker.min.mjs Normal file

File diff suppressed because one or more lines are too long

View File

@ -3,11 +3,8 @@ import { Document, Page, pdfjs } from 'react-pdf';
import { Typography } from '@mui/material'; import { Typography } from '@mui/material';
// https://github.com/wojtekmaj/react-pdf?tab=readme-ov-file#import-worker-recommended // https://github.com/wojtekmaj/react-pdf?tab=readme-ov-file#copy-worker-to-public-directory
pdfjs.GlobalWorkerOptions.workerSrc = new URL( pdfjs.GlobalWorkerOptions.workerSrc = process.env.PUBLIC_URL + '/pdf.worker.min.mjs'
'pdfjs-dist/build/pdf.worker.min.mjs',
import.meta.url,
).toString();
const TermsAndConditionsBox = ({height}: {height: string}) => { const TermsAndConditionsBox = ({height}: {height: string}) => {
const [numPages, setNumPages] = useState<number>(); const [numPages, setNumPages] = useState<number>();
@ -30,7 +27,10 @@ const TermsAndConditionsBox = ({height}: {height: string}) => {
alignItems: 'center' alignItems: 'center'
}} }}
> >
<Document file='/TermsAndConditions.pdf' onLoadSuccess={onDocumentLoadSuccess}> <Document
file={process.env.PUBLIC_URL + '/TermsAndConditions.pdf'}
onLoadSuccess={onDocumentLoadSuccess}
>
{Array.apply(null, Array(numPages)) {Array.apply(null, Array(numPages))
.map((x, i) => i + 1) .map((x, i) => i + 1)
.map((page) => { .map((page) => {

View File

@ -13,7 +13,7 @@ const TermsAndConditionsDialog: React.FC<TermsDialogProps> = ({ open, onClose })
return ( return (
<Dialog open={open} onClose={onClose} maxWidth="lg"> <Dialog open={open} onClose={onClose} maxWidth="lg">
<DialogContent> <DialogContent>
<TermsAndConditionsBox height='75vh' /> <TermsAndConditionsBox height='65vh' />
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button onClick={onClose} color="primary"> <Button onClick={onClose} color="primary">