Browse Source

consum prueba estatus

amenpunk 2 years ago
parent
commit
3d28a6d17c
2 changed files with 32 additions and 6 deletions
  1. 1 1
      src/Pages/Logincs.jsx
  2. 31 5
      src/Pages/Prueba.jsx

+ 1 - 1
src/Pages/Logincs.jsx

84
             password,
84
             password,
85
             passid: pass_id,
85
             passid: pass_id,
86
             pass: password,
86
             pass: password,
87
-            assingid: 'ok',
87
+            assingid: 0,
88
             idsuperpwd: idSueperContrasenia
88
             idsuperpwd: idSueperContrasenia
89
           }
89
           }
90
 
90
 

+ 31 - 5
src/Pages/Prueba.jsx

8
 import { Header } from '../Components/Test/Cleaver/Header';
8
 import { Header } from '../Components/Test/Cleaver/Header';
9
 import { useSelector, useDispatch } from 'react-redux';
9
 import { useSelector, useDispatch } from 'react-redux';
10
 import { setRole } from '../Slices/userSlice'
10
 import { setRole } from '../Slices/userSlice'
11
+import { Loading } from '../Components/Generics/loading';
11
 
12
 
12
 export function Prueba() {
13
 export function Prueba() {
13
 
14
 
15
   let auth = useSelector((state) => state.token.token)
16
   let auth = useSelector((state) => state.token.token)
16
   let profile = useSelector((state) => state.user)
17
   let profile = useSelector((state) => state.user)
17
   let dispatch = useDispatch();
18
   let dispatch = useDispatch();
19
+
18
   let [data, setData] = useState({});
20
   let [data, setData] = useState({});
21
+  let [asignacion, setAsignacion] = useState(null);
19
 
22
 
20
   useState(() => {
23
   useState(() => {
21
     let rest = new Service(`/prueba/findid/${id}`)
24
     let rest = new Service(`/prueba/findid/${id}`)
24
         setData(resp.data)
27
         setData(resp.data)
25
       })
28
       })
26
       .catch(_e => setData({}))
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
   }, [id])
43
   }, [id])
28
 
44
 
29
   let now = new Date().toISOString();
45
   let now = new Date().toISOString();
44
   }
60
   }
45
 
61
 
46
   const CreateAssign = () => {
62
   const CreateAssign = () => {
47
-
48
-
49
     let rest = new Service("/prueba/asignacion");
63
     let rest = new Service("/prueba/asignacion");
50
     rest.postQuery(assig_data, auth.token)
64
     rest.postQuery(assig_data, auth.token)
51
       .then(({ data: resp }) => {
65
       .then(({ data: resp }) => {
52
         let { id: assingid } = resp
66
         let { id: assingid } = resp
67
+
68
+        setAsignacion({
69
+          ...asignacion,
70
+          estadoFinal:"ONLYASSIGNED_TEST"
71
+        })
72
+
53
         toast.success("Asignación creada ", assingid)
73
         toast.success("Asignación creada ", assingid)
54
         dispatch(setRole({ assingid, current_test_id: id }))
74
         dispatch(setRole({ assingid, current_test_id: id }))
55
       })
75
       })
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
     return <Cleaver />
90
     return <Cleaver />
65
   }
91
   }
66
 
92