summaryrefslogtreecommitdiffstats
path: root/front/odiparpack/app/containers/Odipar/Almacen
diff options
context:
space:
mode:
Diffstat (limited to 'front/odiparpack/app/containers/Odipar/Almacen')
-rw-r--r--front/odiparpack/app/containers/Odipar/Almacen/Almacenes.js66
-rw-r--r--front/odiparpack/app/containers/Odipar/Almacen/table/CrudAlmacen.js148
-rw-r--r--front/odiparpack/app/containers/Odipar/Almacen/table/FormAlmacen.js124
-rw-r--r--front/odiparpack/app/containers/Odipar/Almacen/table/dataAlmacen.js75
-rw-r--r--front/odiparpack/app/containers/Odipar/Almacen/table/index.js1
5 files changed, 414 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