|
@@ -8,6 +8,7 @@ import { Cleaver } from './Pruebas/Cleaver';
|
8
|
8
|
import { Header } from '../Components/Test/Cleaver/Header';
|
9
|
9
|
import { useSelector, useDispatch } from 'react-redux';
|
10
|
10
|
import { setRole } from '../Slices/userSlice'
|
|
11
|
+import { Loading } from '../Components/Generics/loading';
|
11
|
12
|
|
12
|
13
|
export function Prueba() {
|
13
|
14
|
|
|
@@ -15,7 +16,9 @@ export function Prueba() {
|
15
|
16
|
let auth = useSelector((state) => state.token.token)
|
16
|
17
|
let profile = useSelector((state) => state.user)
|
17
|
18
|
let dispatch = useDispatch();
|
|
19
|
+
|
18
|
20
|
let [data, setData] = useState({});
|
|
21
|
+ let [asignacion, setAsignacion] = useState(null);
|
19
|
22
|
|
20
|
23
|
useState(() => {
|
21
|
24
|
let rest = new Service(`/prueba/findid/${id}`)
|
|
@@ -24,6 +27,19 @@ export function Prueba() {
|
24
|
27
|
setData(resp.data)
|
25
|
28
|
})
|
26
|
29
|
.catch(_e => setData({}))
|
|
30
|
+
|
|
31
|
+ let status_asign_url = `/prueba/estatus/${profile.profile.pass}/${profile.profile.email}/${id}`
|
|
32
|
+ rest = new Service(status_asign_url)
|
|
33
|
+
|
|
34
|
+ rest.getQuery(auth.token)
|
|
35
|
+ .then(resp => {
|
|
36
|
+ setAsignacion(resp.data)
|
|
37
|
+ })
|
|
38
|
+ .catch(error => {
|
|
39
|
+ console.log('error: ', error)
|
|
40
|
+ })
|
|
41
|
+
|
|
42
|
+
|
27
|
43
|
}, [id])
|
28
|
44
|
|
29
|
45
|
let now = new Date().toISOString();
|
|
@@ -44,12 +60,16 @@ export function Prueba() {
|
44
|
60
|
}
|
45
|
61
|
|
46
|
62
|
const CreateAssign = () => {
|
47
|
|
-
|
48
|
|
-
|
49
|
63
|
let rest = new Service("/prueba/asignacion");
|
50
|
64
|
rest.postQuery(assig_data, auth.token)
|
51
|
65
|
.then(({ data: resp }) => {
|
52
|
66
|
let { id: assingid } = resp
|
|
67
|
+
|
|
68
|
+ setAsignacion({
|
|
69
|
+ ...asignacion,
|
|
70
|
+ estadoFinal:"ONLYASSIGNED_TEST"
|
|
71
|
+ })
|
|
72
|
+
|
53
|
73
|
toast.success("Asignación creada ", assingid)
|
54
|
74
|
dispatch(setRole({ assingid, current_test_id: id }))
|
55
|
75
|
})
|
|
@@ -58,9 +78,15 @@ export function Prueba() {
|
58
|
78
|
})
|
59
|
79
|
}
|
60
|
80
|
|
61
|
|
- if (profile.role.assingid) {
|
62
|
|
- //TODO:
|
63
|
|
- //case current test id to render specific examn template
|
|
81
|
+ const DOING_STATES = ['ONLYASSIGNED_TEST', 'DOING_TEST', 'FINALY_TEST']
|
|
82
|
+ const NOT_STATE = ['NOTASSIGNED_TEST']
|
|
83
|
+
|
|
84
|
+ console.log('ASIN: ', asignacion)
|
|
85
|
+ if(!asignacion){
|
|
86
|
+ return <Loading/>
|
|
87
|
+ }
|
|
88
|
+
|
|
89
|
+ if (DOING_STATES.includes(asignacion.estadoFinal)) {
|
64
|
90
|
return <Cleaver />
|
65
|
91
|
}
|
66
|
92
|
|