import { resetSimulation, startConversation } from 'Actions/actions' import { ScrollToTop } from 'Components/utils/Scroll' import withColours from 'Components/utils/withColours' import withLanguage from 'Components/utils/withLanguage' import React, { Component } from 'react' 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, noUserInputSelector } from 'Selectors/analyseSelectors' import * as Animate from 'Ui/animate' import AnswerList from './AnswerList' import Conversation from './conversation/Conversation' import Distribution from './Distribution' import PaySlip from './PaySlip' import QuickLink from './QuickLink' import ResultView from './ResultView' import './Simu.css' import TargetSelection from './TargetSelection' @withColours @translate() // Triggers rerender when the language changes @connect( state => ({ noUserInput: noUserInputSelector(state), blockingInputControls: blockingInputControlsSelector(state), conversationStarted: state.conversationStarted, arePreviousAnswers: state.conversationSteps.foldedSteps.length !== 0, nextSteps: state.conversationStarted && nextStepsSelector(state) }), dispatch => ({ startConversation: () => dispatch(startConversation()), resetSimulation: () => { dispatch(resetSimulation()) dispatch(reset('conversation')) } }) ) @withLanguage class Simu extends Component { state = { displayPreviousAnswers: false } render() { let { colours, conversationStarted, noUserInput, arePreviousAnswers, nextSteps, startConversation, resetSimulation, blockingInputControls } = this.props const firstValidInputEntered = !conversationStarted && !blockingInputControls && !noUserInput const displayConversation = conversationStarted && !blockingInputControls const simulationCompleted = !blockingInputControls && conversationStarted && !nextSteps.length const displayPreviousAnswers = arePreviousAnswers && this.state.displayPreviousAnswers return ( <>