diff options
| author | gabrhr <[email protected]> | 2022-05-27 12:50:13 -0500 |
|---|---|---|
| committer | gabrhr <[email protected]> | 2022-05-27 12:50:13 -0500 |
| commit | 9c396976bb42a9d41407358ce1a1d37242230f21 (patch) | |
| tree | 41b5fdf7d321f70c7e39bb788ef6ce0db6b4a6e3 /front/odiparpack/app/containers/App/index.js | |
| parent | 55c0f57d42d82f1f1f5809e9c7d6845b6e0b68af (diff) | |
| download | DP1_project-9c396976bb42a9d41407358ce1a1d37242230f21.tar.gz DP1_project-9c396976bb42a9d41407358ce1a1d37242230f21.tar.bz2 DP1_project-9c396976bb42a9d41407358ce1a1d37242230f21.zip | |
Add redux, dispatch and etiquetas
- estetica de etiquetas (ok)
- add message, pedido Reducer
- add dispatch en Componentes con connect
- add api reducer que obtienen el JSON todo ok
#TODO
- FIX logica de aƱadiir
- FIX axios y dispatch fuera de un componente
Diffstat (limited to 'front/odiparpack/app/containers/App/index.js')
| -rw-r--r-- | front/odiparpack/app/containers/App/index.js | 60 |
1 files changed, 58 insertions, 2 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; |
