mon-entreprise/containers/Explorer.js

54 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-06-29 10:27:04 +00:00
import React from 'react'
import {connect} from 'react-redux'
2016-07-04 16:34:18 +00:00
import {getVariables} from '../selectors'
import TagNavigation from '../components/TagNavigation'
import * as actions from '../actions'
import {bindActionCreators} from 'redux'
import {getTagsToSelect} from '../selectors'
const Variable = ({variable: {variable, tags}, selectedTags}) => <li className="variable">
<h3>{variable}</h3>
<ul>
{Object.keys(tags)
.filter(name => !selectedTags.find(([n]) => name == n))
.map(name =>
<li key={name}>
{name + ': ' + tags[name]}
</li>
)}
</ul>
</li>
class Explorer extends React.Component {
2016-06-29 10:27:04 +00:00
render() {
let {variables, selectedTags, tagsToSelect, actions: {selectTag}} = this.props
2016-06-29 16:57:56 +00:00
return (
<div>
<h1>Liste des prélèvements sociaux sur les salaires en France</h1>
<TagNavigation selectedTags={selectedTags} tagsToSelect={tagsToSelect} selectTag={selectTag}/>
<ul id="variables">
{variables.map((v, i) => <Variable key={i} variable={v} selectedTags={selectedTags}/>)}
</ul>
</div>
2016-06-29 16:57:56 +00:00
)
2016-06-29 10:27:04 +00:00
}
}
2016-06-30 10:16:47 +00:00
const mapStateToProps = state => (
{
variables: getVariables(state),
selectedTags: state.selectedTags,
tagsToSelect: getTagsToSelect(state)
}
)
const actionsToProps = dispatch => ({
actions: bindActionCreators(actions, dispatch)
})
const VariableExplorer = connect(mapStateToProps, actionsToProps)(Explorer)
export default VariableExplorer