浏览代码

update test on modal

amenpunk 2 年之前
父节点
当前提交
1f11f5c86b
共有 3 个文件被更改,包括 24 次插入14 次删除
  1. 10 12
      src/Components/Modal/EditPlaza.js
  2. 2 2
      src/Components/Modal/EliminarPlaza.js
  3. 12 0
      src/Components/Modal/MostrarPlaza.js

+ 10 - 12
src/Components/Modal/EditPlaza.js

28
     aredepto: Yup.number().required('Escoge alguna área'),
28
     aredepto: Yup.number().required('Escoge alguna área'),
29
     fecha: Yup.date("Ingresa una fecha válida"),
29
     fecha: Yup.date("Ingresa una fecha válida"),
30
     notas: Yup.string("Ingresa una nota válida").min(5).max(150),
30
     notas: Yup.string("Ingresa una nota válida").min(5).max(150),
31
-    pruebas: Yup.array()
31
+    tests: Yup.array()
32
 })
32
 })
33
 
33
 
34
 
34
 
53
     const [checklist, setChecklist] = React.useState([]);
53
     const [checklist, setChecklist] = React.useState([]);
54
 
54
 
55
     const addPrueba = (check,id) => {
55
     const addPrueba = (check,id) => {
56
-        let { pruebas } = values
57
-        console.log(pruebas)
56
+        let { tests } = values
58
         let temp ;
57
         let temp ;
59
         if(check){
58
         if(check){
60
-            temp = [...pruebas, {id}]
59
+            temp = [...tests, {id}]
61
         }else{
60
         }else{
62
-            temp = pruebas.filter( test => test.id !== id);
61
+            temp = tests.filter( test => test.id !== id);
63
         }
62
         }
64
         setChecklist(temp.map( test => test.id) )
63
         setChecklist(temp.map( test => test.id) )
65
-        setValues({...values, pruebas: temp})
64
+        setValues({...values, tests: temp})
66
     };
65
     };
67
 
66
 
