import React, {Component} from 'react' import {connect} from 'react-redux' import {Dimmer, Sidebar as SidebarSemantic, Container} from 'semantic-ui-react' import {Header, Sidebar, Footer} from 'components' import {CLOSE_SIDEBAR, OPEN_SIDEBAR, WINDOW_RESIZE} from 'actions/layout' import {LOGOUT_AUTH} from 'actions/auth' import {push} from 'react-router-redux' import {sidebarRouting} from 'routing' class App extends Component { constructor(props) { super(props) } static propTypes = { children: React.PropTypes.node.isRequired, location: React.PropTypes.object, sidebarOpened: React.PropTypes.bool, closeSidebar: React.PropTypes.func, isLoggedIn: React.PropTypes.bool, handleWindowResize: React.PropTypes.func, logout: React.PropTypes.func, checkAuthLogic: React.PropTypes.func, toggleSidebar: React.PropTypes.func, onHeaderRightButtonClick: React.PropTypes.func, router: React.PropTypes.object, isMobile: React.PropTypes.bool } componentWillMount() { let {handleWindowResize, isLoggedIn} = this.props window.addEventListener('resize', handleWindowResize) this.checkAppAuthLogic(isLoggedIn) } /** * Call checkAuthLogic * @param {Bool} loggedIn state.auth.loggedIn, current prop * @return {Bool} Nothing */ checkAppAuthLogic(loggedIn) { let {router, checkAuthLogic} = this.props let path = router.getCurrentLocation().pathname checkAuthLogic(path, loggedIn) return false } componentWillReceiveProps(nextProps) { this.checkAppAuthLogic(nextProps.isLoggedIn) } render() { let { children, sidebarOpened, closeSidebar, isLoggedIn, logout, onHeaderRightButtonClick, toggleSidebar, isMobile } = this.props let title = children.props.route.name let sidebarProps = { isMobile, logout, open: sidebarOpened, routing: sidebarRouting } let headerProps = { toggleSidebar, title, isLoggedIn, onHeaderRightButtonClick } let dimmerProps = { active: sidebarOpened, onClick: closeSidebar } return (