-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
SalaryExplanation.js
115 lines (111 loc) · 2.93 KB
/
SalaryExplanation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { T } from 'Components'
import Distribution from 'Components/Distribution'
import PaySlip from 'Components/PaySlip'
import { compose } from 'ramda'
import React, { useRef } from 'react'
import emoji from 'react-easy-emoji'
import { Trans } from 'react-i18next'
import { connect } from 'react-redux'
import { usePeriod } from 'Selectors/analyseSelectors'
import * as Animate from 'Ui/animate'
class ErrorBoundary extends React.Component {
state = {}
static getDerivedStateFromError() {
return {
error:
'The SalaryExplanation component triggered an error. This often happens in its subcomponents reducers'
}
}
render() {
if (this.state.error)
return <div css="background: red; ">Erreur : {this.state.error}</div>
return this.props.children
}
}
export default compose(
connect(state => ({
showDistributionFirst: !state.conversationSteps.foldedSteps.length
}))
)(function SalaryExplanation({ showDistributionFirst }) {
const distributionRef = useRef({})
return (
<ErrorBoundary>
<Animate.fromTop key={showDistributionFirst}>
{showDistributionFirst ? (
<>
<DistributionSection />
<PaySlipSection />
</>
) : (
<>
<div css="text-align: center">
<button
className="ui__ small simple button"
onClick={() =>
distributionRef.current.scrollIntoView({
behavior: 'smooth',
block: 'start'
})
}>
{emoji('📊')} <T>Voir la répartition des cotisations</T>
</button>
</div>
<PaySlipSection />
<div ref={distributionRef}>
<DistributionSection />
</div>
</>
)}
<br />
<p className="ui__ notice">
<Trans i18nKey="payslip.notice">
Le simulateur vous aide à comprendre votre bulletin de paie, sans
lui être opposable. Pour plus d'informations, rendez vous
sur
<a
alt="service-public.fr"
href="https://www.service-public.fr/particuliers/vosdroits/F559">
service-public.fr
</a>
.
</Trans>
</p>
<p className="ui__ notice">
<Trans i18nKey="payslip.disclaimer">
Il ne prend pour l'instant pas en compte les accords et conventions
collectives, ni la myriade d'aides aux entreprises. Trouvez votre
convention collective{' '}
<a href="https://socialgouv.github.io/conventions-collectives">
ici
</a>
, et explorez les aides sur
<a href="https://www.aides-entreprises.fr">aides-entreprises.fr</a>.
</Trans>
</p>
</Animate.fromTop>
</ErrorBoundary>
)
})
function PaySlipSection() {
const period = usePeriod()
return (
<section>
<h2>
<Trans>
{period === 'mois'
? 'Fiche de paie mensuelle'
: 'Détail annuel des cotisations'}
</Trans>
</h2>
<PaySlip />
</section>
)
}
const DistributionSection = () => (
<section>
<h2>
<Trans>À quoi servent mes cotisations ?</Trans>
</h2>
<Distribution />
</section>
)