Fix react-pdf for prod build #15

Merged
nabarun merged 1 commits from deep-stack/testnet-onboarding-app:ng-fix-pdf into main 2024-08-08 12:58:58 +00:00
3 changed files with 28 additions and 7 deletions
Showing only changes of commit 866dfe7c0e - Show all commits

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';
// 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) => {

View File

@ -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">