Browse Source

modal report fix

amenpunk 1 year ago
parent
commit
7cc0737617

+ 3 - 2
src/Components/Resultados/Config.jsx

153
   },
153
   },
154
 }
154
 }
155
 
155
 
156
-export const BuildColumns = (columns) => {
156
+export const BuildColumns = (columns, setId) => {
157
+  console.log("BUILD:", setId)
157
   return columns.map((column) => {
158
   return columns.map((column) => {
158
     return {
159
     return {
159
       'id' : column.id,
160
       'id' : column.id,
160
       'pwd' : atob( column.pwd ),
161
       'pwd' : atob( column.pwd ),
161
-      'users' : <DenseTable users={column.candidatospwds}/>,
162
+      'users' : <DenseTable users={column.candidatospwds} setId={(id) => setId(id)} />,
162
     }
163
     }
163
   })
164
   })
164
 
165
 

+ 5 - 3
src/Components/Resultados/TestDataTable.jsx

6
 import { Service } from '../../Utils/HTTP'
6
 import { Service } from '../../Utils/HTTP'
7
 import MUIDataTable from "mui-datatables";
7
 import MUIDataTable from "mui-datatables";
8
 
8
 
9
-export const TestDataTable = () => {
9
+export const TestDataTable = (props) => {
10
   
10
   
11
+  let { setId } = props; 
11
   const auth = useSelector((state) => state.token)
12
   const auth = useSelector((state) => state.token)
12
 
13
 
13
   const options = {
14
   const options = {
16
     // textLabels: TextLabels,
17
     // textLabels: TextLabels,
17
     onRowClick: (test) => {
18
     onRowClick: (test) => {
18
       //TODO: render exam
19
       //TODO: render exam
19
-      console.log(test)
20
+      // console.log(test)
21
+      setId(test[0])
20
     },
22
     },
21
     elevation: 9,
23
     elevation: 9,
22
     download : false,
24
     download : false,
35
       <MUIDataTable
37
       <MUIDataTable
36
         sx={{ '& MuiPaper': { elevation: 0, boxShadow: 'none', color: "red" } }}
38
         sx={{ '& MuiPaper': { elevation: 0, boxShadow: 'none', color: "red" } }}
37
         title={"Expedientes"}
39
         title={"Expedientes"}
38
-        data={BuildColumns( status === 'success' ? data.data : [])}
40
+        data={BuildColumns( status === 'success' ? data.data : [], setId )}
39
         columns={Encabezados}
41
         columns={Encabezados}
40
         options={options}
42
         options={options}
41
       />
43
       />

+ 53 - 42
src/Pages/Resultados.jsx

12
 // import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
12
 // import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
13
 //
13
 //
14
 //
14
 //
15
-import { 
16
-  Button, Box, Paper,LinearProgress,
17
-  Typography
15
+import {
16
+  Button, Box, Paper, LinearProgress,
17
+  Typography, Dialog, DialogContent, DialogTitle
18
 } from '@mui/material'
18
 } from '@mui/material'
19
 
19
 
20
 function LinearProgressWithLabel(props) {
20
 function LinearProgressWithLabel(props) {
61
   return (
61
   return (
62
     <div>
62
     <div>
63
 
63
 
64
-        {
65
-          progress < 100 ?
66
-          <LinearProgressWithLabel value={progress}/>
67
-            : null
68
-        }
64
+      {
65
+        progress < 100 ?
66
+          <LinearProgressWithLabel value={progress} />
67
+          : null
68
+      }
69
 
69
 
70
       <div className="pdf_controls">
70
       <div className="pdf_controls">
71
 
71
 
72
 
72
 
73
-      <div className="btn_pdfcontrol">
74
-        <Button 
73
+        <div className="btn_pdfcontrol">
74
+          <Button
75
             className="btnmain"
75
             className="btnmain"
76
-            style={{ margin: 2 }} 
77
-            variant="contained" 
76
+            style={{ margin: 2 }}
77
+            variant="contained"
78
             onClick={() => pageNumber > 1 ? setPageNumber(pageNumber - 1) : null} >
78
             onClick={() => pageNumber > 1 ? setPageNumber(pageNumber - 1) : null} >
79
-          Anterior
80
-        </Button>
81
-        <Button 
79
+            Anterior
80
+          </Button>
81
+          <Button
82
             className="btnmain"
82
             className="btnmain"
83
-            style={{ margin: 2 }} 
84
-            variant="contained" 
85
-            onClick={() => pageNumber + 1 <= numPages   ? setPageNumber(pageNumber + 1) : null} >
86
-          Siguiente
87
-        </Button>
88
-      </div>
83
+            style={{ margin: 2 }}
84
+            variant="contained"
85
+            onClick={() => pageNumber + 1 <= numPages ? setPageNumber(pageNumber + 1) : null} >
86
+            Siguiente
87
+          </Button>
88
+        </div>
89
 
89
 
90
         <div>
90
         <div>
91
-          <b style={{marginRight : 15}}>
91
+          <b style={{ marginRight: 15 }}>
92
             Página {pageNumber} de {numPages}
92
             Página {pageNumber} de {numPages}
93
           </b>
93
           </b>
94
 
94
 
95
-          <Button 
95
+          <Button
96
             className="btnmain"
96
             className="btnmain"
97
-            variant="contained" 
97
+            variant="contained"
98
             onClick={Download} >
98
             onClick={Download} >
99
-            <DownloadIcon/>
99
+            <DownloadIcon />
100
           </Button>
100
           </Button>
101
         </div>
101
         </div>
102
 
102
 
104
 
104
 
105
       <div className="Example__container">
105
       <div className="Example__container">
106
         <div className="Example__container__document">
106
         <div className="Example__container__document">
107
-          { pdf ?
108
-            (<Document 
109
-              renderMode="canvas" 
110
-              file={pdf?.data} 
111
-              onLoadSuccess={onDocumentLoadSuccess} 
107
+          {pdf ?
108
+            (<Document
109
+              renderMode="canvas"
110
+              file={pdf?.data}
111
+              onLoadSuccess={onDocumentLoadSuccess}
112
               loading={Loading}
112
               loading={Loading}
113
-              onLoadProgress={({loaded, total}) => {
113
+              onLoadProgress={({ loaded, total }) => {
114
                 setProgress((loaded / total) * 100)
114
                 setProgress((loaded / total) * 100)
115
               }}
115
               }}
116
             >
116
             >
129
   let { id } = useParams();
129
   let { id } = useParams();
130
   let auth = useSelector((state) => state.token)
130
   let auth = useSelector((state) => state.token)
131
   let [pdf, setPdf] = useState(null);
131
   let [pdf, setPdf] = useState(null);
132
+  let [idResult, setIDResult] = useState(id);
132
 
133
 
133
   useEffect(() => {
134
   useEffect(() => {
135
+    console.log("ID:", idResult)
134
 
136
 
135
-    if(!id) {
137
+    if (!idResult) {
136
       console.log('no hay id')
138
       console.log('no hay id')
137
       return
139
       return
138
     }
140
     }
139
-    let url = `/report/cleaverResult/${id}?output=pdf`
141
+    let url = `/report/cleaverResult/${idResult}?output=pdf`
140
     let rest = new Service(url);
142
     let rest = new Service(url);
141
 
143
 
142
     pdfjs.GlobalWorkerOptions.workerSrc = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;
144
     pdfjs.GlobalWorkerOptions.workerSrc = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;
146
       .then(blob => setPdf(blob))
148
       .then(blob => setPdf(blob))
147
       .catch(error => console.log({ error }))
149
       .catch(error => console.log({ error }))
148
 
150
 
149
-  }, [auth, id])
151
+  }, [auth, idResult])
150
 
152
 
151
   return (
153
   return (
152
     <div className="content-section">
154
     <div className="content-section">
153
       <div className="main">
155
       <div className="main">
154
         <Box sx={{ width: '100%' }}>
156
         <Box sx={{ width: '100%' }}>
155
-          <Paper 
156
-            elevation={2} 
157
+          <Paper
158
+            elevation={2}
157
             sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh', boxShadow: 'none !important' }}>
159
             sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh', boxShadow: 'none !important' }}>
158
-            <h1>Reporte de Resultados</h1><hr/>
159
-            <TestDataTable/>
160
-            {
161
-              pdf ? 
162
-                ( <MyDocument token={auth.token} id={id} pdf={pdf} />) : null
163
-            }
160
+            <h1>Reporte de Resultados</h1><hr />
161
+            <TestDataTable setId={setIDResult} />
164
           </Paper>
162
           </Paper>
165
         </Box>
163
         </Box>
166
       </div>
164
       </div>
165
+
166
+      <Dialog open={pdf !== null} fullWidth maxWidth="lg" onHide={() => setPdf(null)}>
167
+        <DialogTitle>Reporte de Resultados
168
+          <button type="button" className="close" onClick={() => setPdf(null)}>&times;</button>
169
+        </DialogTitle>
170
+        <DialogContent>
171
+          {
172
+            pdf ?
173
+              (<MyDocument token={auth.token} id={id} pdf={pdf} />) : null
174
+          }
175
+        </DialogContent>
176
+      </Dialog>
177
+
167
     </div>
178
     </div>
168
   )
179
   )
169
 }
180
 }

+ 16 - 10
src/temp.js

7
 import TableRow from '@mui/material/TableRow';
7
 import TableRow from '@mui/material/TableRow';
8
 import Paper from '@mui/material/Paper';
8
 import Paper from '@mui/material/Paper';
9
 import { } from '@mui/material'
9
 import { } from '@mui/material'
10
-import { useNavigate } from 'react-router-dom'
10
+// import { useNavigate } from 'react-router-dom'
11
 import { useSelector } from 'react-redux';
11
 import { useSelector } from 'react-redux';
12
 import { Service } from './Utils/HTTP';
12
 import { Service } from './Utils/HTTP';
13
 
13
 
27
 
27
 
28
 function IconStatus(props) {
28
 function IconStatus(props) {
29
 
29
 
30
-  let navigate = useNavigate()
30
+  let { pwd, setId } = props
31
+  // let navigate = useNavigate()
32
+  // console.log('MPROP',props)
31
   let auth = useSelector((state) => state.token)
33
   let auth = useSelector((state) => state.token)
32
 
34
 
33
   const calificar = () => {
35
   const calificar = () => {
36
     rest
38
     rest
37
       .getQuery(auth.token)
39
       .getQuery(auth.token)
38
       .then(r => {
40
       .then(r => {
39
-        navigate('/dashboard/resultados/' + props.pwd)
41
+        console.log("SENDING ID:", pwd)
42
+        setId(pwd)()
43
+        // console.log('RESULTADO:',r)
44
+        // navigate('/dashboard/resultados/' + props.pwd)
40
       })
45
       })
41
       .catch(e => {
46
       .catch(e => {
42
         // navigate('/dashboard/resultados/' + props.pwd)
47
         // navigate('/dashboard/resultados/' + props.pwd)
64
 
69
 
65
 
70
 
66
 
71
 
67
-function getOperation(estado, SuperPWD) {
72
+function getOperation(estado, SuperPWD,setId) {
68
   // Patrik: 100 -> Significa que el examen esta completo
73
   // Patrik: 100 -> Significa que el examen esta completo
69
   // Patrik: 99 -> Que el candidato lo esta haciendo (como "doing test" del otro servicio)
74
   // Patrik: 99 -> Que el candidato lo esta haciendo (como "doing test" del otro servicio)
70
   // Patrik: 97 ->  Que hay un error y que hay mas respuestas de las que deberian
75
   // Patrik: 97 ->  Que hay un error y que hay mas respuestas de las que deberian
77
     case 99: // el candidato se encuentra realizndolo
82
     case 99: // el candidato se encuentra realizndolo
78
       return <IconStatus color="#f5f511" icon={AssignmentTurnedInIcon} message="El candidato se encuentra realizando la prueba" />
83
       return <IconStatus color="#f5f511" icon={AssignmentTurnedInIcon} message="El candidato se encuentra realizando la prueba" />
79
     case 100: // finalizado
84
     case 100: // finalizado
80
-      return <IconStatus color="#0bd641" estado={100} icon={CheckBoxIcon} message="Calificar el examen" pwd={SuperPWD} />
85
+      return <IconStatus setId={setId} color="#0bd641" estado={100} icon={CheckBoxIcon} message="Calificar el examen" pwd={SuperPWD} />
81
     default: return null
86
     default: return null
82
   }
87
   }
83
 }
88
 }
85
 
90
 
86
 function Asignaciones(props) {
91
 function Asignaciones(props) {
87
 
92
 
88
-  let { estado, cattest, id: SuperPWD } = props.asign;
93
+  let { asign, setId } = props;
94
+  let { estado, cattest, id: SuperPWD } = asign;
89
 
95
 
90
   return (
96
   return (
91
     <tr>
97
     <tr>
106
             ) : null
112
             ) : null
107
       */}
113
       */}
108
         {
114
         {
109
-          getOperation(estado, SuperPWD)
115
+          getOperation(estado, SuperPWD, setId)
110
         }
116
         }
111
       </td>
117
       </td>
112
     </tr>
118
     </tr>
117
 
123
 
118
 
124
 
119
 export function DenseTable(props) {
125
 export function DenseTable(props) {
120
-  let { users} = props
121
-  console.log("users", users)
126
+  let { users,setId } = props
127
+  // console.log("users", users)
122
   return (
128
   return (
123
     <TableContainer component={Paper}>
129
     <TableContainer component={Paper}>
124
       <Table sx={{ minWidth: 650 }} size="small" aria-label="a dense table">
130
       <Table sx={{ minWidth: 650 }} size="small" aria-label="a dense table">
138
                 {row.candi.nombre  + " " + row.candi.apellidos}
144
                 {row.candi.nombre  + " " + row.candi.apellidos}
139
               </TableCell>
145
               </TableCell>
140
               <TableCell align="left">
146
               <TableCell align="left">
141
-                {row.asignaciones.map(a => <Asignaciones key={a.id} asign={a}/>)}
147
+                {row.asignaciones.map(a => <Asignaciones setId={setId} key={a.id} asign={a}/>)}
142
               </TableCell>
148
               </TableCell>
143
             </TableRow>
149
             </TableRow>
144
           ))}
150
           ))}