import { startConversation } from 'Actions/actions' 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 { blockingInputControlsSelector, nextStepsSelector } from 'Selectors/analyseSelectors' import { noUserInputSelector } from 'Selectors/situationSelectors' 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 Sondage from './Sondage' 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) }), { startConversation } ) @withLanguage export default class Simu extends Component { state = { displayPreviousAnswers: false } render() { let { colours, conversationStarted, noUserInput, arePreviousAnswers, nextSteps, startConversation, 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 ( <>