浏览代码

complete circle

amenpunk 2 年之前
父节点
当前提交
bae2bacded

+ 2 - 2
src/App.css

@@ -205,7 +205,7 @@
205 205
 }
206 206
 
207 207
 #login_btn_fn:hover{
208
-    background-color: var(--second)
208
+    background-color: var(--main);
209 209
 }
210 210
 
211 211
 .btn_plaza_common{
@@ -213,7 +213,7 @@
213 213
 }
214 214
 
215 215
 .btn_plaza_common:hover{
216
-    color:var(--second) !important;
216
+    color:var(--main) !important;
217 217
 }
218 218
 .center_pagination_puestos{
219 219
     display :flex;

+ 0 - 149
src/Components/AgregarManual.js

@@ -1,149 +0,0 @@
1
-import React from 'react';
2
-import * as Yup from 'yup';
3
-import { Formik, Field, Form } from 'formik';
4
-import { Row, Col, Modal, Button} from 'react-bootstrap'
5
-
6
-import NotFound from '../../Images/not_found.png';
7
-const SUPPORTED_FORMATS = ["image/jpg", "image/jpeg", "image/gif", "image/png"];
8
-
9
-const NewPlazaSchema = Yup.object().shape({
10
-    nombre : Yup.string().required('El nombre es requerido').min(5).max(20),
11
-    description : Yup.string().required('La description es requerida').min(5).max(20),
12
-    salario : Yup.number().required('El salario es requerido'),
13
-    imagen:  Yup.mixed().required('El imagen es requerido').test('fileSize', "El archivo es demasiado grande", value => {
14
-        if(!value || value.length <= 0) return false
15
-        return value[0].size < 200000
16
-    }).test('fileType', "El tipo del archivo no es válido", value => {
17
-        if(!value) return false
18
-        return SUPPORTED_FORMATS.includes(value[0].type)
19
-    })
20
-})
21
-
22
-export default function Manual ( props ) {
23
-
24
-    let [ filename, setFilename ] = React.useState('');
25
-    let [ file, setFile ] = React.useState(undefined);
26
-    let [ type, setType ] = React.useState(undefined);
27
-    let [ validType, setValidType ] = React.useState(false);
28
-
29
-    let { visible, onClose } = props
30
-    const hiddenFileInput = React.useRef(null);
31
-
32
-    const PickFile = event => hiddenFileInput.current.click();
33
-
34
-    React.useEffect(() => {
35
-        if( SUPPORTED_FORMATS.includes(type) ){
36
-            setValidType(true)
37
-        }else{
38
-            setValidType(false)
39
-        }
40
-
41
-    }, [type])
42
-
43
-
44
-    return (
45
-        <Modal size="lg" aria-labelledby="contained-modal-title-vcenter" centered  show={visible} onHide={onClose}>
46
-            <Modal.Header>
47
-                <button onClick={onClose}  type="button" className="close" data-dismiss="modal">&times;</button>
48
-                <h4 className="modal-title">Agregar plaza</h4>
49
-            </Modal.Header>
50
-            <Modal.Body className="modal-body">
51
-
52
-                <Formik
53
-
54
-                    initialValues={{
55
-                        nombre: '',
56
-                        description: '',
57
-                        salario: '',
58
-                        imagen: '',
59
-                    }}
60
-
61
-                    validationSchema={NewPlazaSchema}
62
-                    onSubmit={ (values) => {
63
-                        // console.log('VALUES >> ',values)
64
-                        props.setManual(false)
65
-                    }} >
66
-
67
-
68
-                    { ({  errors, touched, validateField, validateForm, setFieldValue  }) => (
69
-                        <Form>
70
-                            <Row>
71
-
72
-                                <Col md="4">
73
-                                    <div className="img-container">
74
-                                        <img alt="agregar plaza manual" src={ validType ? file : NotFound}/>
75
-                                    </div>
76
-                                </Col>
77
-
78
-                                <Col md="8">
79
-
80
-                                    <input 
81
-                                        value={filename} 
82
-                                        type="text" 
83
-                                        className="file-upload-input" 
84
-                                        disabled="" 
85
-                                        placeholder="Ningún archivo seleccionado" readOnly
86
-                                    />
87
-
88
-                                    <Button className="btn_add_producto_confirm" style={{ marginLeft : 15 }} onClick={PickFile}>
89
-                                        SUBIR FOTO
90
-                                    </Button>
91
-
92
-                                    {errors.imagen && touched.imagen && <div className="error_feedback">{errors.imagen}</div>}
93
-                                    <input
94
-                                        multiple={false}
95
-                                        type="file"
96
-                                        ref={hiddenFileInput}
97
-                                        onChange={(event) => {
98
-                                            const files = event.target.files;
99
-                                            console.log('files crud ', files[0])
100
-                                            let myFiles =Array.from(files);
101
-                                            setFieldValue("imagen", myFiles);
102
-                                            setFilename(myFiles[0].name)
103
-                                            setType(myFiles[0].type)
104
-                                            const objectUrl = URL.createObjectURL(files[0])
105
-                                            setFile(objectUrl)
106
-                                        }}
107
-                                        style={{display: 'none'}}
108
-                                    />
109
-
110
-                                </Col>
111
-
112
-                            </Row>
113
-                            <div className="data_product">
114
-                                <Row>
115
-                                    <Col md="12">
116
-
117
-                                        {errors.nombre && touched.nombre && <div className="error_feedback">{errors.nombre}</div>}
118
-                                        <Field name="nombre" placeholder="Nombre de la plaza"/>
119
-
120
-                                        {errors.description && touched.description && <div className="error_feedback">{errors.description}</div>}
121
-                                        <Field name="description">
122
-                                            {({ field, form, meta }) => {
123
-                                                return(
124
-                                                    <textarea id="description" name="description" value={field.value} onChange={field.onChange} placeholder="Descripción general de la plaza"></textarea>
125
-                                                )
126
-                                            }}
127
-                                        </Field>
128
-
129
-                                        {errors.salario && touched.salario && <div className="error_feedback">{errors.salario}</div>}
130
-                                        <Field name="salario" type="number" placeholder="Salario"/>
131
-
132
-
133
-                                    </Col>
134
-                                    <div className="add_producto_confirm">
135
-                                        <button className="btn_add_producto_confirm" type="submit">Agregar plaza</button>
136
-                                    </div>
137
-                                </Row>
138
-                            </div>
139
-                        </Form>
140
-                    )}
141
-
142
-
143
-
144
-
145
-                </Formik>
146
-            </Modal.Body>
147
-        </Modal>
148
-    )
149
-}

+ 44 - 26
src/Components/Modal/AgregarManual.js

@@ -5,39 +5,48 @@ import { Modal } from 'react-bootstrap'
5 5
 
6 6
 import DateFnsUtils from '@date-io/date-fns';
7 7
 import { DesktopDatePicker,LocalizationProvider } from '@mui/lab';
8
-import {  Button, Stack, TextField, } from '@mui/material';
8
+import {  Button, Stack, TextField, MenuItem,FormControl, InputLabel, Select } from '@mui/material';
9 9
 
10 10
 import { Service } from '../../Utils/HTTP';
11 11
 import  useAuth from '../../Auth/useAuth';
12 12
 
13
+import { departamentos } from '../Password/Rows'
14
+
13 15
 
14 16
 export default function Manual ( props ) {
15 17
 
16 18
     const NewPlazaSchema = Yup.object().shape({
17
-        nombrepuesto : Yup.string().required('El nombre es requerido').min(5).max(100),
19
+        nombrepuesto : Yup.string().required('El nombre es requerido').min(5, "El nombre del  puesto debe ser mayor a 5 caracteres").max(100),
18 20
         puestosuperior : Yup.number("El puesto superior debe ser un número"),
19 21
         aredepto : Yup.number().required('Escoge alguna área'),
20 22
         fecha : Yup.date("Ingresa una fecha válida"),
21 23
         notas : Yup.string("Ingresa una nota válida").min(5).max(150),
22 24
     })
25
+    
26
+    const [departamento, setDepartamento] = React.useState('');
27
+
28
+    const changeDepartamento = (event) => {
29
+        setDepartamento(event.target.value);
30
+    };
31
+
23 32
 
24 33
     const [date, setDate] = React.useState(new Date());
25 34
     const auth = useAuth();
26 35
     const token = auth.getToken();
27 36
 
28
-    let { visible, onClose, success, error } = props
37
+    let { visible, onClose, Complete } = props
29 38
 
30 39
     const formik = useFormik({
31 40
         initialValues: {
32
-            nombrepuesto: "QA ENGINIER",
33
-            puestosuperior: 3,
41
+            nombrepuesto: "",
42
+            puestosuperior: "",
34 43
             aredepto: 1,
35 44
             fecha: date,
36
-            notas: "alguna nota ",
45
+            notas: "",
37 46
         },
38
-        onSubmit: (fields) => {
47
+        onSubmit: ( fields, { resetForm } ) => {
39 48
 
40
-            fields['fecha'] = "2023-06-11T00:22:15.211"//new Date(fields.fecha).toString() //getDate(fields.fecha);
49
+            fields['fecha'] =  new Date(fields.fecha).toISOString();
41 50
             fields['areadeptoplz_id'] = 1;
42 51
             fields['id'] = -1;
43 52
 
@@ -45,21 +54,21 @@ export default function Manual ( props ) {
45 54
 
46 55
             Rest
47 56
             .post( fields, token )
48
-            .then(data => {
57
+            .then( _ => {
58
+                resetForm();
59
+                Complete(true);
49 60
                 onClose();
50
-                success();
51
-                console.log('data ', data)
52 61
             })
53 62
             .catch(err => {
54
-                error();
55 63
                 console.error(err)
64
+                Complete(false);
56 65
             })
57 66
 
58 67
         },
59 68
         validationSchema: NewPlazaSchema,
60 69
     });
61 70
 
62
-    const { errors, touched, handleSubmit, getFieldProps } = formik;
71
+    const { errors, touched, handleSubmit, getFieldProps} = formik;
63 72
 
64 73
     return (
65 74
 
@@ -73,6 +82,7 @@ export default function Manual ( props ) {
73 82
                 <FormikProvider style={{ padding : 25 }} value={formik}>
74 83
                     <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
75 84
                         <Stack spacing={3}>
85
+
76 86
                             <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
77 87
 
78 88
                                 <TextField
@@ -93,14 +103,26 @@ export default function Manual ( props ) {
93 103
 
94 104
                             </Stack>
95 105
                             <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
96
-                                <TextField
97
-                                    label="Departamento"
98
-                                    fullWidth
99
-                                    type="text"
100
-                                    {...getFieldProps('aredepto')}
101
-                                    error={Boolean(touched.aredepto && errors.aredepto)}
102
-                                    helperText={touched.aredepto && errors.aredepto}
103
-                                />
106
+                                <FormControl fullWidth>
107
+                                    <InputLabel id="demo-simple-select-label">Departamento</InputLabel>
108
+                                    <Select
109
+                                        labelId="demo-simple-select-label"
110
+                                        value={departamento}
111
+                                        label="Departamento"
112
+                                        onChange={changeDepartamento}
113
+                                        {...getFieldProps('aredepto')}
114
+                                        error={Boolean(touched.aredepto && errors.aredepto)} >
115
+                                        {
116
+                                        departamentos.map( ( nivel, index ) => {
117
+                                            return (
118
+                                                <MenuItem key={nivel} value={index}>{nivel}</MenuItem>
119
+                                            )
120
+                                        })
121
+                                    }
122
+                                    </Select>
123
+                                </FormControl>
124
+
125
+
104 126
                                 <LocalizationProvider 
105 127
                                     dateAdapter={DateFnsUtils}>
106 128
                                     <DesktopDatePicker
@@ -145,17 +167,13 @@ export default function Manual ( props ) {
145 167
                                 type="submit"
146 168
                                 className="registerBtn" 
147 169
                                 variant="contained"
148
-                                sx={{ mt: 1, mr: 1 }}
149
-                            >
170
+                                sx={{ mt: 1, mr: 1 }} >
150 171
                                 {'Guardar'}
151 172
                             </Button>
152 173
                         </Modal.Footer>
153 174
 
154 175
                     </Form>
155 176
                 </FormikProvider>
156
-
157
-
158
-
159 177
             </Modal.Body>
160 178
         </Modal>
161 179
     )

+ 8 - 0
src/Components/Password/Rows.js

@@ -54,6 +54,7 @@ export const encabezados = [
54 54
         label: 'Operacion',
55 55
     },
56 56
 ]
57
+
57 58
 export const niveles_educativos = [
58 59
     "Primaria",
59 60
     "Basico",
@@ -66,3 +67,10 @@ export const niveles_educativos = [
66 67
     "Certificacion",
67 68
     "Cursos"
68 69
 ]
70
+
71
+
72
+export const departamentos = [
73
+    "Jutiapa",
74
+    "Guatemala",
75
+    "Santa Rosa",
76
+]

+ 15 - 8
src/Components/Puestos/GridMode.jsx

@@ -7,21 +7,28 @@ import {
7 7
     HighlightOff as HighlightOffIcon,
8 8
 } from '@mui/icons-material';
9 9
 
10
+import { Grow } from '@mui/material';
11
+
10 12
 
11 13
 import { Row, Col } from 'react-bootstrap'
12 14
 
13 15
 export function GridMode(props){
14 16
 
15
-    let { setEdit, setDelete, setShow, setPuesto, data ,index} = props;
16
-    console.log('data reci', data,index)
17
+    let { setEdit, setDelete, setShow, setPuesto, data ,index, showing} = props;
17 18
 
18 19
     return(
19 20
         <React.Fragment> 
20 21
             {
21
-                data.length ? 
22
-                    data[index].map( plaza => {
22
+                data.length && showing === 'grid' ? 
23
+                    data[index].map( (plaza,i) => {
23 24
                         return(
24
-                            <Col key={plaza.id} lg="4" md="6" sm="6" xs="12" >
25
+                        <Grow  
26
+                            in={true}
27
+                            style={{ transformOrigin: '0 0 0' }}
28
+                            timeout={500}
29
+                            key={plaza.id}
30
+                            >
31
+                            <Col  lg="4" md="6" sm="6" xs="12" >
25 32
                                 <div className="panel">
26 33
                                     <Row>
27 34
                                         <Col md="4">
@@ -32,8 +39,7 @@ export function GridMode(props){
32 39
                                         <Col md="8">
33 40
                                             <div className="info_details">
34 41
                                                 <p>{ plaza.nombre }</p>
35
-                                                <p>{ plaza.description }</p>
36
-                                                <p>{'100'}</p>
42
+                                                <p>{ plaza.description.slice(0,17) + "..." }</p>
37 43
                                             </div>
38 44
                                             <div className="btn_interactivos">
39 45
 
@@ -76,8 +82,9 @@ export function GridMode(props){
76 82
                                     </Row>
77 83
                                 </div>
78 84
                             </Col>
85
+                        </Grow>
79 86
                         )
80
-                }) : <div>no hay ni mierda</div>
87
+                }) : <div></div>
81 88
             }
82 89
         </React.Fragment>
83 90
     )

+ 7 - 6
src/Components/Puestos/ListMode.jsx

@@ -1,9 +1,10 @@
1 1
 import {  Col, Button, Table } from 'react-bootstrap'
2
+import Zoom from '@mui/material/Zoom';
2 3
 
3 4
 export function ListMode(props) {
4 5
     
5 6
     const opciones = { weekday: 'long', year: 'numeric', month: 'short', day: 'numeric' };
6
-    let { setEdit, setDelete, setShow, setPuesto, data, index } = props;
7
+    let { setEdit, setDelete, setShow, setPuesto, data, index, showing } = props;
7 8
 
8 9
     return(
9 10
         <Col md="12">
@@ -18,12 +19,12 @@ export function ListMode(props) {
18 19
                         </tr>
19 20
                     </thead>
20 21
                     <tbody>
21
-
22 22
                         {
23
-                            data.length ? 
23
+                            data.length && showing === 'list' ? 
24 24
                                 data[index].map( (plaza) => {
25 25
                                     return (
26
-                                        <tr key={plaza.id}>
26
+                                    <Zoom key={plaza.id} in={true}>
27
+                                        <tr >
27 28
                                             <td className="text-center">{ plaza.nombre }</td>
28 29
                                             <td className="text-center">{ plaza.description }</td>
29 30
                                             <td className="text-center">{ new Date( plaza.created ).toLocaleDateString('es-GT',opciones) }</td>
@@ -52,10 +53,10 @@ export function ListMode(props) {
52 53
                                                 </Button>
53 54
                                             </td>
54 55
                                         </tr>
56
+                                    </Zoom>
55 57
                                     )
56
-                                }) : undefined
58
+                            }) : <h1>no data bro</h1>
57 59
                         }
58
-
59 60
                     </tbody>
60 61
                     <tfoot>
61 62
                         <tr>

+ 3 - 3
src/Css/all.css

@@ -807,9 +807,9 @@ table.dataTable tbody th, table.dataTable tbody td {
807 807
     float: right;
808 808
 }
809 809
 .btn_add_producto {
810
-    border: 1px solid var(--second);
811
-    background: var(--second);
812
-    border-radius: 10px;
810
+    border: 1px solid var(--main);
811
+    background: var(--main);
812
+    border-radius: 5px;
813 813
     color: #fff;
814 814
     font-size: 12px;
815 815
     margin : 3px;

+ 68 - 46
src/Pages/Puestos.jsx

@@ -26,12 +26,8 @@ import { ListMode } from '../Components/Puestos/ListMode'
26 26
 import { GridMode } from '../Components/Puestos/GridMode'
27 27
 import { Add as AddIcon, } from '@mui/icons-material/'
28 28
 
29
-
30
-const Success =  () => toast.success('Plaza Agregada!!')
31
-const Error =  () => toast.error('Ups creo que ocurrio un error, intentalo nuevamente')
32
-
33 29
 function Divide(arregloOriginal){
34
-    const LONGITUD_PEDAZOS = 9;
30
+    const LONGITUD_PEDAZOS = 7;
35 31
     let arregloDeArreglos = [];
36 32
     for (let i = 0; i < arregloOriginal.length; i += LONGITUD_PEDAZOS) {
37 33
         let pedazo = arregloOriginal.slice(i, i + LONGITUD_PEDAZOS);
@@ -42,39 +38,62 @@ function Divide(arregloOriginal){
42 38
 
43 39
 export function Puestos() {
44 40
 
41
+    const Complete =  (status) => {
42
+
43
+        if(!status){
44
+            toast.error('Ups creo que ocurrio un error, intentalo nuevamente')
45
+        }
46
+
47
+        let rest = new Service("/plaza/getall")
48
+        rest
49
+            .get(token)
50
+            .then(({data}) => {
51
+                let entries = data.map( e => {
52
+                    return {
53
+                        nombre : e.nombrepuesto,
54
+                        description : e.notas,
55
+                        id : e.id,
56
+                        created: e.create_day,
57
+                        data: e
58
+                    };
59
+                })
60
+                setData(Divide(entries))
61
+            })
62
+            .catch((error) => {
63
+                console.log('error fetching data  ', error );
64
+            })
65
+
66
+        toast.success('Puesto agregado exitosamente')
67
+    } 
68
+
45 69
     const auth = useAuth();
46 70
     const [data, setData] = useState([]);
47 71
     const [page, setPage] = useState(1);
48 72
     const token = auth.getToken();
49
-    
50
-    const changePage = ( _ , value) => {
51
-        let page_numer = value;
52
-        // let divided =  Divide(data)
53
-        setPage(page_numer);
54
-        // setData(divided)
55
-    };
73
+
74
+    const changePage = ( _ , value) => setPage(value);
56 75
 
57 76
     useEffect(() => {
58 77
 
59 78
         let rest = new Service("/plaza/getall")
60
-
61 79
         rest
62
-        .get(token)
63
-        .then(({data}) => {
64
-            let entries = data.map( e => {
65
-                return {
66
-                    nombre : e.nombrepuesto,
67
-                    description : e.notas,
68
-                    id : e.id,
69
-                    created: e.create_day,
70
-                    data: e
71
-                };
80
+            .get(token)
81
+            .then(({data}) => {
82
+                let entries = data.map( e => {
83
+                    return {
84
+                        nombre : e.nombrepuesto,
85
+                        description : e.notas,
86
+                        id : e.id,
87
+                        created: e.create_day,
88
+                        data: e
89
+                    };
90
+                })
91
+                setData(Divide(entries))
72 92
             })
73
-            setData(Divide(entries))
74
-        })
75
-        .catch((error) => {
76
-            console.log('error fetching data  ', error );
77
-        })
93
+            .catch((error) => {
94
+                console.log('error fetching data  ', error );
95
+            })
96
+
78 97
 
79 98
     },[token])
80 99
 
@@ -139,41 +158,43 @@ export function Puestos() {
139 158
                         <div className={`main_productos ${ alignment === 'grid' ? 'activar_vista' : 'desactivar_vista'  }`} id="grid_view">
140 159
                             <Row>
141 160
                                 <GridMode
161
+                                    showing={alignment}
142 162
                                     data={data}
143 163
                                     index={page - 1}
144 164
                                     setPuesto={setPuesto}
145 165
                                     setEdit={setEdit}
146 166
                                     setDelete={setDelete}
147 167
                                     setShow={setShow}
148
-                                />
168
+                                    />
149 169
                             </Row>
150 170
                         </div>
151 171
                         <div className={`main_list_products ${alignment === 'list' ?  'activar_vista' : 'desactivar_vista'}`} id="list_view_products">
152 172
                             <Row>
153 173
                                 <ListMode 
174
+                                    showing={alignment}
154 175
                                     data={data}
155
-                                    index={page -1}
176
+                                    index={page - 1}
156 177
                                     setPuesto={setPuesto}
157 178
                                     setEdit={setEdit}
158 179
                                     setDelete={setDelete}
159 180
                                     setShow={setShow}
160
-                                />
181
+                                    />
161 182
                             </Row>
162 183
                         </div>
163 184
 
164
-                            <Pagination 
165
-                                sx={{
166
-                                    "& ul" :{
167
-                                        "padding-top" : "20px",
168
-                                        "justify-content": "center"
169
-                                    }
170
-                                }}
171
-                                siblingCount={2} 
172
-                                boundaryCount={2}
173
-                                shape='rounded' 
174
-                                count={data.length} 
175
-                                page={page} 
176
-                                onChange={changePage} 
185
+                        <Pagination 
186
+                            sx={{
187
+                                "& ul" :{
188
+                                    paddingTop: "20px",
189
+                                    justifyContent: "center"
190
+                                }
191
+                            }}
192
+                            siblingCount={2} 
193
+                            boundaryCount={2}
194
+                            shape='rounded' 
195
+                            count={data.length} 
196
+                            page={page} 
197
+                            onChange={changePage} 
177 198
                             />
178 199
 
179 200
                     </Paper>
@@ -181,8 +202,9 @@ export function Puestos() {
181 202
 
182 203
             </div>
183 204
 
184
-            <Express success={Success} setExpress={setExpress} visible={expres} onClose={() => setExpress(false) } />
185
-            <Manual success={Success} error={Error} setManual={setManual} visible={manual}  onClose={() => setManual(false) } />
205
+            <Express setExpress={setExpress} visible={expres} onClose={() => setExpress(false) } />
206
+
207
+            <Manual Complete={Complete} visible={manual} onClose={() => setManual(false)}/>
186 208
 
187 209
             <Editar   puesto={puesto} visible={edit} onClose={() => setEdit(false)} />
188 210
             <Eliminar puesto={puesto} visible={del} onClose={() => setDelete(false)} />