mon-entreprise/source/components/Simu.js

151 lines
4.1 KiB
JavaScript
Raw Normal View History

import { startConversation } from 'Actions/actions'
import ScrollToTop from 'Components/utils/ScrollToTop'
2018-07-12 08:09:41 +00:00
import withColours from 'Components/utils/withColours'
import React, { Component } from 'react'
2018-07-12 08:09:41 +00:00
import { Trans } from 'react-i18next'
2018-06-06 16:17:13 +00:00
import { connect } from 'react-redux'
import { Link } from 'react-router-dom'
import { animated, Spring } from 'react-spring'
import {
blockingInputControlsSelector,
2018-07-06 16:25:59 +00:00
nextStepsSelector,
noUserInputSelector
} from 'Selectors/analyseSelectors'
2018-07-12 08:09:41 +00:00
import * as Animate from 'Ui/animate'
import AnswerList from './AnswerList'
import Conversation from './conversation/Conversation'
2018-07-12 08:09:41 +00:00
import Distribution from './Distribution'
import PaySlip from './PaySlip'
import QuickLink from './QuickLink'
import './Simu.css'
import TargetSelection from './TargetSelection'
2018-06-06 16:17:13 +00:00
@withColours
@connect(
state => ({
noUserInput: noUserInputSelector(state),
blockingInputControls: blockingInputControlsSelector(state),
2018-07-06 16:25:59 +00:00
conversationStarted: state.conversationStarted,
arePreviousAnswers: state.conversationSteps.foldedSteps.length !== 0,
2018-07-06 16:25:59 +00:00
nextSteps: state.conversationStarted && nextStepsSelector(state)
}),
{
startConversation
}
)
export default class Simu extends Component {
state = {
displayPreviousAnswers: false
}
render() {
let {
colours,
conversationStarted,
noUserInput,
arePreviousAnswers,
2018-07-06 16:25:59 +00:00
nextSteps,
startConversation,
blockingInputControls
} = this.props
2018-07-06 16:25:59 +00:00
const firstValidInputEntered =
!conversationStarted && !blockingInputControls && !noUserInput
const displayConversation = conversationStarted && !blockingInputControls
2018-07-06 16:25:59 +00:00
const simulationCompleted =
!blockingInputControls && conversationStarted && !nextSteps.length
const displayPreviousAnswers =
arePreviousAnswers && this.state.displayPreviousAnswers
2018-07-06 16:25:59 +00:00
return (
<>
<div id="simu">
{arePreviousAnswers && (
<div className="change-answer-link">
<button
className="ui__ link-button"
onClick={() => this.setState({ displayPreviousAnswers: true })}>
Change my answers
</button>
</div>
)}
<Spring
to={{
2018-07-06 16:25:59 +00:00
height: firstValidInputEntered ? 'auto' : 0,
opacity: firstValidInputEntered ? 1 : 0
}}
native>
{styles => (
<animated.div
2018-07-12 08:09:41 +00:00
className="ui__ button-container"
style={{
...styles,
display: 'flex',
overflow: 'hidden',
flexWrap: 'wrap',
fontSize: '110%',
justifyContent: 'space-evenly'
}}>
<QuickLink />
</animated.div>
)}
</Spring>
{simulationCompleted && (
<>
<h1>No more questions left!</h1>
<p>
<Trans>
You have reached the most accurate estimate. You can now turn
your hiring project into reality.
</Trans>
</p>
2018-07-06 16:25:59 +00:00
<div style={{ textAlign: 'center' }}>
<Link className="ui__ button" to="/hiring-process">
See the procedures
2018-07-06 16:25:59 +00:00
</Link>
</div>
</>
)}
<div id="focusZone">
{displayConversation && (
<>
<ScrollToTop />
<Conversation textColourOnWhite={colours.textColourOnWhite} />
</>
2018-07-06 16:25:59 +00:00
)}
<TargetSelection colours={colours} />
</div>
{conversationStarted && (
2018-07-12 08:09:41 +00:00
<Animate.fromBottom>
<h2>Payslip</h2>
2018-07-12 08:09:41 +00:00
<PaySlip />
</Animate.fromBottom>
)}
{displayPreviousAnswers && (
<AnswerList
onClose={() => this.setState({ displayPreviousAnswers: false })}
/>
)}
2018-03-15 14:51:39 +00:00
</div>
2018-07-06 16:25:59 +00:00
{firstValidInputEntered && (
<Animate.fromBottom>
<h2>What&apos;s included in my contributions?</h2>
<Distribution />
<h2>Estimate my real costs</h2>
<p>
This is a <strong>rough estimate</strong> based on a pre-made
generic contract. French legislation provides for a multitude of
special cases, and specific rules that can considerably change
hiring costs.
</p>
<p style={{ textAlign: 'center' }}>
<button className="ui__ button" onClick={startConversation}>
Estimate my real costs
</button>
</p>
</Animate.fromBottom>
)}
</>
)
}
}