Ajoute un bouton retour pour remettre la simulation à zéro

Dans le futur, on pourra utiliser le bouton du navigateur
pull/360/head
Johan Girod 2018-09-13 15:19:56 +02:00
parent a713d3d4d9
commit 061cbfbd5a
3 changed files with 21 additions and 6 deletions

View File

@ -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',

View File

@ -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 (
<>
<div id="simu">
{displayConversation && (
<button className="ui__ button small" onClick={resetSimulation}>
&larr;
</button>
)}
{arePreviousAnswers && (
<div className="change-answer-link">
<button

View File

@ -56,7 +56,7 @@
var(--colour) 50%,
rgba(255, 255, 255, 0.52) 55%
);
background-size: 260%;
background-size: 280%;
background-position-x: 99%;
}
.ui__.button:not(:disabled):not(.simple):hover,