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:
parent
989251dc58
commit
74542a56a5
21
public/pdf.worker.min.mjs
Normal file
21
public/pdf.worker.min.mjs
Normal file
File diff suppressed because one or more lines are too long
@ -3,11 +3,8 @@ import { Document, Page, pdfjs } from 'react-pdf';
|
||||
|
||||
import { Typography } from '@mui/material';
|
||||
|
||||
// https://github.com/wojtekmaj/react-pdf?tab=readme-ov-file#import-worker-recommended
|
||||
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
|
||||
'pdfjs-dist/build/pdf.worker.min.mjs',
|
||||
import.meta.url,
|
||||
).toString();
|
||||
// https://github.com/wojtekmaj/react-pdf?tab=readme-ov-file#copy-worker-to-public-directory
|
||||
pdfjs.GlobalWorkerOptions.workerSrc = process.env.PUBLIC_URL + '/pdf.worker.min.mjs'
|
||||
|
||||
const TermsAndConditionsBox = ({height}: {height: string}) => {
|
||||
const [numPages, setNumPages] = useState<number>();
|
||||
@ -30,7 +27,10 @@ const TermsAndConditionsBox = ({height}: {height: string}) => {
|
||||
alignItems: 'center'
|
||||
}}
|
||||
>
|
||||
<Document file='/TermsAndConditions.pdf' onLoadSuccess={onDocumentLoadSuccess}>
|
||||
<Document
|
||||
file={process.env.PUBLIC_URL + '/TermsAndConditions.pdf'}
|
||||
onLoadSuccess={onDocumentLoadSuccess}
|
||||
>
|
||||
{Array.apply(null, Array(numPages))
|
||||
.map((x, i) => i + 1)
|
||||
.map((page) => {
|
||||
|
@ -13,7 +13,7 @@ const TermsAndConditionsDialog: React.FC<TermsDialogProps> = ({ open, onClose })
|
||||
return (
|
||||
<Dialog open={open} onClose={onClose} maxWidth="lg">
|
||||
<DialogContent>
|
||||
<TermsAndConditionsBox height='75vh' />
|
||||
<TermsAndConditionsBox height='65vh' />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={onClose} color="primary">
|
||||
|
Loading…
Reference in New Issue
Block a user