|
|
@@ -2,15 +2,33 @@ import { useEffect, useState } from 'react';
|
|
|
import { useParams } from 'react-router-dom'
|
|
|
import { Service } from '../Utils/HTTP';
|
|
|
import { useSelector } from 'react-redux';
|
|
|
-import { Button, Box, Paper } from '@mui/material'
|
|
|
import { Document, Page, pdfjs } from 'react-pdf/dist/esm/entry.webpack';
|
|
|
-// import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
|
|
|
+import { Loading } from '../Components/Generics/loading'
|
|
|
+import DownloadIcon from '@mui/icons-material/Download';
|
|
|
import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
|
|
|
import 'react-pdf/dist/esm/Page/TextLayer.css';
|
|
|
+import '../pdf.css'
|
|
|
+// import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
|
|
|
+import {
|
|
|
+ Button, Box, Paper,LinearProgress,
|
|
|
+ Typography
|
|
|
+} from '@mui/material'
|
|
|
|
|
|
-const Cargando = () => <div><h2>loading...</h2></div>
|
|
|
+function LinearProgressWithLabel(props) {
|
|
|
+ return (
|
|
|
+ <Box sx={{ display: 'flex', alignItems: 'center' }}>
|
|
|
+ <Box sx={{ width: '100%', mr: 1 }}>
|
|
|
+ <LinearProgress variant="determinate" {...props} />
|
|
|
+ </Box>
|
|
|
+ <Box sx={{ minWidth: 35 }}>
|
|
|
+ <Typography variant="body2" color="text.secondary">{`${Math.round(
|
|
|
+ props.value,
|
|
|
+ )}%`}</Typography>
|
|
|
+ </Box>
|
|
|
+ </Box>
|
|
|
+ );
|
|
|
+}
|
|
|
|
|
|
-// Create Document Component
|
|
|
const MyDocument = (props) => {
|
|
|
|
|
|
let { pdf } = props;
|
|
|
@@ -22,30 +40,72 @@ const MyDocument = (props) => {
|
|
|
setNumPages(numPages);
|
|
|
}
|
|
|
|
|
|
- function onLoadError(error) {
|
|
|
- console.log('error: ', error)
|
|
|
+ const [progress, setProgress] = useState(10);
|
|
|
+
|
|
|
+ if(!pdf){
|
|
|
+ <Loading/>
|
|
|
}
|
|
|
|
|
|
+ console.log(progress)
|
|
|
+
|
|
|
return (
|
|
|
<div>
|
|
|
+
|
|
|
+ {
|
|
|
+ progress < 100 ?
|
|
|
+ <LinearProgressWithLabel value={progress}/>
|
|
|
+ : null
|
|
|
+ }
|
|
|
+
|
|
|
<div className="pdf_controls">
|
|
|
- <Button variant="contained" onClick={() => pageNumber > 1 ? setPageNumber(pageNumber - 1) : null} >
|
|
|
+
|
|
|
+
|
|
|
+ <div className="btn_pdfcontrol">
|
|
|
+ <Button
|
|
|
+ className="btnmain"
|
|
|
+ style={{ margin: 2 }}
|
|
|
+ variant="contained"
|
|
|
+ onClick={() => pageNumber > 1 ? setPageNumber(pageNumber - 1) : null} >
|
|
|
Anterior
|
|
|
</Button>
|
|
|
- <Button style={{ margin: 5 }} variant="contained" onClick={() => pageNumber + 1 <= numPages ? setPageNumber(pageNumber + 1) : null} >
|
|
|
+ <Button
|
|
|
+ className="btnmain"
|
|
|
+ style={{ margin: 2 }}
|
|
|
+ variant="contained"
|
|
|
+ onClick={() => pageNumber + 1 <= numPages ? setPageNumber(pageNumber + 1) : null} >
|
|
|
Siguiente
|
|
|
</Button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div>
|
|
|
+ <b style={{marginRight : 15}}>
|
|
|
+ Página {pageNumber} de {numPages}
|
|
|
+ </b>
|
|
|
|
|
|
- <p>
|
|
|
- Página {pageNumber} de {numPages}
|
|
|
- </p>
|
|
|
+ <Button
|
|
|
+ className="btnmain"
|
|
|
+ variant="contained"
|
|
|
+ onClick={() => console.log('download')} >
|
|
|
+ <DownloadIcon/>
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
- <div className="Example__container__document">
|
|
|
- <Document renderMode="canvas" file={pdf.data} onLoadSuccess={onDocumentLoadSuccess} onLoadError={onLoadError}>
|
|
|
- <Page width={800} pageNumber={pageNumber} loading={<Cargando />} />
|
|
|
- </Document>
|
|
|
+ <div className="Example__container">
|
|
|
+ <div className="Example__container__document">
|
|
|
+ <Document
|
|
|
+ renderMode="canvas"
|
|
|
+ file={pdf?.data}
|
|
|
+ onLoadSuccess={onDocumentLoadSuccess}
|
|
|
+ loading={Loading}
|
|
|
+ onLoadProgress={({loaded, total}) => {
|
|
|
+ setProgress((loaded / total) * 100)
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <Page loading={Loading} pageNumber={pageNumber} />
|
|
|
+ </Document>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
)
|
|
|
@@ -76,14 +136,10 @@ export function Resultados() {
|
|
|
<div className="content-section">
|
|
|
<div className="main">
|
|
|
<Box sx={{ width: '100%' }}>
|
|
|
- <Paper elevation={0} sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh', boxShadow: 'none !important' }}>
|
|
|
- <h1>Resultados {id}</h1>
|
|
|
- <hr />
|
|
|
- {
|
|
|
- pdf ?
|
|
|
- <MyDocument pdf={pdf} />
|
|
|
- : <div> <h5> loading...</h5></div>
|
|
|
- }
|
|
|
+ <Paper
|
|
|
+ elevation={2}
|
|
|
+ sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh', boxShadow: 'none !important' }}>
|
|
|
+ <MyDocument pdf={pdf} />
|
|
|
</Paper>
|
|
|
</Box>
|
|
|
</div>
|