From fab7d63333b86b9fe0f1c52d2c642b52bbf506c0 Mon Sep 17 00:00:00 2001 From: gabrhr <73925454+gabrhr@users.noreply.github.com> Date: Mon, 6 Jun 2022 11:35:56 -0500 Subject: Add CRUD Camiones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - están ok funcionando: listar, insertar, editar, eliminar #TODO - añadir todos los puntos - Mejorar el path del punto con funcion - añadir tiempos segun distancia - estetica al final (camion, colores, etc) - Arreglar combos - Añadir los reducer de pedidos, rutas, almacen Camiones CRUD - ver codigo de camion corelativo - añadir Ciudad origen --- .../Odipar/Camiones/CamionTab/CamionTab.js | 7 +-- .../Camiones/CamionTab/table/CrudCamionTab.js | 28 +++++---- .../Camiones/CamionTab/table/FormCamionTab.js | 66 ++++++++++++++++------ .../containers/Odipar/Simulacion/SimulacionMain.js | 32 ++++++----- 4 files changed, 86 insertions(+), 47 deletions(-) (limited to 'front/odiparpack/app/containers/Odipar') diff --git a/front/odiparpack/app/containers/Odipar/Camiones/CamionTab/CamionTab.js b/front/odiparpack/app/containers/Odipar/Camiones/CamionTab/CamionTab.js index 5110566..bd86653 100644 --- a/front/odiparpack/app/containers/Odipar/Camiones/CamionTab/CamionTab.js +++ b/front/odiparpack/app/containers/Odipar/Camiones/CamionTab/CamionTab.js @@ -16,6 +16,7 @@ const styles = ({ }); class CamionTab extends Component { + //Obtenemos la lista constructor (props) { super(props) this.state = { @@ -26,7 +27,6 @@ class CamionTab extends Component { this.setState({ dataRealF: res.data, }); - console.log("Vengo del back", res.data) } }) } @@ -34,10 +34,9 @@ class CamionTab extends Component { render() { const {dataRealF} = this.state; - const { classes } = this.props; return ( - - + //Mandamos la lista(dataRealF) y la funcion del GET + ); } diff --git a/front/odiparpack/app/containers/Odipar/Camiones/CamionTab/table/CrudCamionTab.js b/front/odiparpack/app/containers/Odipar/Camiones/CamionTab/table/CrudCamionTab.js index 11c0805..6d5f366 100644 --- a/front/odiparpack/app/containers/Odipar/Camiones/CamionTab/table/CrudCamionTab.js +++ b/front/odiparpack/app/containers/Odipar/Camiones/CamionTab/table/CrudCamionTab.js @@ -19,8 +19,10 @@ import { } from '@material-ui/core'; import { anchorTable, dataApi } from './dataCamion'; import FormCamionTab from './FormCamionTab'; + //actions -import { getPedidos } from 'ba-actions/pedido'; +import { insertarCamion, editarCamion, eliminarCamion } from 'ba-actions/camion'; + const branch = 'crudCamion'; const renderRadioGroup = ({ input, ...rest }) => ( @@ -42,7 +44,7 @@ const styles = ({ class CrudCamionTab extends Component { render() { - //console.log("render ps") + //Obtenemos dataReal y getDataAPI const { classes, fetchData, @@ -59,16 +61,17 @@ class CrudCamionTab extends Component { title, dataReal, dispatch, - editingId + editingId, + getDataAPI } = this.props; - //console.log("render ps DATA", dataReal) - //console.log("original", dataApi) - return (
closeNotif(branch)} variant = "success" message={messageNotif} /> + {/* Enviamos dataReal como dataInit y getDataAPI. + También, mandamos addNewAPI, removeRowAPI, editRowAPI (con funciones de arriba "//actions") + */} - {/* Create Your own form, then arrange or custom it as You like */} - + {/* Create Your own form, then arrange or custom it as You like + ------------> OJO Mandamos dispatch + */} + {/* No need create button or submit, because that already made in this component */} diff --git a/front/odiparpack/app/containers/Odipar/Camiones/CamionTab/table/FormCamionTab.js b/front/odiparpack/app/containers/Odipar/Camiones/CamionTab/table/FormCamionTab.js index 25d107c..f98ae20 100644 --- a/front/odiparpack/app/containers/Odipar/Camiones/CamionTab/table/FormCamionTab.js +++ b/front/odiparpack/app/containers/Odipar/Camiones/CamionTab/table/FormCamionTab.js @@ -2,19 +2,17 @@ import React, { Component } from 'react'; import { withStyles } from '@material-ui/core/styles'; import PropTypes from 'prop-types'; import { Field } from 'redux-form/immutable'; -import {required, integer} from 'ba-api/validation' +import {required} from 'ba-api/validation' import { SelectRedux, - TextFieldRedux, - DatePickerRedux, - EstadoRedux + TextFieldRedux } from 'ba-components/Forms/ReduxFormMUI'; import { MenuItem, InputLabel, - FormControl, - Typography, + FormControl } from '@material-ui/core'; + import { getTipoCamiones } from 'ba-actions/tipoCamion'; const styles = ({ root: { @@ -34,25 +32,56 @@ const styles = ({ flexDirection: 'row' } }); - + +const tipoCamion = [ + { + id: 1, + nombre: "A", + capacidad: 90 + }, + { + id: 2, + nombre: "B", + capacidad: 45 + }, + { + id: 3, + nombre: "C", + capacidad: 30 + }, + { + id: 4, + nombre: "D", + capacidad: 30 + } +] + class FormCamionTab extends Component { + constructor (props) { + super(props) + this.state = { + comboTipos: [] + }; + this.props.dispatch(getTipoCamiones()).then((res) => { + if (res) { + this.setState({ + comboTipos: res.data? res.data : [] + }); + } + }) + } + + saveRef = ref => { this.ref = ref; return this.ref; }; - state = { - selectedDate: new Date(), - } - - handleDateChange = (date) => { - this.setState({ selectedDate: date }); - } render() { const { classes } = this.props; - const { selectedDate } = this.state; const trueBool = true; + const {comboTipos} = this.state return ( <>
@@ -75,8 +104,11 @@ class FormCamionTab extends Component { placeholder="Seleccionar" autoWidth={trueBool} > - A - B + {comboTipos.map((item,index) => { + return ( + {item.nombre} + ) + })}
diff --git a/front/odiparpack/app/containers/Odipar/Simulacion/SimulacionMain.js b/front/odiparpack/app/containers/Odipar/Simulacion/SimulacionMain.js index b9447d8..52d821f 100644 --- a/front/odiparpack/app/containers/Odipar/Simulacion/SimulacionMain.js +++ b/front/odiparpack/app/containers/Odipar/Simulacion/SimulacionMain.js @@ -1,8 +1,9 @@ import React, {Component} from "react"; import { Button, Divider, FormControl, Grid, InputLabel, MenuItem, Paper, Select, Typography } from "@material-ui/core"; import { withStyles } from '@material-ui/core/styles'; -import { Field, reduxForm } from "redux-form"; -import { SelectRedux } from 'ba-components/Forms/ReduxFormMUI'; +import { Link } from 'react-router-dom'; +import { reduxForm } from "redux-form"; + const styles = ({ root: { @@ -30,13 +31,9 @@ class SimulacionMain extends Component { tipo:'' } - changeTipo(tipo){ - this.setState({tipo: tipo}) - } - handleChange = event => { - this.setState({ [event.target.name]: event.target.value }); - }; + this.setState({ tipo: event.target.value }); + }; render() { const trueBool = true; @@ -56,27 +53,32 @@ class SimulacionMain extends Component {
- Tipo de simulación + Tipo de simulación
+ + +
-- cgit v1.2.3