mon-entreprise/containers/Explorer.js

54 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-06-29 10:27:04 +00:00
import React from 'react'
import {selectVariables, selectTagStats} from '../selectors'
import {connect} from 'react-redux'
const Variable = ({data: {variable, tags}}) => <li className="variable">
<h3>{variable}</h3>
<ul>{Object.keys(tags).map(name => <li>
{name + ': ' + tags[name]}
</li>)}</ul>
</li>
class Explorer extends React.Component {
2016-06-29 10:27:04 +00:00
render() {
2016-06-29 16:57:56 +00:00
return (
<div>
<h1>Les prélèvements sociaux sur les salaires</h1>
<ul id="tags">
{this.props.tags.map(tag =>
<TagSelect key={tag.name} tag={tag} />
)}
</ul>
<ul id="variables">
{this.props.variables.map((v, i) => <Variable key={i} data={v}/>)}
</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
class TagSelect extends React.Component {
render(){
let {name, choices, number} = this.props.tag
return (<li>
<span className="name">{`${name} (${number} variables)`}</span>
<ul className="choices">
{[...choices].map(c => <li key={c}>
{c}
</li>)}
</ul>
</li>)
}
}
const mapStateToProps = (state) => (
{
variables: selectVariables(state),
tags: selectTagStats(state)
}
)
const VariableExplorer = connect(mapStateToProps)(Explorer)
export default VariableExplorer