From 061cbfbd5ad06e50ccc0466497d593e2e88012b2 Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Thu, 13 Sep 2018 15:19:56 +0200 Subject: [PATCH] =?UTF-8?q?Ajoute=20un=20bouton=20retour=20pour=20remettre?= =?UTF-8?q?=20la=20simulation=20=C3=A0=20z=C3=A9ro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dans le futur, on pourra utiliser le bouton du navigateur --- source/components/AnswerList.js | 6 +++++- source/components/Simu.js | 19 +++++++++++++++---- source/components/ui/Button/button.css | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/source/components/AnswerList.js b/source/components/AnswerList.js index 1d7960c27..6594d2a06 100644 --- a/source/components/AnswerList.js +++ b/source/components/AnswerList.js @@ -9,6 +9,7 @@ import React from 'react' import emoji from 'react-easy-emoji' import { Trans } from 'react-i18next' import { connect } from 'react-redux' +import { reset } from 'redux-form' import { createSelector } from 'reselect' import { règleAvecValeurSelector } from 'Selectors/regleSelectors' import './AnswerList.css' @@ -89,7 +90,10 @@ export default compose( connect( state => ({ answers: answerWithValueSelector(state) }), dispatch => ({ - resetSimulation: () => dispatch(resetSimulation()), + resetSimulation: () => { + dispatch(resetSimulation()) + dispatch(reset('conversation')) + }, changeAnswer: question => dispatch({ type: 'STEP_ACTION', diff --git a/source/components/Simu.js b/source/components/Simu.js index 9ab56def0..8aac510c8 100644 --- a/source/components/Simu.js +++ b/source/components/Simu.js @@ -1,4 +1,4 @@ -import { startConversation } from 'Actions/actions' +import { resetSimulation, startConversation } from 'Actions/actions' import { ScrollToTop } from 'Components/utils/Scroll' import withColours from 'Components/utils/withColours' import withLanguage from 'Components/utils/withLanguage' @@ -7,6 +7,7 @@ import { Trans, translate } from 'react-i18next' import { connect } from 'react-redux' import { Link } from 'react-router-dom' import { animated, Spring } from 'react-spring' +import { reset } from 'redux-form' import { blockingInputControlsSelector, nextStepsSelector, @@ -33,9 +34,13 @@ import TargetSelection from './TargetSelection' arePreviousAnswers: state.conversationSteps.foldedSteps.length !== 0, nextSteps: state.conversationStarted && nextStepsSelector(state) }), - { - startConversation - } + dispatch => ({ + startConversation: () => dispatch(startConversation()), + resetSimulation: () => { + dispatch(resetSimulation()) + dispatch(reset('conversation')) + } + }) ) @withLanguage export default class Simu extends Component { @@ -50,6 +55,7 @@ export default class Simu extends Component { arePreviousAnswers, nextSteps, startConversation, + resetSimulation, blockingInputControls } = this.props const firstValidInputEntered = @@ -62,6 +68,11 @@ export default class Simu extends Component { return ( <>
+ {displayConversation && ( + + )} {arePreviousAnswers && (