|
@@ -2,7 +2,7 @@ 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 } from '@mui/material'
|
|
5
|
+import { Button, Box, Paper } from '@mui/material'
|
6
|
6
|
import { Document, Page, pdfjs } from 'react-pdf/dist/esm/entry.webpack';
|
7
|
7
|
// import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
|
8
|
8
|
import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
|
|
@@ -18,27 +18,35 @@ const MyDocument = (props) => {
|
18
|
18
|
const [pageNumber, setPageNumber] = useState(1);
|
19
|
19
|
|
20
|
20
|
function onDocumentLoadSuccess({ numPages }) {
|
21
|
|
- console.log('numero de pagians',numPages)
|
|
21
|
+ console.log('numero de pagians', numPages)
|
22
|
22
|
setNumPages(numPages);
|
23
|
23
|
}
|
24
|
24
|
|
25
|
|
- function onLoadError(error){
|
|
25
|
+ function onLoadError(error) {
|
26
|
26
|
console.log('error: ', error)
|
27
|
27
|
}
|
28
|
28
|
|
29
|
29
|
return (
|
30
|
30
|
<div>
|
31
|
|
- <div>
|
32
|
|
- <Button onClick={() =>setPageNumber(pageNumber + 1)} >
|
|
31
|
+ <div className="pdf_controls">
|
|
32
|
+ <Button variant="contained" onClick={() => pageNumber > 1 ? setPageNumber(pageNumber - 1) : null} >
|
|
33
|
+ Anterior
|
|
34
|
+ </Button>
|
|
35
|
+ <Button style={{ margin: 5 }} variant="contained" onClick={() => pageNumber + 1 <= numPages ? setPageNumber(pageNumber + 1) : null} >
|
33
|
36
|
Siguiente
|
34
|
37
|
</Button>
|
|
38
|
+
|
|
39
|
+ <p>
|
|
40
|
+ Página {pageNumber} de {numPages}
|
|
41
|
+ </p>
|
|
42
|
+
|
|
43
|
+ </div>
|
|
44
|
+
|
|
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>
|
35
|
49
|
</div>
|
36
|
|
- <Document renderMode="canvas" file={pdf.data} onLoadSuccess={onDocumentLoadSuccess} onLoadError={onLoadError}>
|
37
|
|
- <Page pageNumber={pageNumber} loading={<Cargando/>} />
|
38
|
|
- </Document>
|
39
|
|
- <p>
|
40
|
|
- Page {pageNumber} of {numPages}
|
41
|
|
- </p>
|
42
|
50
|
</div>
|
43
|
51
|
)
|
44
|
52
|
};
|
|
@@ -55,7 +63,7 @@ export function Resultados() {
|
55
|
63
|
let url = `/report/cleaverResult/${id}?output=pdf`
|
56
|
64
|
let rest = new Service(url);
|
57
|
65
|
|
58
|
|
- pdfjs.GlobalWorkerOptions.workerSrc = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;
|
|
66
|
+ pdfjs.GlobalWorkerOptions.workerSrc = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;
|
59
|
67
|
|
60
|
68
|
rest
|
61
|
69
|
.getBlob(auth.token)
|
|
@@ -67,13 +75,17 @@ export function Resultados() {
|
67
|
75
|
return (
|
68
|
76
|
<div className="content-section">
|
69
|
77
|
<div className="main">
|
70
|
|
- <h1>Resultados {id}</h1>
|
71
|
|
- <hr />
|
72
|
|
- {
|
73
|
|
- pdf ?
|
74
|
|
- <MyDocument pdf={pdf} />
|
75
|
|
- : <div> <h5> loading...</h5></div>
|
76
|
|
- }
|
|
78
|
+ <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
|
+ }
|
|
87
|
+ </Paper>
|
|
88
|
+ </Box>
|
77
|
89
|
</div>
|
78
|
90
|
</div>
|
79
|
91
|
)
|