68
     const getCategories = async () => {
67
     const getCategories = async () => {
85
     const close = () => toggle("EDIT");
84
     const close = () => toggle("EDIT");
86
 
85
 
87
     const { data } = useQuery('categories', getCategories);
86
     const { data } = useQuery('categories', getCategories);
88
-    const { data: tests } = useQuery('tests', getTest);
87
+    const { data: testsCatalog } = useQuery('tests', getTest);
89
 
88
 
90
     const formik = useFormik({
89
     const formik = useFormik({
91
         initialValues: {
90
         initialValues: {
95
             aredepto: 1,
94
             aredepto: 1,
96
             fecha: now,
95
             fecha: now,
97
             notas: "",
96
             notas: "",
98
-            pruebas : []
97
+            tests : []
99
         },
98
         },
100
         onSubmit: (fields, { resetForm }) => {
99
         onSubmit: (fields, { resetForm }) => {
101
             setOpen(true);
100
             setOpen(true);
123
     const { errors, touched, handleSubmit, getFieldProps, setValues, values } = formik;
122
     const { errors, touched, handleSubmit, getFieldProps, setValues, values } = formik;
124
 
123
 
125
     useEffect(() => {
124
     useEffect(() => {
126
-        console.log("PUESTO :: ", puesto)
127
         if (puesto) {
125
         if (puesto) {
128
             setValues({
126
             setValues({
129
                 id: puesto.id,
127
                 id: puesto.id,
132
                 aredepto: puesto.areadeptoplz_id,
130
                 aredepto: puesto.areadeptoplz_id,
133
                 fecha: new Date(puesto.create_day),
131
                 fecha: new Date(puesto.create_day),
134
                 notas: puesto.notas,
132
                 notas: puesto.notas,
135
-                pruebas : puesto.tests
133
+                tests : puesto.tests
136
             })
134
             })
137
             setChecklist(puesto.tests.map(( {id} ) => id))
135
             setChecklist(puesto.tests.map(( {id} ) => id))
138
         }
136
         }
168
                                     <Divider/>
166
                                     <Divider/>
169
                                     <FormGroup>
167
                                     <FormGroup>
170
                                         {
168
                                         {
171
-                                            tests ?
172
-                                            tests.data.map( test => (
169
+                                            testsCatalog ?
170
+                                            testsCatalog.data.map( test => (
173
                                                 <FormControlLabel 
171
                                                 <FormControlLabel 
174
                                                     key={test.id}
172
                                                     key={test.id}
175
                                                     control={
173
                                                     control={

+ 2 - 2
src/Components/Modal/EliminarPlaza.js

16
                 <h1 className="alert">¿Estás seguro que deseas eliminar esta plaza?</h1>
16
                 <h1 className="alert">¿Estás seguro que deseas eliminar esta plaza?</h1>
17
                 <p className="text-alert">Una vez eliminado no será posible recuperarla</p>
17
                 <p className="text-alert">Una vez eliminado no será posible recuperarla</p>
18
                 <Row>
18
                 <Row>
19
-                    <Col md="6">
19
+                    <Col md="6" sm="6" xs="6">
20
                         <div className="cancel_producto_confirm">
20
                         <div className="cancel_producto_confirm">
21
                             <div className="btn_cancelar">
21
                             <div className="btn_cancelar">
22
                                 <a href="/" type="submit">Cancelar</a>
22
                                 <a href="/" type="submit">Cancelar</a>
23
                             </div>
23
                             </div>
24
                         </div>
24
                         </div>
25
                     </Col>
25
                     </Col>
26
-                    <Col md="6">
26
+                    <Col md="6" sm="6" xs="6">
27
                         <div className="delet_producto_confirm">
27
                         <div className="delet_producto_confirm">
28
                             <div className="btn_delete_producto_confirm">
28
                             <div className="btn_delete_producto_confirm">
29
                                 <a  href="/" onClick={() => console.log('ID >> ',puesto.id)} type="submit">Eliminar</a>
29
                                 <a  href="/" onClick={() => console.log('ID >> ',puesto.id)} type="submit">Eliminar</a>

+ 12 - 0
src/Components/Modal/MostrarPlaza.js

2
 import { Modal, Col, Row } from 'react-bootstrap'
2
 import { Modal, Col, Row } from 'react-bootstrap'
3
 import QA from '../../Images/puesto.jpg'
3
 import QA from '../../Images/puesto.jpg'
4
 
4
 
5
+import { Divider, Chip } from '@mui/material'
6
+
5
 function Mostrar(props) {
7
 function Mostrar(props) {
6
 
8
 
7
     let { visible, puesto } = props
9
     let { visible, puesto } = props
8
     const opciones = { weekday: 'long', year: 'numeric', month: 'short', day: 'numeric' };
10
     const opciones = { weekday: 'long', year: 'numeric', month: 'short', day: 'numeric' };
9
     const close = () => props.toggle("VER");
11
     const close = () => props.toggle("VER");
10
 
12
 
13
+
11
     return (
14
     return (
12
         <Modal size="lg" aria-labelledby="contained-modal-title-vcenter" centered show={visible} onHide={close}>
15
         <Modal size="lg" aria-labelledby="contained-modal-title-vcenter" centered show={visible} onHide={close}>
13
             <Modal.Header>
16
             <Modal.Header>
31
                                 type="text"
34
                                 type="text"
32
                                 placeholder="...."
35
                                 placeholder="...."
33
                                 name="sku" readOnly />
36
                                 name="sku" readOnly />
37
+                            <div>
38
+                                {
39
+                                    puesto
40
+                                    ? puesto.tests.map( ( {decription, id} ) => 
41
+                                        (<Chip color="primary" key={id} label={decription}/>)
42
+                                    ) : null
43
+                                }
44
+                            </div>
45
+                            <Divider/>
34
                         </Col>
46
                         </Col>
35
                     </Row>
47
                     </Row>
36
                 </div>
48
                 </div>