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-07 18:31:06 +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-07 18:19:57 +00:00
return < section id = "explanation" > { this . renderExplanation ( targetRules ) } < / s e c t i o n >
}
renderExplanation ( targetRules ) {
2017-12-07 18:31:06 +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-07 18:19:57 +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 ) } / >
}
}