diff --git a/source/components/Simulateur.css b/source/components/Simulateur.css
index da3bd4ad6..755370cea 100644
--- a/source/components/Simulateur.css
+++ b/source/components/Simulateur.css
@@ -81,6 +81,13 @@
-#fin {
+#sim .tip {
font-style: italic;
+ margin-bottom: 2em;
+}
+#sim .tip p {
+ margin: 0;
+}
+#sim .tip progress {
+ margin-left: 1em;
}
diff --git a/source/components/Simulateur.js b/source/components/Simulateur.js
index e9352044c..d2df0c04f 100644
--- a/source/components/Simulateur.js
+++ b/source/components/Simulateur.js
@@ -24,6 +24,8 @@ import Results from 'Components/Results'
themeColours: state.themeColours,
situationGate: state.situationGate,
targetNames: state.targetNames,
+ done: state.done,
+ nextSteps: state.nextSteps,
inputInversions: formValueSelector('conversation')(state, 'inversions')
}),
dispatch => ({
@@ -107,6 +109,8 @@ export default class extends Component {
),
foldedSteps
),
+ done: this.props.done,
+ nextSteps: this.props.nextSteps,
textColourOnWhite: themeColours.textColourOnWhite
}}
/>
diff --git a/source/components/conversation/Conversation.js b/source/components/conversation/Conversation.js
index f59eccb8b..ff0c3d8cb 100644
--- a/source/components/conversation/Conversation.js
+++ b/source/components/conversation/Conversation.js
@@ -2,7 +2,7 @@ import React, { Component } from 'react'
import R from 'ramda'
import Aide from '../Aide'
import Satisfaction from '../Satisfaction'
-import {reduxForm} from 'redux-form'
+import { reduxForm } from 'redux-form'
import Scroll from 'react-scroll'
@reduxForm({
@@ -11,36 +11,57 @@ import Scroll from 'react-scroll'
})
export default class Conversation extends Component {
render() {
- let {foldedSteps, currentQuestion, reinitalise, textColourOnWhite} = this.props
+ let {
+ foldedSteps,
+ currentQuestion,
+ reinitalise,
+ textColourOnWhite,
+ done,
+ nextSteps
+ } = this.props
Scroll.animateScroll.scrollToBottom()
return (
- { !R.isEmpty(foldedSteps) &&
+ {!R.isEmpty(foldedSteps) && (
-
-
Vos réponses
-
- }
- {!currentQuestion &&
-
}
- { !R.isEmpty({}) &&
-
-
-
Affiner votre situation
-
- {}
+ )}
+ {done && (
+
+ {nextSteps.length != 0 && (
+
Votre première estimation est disponible !
+ )}
+ {nextSteps.length != 0 && (
+
+ Il vous reste environ {nextSteps.length}{' '}
+ {nextSteps.length === 1 ? 'questions' : 'question'} pour
+ affiner le calcul
+
+
+ )}
- }
+ )}
- { currentQuestion || }
+ {currentQuestion || }
@@ -48,12 +69,3 @@ export default class Conversation extends Component {
)
}
}
-
-let Conclusion = ({ affiner }) => (
-
-
- Vous pouvez maintenant modifier vos réponses{" "}
- {affiner && "ou affiner votre situation"} : vos résultats ci-dessous seront mis à jour.
-
-
-)
diff --git a/source/engine/generateQuestions.js b/source/engine/generateQuestions.js
index 07eda0374..4878c5836 100644
--- a/source/engine/generateQuestions.js
+++ b/source/engine/generateQuestions.js
@@ -40,7 +40,7 @@ export let collectMissingVariables = targets =>
// R.reduce( (memo, [mv, dependencyOf]) => ({...memo, [mv]: [...(memo[mv] || []), dependencyOf] }), {})
)(targets)
-export let nextSteps = (situationGate, flatRules, analysis) => {
+export let getNextSteps = (situationGate, flatRules, analysis) => {
let impact = ([variable, objectives]) => R.length(objectives)
let missingVariables = collectMissingVariables(analysis.targets),
diff --git a/source/reducers.js b/source/reducers.js
index 7abeeb7d6..3eff9f8ea 100644
--- a/source/reducers.js
+++ b/source/reducers.js
@@ -1,4 +1,4 @@
-import R from 'ramda'
+import R, {head} from 'ramda'
import { combineReducers } from 'redux'
import reduceReducers from 'reduce-reducers'
import { reducer as formReducer, formValueSelector } from 'redux-form'
@@ -10,7 +10,7 @@ import {
nameLeaf,
formatInputs
} from 'Engine/rules'
-import { nextSteps } from 'Engine/generateQuestions'
+import { getNextSteps } from 'Engine/generateQuestions'
import computeThemeColours from 'Components/themeColours'
import {
STEP_ACTION,
@@ -30,6 +30,16 @@ let assume = (evaluator, assumptions) => state => name => {
return userInput != null ? userInput : assumptions[name]
}
+let nextWithoutDefaults = (state, flatRules, analysis, targetNames, intermediateSituation) => {
+ let
+ reanalysis = analyse(analysis.parsedRules, targetNames)(
+ intermediateSituation(state)
+ ),
+ nextSteps = getNextSteps(intermediateSituation(state), flatRules, reanalysis)
+
+ return {currentQuestion: head(nextSteps), nextSteps}
+}
+
export let reduceSteps = (tracker, flatRules, answerSource) => (
state,
action
@@ -52,22 +62,10 @@ export let reduceSteps = (tracker, flatRules, answerSource) => (
let
parsedRules = R.path(['analysis', 'parsedRules'], state),
analysis = analyse(parsedRules || flatRules, targetNames)(situationWithDefaults(state)),
- next = nextSteps(situationWithDefaults(state), flatRules, analysis),
+ nextWithDefaults = getNextSteps(situationWithDefaults(state), flatRules, analysis),
assumptionsMade = !R.isEmpty(rulesDefaults),
- done = next.length == 0,
- currentQuestion =
- done && assumptionsMade
- ? // The simulation is "over" - except we can now fill in extra questions
- // where the answers were previously given default reasonable assumptions
- do {
- let
- reanalysis = analyse(analysis.parsedRules, targetNames)(
- intermediateSituation(state)
- ),
- next = nextSteps(intermediateSituation(state), flatRules, reanalysis)
- R.head(next)
- }
- : R.head(next)
+ done = nextWithDefaults.length == 0
+
let newState = {
...state,
@@ -75,7 +73,13 @@ export let reduceSteps = (tracker, flatRules, answerSource) => (
analysis,
situationGate: situationWithDefaults(state),
explainedVariable: null,
- currentQuestion
+ done,
+ ... (done && assumptionsMade
+ ?
+ // The simulation is "over" - except we can now fill in extra questions
+ // where the answers were previously given default reasonable assumptions
+ nextWithoutDefaults(state, flatRules, analysis, targetNames, intermediateSituation)
+ : {currentQuestion: head(nextWithDefaults), nextSteps: nextWithDefaults})
}
if (action.type == START_CONVERSATION) {
@@ -142,13 +146,15 @@ export default reduceReducers(
false means the user is reconsidering its previous input */
foldedSteps: (steps = []) => steps,
currentQuestion: (state = null) => state,
+ nextSteps: (state = []) => state,
analysis: (state = null) => state,
targetNames: (state = null) => state,
situationGate: (state = name => null) => state,
- refine: (state = false) => state,
+
+ done: (state = null) => state,
themeColours,
diff --git a/test/generateQuestions.test.js b/test/generateQuestions.test.js
index 745534314..32ff70ae3 100644
--- a/test/generateQuestions.test.js
+++ b/test/generateQuestions.test.js
@@ -213,7 +213,7 @@ describe('nextSteps', function() {
{nom: "ko", espace: "top . sum . evt"}],
rules = rawRules.map(enrichRule),
analysis = analyse(rules,"sum")(stateSelector),
- result = nextSteps(stateSelector, rules, analysis)
+ result = getNextSteps(stateSelector, rules, analysis)
expect(result).to.have.lengthOf(1)
expect(result[0]).to.equal("top . sum . evt")
@@ -223,7 +223,7 @@ describe('nextSteps', function() {
let rules = realRules.map(enrichRule),
analysis = analyse(rules,"surcoût CDD")(stateSelector),
missing = collectMissingVariables(analysis.targets),
- result = nextSteps(stateSelector, rules, analysis)
+ result = getNextSteps(stateSelector, rules, analysis)
// expect(objectives).to.have.lengthOf(4)
@@ -254,7 +254,7 @@ describe('nextSteps', function() {
let rules = realRules.map(enrichRule),
analysis = analyse(rules,"salaire")(stateSelector),
missing = collectMissingVariables(analysis.targets),
- result = nextSteps(stateSelector, rules, analysis)
+ result = getNextSteps(stateSelector, rules, analysis)
expect(result[0]).to.equal("contrat salarié . salaire de base")
expect(result[1]).to.equal("contrat salarié . temps partiel")
@@ -266,7 +266,7 @@ describe('nextSteps', function() {
let rules = realRules.map(enrichRule),
analysis = analyse(rules,"salaire net")(stateSelector),
missing = collectMissingVariables(analysis.targets),
- result = nextSteps(stateSelector, rules, analysis)
+ result = getNextSteps(stateSelector, rules, analysis)
expect(result).to.include("contrat salarié . CDD . motif")
});