const isEmpty = require('lodash.isempty'); const React = require('react'); const ReactRedux = require('react-redux'); const ReactRouter = require('react-router'); const NotFound = require('@containers/not-found'); const Redirect = require('@components/redirect'); const selectors = require('@state/selectors'); const SectionComponents = { people: require('./people'), projects: require('./projects'), settings: require('./settings'), }; const { connect } = ReactRedux; const { Match, Miss } = ReactRouter; const { orgByIdSelector, orgSectionsSelector } = selectors; const Org = ({ org = {}, sections = [] }) => { if (isEmpty(org)) { return ( ); } const missMatch = !sections.length ? null : ( ); const navMatches = sections.map((name) => ( )); return (
{navMatches} {missMatch}
); }; Org.propTypes = { org: React.PropTypes.shape({ owner: React.PropTypes.string, uuid: React.PropTypes.string, id: React.PropTypes.string, name: React.PropTypes.string }), sections: React.PropTypes.arrayOf( React.PropTypes.string ) }; const mapStateToProps = (state, ownProps) => ({ org: orgByIdSelector(ownProps.params.org)(state), sections: orgSectionsSelector(ownProps.params.org)(state) }); module.exports = connect(mapStateToProps)(Org);