2016-06-29 10:27:04 +00:00
|
|
|
import React from 'react'
|
2016-07-04 15:28:30 +00:00
|
|
|
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 (
|
2016-07-04 15:28:30 +00:00
|
|
|
<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>)
|
|
|
|
}
|
|
|
|
}
|
2016-07-04 15:28:30 +00:00
|
|
|
|
|
|
|
const mapStateToProps = (state) => (
|
|
|
|
{
|
|
|
|
variables: selectVariables(state),
|
|
|
|
tags: selectTagStats(state)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
const VariableExplorer = connect(mapStateToProps)(Explorer)
|
|
|
|
|
|
|
|
export default VariableExplorer
|