|
@@ -16,10 +16,19 @@ import HighlightOffIcon from '@mui/icons-material/HighlightOff';
|
|
|
|
|
|
|
|
import NotFound from '../Images/not_found.png';
|
|
import NotFound from '../Images/not_found.png';
|
|
|
|
|
|
|
|
|
|
+
|
|
|
const NewPlazaSchema = Yup.object().shape({
|
|
const NewPlazaSchema = Yup.object().shape({
|
|
|
nombre : Yup.string().required('El nombre es requerido').min(5).max(20),
|
|
nombre : Yup.string().required('El nombre es requerido').min(5).max(20),
|
|
|
description : Yup.string().required('La description es requerida').min(5).max(20),
|
|
description : Yup.string().required('La description es requerida').min(5).max(20),
|
|
|
- salario : Yup.number().required('El salario es requerido')
|
|
|
|
|
|
|
+ salario : Yup.number().required('El salario es requerido'),
|
|
|
|
|
+ imagen: Yup.mixed().required('El imagen es requerido').test('fileSize', "El archivo es demasiado grande", value => {
|
|
|
|
|
+ if(!value || value.length <= 0) return false
|
|
|
|
|
+ return value[0].size < 200000
|
|
|
|
|
+ }).test('fileType', "El tipo del archivo no es válido", value => {
|
|
|
|
|
+ let SUPPORTED_FORMATS = ["image/jpg", "image/jpeg", "image/gif", "image/png"];
|
|
|
|
|
+ if(!value) return false
|
|
|
|
|
+ return SUPPORTED_FORMATS.includes(value[0].type)
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
let data = [{
|
|
let data = [{
|
|
@@ -35,15 +44,12 @@ function* idMaker() {
|
|
|
yield index++;
|
|
yield index++;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-var ID = idMaker(); // "Generator { }"
|
|
|
|
|
|
|
+var ID = idMaker();
|
|
|
|
|
|
|
|
for ( var _ of new Array(46) ){
|
|
for ( var _ of new Array(46) ){
|
|
|
- data.push({
|
|
|
|
|
- ...data[0],
|
|
|
|
|
- id : ID.next().value,
|
|
|
|
|
- d : _
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ data.push({ ...data[0], id : ID.next().value, d : _ })
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
function ListMode() {
|
|
function ListMode() {
|
|
|
|
|
|
|
|
let actions = [
|
|
let actions = [
|
|
@@ -68,7 +74,7 @@ function ListMode() {
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
data.length ?
|
|
data.length ?
|
|
|
- data.slice(0,23).map( (plaza, i) => {
|
|
|
|
|
|
|
+ data.slice( 0,23 ).map( (plaza, i) => {
|
|
|
return (
|
|
return (
|
|
|
<tr key={plaza.id}>
|
|
<tr key={plaza.id}>
|
|
|
<td className="text-center">{ plaza.nombre }</td>
|
|
<td className="text-center">{ plaza.nombre }</td>
|
|
@@ -152,28 +158,13 @@ function GridMode () {
|
|
|
|
|
|
|
|
function Manual ( props ) {
|
|
function Manual ( props ) {
|
|
|
|
|
|
|
|
- let [ filename, setFilename ] = React.useState(null);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ let [ filename, setFilename ] = React.useState('');
|
|
|
let { visible, onClose } = props
|
|
let { visible, onClose } = props
|
|
|
-
|
|
|
|
|
- // Create a reference to the hidden file input element
|
|
|
|
|
const hiddenFileInput = React.useRef(null);
|
|
const hiddenFileInput = React.useRef(null);
|
|
|
|
|
|
|
|
- // Programatically click the hidden file input element
|
|
|
|
|
- // when the Button component is clicked
|
|
|
|
|
- const handleClick = event => {
|
|
|
|
|
|
|
+ const PickFile = event => {
|
|
|
hiddenFileInput.current.click();
|
|
hiddenFileInput.current.click();
|
|
|
};
|
|
};
|
|
|
- // Call a function (passed as a prop from the parent component)
|
|
|
|
|
- // to handle the user-selected file
|
|
|
|
|
- const handleChange = event => {
|
|
|
|
|
- const fileUploaded = event.target.files[0];
|
|
|
|
|
- // console.log( "FILE >> ", fileUploaded )
|
|
|
|
|
- setFilename( fileUploaded.name )
|
|
|
|
|
- //props.handleFile(fileUploaded);
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- const validateEmail = (value) => value === "Edgar";
|
|
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<Modal size="lg" aria-labelledby="contained-modal-title-vcenter" centered show={visible} onHide={onClose}>
|
|
<Modal size="lg" aria-labelledby="contained-modal-title-vcenter" centered show={visible} onHide={onClose}>
|
|
@@ -184,18 +175,21 @@ function Manual ( props ) {
|
|
|
<Modal.Body className="modal-body">
|
|
<Modal.Body className="modal-body">
|
|
|
|
|
|
|
|
<Formik
|
|
<Formik
|
|
|
|
|
+
|
|
|
initialValues={{
|
|
initialValues={{
|
|
|
nombre: '',
|
|
nombre: '',
|
|
|
description: '',
|
|
description: '',
|
|
|
salario: '',
|
|
salario: '',
|
|
|
|
|
+ imagen: '',
|
|
|
}}
|
|
}}
|
|
|
|
|
+
|
|
|
validationSchema={NewPlazaSchema}
|
|
validationSchema={NewPlazaSchema}
|
|
|
onSubmit={async (values) => {
|
|
onSubmit={async (values) => {
|
|
|
console.log('VALUES >> ',values)
|
|
console.log('VALUES >> ',values)
|
|
|
}} >
|
|
}} >
|
|
|
|
|
|
|
|
|
|
|
|
|
- { ({ errors, touched, validateField, validateForm }) => (
|
|
|
|
|
|
|
+ { ({ errors, touched, validateField, validateForm, setFieldValue }) => (
|
|
|
<Form>
|
|
<Form>
|
|
|
<Row>
|
|
<Row>
|
|
|
|
|
|
|
@@ -208,20 +202,28 @@ function Manual ( props ) {
|
|
|
<Col md="8">
|
|
<Col md="8">
|
|
|
|
|
|
|
|
<input
|
|
<input
|
|
|
- value={ filename ? filename : "" }
|
|
|
|
|
|
|
+ value={filename}
|
|
|
type="text"
|
|
type="text"
|
|
|
className="file-upload-input"
|
|
className="file-upload-input"
|
|
|
disabled=""
|
|
disabled=""
|
|
|
- placeholder="Ningún archivo seleccionado"/>
|
|
|
|
|
|
|
+ placeholder="Ningún archivo seleccionado" readOnly
|
|
|
|
|
+ />
|
|
|
|
|
|
|
|
- <Button className="btn_add_producto_confirm" style={{ marginLeft : 15 }} onClick={handleClick}>
|
|
|
|
|
|
|
+ <Button className="btn_add_producto_confirm" style={{ marginLeft : 15 }} onClick={PickFile}>
|
|
|
SUBIR FOTO
|
|
SUBIR FOTO
|
|
|
</Button>
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
+ {errors.imagen && touched.imagen && <div className="error_feedback">{errors.imagen}</div>}
|
|
|
<input
|
|
<input
|
|
|
|
|
+ multiple={false}
|
|
|
type="file"
|
|
type="file"
|
|
|
ref={hiddenFileInput}
|
|
ref={hiddenFileInput}
|
|
|
- onChange={handleChange}
|
|
|
|
|
|
|
+ onChange={(event) => {
|
|
|
|
|
+ const files = event.target.files;
|
|
|
|
|
+ let myFiles =Array.from(files);
|
|
|
|
|
+ setFieldValue("imagen", myFiles);
|
|
|
|
|
+ setFilename(myFiles[0].name)
|
|
|
|
|
+ }}
|
|
|
style={{display: 'none'}}
|
|
style={{display: 'none'}}
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
@@ -233,19 +235,19 @@ function Manual ( props ) {
|
|
|
<Col md="12">
|
|
<Col md="12">
|
|
|
|
|
|
|
|
{errors.nombre && touched.nombre && <div className="error_feedback">{errors.nombre}</div>}
|
|
{errors.nombre && touched.nombre && <div className="error_feedback">{errors.nombre}</div>}
|
|
|
- <Field name="nombre" placeholder="Nombre de la plaza" validate={validateEmail}/>
|
|
|
|
|
|
|
+ <Field name="nombre" placeholder="Nombre de la plaza"/>
|
|
|
|
|
|
|
|
{errors.description && touched.description && <div className="error_feedback">{errors.description}</div>}
|
|
{errors.description && touched.description && <div className="error_feedback">{errors.description}</div>}
|
|
|
<Field name="description">
|
|
<Field name="description">
|
|
|
{({ field, form, meta }) => {
|
|
{({ field, form, meta }) => {
|
|
|
return(
|
|
return(
|
|
|
- <textarea id="description" name="description" defaultValue="" value={field.value} onChange={field.onChange} placeholder="Descripción general de la plaza"></textarea>
|
|
|
|
|
|
|
+ <textarea id="description" name="description" value={field.value} onChange={field.onChange} placeholder="Descripción general de la plaza"></textarea>
|
|
|
)
|
|
)
|
|
|
}}
|
|
}}
|
|
|
</Field>
|
|
</Field>
|
|
|
|
|
|
|
|
{errors.salario && touched.salario && <div className="error_feedback">{errors.salario}</div>}
|
|
{errors.salario && touched.salario && <div className="error_feedback">{errors.salario}</div>}
|
|
|
- <Field name="salario" type="number" name="salario" placeholder="Salario"/>
|
|
|
|
|
|
|
+ <Field name="salario" type="number" placeholder="Salario"/>
|
|
|
|
|
|
|
|
|
|
|
|
|
</Col>
|
|
</Col>
|