2017-12-07 14:19:51 +00:00
import React , { Component } from 'react'
2018-03-29 07:58:20 +00:00
import { Trans , translate } from 'react-i18next'
2017-12-07 14:19:51 +00:00
import ResultsGrid from 'Components/ResultsGrid'
import { salaries } from 'Components/TargetSelection'
2018-03-15 14:51:39 +00:00
import { isEmpty , intersection , head , path } from 'ramda'
2017-12-07 14:19:51 +00:00
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'
2018-03-15 14:51:39 +00:00
import { connect } from 'react-redux'
2018-03-19 18:18:58 +00:00
import SearchButton from './SearchButton'
2018-04-05 09:43:59 +00:00
import withColours from './withColours'
2018-04-12 16:25:30 +00:00
@ translate ( )
2018-04-05 09:43:59 +00:00
@ withColours
2018-03-15 14:51:39 +00:00
@ connect ( state => ( {
analysis : state . analysis
} ) )
2017-12-07 14:19:51 +00:00
export default class Explanation extends Component {
render ( ) {
2018-03-15 14:51:39 +00:00
let targetRules = path ( [ 'analysis' , 'targets' ] , this . props )
2017-12-07 14:19:51 +00:00
if ( ! targetRules ) return null
2017-12-19 16:29:21 +00:00
return (
2018-04-26 15:30:51 +00:00
< section id = "explanation" >
{ this . renderExplanation ( targetRules ) }
< div id = "warning" >
< p >
< i className = "fa fa-info-circle" aria - hidden = "true" / >
< Trans i18nKey = "disclaimer" >
2018-04-30 15:22:40 +00:00
Le simulateur vous aide à comprendre votre bulletin de paie , sans
lui être opposable . Il ne prend pour l ' instant pas en compte les
conventions et accords collectifs , ni la myriade d ' aides à
explorer sur
2018-04-26 15:30:51 +00:00
< / T r a n s >
2018-04-27 10:09:31 +00:00
< a href = "https://www.aides-entreprises.fr" target = "_blank" >
{ ' ' }
aides - entreprises . fr
< / a > .
2018-04-26 15:30:51 +00:00
< / p >
< / d i v >
< / s e c t i o n >
2017-12-19 16:29:21 +00:00
)
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 ) ) )
2018-03-19 18:18:58 +00:00
return (
< >
< SearchButton / >
< 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 (
2018-03-15 14:51:39 +00:00
< p >
< Trans i18nKey = "clickForMore" >
Cliquez sur les lignes de résultat ci - dessus pour les comprendre
< / T r a n s >
< / p >
2017-12-19 16:29:21 +00:00
)
2017-12-07 14:19:51 +00:00
return < Rule rule = { head ( targetRules ) } / >
}
}