2017-11-15 09:49:55 +00:00
|
|
|
import React, { Component } from 'react'
|
|
|
|
import { rules } from 'Engine/rules'
|
|
|
|
import { propEq, reject } from 'ramda'
|
|
|
|
import { Link } from 'react-router-dom'
|
2017-11-16 17:11:42 +00:00
|
|
|
import './TargetSelection.css'
|
2017-11-15 09:49:55 +00:00
|
|
|
|
|
|
|
export default class TargetSelection extends Component {
|
|
|
|
state = {
|
2017-11-16 09:29:11 +00:00
|
|
|
targets: []
|
2017-11-15 09:49:55 +00:00
|
|
|
}
|
|
|
|
render() {
|
|
|
|
let { targets } = this.state
|
|
|
|
|
|
|
|
return (
|
2017-11-16 17:11:42 +00:00
|
|
|
<section id="targetSelection">
|
2017-11-16 13:38:03 +00:00
|
|
|
<h2>Qu'allons-nous calculer ?</h2>
|
2017-11-15 09:49:55 +00:00
|
|
|
{this.renderOutputList()}
|
2017-11-16 09:29:11 +00:00
|
|
|
{targets.length !== 0 && (
|
2017-11-15 09:49:55 +00:00
|
|
|
<Link to={'/simu/' + targets.join('+')}>
|
|
|
|
<button>Valider</button>
|
|
|
|
</Link>
|
|
|
|
)}
|
|
|
|
</section>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
renderOutputList() {
|
|
|
|
let salaires = rules.filter(propEq('type', 'salaire')),
|
|
|
|
{ targets } = this.state
|
|
|
|
return (
|
2017-11-16 17:11:42 +00:00
|
|
|
<div>
|
2017-11-15 09:49:55 +00:00
|
|
|
{salaires.map(s => (
|
2017-11-22 09:18:55 +00:00
|
|
|
<span key={s.name}>
|
2017-11-20 10:15:04 +00:00
|
|
|
<input
|
|
|
|
id={s.name}
|
|
|
|
type="checkbox"
|
|
|
|
checked={targets.includes(s.name)}
|
|
|
|
onChange={() =>
|
|
|
|
this.setState({
|
|
|
|
targets: targets.find(t => t === s.name)
|
|
|
|
? reject(t => t === s.name, targets)
|
|
|
|
: [...targets, s.name]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
/>
|
2017-11-22 09:18:55 +00:00
|
|
|
<label htmlFor={s.name} key={s.name}>
|
2017-11-20 10:15:04 +00:00
|
|
|
<i className="fa fa-square-o fa-2x" />
|
|
|
|
<i className="fa fa-check-square-o fa-2x" />
|
|
|
|
<div>
|
|
|
|
<span className="optionTitle">{s.title || s.name}</span>
|
|
|
|
<p>{s['résumé']}</p>
|
|
|
|
</div>
|
|
|
|
</label>
|
|
|
|
</span>
|
|
|
|
))}
|
2017-11-16 17:11:42 +00:00
|
|
|
</div>
|
2017-11-15 09:49:55 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|