diff options
Diffstat (limited to 'front/odiparpack/app/containers/Odipar')
10 files changed, 913 insertions, 0 deletions
diff --git a/front/odiparpack/app/containers/Odipar/Almacen/Almacenes.js b/front/odiparpack/app/containers/Odipar/Almacen/Almacenes.js new file mode 100644 index 0000000..31a3039 --- /dev/null +++ b/front/odiparpack/app/containers/Odipar/Almacen/Almacenes.js @@ -0,0 +1,66 @@ +import React, { Component } from 'react'; +import { withStyles } from '@material-ui/core/styles'; +import PropTypes from 'prop-types'; +import { CrudAlmacen } from './table' +import { Paper, Typography } from '@material-ui/core'; +import { connect } from 'react-redux'; + +//actions +import { getAlmacenes } from '../../../actions/almacen'; + +const styles = ({ + root: { + flexGrow: 1, + marginTop: 30, + } + }); + +class Almacenes extends Component { + constructor (props) { + super(props) + this.state = { + dataRealF: [] + }; + this.props.dispatch(getAlmacenes()).then((res) => { + if (res) { + this.setState({ + dataRealF: res.data, + }); + } + }) + //console.log("Pedido - LUEGO DE THEN ", this.state.dataRealF) + } + + + render() { + const {dataRealF} = this.state; + //console.log ("aNTESZSSSS?") + const { classes } = this.props; + return ( + <div> + <Typography variant="h4"> + {`Almacenes`} + </Typography> + <div> + <Paper className={classes.root}> + <CrudAlmacen title = "Lista de Almacenes" dataReal={dataRealF}/> + </Paper> + </div> + </div> + ); + } +} + +Almacenes.propTypes = { + classes: PropTypes.object.isRequired, +}; + +const mapDispatchToProps = dispatch => ({ + dispatch +}); + +const AlmacenesMapped = connect( + mapDispatchToProps +)(Almacenes); + +export default withStyles(styles)(AlmacenesMapped);
\ No newline at end of file diff --git a/front/odiparpack/app/containers/Odipar/Almacen/table/CrudAlmacen.js b/front/odiparpack/app/containers/Odipar/Almacen/table/CrudAlmacen.js new file mode 100644 index 0000000..887d603 --- /dev/null +++ b/front/odiparpack/app/containers/Odipar/Almacen/table/CrudAlmacen.js @@ -0,0 +1,148 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import { withStyles } from '@material-ui/core/styles'; +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; +import { + fetchAction, + addAction, + closeAction, + submitAction, + removeAction, + editAction, + closeNotifAction +} from 'ba-actions/CrudTbFrmActions'; +import { CrudTableForm, Notification } from 'ba-components'; +import { + Paper, + RadioGroup, +} from '@material-ui/core'; +import { anchorTable, dataApi } from './dataAlmacen'; +import FormAlmacen from './FormAlmacen'; +//actions +import { getPedidos } from '../../../../actions/pedido'; +const branch = 'crudAlmacen'; + +const renderRadioGroup = ({ input, ...rest }) => ( + <RadioGroup + {...input} + {...rest} + valueselected={input.value} + onChange={(event, value) => input.onChange(value)} + /> +); + + +const styles = ({ + root: { + flexGrow: 1, + } +}); + +class CrudAlmacen extends Component { + render() { + //console.log("render ps") + const { + classes, + fetchData, + addNew, + closeForm, + submit, + removeRow, + editRow, + dataTable, + openForm, + initValues, + closeNotif, + messageNotif, + title, + dataReal, + dispatch, + editingId + } = this.props; + + //console.log("render ps DATA", dataReal) + //console.log("original", dataApi) + //console.log("original", anchorTable) + + return ( + <div> + <Notification close={() => closeNotif(branch)} variant = "success" message={messageNotif} /> + <Paper className={classes.root}> + <CrudTableForm + dataTable={dataTable} + openForm={openForm} + dataInit={dataReal} + anchor={anchorTable} + title={title} + fetchData={fetchData} + addNew={addNew} + closeForm={closeForm} + submit={submit} + removeRow={removeRow} + editRow={editRow} + branch={branch} + initValues={initValues} + addNewAPI={getPedidos} + removeRowAPI={getPedidos} + editRowAPI={getPedidos} + dispatch = {dispatch} + editingId = {editingId} + > + {/* Create Your own form, then arrange or custom it as You like */} + <FormAlmacen/> + {/* No need create button or submit, because that already made in this component */} + </CrudTableForm> + </Paper> + </div> + ); + } +} + +renderRadioGroup.propTypes = { + input: PropTypes.object.isRequired, +}; + +CrudAlmacen.propTypes = { + dataTable: PropTypes.object.isRequired, + openForm: PropTypes.bool.isRequired, + classes: PropTypes.object.isRequired, + fetchData: PropTypes.func.isRequired, + addNew: PropTypes.func.isRequired, + closeForm: PropTypes.func.isRequired, + submit: PropTypes.func.isRequired, + removeRow: PropTypes.func.isRequired, + editRow: PropTypes.func.isRequired, + initValues: PropTypes.object.isRequired, + closeNotif: PropTypes.func.isRequired, + messageNotif: PropTypes.string.isRequired, + title: PropTypes.string.isRequired, +}; + + +const mapStateToProps = state => ({ + force: state, // force state from reducer + initValues: state.getIn([branch, 'formValues']), + dataTable: state.getIn([branch, 'dataTable']), + openForm: state.getIn([branch, 'showFrm']), + messageNotif: state.getIn([branch, 'notifMsg']), + editingId: state.getIn([branch, 'editingId']), +}); + +const mapDispatchToProps = dispatch => ({ + fetchData: bindActionCreators(fetchAction, dispatch), + addNew: bindActionCreators(addAction, dispatch), + closeForm: bindActionCreators(closeAction, dispatch), + submit: bindActionCreators(submitAction, dispatch), + removeRow: bindActionCreators(removeAction, dispatch), + editRow: bindActionCreators(editAction, dispatch), + closeNotif: bindActionCreators(closeNotifAction, dispatch), + dispatch +}); + +const CrudAlmacenMapped = connect( + mapStateToProps, + mapDispatchToProps +)(CrudAlmacen); + +export default withStyles(styles)(CrudAlmacenMapped); diff --git a/front/odiparpack/app/containers/Odipar/Almacen/table/FormAlmacen.js b/front/odiparpack/app/containers/Odipar/Almacen/table/FormAlmacen.js new file mode 100644 index 0000000..05cfda7 --- /dev/null +++ b/front/odiparpack/app/containers/Odipar/Almacen/table/FormAlmacen.js @@ -0,0 +1,124 @@ +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 { + SelectRedux, + TextFieldRedux +} from 'ba-components/Forms/ReduxFormMUI'; +import { + MenuItem, + InputLabel, + FormControl, + } from '@material-ui/core'; + +const styles = ({ + root: { + flexGrow: 1, + }, + field: { + width: '100%', + marginBottom: 20 + }, + fieldBasic: { + width: '100%', + marginBottom: 20, + marginTop: 10 + }, + inlineWrap: { + display: 'flex', + flexDirection: 'row' + } + }); + + +class FormAlmacen extends Component { + saveRef = ref => { + this.ref = ref; + return this.ref; + }; + + render() { + const { classes } = this.props; + const trueBool = true; + return ( + <> + <div> + <FormControl className={classes.field}> + <InputLabel htmlFor="selection">Tipo de Almacen</InputLabel> + <Field + name="esPrincipal" + component={SelectRedux} + placeholder="Seleccionar" + autoWidth={trueBool} + > + <MenuItem value={true}>Principal</MenuItem> + <MenuItem value={false}>Pequeño</MenuItem> + </Field> + </FormControl> + </div> + <div> + <FormControl className={classes.field}> + <InputLabel htmlFor="selection">Region</InputLabel> + <Field + name="region" + component={SelectRedux} + placeholder="Seleccionar" + autoWidth={trueBool} + > + <MenuItem value="Costa">Costa</MenuItem> + <MenuItem value="Sierra">Sierra</MenuItem> + <MenuItem value="Selva">Selva</MenuItem> + </Field> + </FormControl> + </div> + <div> + <FormControl className={classes.field}> + <InputLabel htmlFor="selection">Provincia</InputLabel> + <Field + name="provincia" + component={SelectRedux} + placeholder="Seleccionar" + autoWidth={trueBool} + > + <MenuItem value="Lima">Lima</MenuItem> + <MenuItem value="Arequipa">Arequipa</MenuItem> + <MenuItem value="Cuzco">Cuzco</MenuItem> + </Field> + </FormControl> + </div> + <div> + <Field + name="latitud" + component={TextFieldRedux} + placeholder="Latitud" + label="Latitud de Provincia" + validate={required} + disabled + required + ref={this.saveRef} + className={classes.field} + /> + <Field + name="longitud" + component={TextFieldRedux} + placeholder="Longitud" + label="Longitud de Provincia" + validate={required} + disabled + required + ref={this.saveRef} + className={classes.field} + /> + </div> + </> + ); + } +} + +FormAlmacen.propTypes = { + classes: PropTypes.object.isRequired, + }; + +export default withStyles(styles)(FormAlmacen);
\ No newline at end of file diff --git a/front/odiparpack/app/containers/Odipar/Almacen/table/dataAlmacen.js b/front/odiparpack/app/containers/Odipar/Almacen/table/dataAlmacen.js new file mode 100644 index 0000000..685df27 --- /dev/null +++ b/front/odiparpack/app/containers/Odipar/Almacen/table/dataAlmacen.js @@ -0,0 +1,75 @@ +export const anchorTable = [ + { + name: 'id', + label: 'Identificador', + initialValue: '', + hidden: false, + type: 'texto' + }, { + name: 'esPrincipal', + label: 'Tipo de Almacen', + initialValue: true, + width: 'auto', + hidden: false, + type: 'etiq_alma' + }, { + name: 'region', + label: 'Region', + initialValue: 'Costa', + width: 'auto', + hidden: false, + type: 'texto' + }, { + name: 'provincia', + label: 'Provincia', + initialValue: 'Lima', + width: 'auto', + hidden: false, + type: 'texto' + }, { + name: 'latitud', + label: 'Latitud', + initialValue: 0, + width: 'auto', + hidden: false, + type: 'texto' + }, { + name: 'longitud', + label: 'Longitud', + initialValue: 0, + width: 'auto', + hidden: false, + type: 'texto' + }, + { + name: 'action', + label: 'Acciones', + initialValue: '', + hidden: false + }, +]; + +export const dataApi = [ + { + id: '1', + esPrincipal: false, + region: 'Costa', + provincia: 'Arequipa', + latitud: 24, + longitud: 50, + estado: 0, + correo: '[email protected]', + dni: '123456' + }, { + id: '2', + esPrincipal: true, + region: 'Costa', + provincia: 'Lima', + latitud: 24, + longitud: 50, + nombre: 'Juan', + estado: 1, + correo: '[email protected]', + dni: '123456' + } +]; diff --git a/front/odiparpack/app/containers/Odipar/Almacen/table/index.js b/front/odiparpack/app/containers/Odipar/Almacen/table/index.js new file mode 100644 index 0000000..38d22f6 --- /dev/null +++ b/front/odiparpack/app/containers/Odipar/Almacen/table/index.js @@ -0,0 +1 @@ +export CrudAlmacen from "./CrudAlmacen";
\ No newline at end of file diff --git a/front/odiparpack/app/containers/Odipar/Pedidos/Pedidos.js b/front/odiparpack/app/containers/Odipar/Pedidos/Pedidos.js new file mode 100644 index 0000000..f617458 --- /dev/null +++ b/front/odiparpack/app/containers/Odipar/Pedidos/Pedidos.js @@ -0,0 +1,73 @@ +import React, { Component } from 'react'; +import { withStyles } from '@material-ui/core/styles'; +import PropTypes from 'prop-types'; +import { CrudPedido } from './table' +import { Paper, Typography } from '@material-ui/core'; +import { connect } from 'react-redux'; + +//actions +import { getPedidos } from 'ba-actions/pedido'; + +const styles = ({ + root: { + flexGrow: 1, + marginTop: 30, + } + }); + +class Pedidos extends Component { + constructor (props) { + super(props) + this.state = { + dataRealF: [] + }; + this.props.dispatch(getPedidos()).then((res) => { + if (res) { + this.setState({ + dataRealF: res.data, + }); + } + }) + //console.log("Pedido - LUEGO DE THEN ", this.state.dataRealF) + } + + + render() { + const {dataRealF} = this.state; + //console.log ("aNTESZSSSS?", pedidosLista) + const { classes } = this.props; + return ( + <div> + <Typography variant="h4"> + {`Pedidos`} + </Typography> + <div> + <Paper className={classes.root}> + <CrudPedido title = "Historial de Pedidos" dataReal={dataRealF}/> + </Paper> + </div> + </div> + ); + } +} + +Pedidos.propTypes = { + classes: PropTypes.object.isRequired, +}; + +const reducer = 'pedido' +const mapStateToProps = state => ({ + force: state, // force state from reducer + pedidosLista : state.getIn([reducer]), +}); + +const mapDispatchToProps = dispatch => ({ + dispatch +}); + +const PedidosMapped = connect( + mapStateToProps, + mapDispatchToProps +)(Pedidos); + +export default withStyles(styles)(PedidosMapped);
\ No newline at end of file diff --git a/front/odiparpack/app/containers/Odipar/Pedidos/table/CrudPedido.js b/front/odiparpack/app/containers/Odipar/Pedidos/table/CrudPedido.js new file mode 100644 index 0000000..c7a7a58 --- /dev/null +++ b/front/odiparpack/app/containers/Odipar/Pedidos/table/CrudPedido.js @@ -0,0 +1,149 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import { withStyles } from '@material-ui/core/styles'; +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; +import { + fetchAction, + addAction, + closeAction, + submitAction, + removeAction, + editAction, + closeNotifAction +} from 'ba-actions/CrudTbFrmActions'; +import { CrudTableForm, Notification } from 'ba-components'; +import { + Paper, + RadioGroup, +} from '@material-ui/core'; +import { anchorTable, dataApi } from './sampleData'; +import FormPedido from './FormPedido'; +//actions +import { getPedidos } from '../../../../actions/pedido'; +const branch = 'crudPedido'; + +const renderRadioGroup = ({ input, ...rest }) => ( + <RadioGroup + {...input} + {...rest} + valueselected={input.value} + onChange={(event, value) => input.onChange(value)} + /> +); + + +const styles = ({ + root: { + flexGrow: 1, + } +}); + +class CrudPedido extends Component { + + render() { + //console.log("render ps") + const { + classes, + fetchData, + addNew, + closeForm, + submit, + removeRow, + editRow, + dataTable, + openForm, + initValues, + closeNotif, + messageNotif, + title, + dataReal, + dispatch, + editingId + } = 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}> + <CrudTableForm + dataTable={dataTable} + openForm={openForm} + dataInit={dataReal} + anchor={anchorTable} + title={title} + fetchData={fetchData} + addNew={addNew} + closeForm={closeForm} + submit={submit} + removeRow={removeRow} + editRow={editRow} + branch={branch} + initValues={initValues} + addNewAPI={getPedidos} + removeRowAPI={getPedidos} + editRowAPI={getPedidos} + dispatch = {dispatch} + editingId = {editingId} + > + {/* Create Your own form, then arrange or custom it as You like */} + <FormPedido/> + {/* No need create button or submit, because that already made in this component */} + </CrudTableForm> + </Paper> + </div> + ); + } +} + +renderRadioGroup.propTypes = { + input: PropTypes.object.isRequired, +}; + +CrudPedido.propTypes = { + dataTable: PropTypes.object.isRequired, + openForm: PropTypes.bool.isRequired, + classes: PropTypes.object.isRequired, + fetchData: PropTypes.func.isRequired, + addNew: PropTypes.func.isRequired, + closeForm: PropTypes.func.isRequired, + submit: PropTypes.func.isRequired, + removeRow: PropTypes.func.isRequired, + editRow: PropTypes.func.isRequired, + initValues: PropTypes.object.isRequired, + closeNotif: PropTypes.func.isRequired, + messageNotif: PropTypes.string.isRequired, + title: PropTypes.string.isRequired, +}; + + +const mapStateToProps = state => ({ + force: state, // force state from reducer + initValues: state.getIn([branch, 'formValues']), + dataTable: state.getIn([branch, 'dataTable']), + openForm: state.getIn([branch, 'showFrm']), + messageNotif: state.getIn([branch, 'notifMsg']), + editingId: state.getIn([branch, 'editingId']), + pedidosLista : state.getIn(['pedido','pedidos']), +}); + +const mapDispatchToProps = dispatch => ({ + fetchData: bindActionCreators(fetchAction, dispatch), + addNew: bindActionCreators(addAction, dispatch), + closeForm: bindActionCreators(closeAction, dispatch), + submit: bindActionCreators(submitAction, dispatch), + removeRow: bindActionCreators(removeAction, dispatch), + editRow: bindActionCreators(editAction, dispatch), + closeNotif: bindActionCreators(closeNotifAction, dispatch), + dispatch +}); + +const CrudPedidoMapped = connect( + mapStateToProps, + mapDispatchToProps +)(CrudPedido); + +export default withStyles(styles)(CrudPedidoMapped); diff --git a/front/odiparpack/app/containers/Odipar/Pedidos/table/FormPedido.js b/front/odiparpack/app/containers/Odipar/Pedidos/table/FormPedido.js new file mode 100644 index 0000000..548f47b --- /dev/null +++ b/front/odiparpack/app/containers/Odipar/Pedidos/table/FormPedido.js @@ -0,0 +1,186 @@ +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 { + SelectRedux, + TextFieldRedux, + DatePickerRedux, + EstadoRedux +} from 'ba-components/Forms/ReduxFormMUI'; +import { + MenuItem, + InputLabel, + FormControl, + Typography, + } from '@material-ui/core'; + +const styles = ({ + root: { + flexGrow: 1, + }, + field: { + width: '100%', + marginBottom: 20 + }, + fieldBasic: { + width: '100%', + marginBottom: 20, + marginTop: 10 + }, + inlineWrap: { + display: 'flex', + flexDirection: 'row' + } + }); + + +class FormPedido extends Component { + 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; + return ( + <> + <Typography variant="h5"> + {`Datos de Pedido`} + </Typography> + <div> + <Field + name="cantidad" + component={TextFieldRedux} + placeholder="Cantidad paquetes A" + label="Cantidad de Paquetes A" + type = {'number'} + validate={[required, integer]} + required + ref={this.saveRef} + className={classes.field} + /> + </div> + <div> + <FormControl className={classes.field}> + <Field + name = "fecha" + component={DatePickerRedux} + label="Fecha de Registro" + readonly= {true} + /> + </FormControl> + </div> + <div> + <InputLabel htmlFor="selection" style={{fontSize:12.5, marginBottom: 5}}>Estado</InputLabel> + <Field + name = "estado" + component={EstadoRedux} + /> + + </div> + <Typography variant="h5" style={{marginTop: 5}}> + {`Datos de Entrega`} + </Typography> + <div> + <FormControl className={classes.field}> + <InputLabel htmlFor="selection">Origen</InputLabel> + <Field + name="origen" + component={SelectRedux} + placeholder="Seleccionar" + autoWidth={trueBool} + > + <MenuItem value="Lima">Lima</MenuItem> + <MenuItem value="Arequipa">Arequipa</MenuItem> + <MenuItem value="Cuzco">Cuzco</MenuItem> + </Field> + </FormControl> + </div> + <div> + <FormControl className={classes.field}> + <InputLabel htmlFor="selection">Destino</InputLabel> + <Field + name="destino" + component={SelectRedux} + placeholder="Seleccionar" + autoWidth={trueBool} + > + <MenuItem value="Lima">Lima</MenuItem> + <MenuItem value="Arequipa">Arequipa</MenuItem> + <MenuItem value="Cuzco">Cuzco</MenuItem> + </Field> + </FormControl> + </div> + <div> + <Field + name="plazo_entrega" + component={TextFieldRedux} + placeholder="Plazo entrega" + label="Plazo de Entrega" + ref={this.saveRef} + disabled + className={classes.field} + /> + </div> + + <Typography variant="h5"> + {`Datos de Cliente`} + </Typography> + + <div> + <Field + name="nombre" + component={TextFieldRedux} + placeholder="Ingrese el nombre" + label="Nombre del Cliente" + validate={required} + required + ref={this.saveRef} + className={classes.field} + /> + </div> + <div> + <Field + name="dni" + component={TextFieldRedux} + placeholder="Ingrese el RUC" + label="RUC del Cliente" + validate={required} + required + ref={this.saveRef} + className={classes.field} + /> + </div> + <div> + <Field + name="correo" + component={TextFieldRedux} + placeholder="Ingrese el correo" + label="Correo del Cliente" + validate={required} + required + ref={this.saveRef} + className={classes.field} + /> + </div> + </> + ); + } +} + +FormPedido.propTypes = { + classes: PropTypes.object.isRequired, + }; + +export default withStyles(styles)(FormPedido);
\ No newline at end of file diff --git a/front/odiparpack/app/containers/Odipar/Pedidos/table/index.js b/front/odiparpack/app/containers/Odipar/Pedidos/table/index.js new file mode 100644 index 0000000..48f7c9e --- /dev/null +++ b/front/odiparpack/app/containers/Odipar/Pedidos/table/index.js @@ -0,0 +1 @@ +export CrudPedido from "./CrudPedido";
\ No newline at end of file diff --git a/front/odiparpack/app/containers/Odipar/Pedidos/table/sampleData.js b/front/odiparpack/app/containers/Odipar/Pedidos/table/sampleData.js new file mode 100644 index 0000000..4972669 --- /dev/null +++ b/front/odiparpack/app/containers/Odipar/Pedidos/table/sampleData.js @@ -0,0 +1,90 @@ +export const anchorTable = [ + { + name: 'id', + label: 'Identificador', + initialValue: '', + hidden: false, + type: 'texto' + }, { + name: 'cantidad', + label: 'Cantidad', + initialValue: 0, + width: 'auto', + hidden: false, + type: 'texto' + }, { + name: 'fecha', + label: 'Fecha de pedido', + initialValue: new Date(), + width: 'auto', + hidden: false, + type: 'texto' + }, { + name: 'origen', + label: 'Origen', + initialValue: 'Lima', + width: 'auto', + hidden: false, + type: 'texto' + }, { + name: 'destino', + label: 'Destino', + initialValue: 'Lima', + width: 'auto', + hidden: false, + type: 'texto' + }, { + name: 'plazo_entrega', + label: 'Plazo de entrega', + initialValue: 'aja', + width: 'auto', + hidden: false, + type: 'texto' + }, { + name: 'nombre', + label: 'Cliente', + initialValue: null, + width: 'auto', + hidden: false, + type: 'texto' + }, { + name: 'estado', + label: 'Estado', + initialValue: 0, + width: 'auto', + hidden: false, + type: 'etiq_pedido' + }, + { + name: 'action', + label: 'Action', + initialValue: '', + hidden: false + }, +]; + +export const dataApi = [ + { + id: '1', + cantidad: 30, + origen: 'Arequipa', + fecha: '24/05/2022 11:28 AM', + destino: 'Cuzco', + plazo_entrega: '24 horas', + nombre: 'Juan', + estado: 0, + correo: '[email protected]', + dni: '123456' + }, { + id: '2', + cantidad: 30, + fecha: '24/05/2022 10:28 AM', + origen: 'Lima', + destino: 'Cuzco', + plazo_entrega: '24 horas', + nombre: 'Juan', + estado: 1, + correo: '[email protected]', + dni: '123456' + } +]; |
