diff --git a/client/src/reducers/rootReducer.js b/client/src/reducers/rootReducer.js index e4ecba17b..4edf6109d 100644 --- a/client/src/reducers/rootReducer.js +++ b/client/src/reducers/rootReducer.js @@ -9,6 +9,18 @@ const initState = { } const rootReducer = (state = initState, action) => { + if (action.type === 'HIDE_FOOTER') { + let newState = JSON.parse(JSON.stringify(state)) + newState.context.masterApp.footer.visible = false + return newState + } + + if (action.type === 'SHOW_FOOTER') { + let newState = JSON.parse(JSON.stringify(state)) + newState.context.masterApp.footer.visible = true + return newState + } + return state } diff --git a/client/src/views/charts/index.js b/client/src/views/charts/index.js index 740f6fc17..8cf31ef85 100644 --- a/client/src/views/charts/index.js +++ b/client/src/views/charts/index.js @@ -4,6 +4,7 @@ import PropTypes from 'prop-types' import CssBaseline from '@material-ui/core/CssBaseline' import Typography from '@material-ui/core/Typography' import { withStyles } from '@material-ui/core/styles' +import { connect } from 'react-redux' const styles = theme => ({ '@global': { @@ -30,16 +31,14 @@ class Charts extends Component { window.canvasApp.visible = true let body = document.getElementById('body') body.style = 'margin: 0px; padding: 0px; border: 0px; overflow:hidden;' - window.SHOW_FOOTER = false - console.log('HIDDING FOOTER') + this.props.hideFooter() } componentWillUnmount () { window.canvasApp.visible = false let body = document.getElementById('body') body.style = '' - window.SHOW_FOOTER = true - console.log('SHOWING FOOTER') + this.props.showFooter() } render () { @@ -54,4 +53,17 @@ Charts.propTypes = { classes: PropTypes.object.isRequired } -export default withStyles(styles)(Charts) +const mapStateToProps = (state) => { + return { + context: state.context + } +} + +const mapDispatchToProps = (dispatch) => { + return { + hideFooter: () => { dispatch({type: 'HIDE_FOOTER'}) }, + showFooter: () => { dispatch({type: 'SHOW_FOOTER'}) } + } +} + +export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(Charts)) diff --git a/client/src/views/footer/index.js b/client/src/views/footer/index.js index c8bd0a0a2..c82b1ec16 100644 --- a/client/src/views/footer/index.js +++ b/client/src/views/footer/index.js @@ -41,20 +41,11 @@ const styles = theme => ({ class Footer extends Component { - componentDidMount () { - console.log('componentDidMount') - } - - componentWillUnmount () { - console.log('componentWillUnmount') - } - render () { let { classes } = this.props - console.log('SHOW_FOOTER', window.SHOW_FOOTER) - console.log('FOOTER PROPRS', this.props) - const { masterApp } = this.props.context.masterApp - if (window.SHOW_FOOTER === false) { + + const masterApp = this.props.context.masterApp + if (masterApp.footer.visible === false) { return (
) } else { return (