mon-entreprise/source/components/Simu.js

169 lines
4.6 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 ResultView from './ResultView'
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 })}>
<Trans> Modifier mes réponses</Trans>
</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>
<Trans i18nKey="simulation-end.title">
Plus de questions !
</Trans>
</h1>
<p>
<Trans i18nKey="simulation-end.text">
Vous avez atteint l'estimation la plus précise. Vous pouvez
maintenant concrétiser votre projet d'embauche.
</Trans>
</p>
2018-07-06 16:25:59 +00:00
<div style={{ textAlign: 'center' }}>
<Link className="ui__ button" to="/hiring-process">
<Trans i18nKey="simulation-end.cta">
Connaître les démarches
</Trans>
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>
<ResultView />
2018-07-12 08:09:41 +00:00
</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>
<Trans>A quoi servent mes cotisations ?</Trans>
</h2>
<Distribution />
<h2>
<Trans>Estimer mes coûts réels</Trans>
</h2>
<p>
<Trans i18nk="estimate-real-costs">
Il s'agit d'une <strong>estimation brut</strong> sur la base
d'un contrat générique pré-établi. La législation française
prévoit une multitude de cas particuliers et des règles
spécifiques qui peuvent modifier considérablement les coûts
d'embauche.
</Trans>
</p>
<p style={{ textAlign: 'center' }}>
<button className="ui__ button" onClick={startConversation}>
<Trans>Estimer mes coûts réels</Trans>
</button>
</p>
<h2>
<Trans>Fiche de paie</Trans>
</h2>
<PaySlip />
</Animate.fromBottom>
)}
</>
)
}
}