2020-04-23 15:44:41 +00:00
|
|
|
import React from 'react'
|
2019-10-08 15:34:45 +00:00
|
|
|
import { useSelector } from 'react-redux'
|
2020-04-05 21:27:31 +00:00
|
|
|
import { DottedName } from 'Rules'
|
2020-04-21 13:49:48 +00:00
|
|
|
import { parsedRulesSelector } from 'Selectors/analyseSelectors'
|
|
|
|
import répartitionSelector from 'Selectors/repartitionSelectors'
|
2018-06-12 10:21:36 +00:00
|
|
|
import './Distribution.css'
|
2018-06-18 09:10:26 +00:00
|
|
|
import './PaySlip'
|
2018-06-12 10:21:36 +00:00
|
|
|
import RuleLink from './RuleLink'
|
2020-04-23 15:44:41 +00:00
|
|
|
import BarChartBranch from './BarChart'
|
2018-06-12 10:21:36 +00:00
|
|
|
|
2019-10-08 15:34:45 +00:00
|
|
|
export default function Distribution() {
|
2020-04-21 13:49:48 +00:00
|
|
|
const distribution = useSelector(répartitionSelector) as any
|
2018-06-12 10:21:36 +00:00
|
|
|
|
2020-04-21 13:49:48 +00:00
|
|
|
if (!Object.values(distribution).length) {
|
|
|
|
return null
|
|
|
|
}
|
2019-09-11 08:06:26 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="distribution-chart__container">
|
2020-04-21 13:49:48 +00:00
|
|
|
{distribution.répartition.map(
|
|
|
|
([brancheDottedName, { partPatronale, partSalariale }]) => (
|
|
|
|
<DistributionBranch
|
|
|
|
key={brancheDottedName}
|
|
|
|
dottedName={brancheDottedName}
|
|
|
|
value={partPatronale + partSalariale}
|
2020-04-23 15:44:41 +00:00
|
|
|
maximum={distribution.maximum}
|
2020-04-21 13:49:48 +00:00
|
|
|
/>
|
|
|
|
)
|
|
|
|
)}
|
2019-09-11 08:06:26 +00:00
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)
|
2018-06-12 10:21:36 +00:00
|
|
|
}
|
2019-10-08 15:34:45 +00:00
|
|
|
|
2019-11-15 21:23:21 +00:00
|
|
|
type DistributionBranchProps = {
|
2020-03-30 17:14:03 +00:00
|
|
|
dottedName: DottedName
|
2019-11-15 21:23:21 +00:00
|
|
|
value: number
|
2020-04-23 15:44:41 +00:00
|
|
|
maximum: number
|
2019-11-15 21:23:21 +00:00
|
|
|
icon?: string
|
|
|
|
}
|
|
|
|
|
|
|
|
export function DistributionBranch({
|
|
|
|
dottedName,
|
|
|
|
value,
|
|
|
|
icon,
|
2020-04-23 15:44:41 +00:00
|
|
|
maximum
|
2019-11-15 21:23:21 +00:00
|
|
|
}: DistributionBranchProps) {
|
2020-04-21 13:49:48 +00:00
|
|
|
const rules = useSelector(parsedRulesSelector)
|
2020-04-23 15:44:41 +00:00
|
|
|
const branch = rules[dottedName]
|
2019-10-08 15:34:45 +00:00
|
|
|
return (
|
2020-04-23 15:44:41 +00:00
|
|
|
<BarChartBranch
|
|
|
|
value={value}
|
|
|
|
maximum={maximum}
|
|
|
|
title={<RuleLink {...branch} />}
|
|
|
|
icon={icon ?? branch.icons}
|
|
|
|
description={branch.summary}
|
|
|
|
unit="€"
|
|
|
|
/>
|
2019-10-08 15:34:45 +00:00
|
|
|
)
|
|
|
|
}
|