1
0
mirror of https://github.com/yldio/copilot.git synced 2024-12-04 09:00:05 +02:00
copilot/frontend/src/containers/org/section.js

48 lines
920 B
JavaScript
Raw Normal View History

2016-12-20 21:06:02 +02:00
const React = require('react');
const ReactRedux = require('react-redux');
2017-01-03 00:32:29 +02:00
const PropTypes = require('@root/prop-types');
2016-12-20 21:06:02 +02:00
const selectors = require('@state/selectors');
const Section = require('@components/section');
const {
connect
} = ReactRedux;
const {
orgByIdSelector,
orgSectionsSelector
} = selectors;
const OrgSection = ({
children,
org = {},
sections = []
}) => {
const links = sections.map((name) => ({
pathname: `/${org.id}/${name}`,
name
}));
return (
<Section links={links} name={org.name}>
{children}
</Section>
);
};
OrgSection.propTypes = {
children: React.PropTypes.node,
2017-01-03 00:32:29 +02:00
org: PropTypes.org,
sections: PropTypes.sections
2016-12-20 21:06:02 +02:00
};
const mapStateToProps = (state, ownProps) => ({
org: orgByIdSelector(ownProps.params.org)(state),
sections: orgSectionsSelector(ownProps.params.org)(state)
});
2017-01-03 00:32:29 +02:00
module.exports = connect(
mapStateToProps
)(OrgSection);