diff --git a/source/actions.js b/source/actions.js index cc613bfe7..1d4466155 100644 --- a/source/actions.js +++ b/source/actions.js @@ -1,11 +1,23 @@ +/* @flow */ +import type { ResetSimulationAction } from './types/Actions' + // The input "conversation" is composed of "steps" // The state keeps track of which of them have been submitted // The user can also come back to one of his answers and edit it export const STEP_ACTION = 'STEP_ACTION' + +// $FlowFixMe export function stepAction(name, step, source) { return { type: STEP_ACTION, name, step, source } } +export function resetSimulation(): ResetSimulationAction { + return { + type: 'RESET_SIMULATION' + } +} + +// $FlowFixMe export function setExample(name, situation) { return { type: 'SET_EXAMPLE', situation, name } } @@ -13,6 +25,8 @@ export function setExample(name, situation) { export const START_CONVERSATION = 'START_CONVERSATION' export const CHANGE_THEME_COLOUR = 'CHANGE_THEME_COLOUR' + +// $FlowFixMe export function changeThemeColour(colour) { return { type: CHANGE_THEME_COLOUR, colour } } diff --git a/source/components/conversation/FoldedSteps.js b/source/components/conversation/FoldedSteps.js index 382dc1347..f9445788a 100644 --- a/source/components/conversation/FoldedSteps.js +++ b/source/components/conversation/FoldedSteps.js @@ -4,7 +4,8 @@ import { connect } from 'react-redux' //import styles from './.css' // css in conversation.Css import { isEmpty, map, pick } from 'ramda' -import ReactPiwik from '../Tracker' +import { reset } from 'redux-form' +import { resetSimulation } from '../../actions' import { getInputComponent } from 'Engine/generateQuestions' import withColours from '../withColours' import { scroller, Element, animateScroll } from 'react-scroll' @@ -21,20 +22,20 @@ import { scroller, Element, animateScroll } from 'react-scroll' 'analysis', 'flatRules' ]), - dispatch => ({ - reinitialise: () => { - ReactPiwik.push(['trackEvent', 'restart', '']) - // TODO horrible hack : our state should be refactored to enable resetting the relevant part of it - window.location.reload(false) - } - }) + { + resetSimulation, + resetForm: () => reset('conversation') + } ) @translate() -export default class extends Component { +export default class FoldedSteps extends Component { + handleSimulationReset = () => { + this.props.resetForm() + this.props.resetSimulation() + } render() { let { foldedSteps, - reinitialise, targetNames, flatRules, themeColours: { textColourOnWhite } @@ -44,7 +45,9 @@ export default class extends Component { return (
-