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'
|
|
|
|
|
|
|
|
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 (
|
|
|
|
<section id="selection">
|
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 (
|
|
|
|
<select
|
|
|
|
multiple
|
|
|
|
value={targets}
|
2017-11-16 09:29:11 +00:00
|
|
|
onMouseDown={e => e.target.value != '' &&
|
2017-11-15 09:49:55 +00:00
|
|
|
this.setState({
|
|
|
|
targets: targets.find(t => t === e.target.value)
|
|
|
|
? reject(t => t === e.target.value, targets)
|
|
|
|
: [...targets, e.target.value]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{salaires.map(s => (
|
|
|
|
<option key={s.name} value={s.name}>
|
2017-11-16 09:29:11 +00:00
|
|
|
<div className="optionTitle">{s.title || s.name}</div>
|
|
|
|
<span>{s['résumé']}</span>
|
2017-11-15 09:49:55 +00:00
|
|
|
</option>
|
|
|
|
))}
|
|
|
|
</select>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|