Affichage de la bonne branche sur les pages règle
parent
96d5c933f0
commit
5174253625
|
@ -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 (
|
||||
<div id="targets">
|
||||
<h3>{target.title}</h3>
|
||||
|
@ -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('📖')}
|
||||
</Link>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -15,3 +15,10 @@
|
|||
#toSimulation i {
|
||||
margin: 0 0.4em;
|
||||
}
|
||||
|
||||
#situationBranch {
|
||||
color: white;
|
||||
background: #333;
|
||||
border-radius: 0.3em;
|
||||
padding: 0.2em 0.6em;
|
||||
}
|
||||
|
|
|
@ -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 (
|
||||
<div id="RulePage">
|
||||
<ScrollToTop />
|
||||
|
@ -60,12 +63,15 @@ export default compose(
|
|||
visible={this.props.valuesToShow}
|
||||
colour={this.props.themeColours.colour}
|
||||
/>
|
||||
{situationBranch && (
|
||||
<span id="situationBranch">{situationBranch}</span>
|
||||
)}
|
||||
<SearchButton
|
||||
className="rule-page__search"
|
||||
rulePageBasePath="../règle"
|
||||
/>
|
||||
</div>
|
||||
<Rule dottedName={dottedName} />
|
||||
<Rule {...simulationConfig} dottedName={dottedName} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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 (
|
||||
<>
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 =>
|
||||
|
|
Loading…
Reference in New Issue