|
@@ -2,15 +2,33 @@ import { useEffect, useState } from 'react';
|
2
|
2
|
import { useParams } from 'react-router-dom'
|
3
|
3
|
import { Service } from '../Utils/HTTP';
|
4
|
4
|
import { useSelector } from 'react-redux';
|
5
|
|
-import { Button, Box, Paper } from '@mui/material'
|
6
|
5
|
import { Document, Page, pdfjs } from 'react-pdf/dist/esm/entry.webpack';
|
7
|
|
-// import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
|
|
6
|
+import { Loading } from '../Components/Generics/loading'
|
|
7
|
+import DownloadIcon from '@mui/icons-material/Download';
|
8
|
8
|
import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
|
9
|
9
|
import 'react-pdf/dist/esm/Page/TextLayer.css';
|
|
10
|
+import '../pdf.css'
|
|
11
|
+// import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
|
|
12
|
+import {
|
|
13
|
+ Button, Box, Paper,LinearProgress,
|
|
14
|
+ Typography
|
|
15
|
+} from '@mui/material'
|
10
|
16
|
|
11
|
|
-const Cargando = () => <div><h2>loading...</h2></div>
|
|
17
|
+function LinearProgressWithLabel(props) {
|
|
18
|
+ return (
|
|
19
|
+ <Box sx={{ display: 'flex', alignItems: 'center' }}>
|
|
20
|
+ <Box sx={{ width: '100%', mr: 1 }}>
|
|
21
|
+ <LinearProgress variant="determinate" {...props} />
|
|
22
|
+ </Box>
|
|
23
|
+ <Box sx={{ minWidth: 35 }}>
|
|
24
|
+ <Typography variant="body2" color="text.secondary">{`${Math.round(
|
|
25
|
+ props.value,
|
|
26
|
+ )}%`}</Typography>
|
|
27
|
+ </Box>
|
|
28
|
+ </Box>
|
|
29
|
+ );
|
|
30
|
+}
|
12
|
31
|
|
13
|
|
-// Create Document Component
|
14
|
32
|
const MyDocument = (props) => {
|
15
|
33
|
|
16
|
34
|
let { pdf } = props;
|
|
@@ -22,30 +40,72 @@ const MyDocument = (props) => {
|
22
|
40
|
setNumPages(numPages);
|
23
|
41
|
}
|
24
|
42
|
|
25
|
|
- function onLoadError(error) {
|
26
|
|
- console.log('error: ', error)
|
|
43
|
+ const [progress, setProgress] = useState(10);
|
|
44
|
+
|
|
45
|
+ if(!pdf){
|
|
46
|
+ <Loading/>
|
27
|
47
|
}
|
28
|
48
|
|
|
49
|
+ console.log(progress)
|
|
50
|
+
|
29
|
51
|
return (
|
30
|
52
|
<div>
|
|
53
|
+
|
|
54
|
+ {
|
|
55
|
+ progress < 100 ?
|
|
56
|
+ <LinearProgressWithLabel value={progress}/>
|
|
57
|
+ : null
|
|
58
|
+ }
|
|
59
|
+
|
31
|
60
|
<div className="pdf_controls">
|
32
|
|
- <Button variant="contained" onClick={() => pageNumber > 1 ? setPageNumber(pageNumber - 1) : null} >
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+ <div className="btn_pdfcontrol">
|
|
64
|
+ <Button
|
|
65
|
+ className="btnmain"
|
|
66
|
+ style={{ margin: 2 }}
|
|
67
|
+ variant="contained"
|
|
68
|
+ onClick={() => pageNumber > 1 ? setPageNumber(pageNumber - 1) : null} >
|
33
|
69
|
Anterior
|
34
|
70
|
</Button>
|
35
|
|
- <Button style={{ margin: 5 }} variant="contained" onClick={() => pageNumber + 1 <= numPages ? setPageNumber(pageNumber + 1) : null} >
|
|
71
|
+ <Button
|
|
72
|
+ className="btnmain"
|
|
73
|
+ style={{ margin: 2 }}
|
|
74
|
+ variant="contained"
|
|
75
|
+ onClick={() => pageNumber + 1 <= numPages ? setPageNumber(pageNumber + 1) : null} >
|
36
|
76
|
Siguiente
|
37
|
77
|
</Button>
|
|
78
|
+ </div>
|
|
79
|
+
|
|
80
|
+ <div>
|
|
81
|
+ <b style={{marginRight : 15}}>
|
|
82
|
+ Página {pageNumber} de {numPages}
|
|
83
|
+ </b>
|
38
|
84
|
|
39
|
|
- <p>
|
40
|
|
- Página {pageNumber} de {numPages}
|
41
|
|
- </p>
|
|
85
|
+ <Button
|
|
86
|
+ className="btnmain"
|
|
87
|
+ variant="contained"
|
|
88
|
+ onClick={() => console.log('download')} >
|
|
89
|
+ <DownloadIcon/>
|
|
90
|
+ </Button>
|
|
91
|
+ </div>
|
42
|
92
|
|
43
|
93
|
</div>
|
44
|
94
|
|
45
|
|
- <div className="Example__container__document">
|
46
|
|
- <Document renderMode="canvas" file={pdf.data} onLoadSuccess={onDocumentLoadSuccess} onLoadError={onLoadError}>
|
47
|
|
- <Page width={800} pageNumber={pageNumber} loading={<Cargando />} />
|
48
|
|
- </Document>
|
|
95
|
+ <div className="Example__container">
|
|
96
|
+ <div className="Example__container__document">
|
|
97
|
+ <Document
|
|
98
|
+ renderMode="canvas"
|
|
99
|
+ file={pdf?.data}
|
|
100
|
+ onLoadSuccess={onDocumentLoadSuccess}
|
|
101
|
+ loading={Loading}
|
|
102
|
+ onLoadProgress={({loaded, total}) => {
|
|
103
|
+ setProgress((loaded / total) * 100)
|
|
104
|
+ }}
|
|
105
|
+ >
|
|
106
|
+ <Page loading={Loading} pageNumber={pageNumber} />
|
|
107
|
+ </Document>
|
|
108
|
+ </div>
|
49
|
109
|
</div>
|
50
|
110
|
</div>
|
51
|
111
|
)
|
|
@@ -76,14 +136,10 @@ export function Resultados() {
|
76
|
136
|
<div className="content-section">
|
77
|
137
|
<div className="main">
|
78
|
138
|
<Box sx={{ width: '100%' }}>
|
79
|
|
- <Paper elevation={0} sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh', boxShadow: 'none !important' }}>
|
80
|
|
- <h1>Resultados {id}</h1>
|
81
|
|
- <hr />
|
82
|
|
- {
|
83
|
|
- pdf ?
|
84
|
|
- <MyDocument pdf={pdf} />
|
85
|
|
- : <div> <h5> loading...</h5></div>
|
86
|
|
- }
|
|
139
|
+ <Paper
|
|
140
|
+ elevation={2}
|
|
141
|
+ sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh', boxShadow: 'none !important' }}>
|
|
142
|
+ <MyDocument pdf={pdf} />
|
87
|
143
|
</Paper>
|
88
|
144
|
</Box>
|
89
|
145
|
</div>
|