diff options
Diffstat (limited to 'front/odiparpack/app/containers')
5 files changed, 114 insertions, 24 deletions
diff --git a/front/odiparpack/app/containers/App/index.js b/front/odiparpack/app/containers/App/index.js index a7313fe..ea78618 100644 --- a/front/odiparpack/app/containers/App/index.js +++ b/front/odiparpack/app/containers/App/index.js @@ -5,11 +5,51 @@ import Auth from './Auth'; import Application from './Application'; import LoginDedicated from '../Pages/Standalone/LoginDedicated'; import ThemeWrapper from './ThemeWrapper'; +import { Snackbar, Button, Icon } from '@material-ui/core'; +import { connect } from 'react-redux'; window.__MUI_USE_NEXT_TYPOGRAPHY_VARIANTS__ = true; -function App() { +function App(props) { + + const handleMessageClose = () => { + props.dispatch(closeMessage()) + } + + const { + openMessage = false, + message = '', + type = 'error' + } = props + return ( <ThemeWrapper> + <Snackbar + anchorOrigin={{ + vertical: 'top', + horizontal: 'right', + }} + open={openMessage} + autoHideDuration={6000} + onClose={handleMessageClose} + message={ + <div className="center-aligned-child"> + <Icon style={{ + fontSize: 20, + marginRight: 15 + }} > + {type === 'success' ? 'check_circle' : 'report_problem'} + </Icon> + {message} + </div> + } + action={[ + <Button key="undo" color="secondary" size="small" onClick={handleMessageClose}> + <Icon> + {'close'} + </Icon> + </Button> + ]} + /> <Switch> <Route path="/" exact component={LoginDedicated} /> <Route path="/app" component={Application} /> @@ -20,4 +60,20 @@ function App() { ); } -export default App; +const reducer = 'message'; +const mapStateToProps = state => ({ + force: state, // force state from reducer + message: state.getIn([reducer, 'message']), + type: state.getIn([reducer, 'type']), + openMessage: state.getIn([reducer, 'openMessage']) +}); + +const mapDispatchToProps = dispatch => ({ + dispatch: dispatch +}); +const AppMapped = connect( + mapStateToProps, + mapDispatchToProps +)(App); + +export default AppMapped; diff --git a/front/odiparpack/app/containers/Odipar/Pedidos/Pedidos.js b/front/odiparpack/app/containers/Odipar/Pedidos/Pedidos.js index c1539e0..a9baab8 100644 --- a/front/odiparpack/app/containers/Odipar/Pedidos/Pedidos.js +++ b/front/odiparpack/app/containers/Odipar/Pedidos/Pedidos.js @@ -3,7 +3,7 @@ import { withStyles } from '@material-ui/core/styles'; import PropTypes from 'prop-types'; import { CrudPedido } from './table' import { Paper, Typography } from '@material-ui/core'; -import { etiqueta } from 'ba-components/Odipar/common'; + const styles = ({ root: { flexGrow: 1, @@ -19,9 +19,6 @@ class Pedidos extends Component { <Typography variant="h4"> {`Pedidos`} </Typography> - <div> - {etiqueta("etiq_pedido", 1)} - </div> <div> <Paper className={classes.root}> <CrudPedido title = "Historial de Pedidos"/> diff --git a/front/odiparpack/app/containers/Odipar/Pedidos/table/CrudPedido.js b/front/odiparpack/app/containers/Odipar/Pedidos/table/CrudPedido.js index b11881f..d1fd553 100644 --- a/front/odiparpack/app/containers/Odipar/Pedidos/table/CrudPedido.js +++ b/front/odiparpack/app/containers/Odipar/Pedidos/table/CrudPedido.js @@ -19,7 +19,8 @@ import { } from '@material-ui/core'; import { anchorTable, dataApi } from './sampleData'; import FormPedido from './FormPedido'; - +//actions +import { setPedidos, getPedidos } from '../../../../actions/pedido'; const branch = 'crudPedido'; @@ -40,7 +41,25 @@ 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") const { classes, fetchData, @@ -56,6 +75,11 @@ class CrudPedido extends Component { messageNotif, title, } = this.props; + + const {dataReal} = this.state; + //console.log("render ps DATA", dataReal) + //console.log("original", dataApi) + return ( <div> <Notification close={() => closeNotif(branch)} message={messageNotif} /> @@ -63,7 +87,7 @@ class CrudPedido extends Component { <CrudTableForm dataTable={dataTable} openForm={openForm} - dataInit={dataApi} + dataInit={dataReal} anchor={anchorTable} title={title} fetchData={fetchData} @@ -112,6 +136,7 @@ const mapStateToProps = state => ({ dataTable: state.getIn([branch, 'dataTable']), openForm: state.getIn([branch, 'showFrm']), messageNotif: state.getIn([branch, 'notifMsg']), + pedidosLista : state.getIn(['pedido','pedidos']), }); const mapDispatchToProps = dispatch => ({ @@ -122,6 +147,7 @@ const mapDispatchToProps = dispatch => ({ removeRow: bindActionCreators(removeAction, dispatch), editRow: bindActionCreators(editAction, dispatch), closeNotif: bindActionCreators(closeNotifAction, dispatch), + dispatch }); const CrudPedidoMapped = connect( diff --git a/front/odiparpack/app/containers/Odipar/Pedidos/table/sampleData.js b/front/odiparpack/app/containers/Odipar/Pedidos/table/sampleData.js index 2e2b003..e16f7cc 100644 --- a/front/odiparpack/app/containers/Odipar/Pedidos/table/sampleData.js +++ b/front/odiparpack/app/containers/Odipar/Pedidos/table/sampleData.js @@ -4,10 +4,10 @@ export const anchorTable = [ label: 'Id', initialValue: '', hidden: true, - type: 'texto' }, { name: 'cantidad', label: 'Cantidad', + initialValue: 0, width: 'auto', hidden: false, type: 'texto' @@ -21,28 +21,28 @@ export const anchorTable = [ }, { name: 'origen', label: 'Origen', - initialValue: 'option1', + initialValue: 'Lima', width: 'auto', hidden: false, type: 'texto' }, { name: 'destino', label: 'Destino', - initialValue: 'option1', + initialValue: 'Lima', width: 'auto', hidden: false, type: 'texto' }, { name: 'plazo_entrega', label: 'Plazo de entrega', - initialValue: true, + initialValue: 'aja', width: 'auto', hidden: false, type: 'texto' }, { name: 'nombre', label: 'Cliente', - initialValue: true, + initialValue: null, width: 'auto', hidden: false, type: 'texto' @@ -53,7 +53,8 @@ export const anchorTable = [ width: 'auto', hidden: false, type: 'etiq_pedido' - }, { + }, + { name: 'action', label: 'Action', initialValue: '', @@ -65,8 +66,9 @@ export const dataApi = [ { id: '1', cantidad: 30, - fecha: '24/05/2022 11:28 AM', + origen: 'Arequipa', + fecha: '24/05/2022 11:28 AM', destino: 'Cuzco', plazo_entrega: '24 horas', nombre: 'Juan', diff --git a/front/odiparpack/app/containers/Tables/demos/sampleData.js b/front/odiparpack/app/containers/Tables/demos/sampleData.js index d53d8e2..c783c81 100644 --- a/front/odiparpack/app/containers/Tables/demos/sampleData.js +++ b/front/odiparpack/app/containers/Tables/demos/sampleData.js @@ -9,53 +9,62 @@ export const anchorTable = [ label: 'Text Field', initialValue: null, width: 'auto', - hidden: false + hidden: false, + type:"texto" }, { name: 'email', label: 'Email Field', initialValue: null, width: 'auto', - hidden: false + hidden: false, + type:"texto" }, { name: 'radio', label: 'Radio Option', initialValue: 'option1', width: '80', - hidden: false + hidden: false, + type:"texto" }, { name: 'selection', label: 'Selection', initialValue: 'option1', width: '80', - hidden: false + hidden: false, + type:"texto" }, { name: 'onof', label: 'On/Of Input', initialValue: true, width: '80', - hidden: false + hidden: false, + type:"texto" }, { name: 'checkbox', label: 'Checkbox', initialValue: true, width: '80', - hidden: false + hidden: false, + type:"texto" }, { name: 'textarea', label: 'Text Area', initialValue: 'This is default text', width: 'auto', - hidden: false + hidden: false, + type:"texto" }, { name: 'edited', label: '', initialValue: '', - hidden: true + hidden: true, + type:"texto" }, { name: 'action', label: 'Action', initialValue: '', - hidden: false + hidden: false, + type:"texto" }, ]; |
