Browse Source

add mockup

amenpunk 2 years ago
parent
commit
8e24dee888
2 changed files with 95 additions and 130 deletions
  1. 94 129
      src/Components/Modal/AgregarManual.js
  2. 1 1
      src/Pages/Puestos.jsx

+ 94 - 129
src/Components/Modal/AgregarManual.js

@@ -1,149 +1,114 @@
1 1
 import React from 'react';
2 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
-})
3
+import { useFormik, Form, FormikProvider } from 'formik';
4
+import { Modal } from 'react-bootstrap'
21 5
 
22
-export default function Manual ( props ) {
6
+import {  
7
+    Box, Button,
8
+    Stack, TextField, 
9
+    InputLabel,MenuItem,FormControl,Select
10
+} from '@mui/material';
23 11
 
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 12
 
29
-    let { visible, onClose, success } = props
30
-    const hiddenFileInput = React.useRef(null);
31 13
 
32
-    const PickFile = event => hiddenFileInput.current.click();
14
+export default function Manual ( props ) {
33 15
 
34
-    React.useEffect(() => {
35
-        if( SUPPORTED_FORMATS.includes(type) ){
36
-            setValidType(true)
37
-        }else{
38
-            setValidType(false)
39
-        }
16
+    const NewPlazaSchema = Yup.object().shape({
17
+        nombrepuesto : Yup.string().required('El nombre es requerido').min(5).max(100),
18
+        puestosuperior : Yup.number("El puesto superior debe ser un numero"),
19
+        areadepto : Yup.number().required('Escoge alguna area'),
20
+        fecha : Yup.date("Ingresa una fecha válida").required('Ingresa una fecha válida'),
21
+        notas : Yup.string().required('Ingresa una fecha válida'),
22
+    })
40 23
 
41
-    }, [type])
24
+    let { visible, onClose, success } = props
42 25
 
26
+    const formik = useFormik({
27
+        initialValues: {
28
+            nombrepuesto: "",
29
+            puestosuperior: "",
30
+            areadepto: "",
31
+            fecha: "",
32
+            notas: "",
33
+        },
34
+        onSubmit: (fields) => {
35
+            console.log(fields)
36
+        },
37
+        validationSchema: NewPlazaSchema,
38
+    });
39
+
40
+    const { errors, touched, handleSubmit, getFieldProps } = formik;
43 41
 
44 42
     return (
43
+
45 44
         <Modal size="lg" aria-labelledby="contained-modal-title-vcenter" centered  show={visible} onHide={onClose}>
46 45
             <Modal.Header>
47 46
                 <button onClick={onClose}  type="button" className="close" data-dismiss="modal">&times;</button>
48
-                <h4 className="modal-title">Agregar plaza</h4>
47
+                <h4 className="modal-title" style={{color : '#252525'}}>Agregar plaza</h4>
49 48
             </Modal.Header>
50 49
             <Modal.Body className="modal-body">
51 50
 
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
-                        success();
65
-                        props.setManual(false)
66
-                    }} >
67
-
68
-
69
-                    { ({  errors, touched, validateField, validateForm, setFieldValue  }) => (
70
-                        <Form>
71
-                            <Row>
72
-
73
-                                <Col md="4">
74
-                                    <div className="img-container">
75
-                                        <img alt="agregar plaza manual" src={ validType ? file : NotFound}/>
76
-                                    </div>
77
-                                </Col>
78
-
79
-                                <Col md="8">
80
-
81
-                                    <input 
82
-                                        value={filename} 
83
-                                        type="text" 
84
-                                        className="file-upload-input" 
85
-                                        disabled="" 
86
-                                        placeholder="Ningún archivo seleccionado" readOnly
87
-                                    />
88
-
89
-                                    <Button className="btn_add_producto_confirm" style={{ marginLeft : 15 }} onClick={PickFile}>
90
-                                        SUBIR FOTO
91
-                                    </Button>
92
-
93
-                                    {errors.imagen && touched.imagen && <div className="error_feedback">{errors.imagen}</div>}
94
-                                    <input
95
-                                        multiple={false}
96
-                                        type="file"
97
-                                        ref={hiddenFileInput}
98
-                                        onChange={(event) => {
99
-                                            const files = event.target.files;
100
-                                            console.log('files crud ', files[0])
101
-                                            let myFiles =Array.from(files);
102
-                                            setFieldValue("imagen", myFiles);
103
-                                            setFilename(myFiles[0].name)
104
-                                            setType(myFiles[0].type)
105
-                                            const objectUrl = URL.createObjectURL(files[0])
106
-                                            setFile(objectUrl)
107
-                                        }}
108
-                                        style={{display: 'none'}}
109
-                                    />
110
-
111
-                                </Col>
112
-
113
-                            </Row>
114
-                            <div className="data_product">
115
-                                <Row>
116
-                                    <Col md="12">
117
-
118
-                                        {errors.nombre && touched.nombre && <div className="error_feedback">{errors.nombre}</div>}
119
-                                        <Field name="nombre" placeholder="Nombre de la plaza"/>
120
-
121
-                                        {errors.description && touched.description && <div className="error_feedback">{errors.description}</div>}
122
-                                        <Field name="description">
123
-                                            {({ field, form, meta }) => {
124
-                                                return(
125
-                                                    <textarea id="description" name="description" value={field.value} onChange={field.onChange} placeholder="Descripción general de la plaza"></textarea>
126
-                                                )
127
-                                            }}
128
-                                        </Field>
129
-
130
-                                        {errors.salario && touched.salario && <div className="error_feedback">{errors.salario}</div>}
131
-                                        <Field name="salario" type="number" placeholder="Salario"/>
132
-
133
-
134
-                                    </Col>
135
-                                    <div className="add_producto_confirm">
136
-                                        <button className="btn_add_producto_confirm" type="submit">Agregar plaza</button>
137
-                                    </div>
138
-                                </Row>
139
-                            </div>
140
-                        </Form>
141
-                    )}
142
-
143
-
144
-
145
-
146
-                </Formik>
51
+                <FormikProvider style={{ padding : 25 }} value={formik}>
52
+                    <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
53
+                        <Stack spacing={3}>
54
+                            <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
55
+
56
+                                <TextField
57
+                                    label="Nombre: "
58
+                                    fullWidth
59
+                                    {...getFieldProps('nombrepuesto')}
60
+                                    error={Boolean(touched.nombrepuesto && errors.nombrepuesto)}
61
+                                    helperText={touched.nombrepuesto && errors.nombrepuesto}
62
+                                />
63
+
64
+                                <TextField
65
+                                    label="Puesto Superior: "
66
+                                    fullWidth
67
+                                    {...getFieldProps('puestosuperior')}
68
+                                    error={Boolean(touched.puestosuperior && errors.puestosuperior)}
69
+                                    helperText={touched.puestosuperior && errors.puestosuperior}
70
+                                />
71
+
72
+                            </Stack>
73
+                            <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
74
+                                <TextField
75
+                                    label="Departamento"
76
+                                    fullWidth
77
+                                    type="text"
78
+                                    {...getFieldProps('puestosuperior')}
79
+                                    error={Boolean(touched.areadepto && errors.areadepto)}
80
+                                    helperText={touched.areadepto && errors.areadepto}
81
+                                />
82
+                                <TextField
83
+                                    label="Fecha Creacion"
84
+                                    fullWidth
85
+                                    type="text"
86
+                                    {...getFieldProps('fecha')}
87
+                                    error={Boolean(touched.fecha && errors.fecha)}
88
+                                    helperText={touched.fecha && errors.fecha}
89
+                                />
90
+                            </Stack>
91
+                            <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>
92
+                                <TextField
93
+                                    id="filled-multiline-static"
94
+                                    multiline
95
+                                    rows={4}
96
+                                    defaultValue="Default Value"
97
+                                    variant="filled"
98
+                                    label="notas"
99
+                                    fullWidth
100
+                                    type="text"
101
+                                    {...getFieldProps('notas')}
102
+                                    error={Boolean(touched.notas && errors.notas)}
103
+                                    helperText={touched.notas && errors.notas}
104
+                                />
105
+                            </Stack>
106
+                        </Stack>
107
+                    </Form>
108
+                </FormikProvider>
109
+
110
+                <Modal.Footer>OK</Modal.Footer>
111
+
147 112
             </Modal.Body>
148 113
         </Modal>
149 114
     )

+ 1 - 1
src/Pages/Puestos.jsx

@@ -76,7 +76,7 @@ export function Puestos() {
76 76
 
77 77
     let [puesto, setPuesto] = React.useState(false);
78 78
 
79
-    let [manual, setManual] = React.useState(false);
79
+    let [manual, setManual] = React.useState(true);
80 80
     let [expres, setExpress] = React.useState(false);
81 81
 
82 82
     let [edit, setEdit] = React.useState(false);