import React, { Component } from 'react' import { Trans, translate } from 'react-i18next' import { findRuleByName } from 'Engine/rules' import { reject, curry, pipe, equals, filter, contains, length } from 'ramda' import { connect } from 'react-redux' import { Link } from 'react-router-dom' import './TargetSelection.css' import BlueButton from './BlueButton' export let salaries = ['salaire net', 'salaire brut', 'salaire total'] @connect(state => ({ flatRules: state.flatRules })) @translate() export default class TargetSelection extends Component { state = { targets: [] } render() { let { targets } = this.state, ready = targets.length > 0 return (

Que voulez-vous calculer ?

{this.renderOutputList()}

Vous pouvez faire plusieurs choix

Valider
) } renderOutputList() { let popularTargets = [...salaries, 'aides employeur'].map( curry(findRuleByName)(flatRules) ), { targets } = this.state, textColourOnWhite = this.props.themeColours.textColourOnWhite, // You can't select 3 salaries, as one must be an input in the next step optionDisabled = name => contains('salaire', name) && pipe( reject(equals(name)), filter(contains('salaire')), length, equals(2) )(targets), optionIsChecked = s => targets.includes(s.name) return (
{popularTargets.map(s => (
this.setState({ targets: targets.find(t => t === s.name) ? reject(t => t === s.name, targets) : [...targets, s.name] }) } />
))}
) } }