소스 검색

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

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

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

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

@@ -2,12 +2,15 @@ import React, { memo } from 'react';
2 2
 import { Modal, Col, Row } from 'react-bootstrap'
3 3
 import QA from '../../Images/puesto.jpg'
4 4
 
5
+import { Divider, Chip } from '@mui/material'
6
+
5 7
 function Mostrar(props) {
6 8
 
7 9
     let { visible, puesto } = props
8 10
     const opciones = { weekday: 'long', year: 'numeric', month: 'short', day: 'numeric' };
9 11
     const close = () => props.toggle("VER");
10 12
 
13
+
11 14
     return (
12 15
         <Modal size="lg" aria-labelledby="contained-modal-title-vcenter" centered show={visible} onHide={close}>
13 16
             <Modal.Header>
@@ -31,6 +34,15 @@ function Mostrar(props) {
31 34
                                 type="text"
32 35
                                 placeholder="...."
33 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 46
                         </Col>
35 47
                     </Row>
36 48
                 </div>