{"size": 1429, "ext": "js", "max_stars_repo_path": "imports/ui/containers/PageLayout.js", "max_stars_repo_name": "boonya/dumb-home", "max_stars_repo_stars_event_min_datetime": "2019-04-10T11:25:45.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-10T11:25:45.000Z", "max_issues_repo_path": "imports/ui/containers/PageLayout.js", "max_issues_repo_name": "boonya/dumb-home", "max_issues_repo_issues_event_min_datetime": "2020-04-06T09:34:07.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-26T21:03:08.000Z", "max_forks_repo_path": "imports/ui/containers/PageLayout.js", "max_forks_repo_name": "boonya/dumb-home", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 20, "max_forks_count": null, "avg_line_length": 27.4807692308, "max_line_length": 97, "alphanum_fraction": 0.7151854444}
/* eslint react/forbid-prop-types: 0 */
import PropTypes from 'prop-types';
import React from 'react';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';

import Routes from '../routes';

import actions from '../redux/actions';

import { isReady } from '../redux/utils/state';
import { getMe } from '../redux/reducers/me';
import { getTitle } from '../redux/reducers/config';

import Layout from '../components/PageLayout';

const NavbarPropsSelector = createSelector([getMe, getTitle], (me, title) => ({
  isLoggedIn: isReady(me) && me.isLoggedIn(),
  title,
  landingPath: Routes.Landing,
  toggleMenu: null,
}));

const mapStateToProps = createSelector([NavbarPropsSelector], (NavbarProps) => ({
  NavbarProps,
}));

const mapDispatchToProps = (dispatch) => ({
  logout: () => dispatch(actions.me.logout()),
});

const PageLayout = ({ children, logout, NavbarProps, ContainerProps, withNavbar }) => (
  <Layout NavbarProps={withNavbar && { ...NavbarProps, logout }} ContainerProps={ContainerProps}>
    {children}
  </Layout>
);

PageLayout.propTypes = {
  children: PropTypes.node.isRequired,
  logout: PropTypes.func.isRequired,
  NavbarProps: PropTypes.object.isRequired,
  ContainerProps: PropTypes.object,
  withNavbar: PropTypes.bool,
};

PageLayout.defaultProps = {
  ContainerProps: null,
  withNavbar: false,
};

export default connect(mapStateToProps, mapDispatchToProps)(PageLayout);
