diff --git a/source/components/ComparativeSimulation.js b/source/components/ComparativeSimulation.js index 376a1c2f9..8a20e66c5 100644 --- a/source/components/ComparativeSimulation.js +++ b/source/components/ComparativeSimulation.js @@ -1,6 +1,6 @@ import React from 'react' import { connect } from 'react-redux' -import { isEmpty, compose } from 'ramda' +import { isEmpty, compose, chain, uniqBy } from 'ramda' import Answers from 'Components/AnswerList' import Conversation from 'Components/conversation/Conversation' import withColours from 'Components/utils/withColours' @@ -19,7 +19,7 @@ export default compose( connect(state => ({ previousAnswers: state.conversationSteps.foldedSteps, noNextSteps: nextStepsSelector(state, simulationConfig).length == 0, - analysis: analysisWithDefaultsSelector(state, simulationConfig) + analyses: analysisWithDefaultsSelector(state, simulationConfig) })) )( class extends React.Component { @@ -27,12 +27,12 @@ export default compose( displayAnswers: false } render() { - let { - colours, - noNextSteps, - previousAnswers, - analysis: { controls } - } = this.props + let { colours, noNextSteps, previousAnswers, analyses } = this.props + let controls = uniqBy( + ({ test, dottedName }) => test + dottedName, + chain(({ controls }) => controls, analyses) + ) + return (
{createMarkdownDiv(simulationConfig.titre)}
diff --git a/source/components/ComparativeTargets.js b/source/components/ComparativeTargets.js index a41d37c19..2b91ab9ac 100644 --- a/source/components/ComparativeTargets.js +++ b/source/components/ComparativeTargets.js @@ -1,5 +1,8 @@ import React from 'react' -import { analysisWithDefaultsSelector } from 'Selectors/analyseSelectors' +import { + flatRulesSelector, + analysisWithDefaultsSelector +} from 'Selectors/analyseSelectors' import { connect } from 'react-redux' import './ComparativeTargets.css' import withColours from 'Components/utils/withColours' @@ -9,23 +12,29 @@ import { compose } from 'ramda' import simulationConfig from './simulateur-rémunération-dirigeant.yaml' import AnimatedTargetValue from './AnimatedTargetValue' import PeriodSwitch from 'Components/PeriodSwitch' +import { findRuleByDottedName } from 'Engine/rules' export default compose( connect(state => ({ + target: findRuleByDottedName( + flatRulesSelector(state), + simulationConfig.objectif + ), analyses: analysisWithDefaultsSelector(state, simulationConfig) })), withColours )( class ComparativeTargets extends React.Component { render() { - let { colours, analyses } = this.props + let { colours, analyses, target } = this.props return (
-

{analyses[0].targets[0].title}

+

{target.title}

    {analyses.map((analysis, i) => { - let { title, nodeValue, dottedName } = analysis.targets[0], + if (!analysis.targets) return null + let { nodeValue, dottedName } = analysis.targets[0], name = simulationConfig.branches[i].nom return (