|
@@ -1,8 +1,6 @@
|
1
|
|
-import React, { } from 'react';
|
2
|
|
-import { Row, Col, Modal, Button, Table } from 'react-bootstrap'
|
|
1
|
+import React from 'react';
|
|
2
|
+import { Row, Col, Button, Table } from 'react-bootstrap'
|
3
|
3
|
import { Box } from '@mui/material';
|
4
|
|
-import { Formik, Field, Form } from 'formik';
|
5
|
|
-import * as Yup from 'yup';
|
6
|
4
|
|
7
|
5
|
import ToggleButton from '@mui/material/ToggleButton';
|
8
|
6
|
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
|
|
@@ -15,25 +13,10 @@ import EditIcon from '@mui/icons-material/Edit';
|
15
|
13
|
import HighlightOffIcon from '@mui/icons-material/HighlightOff';
|
16
|
14
|
|
17
|
15
|
import NotFound from '../Images/not_found.png';
|
18
|
|
-const SUPPORTED_FORMATS = ["image/jpg", "image/jpeg", "image/gif", "image/png"];
|
19
|
16
|
|
|
17
|
+import Express from '../Components/Modal/AgregarExpress';
|
|
18
|
+import Manual from '../Components/Modal/AgregarManual';
|
20
|
19
|
|
21
|
|
-const NewPlazaSchema = Yup.object().shape({
|
22
|
|
- nombre : Yup.string().required('El nombre es requerido').min(5).max(20),
|
23
|
|
- description : Yup.string().required('La description es requerida').min(5).max(20),
|
24
|
|
- salario : Yup.number().required('El salario es requerido'),
|
25
|
|
- imagen: Yup.mixed().required('El imagen es requerido').test('fileSize', "El archivo es demasiado grande", value => {
|
26
|
|
- if(!value || value.length <= 0) return false
|
27
|
|
- return value[0].size < 200000
|
28
|
|
- }).test('fileType', "El tipo del archivo no es válido", value => {
|
29
|
|
- if(!value) return false
|
30
|
|
- return SUPPORTED_FORMATS.includes(value[0].type)
|
31
|
|
- })
|
32
|
|
-})
|
33
|
|
-
|
34
|
|
-const ExpressSchema = Yup.object().shape({
|
35
|
|
- link : Yup.string().required('El enlace es requerido').url("Debes agregar un enlace válido, recurda iniciar con http o https ").min(5).max(190),
|
36
|
|
-})
|
37
|
20
|
|
38
|
21
|
let data = [{
|
39
|
22
|
nombre : 'The standard Lorem Ipsum passage, used since the 1500s',
|
|
@@ -57,9 +40,9 @@ for ( var _ of new Array(46) ){
|
57
|
40
|
function ListMode() {
|
58
|
41
|
|
59
|
42
|
let actions = [
|
60
|
|
- <Button className="ver_producto">Ver</Button>,
|
61
|
|
- <Button className="editar_producto">Editar</Button>,
|
62
|
|
- <Button className="eliminar_producto">Eliminar</Button>,
|
|
43
|
+ <Button onClick={ () => console.log('ver producto') } className="ver_producto">Ver</Button>,
|
|
44
|
+ <Button onClick={ () => console.log('editar producto') } className="editar_producto">Editar</Button>,
|
|
45
|
+ <Button onClick={ () => console.log('eliminar producto') } className="eliminar_producto">Eliminar</Button>,
|
63
|
46
|
]
|
64
|
47
|
|
65
|
48
|
return(
|
|
@@ -160,190 +143,6 @@ function GridMode () {
|
160
|
143
|
)
|
161
|
144
|
}
|
162
|
145
|
|
163
|
|
-function Manual ( props ) {
|
164
|
|
-
|
165
|
|
- let [ filename, setFilename ] = React.useState('');
|
166
|
|
- let [ file, setFile ] = React.useState(undefined);
|
167
|
|
- let [ type, setType ] = React.useState(undefined);
|
168
|
|
- let [ validType, setValidType ] = React.useState(false);
|
169
|
|
-
|
170
|
|
- let { visible, onClose } = props
|
171
|
|
- const hiddenFileInput = React.useRef(null);
|
172
|
|
-
|
173
|
|
- const PickFile = event => {
|
174
|
|
- hiddenFileInput.current.click();
|
175
|
|
- };
|
176
|
|
-
|
177
|
|
- React.useEffect(() => {
|
178
|
|
-
|
179
|
|
- if( SUPPORTED_FORMATS.includes(type) ){
|
180
|
|
- setValidType(true)
|
181
|
|
- }else{
|
182
|
|
- setValidType(false)
|
183
|
|
- }
|
184
|
|
-
|
185
|
|
- }, [type])
|
186
|
|
-
|
187
|
|
-
|
188
|
|
-
|
189
|
|
- return (
|
190
|
|
- <Modal size="lg" aria-labelledby="contained-modal-title-vcenter" centered show={visible} onHide={onClose}>
|
191
|
|
- <Modal.Header>
|
192
|
|
- <button onClick={onClose} type="button" className="close" data-dismiss="modal">×</button>
|
193
|
|
- <h4 className="modal-title">Agregar plaza</h4>
|
194
|
|
- </Modal.Header>
|
195
|
|
- <Modal.Body className="modal-body">
|
196
|
|
-
|
197
|
|
- <Formik
|
198
|
|
-
|
199
|
|
- initialValues={{
|
200
|
|
- nombre: '',
|
201
|
|
- description: '',
|
202
|
|
- salario: '',
|
203
|
|
- imagen: '',
|
204
|
|
- }}
|
205
|
|
-
|
206
|
|
- validationSchema={NewPlazaSchema}
|
207
|
|
- onSubmit={ (values) => {
|
208
|
|
- // console.log('VALUES >> ',values)
|
209
|
|
- props.setManual(false)
|
210
|
|
- }} >
|
211
|
|
-
|
212
|
|
-
|
213
|
|
- { ({ errors, touched, validateField, validateForm, setFieldValue }) => (
|
214
|
|
- <Form>
|
215
|
|
- <Row>
|
216
|
|
-
|
217
|
|
- <Col md="4">
|
218
|
|
- <div className="img-container">
|
219
|
|
- <img alt="agregar plaza manual" src={ validType ? file : NotFound}/>
|
220
|
|
- </div>
|
221
|
|
- </Col>
|
222
|
|
-
|
223
|
|
- <Col md="8">
|
224
|
|
-
|
225
|
|
- <input
|
226
|
|
- value={filename}
|
227
|
|
- type="text"
|
228
|
|
- className="file-upload-input"
|
229
|
|
- disabled=""
|
230
|
|
- placeholder="Ningún archivo seleccionado" readOnly
|
231
|
|
- />
|
232
|
|
-
|
233
|
|
- <Button className="btn_add_producto_confirm" style={{ marginLeft : 15 }} onClick={PickFile}>
|
234
|
|
- SUBIR FOTO
|
235
|
|
- </Button>
|
236
|
|
-
|
237
|
|
- {errors.imagen && touched.imagen && <div className="error_feedback">{errors.imagen}</div>}
|
238
|
|
- <input
|
239
|
|
- multiple={false}
|
240
|
|
- type="file"
|
241
|
|
- ref={hiddenFileInput}
|
242
|
|
- onChange={(event) => {
|
243
|
|
- const files = event.target.files;
|
244
|
|
- console.log('files crud ', files[0])
|
245
|
|
- let myFiles =Array.from(files);
|
246
|
|
- setFieldValue("imagen", myFiles);
|
247
|
|
- setFilename(myFiles[0].name)
|
248
|
|
- setType(myFiles[0].type)
|
249
|
|
- const objectUrl = URL.createObjectURL(files[0])
|
250
|
|
- setFile(objectUrl)
|
251
|
|
- }}
|
252
|
|
- style={{display: 'none'}}
|
253
|
|
- />
|
254
|
|
-
|
255
|
|
- </Col>
|
256
|
|
-
|
257
|
|
- </Row>
|
258
|
|
- <div className="data_product">
|
259
|
|
- <Row>
|
260
|
|
- <Col md="12">
|
261
|
|
-
|
262
|
|
- {errors.nombre && touched.nombre && <div className="error_feedback">{errors.nombre}</div>}
|
263
|
|
- <Field name="nombre" placeholder="Nombre de la plaza"/>
|
264
|
|
-
|
265
|
|
- {errors.description && touched.description && <div className="error_feedback">{errors.description}</div>}
|
266
|
|
- <Field name="description">
|
267
|
|
- {({ field, form, meta }) => {
|
268
|
|
- return(
|
269
|
|
- <textarea id="description" name="description" value={field.value} onChange={field.onChange} placeholder="Descripción general de la plaza"></textarea>
|
270
|
|
- )
|
271
|
|
- }}
|
272
|
|
- </Field>
|
273
|
|
-
|
274
|
|
- {errors.salario && touched.salario && <div className="error_feedback">{errors.salario}</div>}
|
275
|
|
- <Field name="salario" type="number" placeholder="Salario"/>
|
276
|
|
-
|
277
|
|
-
|
278
|
|
- </Col>
|
279
|
|
- <div className="add_producto_confirm">
|
280
|
|
- <button className="btn_add_producto_confirm" type="submit">Agregar plaza</button>
|
281
|
|
- </div>
|
282
|
|
- </Row>
|
283
|
|
- </div>
|
284
|
|
- </Form>
|
285
|
|
- )}
|
286
|
|
-
|
287
|
|
-
|
288
|
|
-
|
289
|
|
-
|
290
|
|
- </Formik>
|
291
|
|
- </Modal.Body>
|
292
|
|
- </Modal>
|
293
|
|
- )
|
294
|
|
-}
|
295
|
|
-
|
296
|
|
-function Express (props) {
|
297
|
|
- let { visible, onClose } = props
|
298
|
|
- return (
|
299
|
|
- <Modal size="lg" aria-labelledby="contained-modal-title-vcenter" centered show={visible} onHide={onClose}>
|
300
|
|
- <Modal.Header>
|
301
|
|
- <button onClick={onClose} type="button" className="close" data-dismiss="modal">×</button>
|
302
|
|
- <h4 className="modal-title">Agregar plaza express</h4>
|
303
|
|
- </Modal.Header>
|
304
|
|
- <Modal.Body>
|
305
|
|
-
|
306
|
|
- <Formik
|
307
|
|
- initialValues={{
|
308
|
|
- link : ''
|
309
|
|
- }}
|
310
|
|
- validationSchema={ExpressSchema}
|
311
|
|
- onSubmit={ (values) => {
|
312
|
|
- props.setExpress(false)
|
313
|
|
- console.log('VALUES Express >> ',values)
|
314
|
|
- }}
|
315
|
|
- >
|
316
|
|
- { ({ errors, touched, validateField, validateForm, setFieldValue }) => (
|
317
|
|
-
|
318
|
|
- <Form>
|
319
|
|
- <div className="data_product">
|
320
|
|
- <div className="row">
|
321
|
|
- <div className="col-md-12">
|
322
|
|
- {/* <input type="link" name="link" placeholder="Link de la plaza"/> */}
|
323
|
|
- <Field type="link" name="link" placeholder="Link de la plaza"/>
|
324
|
|
- {errors.link && touched.link && <div className="error_feedback">{errors.link}</div>}
|
325
|
|
- </div>
|
326
|
|
- <div className="add_producto_confirm">
|
327
|
|
- <button className="btn_add_producto_confirm" type="submit">Agregar plaza</button>
|
328
|
|
- {/* <div className="btn_add_producto_confirm"> */}
|
329
|
|
- {/* <span type="submit">Agregar plaza</span> */}
|
330
|
|
- {/* </div> */}
|
331
|
|
- </div>
|
332
|
|
- </div>
|
333
|
|
- </div>
|
334
|
|
- </Form>
|
335
|
|
- )}
|
336
|
|
-
|
337
|
|
- </Formik>
|
338
|
|
-
|
339
|
|
-
|
340
|
|
-
|
341
|
|
- </Modal.Body>
|
342
|
|
- </Modal>
|
343
|
|
- )
|
344
|
|
-}
|
345
|
|
-
|
346
|
|
-
|
347
|
146
|
export function Puestos() {
|
348
|
147
|
|
349
|
148
|
const [alignment, setAlignment] = React.useState('list');
|