2016-09-21 03:07:32 +00:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
2016-09-30 18:55:15 +00:00
|
|
|
import { StyleRoot } from 'radium';
|
|
|
|
import componentStyles from './styles';
|
2016-10-03 17:54:22 +00:00
|
|
|
import FlashMessage from '../../components/FlashMessage';
|
2016-09-21 03:07:32 +00:00
|
|
|
import SidePanel from '../../components/SidePanel';
|
|
|
|
|
|
|
|
export class CoreLayout extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
children: PropTypes.node,
|
2016-10-05 23:43:37 +00:00
|
|
|
config: PropTypes.shape({
|
|
|
|
org_logo_url: PropTypes.string,
|
|
|
|
org_name: PropTypes.string,
|
|
|
|
}),
|
2016-09-21 03:07:32 +00:00
|
|
|
dispatch: PropTypes.func,
|
2016-10-03 17:54:22 +00:00
|
|
|
notifications: PropTypes.object,
|
2016-09-21 03:07:32 +00:00
|
|
|
user: PropTypes.object,
|
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
2016-10-05 23:43:37 +00:00
|
|
|
const { children, config, dispatch, notifications, user } = this.props;
|
2016-09-30 18:55:15 +00:00
|
|
|
const { wrapperStyles } = componentStyles;
|
2016-09-21 03:07:32 +00:00
|
|
|
|
|
|
|
if (!user) return false;
|
|
|
|
|
2016-09-30 18:55:15 +00:00
|
|
|
const { pathname } = global.window.location;
|
|
|
|
|
2016-09-21 03:07:32 +00:00
|
|
|
return (
|
2016-09-30 18:55:15 +00:00
|
|
|
<StyleRoot>
|
|
|
|
<SidePanel
|
2016-10-05 23:43:37 +00:00
|
|
|
config={config}
|
2016-09-30 18:55:15 +00:00
|
|
|
pathname={pathname}
|
|
|
|
user={user}
|
|
|
|
/>
|
|
|
|
<div style={wrapperStyles}>
|
2016-10-03 17:54:22 +00:00
|
|
|
<FlashMessage notification={notifications} dispatch={dispatch} />
|
2016-09-30 18:55:15 +00:00
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
</StyleRoot>
|
2016-09-21 03:07:32 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => {
|
|
|
|
const { user } = state.auth;
|
2016-10-03 17:54:22 +00:00
|
|
|
const { notifications } = state;
|
2016-10-05 23:43:37 +00:00
|
|
|
const { config } = state.app;
|
2016-09-21 03:07:32 +00:00
|
|
|
|
2016-10-05 23:43:37 +00:00
|
|
|
return { config, notifications, user };
|
2016-09-21 03:07:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(CoreLayout);
|