2019-01-08 18:19:19 +00:00
|
|
|
import Answers from 'Components/AnswerList'
|
|
|
|
import Conversation from 'Components/conversation/Conversation'
|
2019-01-14 17:53:18 +00:00
|
|
|
import { ScrollToElement } from 'Components/utils/Scroll'
|
2019-01-08 18:19:19 +00:00
|
|
|
import withColours from 'Components/utils/withColours'
|
|
|
|
import { compose, isEmpty } from 'ramda'
|
|
|
|
import React from 'react'
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import {
|
|
|
|
nextStepsSelector,
|
2019-01-17 14:34:44 +00:00
|
|
|
noUserInputSelector,
|
|
|
|
blockingInputControlsSelector,
|
|
|
|
validInputEnteredSelector
|
2019-01-08 18:19:19 +00:00
|
|
|
} from 'Selectors/analyseSelectors'
|
|
|
|
import Animate from 'Ui/animate'
|
|
|
|
|
|
|
|
export default compose(
|
|
|
|
withColours,
|
|
|
|
connect(state => ({
|
2019-01-17 14:34:44 +00:00
|
|
|
conversationStarted: state.conversationStarted,
|
2019-01-08 18:19:19 +00:00
|
|
|
previousAnswers: state.conversationSteps.foldedSteps,
|
|
|
|
noNextSteps: nextStepsSelector(state).length == 0,
|
2019-01-17 14:34:44 +00:00
|
|
|
noUserInput: noUserInputSelector(state),
|
|
|
|
blockingInputControls: blockingInputControlsSelector(state),
|
|
|
|
validInputEntered: validInputEnteredSelector(state)
|
2019-01-08 18:19:19 +00:00
|
|
|
}))
|
|
|
|
)(
|
2019-01-17 14:34:44 +00:00
|
|
|
class Simulation extends React.Component {
|
2019-01-08 18:19:19 +00:00
|
|
|
state = {
|
|
|
|
displayAnswers: false
|
|
|
|
}
|
|
|
|
render() {
|
2019-01-11 10:24:29 +00:00
|
|
|
let {
|
|
|
|
noNextSteps,
|
|
|
|
previousAnswers,
|
|
|
|
noUserInput,
|
2019-01-17 14:34:44 +00:00
|
|
|
conversationStarted,
|
|
|
|
hideUntilUserInput,
|
|
|
|
blockingInputControls
|
2019-01-11 10:24:29 +00:00
|
|
|
} = this.props
|
2019-01-17 14:34:44 +00:00
|
|
|
let arePreviousAnswers = previousAnswers.length > 0,
|
|
|
|
displayConversation = conversationStarted && !blockingInputControls
|
2019-01-08 18:19:19 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{this.state.displayAnswers && (
|
|
|
|
<Answers onClose={() => this.setState({ displayAnswers: false })} />
|
|
|
|
)}
|
2019-01-11 10:24:29 +00:00
|
|
|
{!isEmpty(previousAnswers) && (
|
|
|
|
<button
|
|
|
|
className="ui__ button small plain"
|
2019-01-17 14:34:44 +00:00
|
|
|
style={{
|
|
|
|
visibility: arePreviousAnswers ? 'visible' : 'hidden'
|
|
|
|
}}>
|
|
|
|
onClick={() => this.setState({ displayAnswers: true })}> Mes
|
|
|
|
réponses
|
2019-01-11 10:24:29 +00:00
|
|
|
</button>
|
|
|
|
)}
|
2019-01-17 14:34:44 +00:00
|
|
|
|
|
|
|
{displayConversation && (
|
|
|
|
<>
|
|
|
|
<Conversation
|
|
|
|
textColourOnWhite={this.props.colours.textColourOnWhite}
|
|
|
|
/>
|
|
|
|
{noNextSteps && (
|
|
|
|
<>
|
|
|
|
<h2>Plus de questions ! </h2>
|
|
|
|
<p>Vous avez atteint l'estimation la plus précise.</p>
|
|
|
|
{this.props.customEndMessage && (
|
|
|
|
<p>{this.props.customEndMessage}</p>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
<Animate.fromBottom>{this.props.targets}</Animate.fromBottom>
|
|
|
|
{!noUserInput && this.props.explication}
|
2019-01-08 18:19:19 +00:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|