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

53 lines
1004 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 = []
}) => {
2017-01-03 01:17:12 +02:00
const navLinks = sections.map((name) => ({
2016-12-20 21:06:02 +02:00
pathname: `/${org.id}/${name}`,
name
}));
2017-01-03 01:17:12 +02:00
const nameLinks = [{
pathname: `/${org.id}`,
name: org.name
}];
2016-12-20 21:06:02 +02:00
return (
2017-01-03 01:17:12 +02:00
<Section links={navLinks} name={nameLinks}>
2016-12-20 21:06:02 +02:00
{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);