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" >
< p >
< i className = "fa fa-info-circle" aria - hidden = "true" > < / i > L e c a l c u l n e p r e n d p a s e n c o m p t e l e s c o n v e n t i o n s e t a c c o r d s
collectifs , et n 'est pas opposable à un bulletin de paie. En cas d' écart , vous
pouvez en discuter avec votre responsable .
< / p >
< / 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 ) } / >
}
}