diff --git a/source/components/Simulateur.js b/source/components/Simulateur.js index 1c2dc724f..fc86a7a0c 100644 --- a/source/components/Simulateur.js +++ b/source/components/Simulateur.js @@ -1,24 +1,23 @@ import R from 'ramda' import React, {Component} from 'react' import Helmet from 'react-helmet' -import {reduxForm, formValueSelector, reset} from 'redux-form' +import {formValueSelector, reset} from 'redux-form' import {connect} from 'react-redux' import {Redirect, Link, withRouter} from 'react-router-dom' import classNames from 'classnames' import {START_CONVERSATION} from '../actions' -import Aide from './Aide' import {createMarkdownDiv} from 'Engine/marked' import {rules, findRuleByName, decodeRuleName} from 'Engine/rules' import './conversation/conversation.css' import './Simulateur.css' import {capitalise0} from '../utils' -import Satisfaction from './Satisfaction' +import Conversation from './conversation/Conversation' + let situationSelector = formValueSelector('conversation') @withRouter -@reduxForm({form: 'conversation', destroyOnUnmount: false}) @connect( state => ({ situation: variableName => situationSelector(state, variableName), @@ -27,6 +26,7 @@ let situationSelector = formValueSelector('conversation') extraSteps: state.extraSteps, themeColours: state.themeColours, analysedSituation: state.analysedSituation, + situationGate: state.situationGate, }), dispatch => ({ startConversation: rootVariable => dispatch({type: START_CONVERSATION, rootVariable}), @@ -58,7 +58,7 @@ export default class extends React.Component { let started = !this.props.match.params.intro, - {foldedSteps, extraSteps, unfoldedSteps, situation} = this.props, + {foldedSteps, extraSteps, unfoldedSteps, situation, situationGate} = this.props, sim = path => R.path(R.unless(R.is(Array), R.of)(path))(this.rule.simulateur || {}), reinitalise = () => { @@ -67,7 +67,6 @@ export default class extends React.Component { }, title = sim('titre') || capitalise0(this.rule['titre'] || this.rule['nom']) - return (
@@ -109,85 +108,9 @@ export default class extends React.Component {

- : ( -
-
-
- { !R.isEmpty(foldedSteps) && -
-
-

Vos réponses

- -
- {foldedSteps - .map(step => ( - - ))} -
- } - { !R.isEmpty(extraSteps) && -
-
-

Affiner votre situation

-
- {extraSteps - .map(step => ( - - ))} -
- } -
- { !R.isEmpty(unfoldedSteps) && do { - let step = R.head(unfoldedSteps) - ; - }} -
- {unfoldedSteps.length == 0 && - } -
- -
-
- )} + : } ) } } - -class Conclusion extends Component { - render() { - return ( -
- -
-

- Votre simulation est terminée ! -

-

- N'hésitez pas à modifier vos réponses, ou cliquez sur vos résultats pour comprendre le calcul. -

- -
-
- ) - } -} diff --git a/source/components/conversation/Conversation.js b/source/components/conversation/Conversation.js new file mode 100644 index 000000000..675fc129f --- /dev/null +++ b/source/components/conversation/Conversation.js @@ -0,0 +1,91 @@ +import React, { Component } from 'react' +import R from 'ramda' +import Aide from '../Aide' +import Satisfaction from '../Satisfaction' +import {reduxForm} from 'redux-form' + +@reduxForm({ + form: "conversation", + destroyOnUnmount: false +}) +export default class Conversation extends Component { + render() { + let {foldedSteps, unfoldedSteps, extraSteps, reinitalise, situation, situationGate} = this.props + return ( +
+
+ { !R.isEmpty(foldedSteps) && +
+
+

Vos réponses

+ +
+ {foldedSteps + .map(step => ( + + ))} +
+ } + { !R.isEmpty(extraSteps) && +
+
+

Affiner votre situation

+
+ {extraSteps + .map(step => ( + + ))} +
+ } +
+ { !R.isEmpty(unfoldedSteps) && do { + let step = R.head(unfoldedSteps) + ; + }} +
+ {unfoldedSteps.length == 0 && + } +
+ +
+ ) + } +} + + +class Conclusion extends Component { + render() { + return ( +
+ +
+

+ Votre simulation est terminée ! +

+

+ N'hésitez pas à modifier vos réponses, ou cliquez sur vos résultats pour comprendre le calcul. +

+ +
+
+ ) + } +} diff --git a/source/reducers.js b/source/reducers.js index 76ebf7a7e..dc2683187 100644 --- a/source/reducers.js +++ b/source/reducers.js @@ -45,7 +45,8 @@ export let reduceSteps = (state, action) => { let newState = { ...state, analysedSituation, - situationGate: situationGate + situationGate: situationGate, + extraSteps: [] } if (action.type == START_CONVERSATION) {