2017-11-15 09:49:55 +00:00
|
|
|
import React, { Component } from 'react'
|
2017-11-22 14:31:29 +00:00
|
|
|
import { rules, findRuleByName } from 'Engine/rules'
|
2017-12-20 16:49:58 +00:00
|
|
|
import { reject, curry, pipe, equals, filter, contains, length } from 'ramda'
|
2017-11-15 09:49:55 +00:00
|
|
|
import { Link } from 'react-router-dom'
|
2017-11-16 17:11:42 +00:00
|
|
|
import './TargetSelection.css'
|
2018-01-10 16:51:35 +00:00
|
|
|
import BlueButton from './BlueButton'
|
2017-12-19 16:09:17 +00:00
|
|
|
export let salaries = ['salaire net', 'salaire de base', 'salaire total']
|
2017-12-07 14:19:51 +00:00
|
|
|
|
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() {
|
2018-01-30 10:53:35 +00:00
|
|
|
let { targets } = this.state,
|
|
|
|
ready = targets.length > 0
|
2017-11-15 09:49:55 +00:00
|
|
|
|
|
|
|
return (
|
2017-11-16 17:11:42 +00:00
|
|
|
<section id="targetSelection">
|
2017-12-19 16:09:17 +00:00
|
|
|
<h1>Que voulez-vous calculer ?</h1>
|
2017-11-15 09:49:55 +00:00
|
|
|
{this.renderOutputList()}
|
2018-01-30 10:53:35 +00:00
|
|
|
<div id="action">
|
2018-01-10 16:51:35 +00:00
|
|
|
<p style={{ color: this.props.themeColours.textColourOnWhite }}>
|
|
|
|
Vous pouvez faire plusieurs choix
|
|
|
|
</p>
|
2018-01-30 11:03:33 +00:00
|
|
|
<Link to={'/simu/' + targets.join('+')}>
|
2018-01-30 15:24:28 +00:00
|
|
|
<BlueButton disabled={!ready}>Valider</BlueButton>
|
2018-01-30 11:03:33 +00:00
|
|
|
</Link>
|
2017-12-19 16:09:17 +00:00
|
|
|
</div>
|
2017-11-15 09:49:55 +00:00
|
|
|
</section>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
renderOutputList() {
|
2017-12-19 16:09:17 +00:00
|
|
|
let popularTargets = [...salaries, 'aides employeur différées'].map(
|
|
|
|
curry(findRuleByName)(rules)
|
|
|
|
),
|
2017-12-20 16:49:58 +00:00
|
|
|
{ targets } = this.state,
|
2018-01-10 16:51:35 +00:00
|
|
|
textColourOnWhite = this.props.themeColours.textColourOnWhite,
|
2017-12-20 16:49:58 +00:00
|
|
|
// You can't select 3 salaries, as one must be an input in the next step
|
2018-01-03 15:54:19 +00:00
|
|
|
optionDisabled = name =>
|
|
|
|
contains('salaire', name) &&
|
|
|
|
pipe(
|
|
|
|
reject(equals(name)),
|
|
|
|
filter(contains('salaire')),
|
|
|
|
length,
|
|
|
|
equals(2)
|
2018-01-10 16:51:35 +00:00
|
|
|
)(targets),
|
|
|
|
optionIsChecked = s => targets.includes(s.name)
|
2017-12-20 16:49:58 +00:00
|
|
|
|
2017-11-15 09:49:55 +00:00
|
|
|
return (
|
2017-11-16 17:11:42 +00:00
|
|
|
<div>
|
2017-12-19 16:09:17 +00:00
|
|
|
<div id="targets">
|
|
|
|
{popularTargets.map(s => (
|
|
|
|
<div key={s.name}>
|
|
|
|
<input
|
|
|
|
id={s.name}
|
|
|
|
type="checkbox"
|
2017-12-20 16:49:58 +00:00
|
|
|
disabled={optionDisabled(s.name)}
|
2018-01-10 16:51:35 +00:00
|
|
|
checked={optionIsChecked(s)}
|
2017-12-19 16:09:17 +00:00
|
|
|
onChange={() =>
|
|
|
|
this.setState({
|
|
|
|
targets: targets.find(t => t === s.name)
|
|
|
|
? reject(t => t === s.name, targets)
|
|
|
|
: [...targets, s.name]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
/>
|
2018-01-10 16:51:35 +00:00
|
|
|
<label
|
|
|
|
htmlFor={s.name}
|
|
|
|
key={s.name}
|
|
|
|
style={
|
|
|
|
optionIsChecked(s)
|
|
|
|
? {
|
|
|
|
color: textColourOnWhite
|
|
|
|
}
|
|
|
|
: {}
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{optionIsChecked(s) ? (
|
|
|
|
<i
|
|
|
|
className="fa fa-check-square-o fa-2x"
|
|
|
|
style={{ color: textColourOnWhite }}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<i
|
|
|
|
className="fa fa-square-o fa-2x"
|
2018-01-30 11:03:33 +00:00
|
|
|
style={{ color: '#4b4b66' }}
|
2018-01-10 16:51:35 +00:00
|
|
|
/>
|
|
|
|
)}
|
2017-12-19 16:09:17 +00:00
|
|
|
<div>
|
|
|
|
<span className="optionTitle">{s.title || s.name}</span>
|
2018-01-10 16:51:35 +00:00
|
|
|
<p
|
|
|
|
style={
|
|
|
|
optionIsChecked(s)
|
|
|
|
? { color: textColourOnWhite }
|
2018-01-30 11:03:33 +00:00
|
|
|
: { color: '#4b4b66' }
|
2018-01-10 16:51:35 +00:00
|
|
|
}
|
|
|
|
>
|
|
|
|
{s['résumé']}
|
|
|
|
</p>
|
2017-12-19 16:09:17 +00:00
|
|
|
</div>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
2017-11-16 17:11:42 +00:00
|
|
|
</div>
|
2017-11-15 09:49:55 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|