diff options
| author | gabrhr <[email protected]> | 2022-05-30 20:08:04 -0500 |
|---|---|---|
| committer | gabrhr <[email protected]> | 2022-05-30 20:08:04 -0500 |
| commit | 32fb17de8f78317b165b6f269a8bab2d4e852d0d (patch) | |
| tree | 2de1643fcda13cc5c9c0f28ffcb7a7211d9e2922 /front/odiparpack/app/containers/Odipar | |
| parent | 9c396976bb42a9d41407358ce1a1d37242230f21 (diff) | |
| download | DP1_project-32fb17de8f78317b165b6f269a8bab2d4e852d0d.tar.gz DP1_project-32fb17de8f78317b165b6f269a8bab2d4e852d0d.tar.bz2 DP1_project-32fb17de8f78317b165b6f269a8bab2d4e852d0d.zip | |
Fix axios and add new
- FIX logica de aƱadiir (ok)
- FIX axios y dispatch fuera de un componente (ok)
- Cambiar las notificaciones
Diffstat (limited to 'front/odiparpack/app/containers/Odipar')
3 files changed, 52 insertions, 24 deletions
diff --git a/front/odiparpack/app/containers/Odipar/Pedidos/Pedidos.js b/front/odiparpack/app/containers/Odipar/Pedidos/Pedidos.js index a9baab8..27adce5 100644 --- a/front/odiparpack/app/containers/Odipar/Pedidos/Pedidos.js +++ b/front/odiparpack/app/containers/Odipar/Pedidos/Pedidos.js @@ -3,6 +3,11 @@ 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'; + +// +import { getPedidos } from 'ba-actions/pedido'; +import pedido from '../../../redux/modules/pedido'; const styles = ({ root: { @@ -12,7 +17,25 @@ const styles = ({ }); 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> @@ -21,7 +44,7 @@ class Pedidos extends Component { </Typography> <div> <Paper className={classes.root}> - <CrudPedido title = "Historial de Pedidos"/> + <CrudPedido title = "Historial de Pedidos" dataReal={dataRealF}/> </Paper> </div> </div> @@ -33,4 +56,19 @@ Pedidos.propTypes = { classes: PropTypes.object.isRequired, }; -export default withStyles(styles)(Pedidos);
\ No newline at end of file +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 index d1fd553..c7a7a58 100644 --- a/front/odiparpack/app/containers/Odipar/Pedidos/table/CrudPedido.js +++ b/front/odiparpack/app/containers/Odipar/Pedidos/table/CrudPedido.js @@ -20,8 +20,7 @@ import { import { anchorTable, dataApi } from './sampleData'; import FormPedido from './FormPedido'; //actions -import { setPedidos, getPedidos } from '../../../../actions/pedido'; - +import { getPedidos } from '../../../../actions/pedido'; const branch = 'crudPedido'; const renderRadioGroup = ({ input, ...rest }) => ( @@ -41,25 +40,9 @@ const styles = ({ }); class CrudPedido extends Component { - constructor (props) { - super(props) - this.state = { - dataReal: [] - }; - - this.props.dispatch(getPedidos()) - .then( res => { - console.log("aqui en el then ps", res) - this.setState({ - dataReal: res - }) - }) - console.log("aqui en el then ps 2", this.props.pedidosLista) - - } render() { - console.log("render ps") + //console.log("render ps") const { classes, fetchData, @@ -74,15 +57,17 @@ class CrudPedido extends Component { closeNotif, messageNotif, title, + dataReal, + dispatch, + editingId } = this.props; - const {dataReal} = this.state; //console.log("render ps DATA", dataReal) //console.log("original", dataApi) return ( <div> - <Notification close={() => closeNotif(branch)} message={messageNotif} /> + <Notification close={() => closeNotif(branch)} variant = "success" message={messageNotif} /> <Paper className={classes.root}> <CrudTableForm dataTable={dataTable} @@ -98,6 +83,11 @@ class CrudPedido extends Component { 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/> @@ -136,6 +126,7 @@ const mapStateToProps = state => ({ 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']), }); diff --git a/front/odiparpack/app/containers/Odipar/Pedidos/table/sampleData.js b/front/odiparpack/app/containers/Odipar/Pedidos/table/sampleData.js index e16f7cc..3a7556c 100644 --- a/front/odiparpack/app/containers/Odipar/Pedidos/table/sampleData.js +++ b/front/odiparpack/app/containers/Odipar/Pedidos/table/sampleData.js @@ -66,7 +66,6 @@ export const dataApi = [ { id: '1', cantidad: 30, - origen: 'Arequipa', fecha: '24/05/2022 11:28 AM', destino: 'Cuzco', |
