2017-12-07 14:19:51 +00:00
import React , { Component } from 'react'
import ResultsGrid from 'Components/ResultsGrid'
import { salaries } from 'Components/TargetSelection'
import { isEmpty , intersection , head } from 'ramda'
import Rule from 'Components/rule/Rule'
2017-12-07 18:19:57 +00:00
import './Explanation.css'
2017-12-19 16:29:21 +00:00
import { pluck } from 'ramda'
2017-12-07 14:19:51 +00:00
export default class Explanation extends Component {
render ( ) {
let { targetRules } = this . props
if ( ! targetRules ) return null
2017-12-19 16:29:21 +00:00
return (
< section id = "explanation" >
{ this . renderExplanation ( targetRules ) }
< div id = "warning" >
2018-01-03 15:54:19 +00:00
< p >
< i className = "fa fa-info-circle" aria - hidden = "true" / > Le calcul ne
prend pas en compte les conventions et accords collectifs , et n ' est
pas opposable à un bulletin de paie . En cas d ' écart , vous pouvez en
discuter avec votre responsable .
< / p >
2017-12-19 16:29:21 +00:00
< / d i v >
< / s e c t i o n >
)
2017-12-07 18:19:57 +00:00
}
renderExplanation ( targetRules ) {
2017-12-19 16:29:21 +00:00
if ( ! isEmpty ( intersection ( pluck ( 'name' , targetRules ) , salaries ) ) )
return < ResultsGrid / > // Problem if targetRules is [salaire net, aides] the Explanation will not explain 'aides'. The user will have to click on Aides to understand it. Should we display a list of <Rule /> sections ?
2017-12-07 14:19:51 +00:00
if ( targetRules . length > 1 )
2017-12-19 16:29:21 +00:00
return (
< p > Cliquez sur les lignes de résultat ci - dessus pour les comprendre < / p >
)
2017-12-07 14:19:51 +00:00
return < Rule rule = { head ( targetRules ) } / >
}
}