summaryrefslogtreecommitdiffstats
path: root/front/odiparpack/app/containers/Odipar/Camiones
diff options
context:
space:
mode:
authorgabrhr <[email protected]>2022-06-06 11:35:56 -0500
committergabrhr <[email protected]>2022-06-06 11:35:56 -0500
commitfab7d63333b86b9fe0f1c52d2c642b52bbf506c0 (patch)
tree59e3541bbe92c67fdf54bc0ef6efabb0a4fe1d6c /front/odiparpack/app/containers/Odipar/Camiones
parent3a91d18704ee5ac783b398b1589ee2b14ea35321 (diff)
downloadDP1_project-fab7d63333b86b9fe0f1c52d2c642b52bbf506c0.tar.gz
DP1_project-fab7d63333b86b9fe0f1c52d2c642b52bbf506c0.tar.bz2
DP1_project-fab7d63333b86b9fe0f1c52d2c642b52bbf506c0.zip
Add CRUD Camiones
- 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
Diffstat (limited to 'front/odiparpack/app/containers/Odipar/Camiones')
-rw-r--r--front/odiparpack/app/containers/Odipar/Camiones/CamionTab/CamionTab.js7
-rw-r--r--front/odiparpack/app/containers/Odipar/Camiones/CamionTab/table/CrudCamionTab.js28
-rw-r--r--front/odiparpack/app/containers/Odipar/Camiones/CamionTab/table/FormCamionTab.js66
3 files changed, 69 insertions, 32 deletions
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 (
-
- <CrudCamionTab title = "Listado de Camiones" dataReal={dataRealF}/>
+ //Mandamos la lista(dataRealF) y la funcion del GET
+ <CrudCamionTab title = "Listado de Camiones" dataReal={dataRealF} getDataAPI={getCamiones}/>
);
}
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 (
<div>
<Notification close={() => closeNotif(branch)} variant = "success" message={messageNotif} />
<Paper className={classes.root}>
+ {/* Enviamos dataReal como dataInit y getDataAPI.
+ También, mandamos addNewAPI, removeRowAPI, editRowAPI (con funciones de arriba "//actions")
+ */}
<CrudTableForm
dataTable={dataTable}
openForm={openForm}
@@ -83,14 +86,17 @@ class CrudCamionTab extends Component {
editRow={editRow}
branch={branch}
initValues={initValues}
- addNewAPI={getPedidos}
- removeRowAPI={getPedidos}
- editRowAPI={getPedidos}
+ getDataAPI = {getDataAPI}
+ addNewAPI={insertarCamion}
+ removeRowAPI={eliminarCamion}
+ editRowAPI={editarCamion}
dispatch = {dispatch}
editingId = {editingId}
>
- {/* Create Your own form, then arrange or custom it as You like */}
- <FormCamionTab/>
+ {/* Create Your own form, then arrange or custom it as You like
+ ------------> OJO Mandamos dispatch
+ */}
+ <FormCamionTab dispatch = {dispatch}/>
{/* No need create button or submit, because that already made in this component */}
</CrudTableForm>
</Paper>
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 (
<>
<div>
@@ -75,8 +104,11 @@ class FormCamionTab extends Component {
placeholder="Seleccionar"
autoWidth={trueBool}
>
- <MenuItem value="A">A</MenuItem>
- <MenuItem value="B">B</MenuItem>
+ {comboTipos.map((item,index) => {
+ return (
+ <MenuItem value={item.nombre}>{item.nombre}</MenuItem>
+ )
+ })}
</Field>
</FormControl>
</div>