diff --git a/source/components/ComparativeTargets.js b/source/components/ComparativeTargets.js
index 2b91ab9ac..c193cdc30 100644
--- a/source/components/ComparativeTargets.js
+++ b/source/components/ComparativeTargets.js
@@ -15,18 +15,23 @@ 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)
- })),
+ connect(
+ state => ({
+ target: findRuleByDottedName(
+ flatRulesSelector(state),
+ simulationConfig.objectif
+ ),
+ analyses: analysisWithDefaultsSelector(state, simulationConfig)
+ }),
+ dispatch => ({
+ setSituationBranch: id => dispatch({ type: 'SET_SITUATION_BRANCH', id })
+ })
+ ),
withColours
)(
class ComparativeTargets extends React.Component {
render() {
- let { colours, analyses, target } = this.props
+ let { colours, analyses, target, setSituationBranch } = this.props
return (
{target.title}
@@ -57,6 +62,7 @@ export default compose(
title="Quel est calcul ?"
style={{ color: this.props.colours.colour }}
to={'/règle/' + dottedName}
+ onClick={() => setSituationBranch(i)}
className="explanation">
{emoji('đź“–')}
diff --git a/source/components/Controls.js b/source/components/Controls.js
index aed1c518d..b01c1da33 100644
--- a/source/components/Controls.js
+++ b/source/components/Controls.js
@@ -18,7 +18,6 @@ function Controls({
hiddenControls,
language
}) {
- console.log('C', controls)
if (!controls?.length) return null
/* TODO controls are not translated yet, since our translation system doesn't handle nested yaml properties of base.yaml */
if (language === 'en') return null
diff --git a/source/components/RulePage.css b/source/components/RulePage.css
index 181fe0fd0..98e44ba01 100644
--- a/source/components/RulePage.css
+++ b/source/components/RulePage.css
@@ -15,3 +15,10 @@
#toSimulation i {
margin: 0 0.4em;
}
+
+#situationBranch {
+ color: white;
+ background: #333;
+ border-radius: 0.3em;
+ padding: 0.2em 0.6em;
+}
diff --git a/source/components/RulePage.js b/source/components/RulePage.js
index c1c2c2184..d00e7dd36 100644
--- a/source/components/RulePage.js
+++ b/source/components/RulePage.js
@@ -20,12 +20,14 @@ import Namespace from './rule/Namespace'
import Rule from './rule/Rule'
import './RulePage.css'
import SearchButton from './SearchButton'
+import simulationConfig from 'Components/simulateur-rémunération-dirigeant.yaml'
export default compose(
connect(state => ({
themeColours: state.themeColours,
valuesToShow: !noUserInputSelector(state),
- flatRules: flatRulesSelector(state)
+ flatRules: flatRulesSelector(state),
+ situationBranch: simulationConfig.branches[state.situationBranch]?.nom
})),
withNamespaces()
)(
@@ -52,6 +54,7 @@ export default compose(
return this.renderRule(dottedName)
}
renderRule(dottedName) {
+ let { situationBranch } = this.props
return (
@@ -60,12 +63,15 @@ export default compose(
visible={this.props.valuesToShow}
colour={this.props.themeColours.colour}
/>
+ {situationBranch && (
+ {situationBranch}
+ )}
-
+
)
}
diff --git a/source/components/rule/Rule.js b/source/components/rule/Rule.js
index ba6c88380..8a335e8dc 100644
--- a/source/components/rule/Rule.js
+++ b/source/components/rule/Rule.js
@@ -56,11 +56,11 @@ export default compose(
language
} = this.props,
flatRule = findRuleByDottedName(flatRules, dottedName)
-
let { type, name, title, description, question, ns, icon } = flatRule,
namespaceRules = findRuleByNamespace(flatRules, dottedName)
let displayedRule = analysedExample || analysedRule
+ console.log('ana', analysedRule)
return (
<>
diff --git a/source/reducers/rootReducer.js b/source/reducers/rootReducer.js
index 286df0c60..63e0bf372 100644
--- a/source/reducers/rootReducer.js
+++ b/source/reducers/rootReducer.js
@@ -45,6 +45,15 @@ function currentExample(state = null, { type, situation, name, dottedName }) {
}
}
+function situationBranch(state = null, { type, id }) {
+ switch (type) {
+ case 'SET_SITUATION_BRANCH':
+ return id
+ default:
+ return state
+ }
+}
+
function conversationStarted(state = false, action: Action) {
switch (action.type) {
case 'START_CONVERSATION':
@@ -172,6 +181,7 @@ export default reduceReducers(
explainedVariable,
previousSimulation: defaultTo(null),
currentExample,
+ situationBranch,
hiddenControls,
conversationStarted,
activeTargetInput,
diff --git a/source/règles/base.yaml b/source/règles/base.yaml
index 9e2930ff4..fb83eb13c 100644
--- a/source/règles/base.yaml
+++ b/source/règles/base.yaml
@@ -1914,7 +1914,6 @@
contrĂ´les:
- si: forfait [mensuel] < 15
niveau: avertissement
- message: Vérifiez bien qu'une complémentaire santé si peu chère couvre le panier de soin minimal défini dans la loi.
- espace: contrat salarié . complémentaire santé . forfait
nom: en alsace moselle
diff --git a/source/selectors/analyseSelectors.js b/source/selectors/analyseSelectors.js
index 48d371703..8afb6b49a 100644
--- a/source/selectors/analyseSelectors.js
+++ b/source/selectors/analyseSelectors.js
@@ -79,6 +79,7 @@ let validatedStepsSelector = createSelector(
(foldedSteps, target) => [...foldedSteps, target]
)
let branchesSelector = (state, props) => props?.branches || [{}]
+
let situationBranchesSelector = createSelector(
[formattedSituationSelector, branchesSelector],
(situation, branches) =>
@@ -106,19 +107,24 @@ let situationsWithDefaultsSelector = createSelector(
situations.map(situation => ({ ...defaults, ...situation }))
)
-let analyseRule = (parsedRules, ruleDottedName, situation) =>
- situation &&
- analyse(parsedRules, ruleDottedName)(dottedName => situation[dottedName])
- .targets[0]
+let analyseRule = (parsedRules, ruleDottedName, situationGate) =>
+ analyse(parsedRules, ruleDottedName)(situationGate).targets[0]
export let ruleAnalysisSelector = createSelector(
[
parsedRulesSelector,
(_, { dottedName }) => dottedName,
- situationsWithDefaultsSelector
+ situationsWithDefaultsSelector,
+ state => state.situationBranch || 0,
+ (_, { raccourcis: valueShortcuts }) => valueShortcuts || {}
],
- (rules, dottedName, situations) =>
- analyseRule(rules, dottedName, situations[0])
+ (rules, dottedName, situations, situationBranch, valueShortcuts) =>
+ analyseRule(
+ rules,
+ dottedName,
+ dottedName =>
+ situations[situationBranch][valueShortcuts[dottedName] || dottedName]
+ )
)
let exampleSituationSelector = createSelector(
@@ -142,7 +148,9 @@ export let exampleAnalysisSelector = createSelector(
(_, { dottedName }) => dottedName,
exampleSituationSelector
],
- analyseRule
+ (rules, dottedName, situation) =>
+ situation &&
+ analyseRule(rules, dottedName, dottedName => situation[dottedName])
)
let makeAnalysisSelector = situationSelector =>