1
0
mirror of https://github.com/yldio/copilot.git synced 2024-12-03 00:20:04 +02:00
copilot/frontend/src/containers/org/section.js
2017-01-02 23:17:12 +00:00

53 lines
1004 B
JavaScript

const React = require('react');
const ReactRedux = require('react-redux');
const PropTypes = require('@root/prop-types');
const selectors = require('@state/selectors');
const Section = require('@components/section');
const {
connect
} = ReactRedux;
const {
orgByIdSelector,
orgSectionsSelector
} = selectors;
const OrgSection = ({
children,
org = {},
sections = []
}) => {
const navLinks = sections.map((name) => ({
pathname: `/${org.id}/${name}`,
name
}));
const nameLinks = [{
pathname: `/${org.id}`,
name: org.name
}];
return (
<Section links={navLinks} name={nameLinks}>
{children}
</Section>
);
};
OrgSection.propTypes = {
children: React.PropTypes.node,
org: PropTypes.org,
sections: PropTypes.sections
};
const mapStateToProps = (state, ownProps) => ({
org: orgByIdSelector(ownProps.params.org)(state),
sections: orgSectionsSelector(ownProps.params.org)(state)
});
module.exports = connect(
mapStateToProps
)(OrgSection);