import { ThemeColoursContext } from 'Components/utils/withColours' import Value from 'Components/Value' import { findRuleByDottedName } from 'Engine/rules' import React, { useContext } from 'react' import emoji from 'react-easy-emoji' import { useSelector } from 'react-redux' import { config, animated, useSpring } from 'react-spring' import { flatRulesSelector } from 'Selectors/analyseSelectors' import répartitionSelector from 'Selectors/repartitionSelectors' import { isIE } from '../utils' import './Distribution.css' import './PaySlip' import RuleLink from './RuleLink' import useDisplayOnIntersecting from 'Components/utils/useDisplayOnIntersecting' export default function Distribution() { const distribution = useSelector(répartitionSelector) if (!Object.values(distribution).length) { return null } return ( <>
{distribution.répartition.map( ([brancheDottedName, { partPatronale, partSalariale }]) => ( ) )}
) } const ANIMATION_SPRING = config.gentle function DistributionBranch({ brancheDottedName, partPatronale, partSalariale, distribution }) { const rules = useSelector(flatRulesSelector) const [intersectionRef, brancheInViewport] = useDisplayOnIntersecting({ threshold: 0.5 }) const colours = useContext(ThemeColoursContext) const branche = findRuleByDottedName(rules, brancheDottedName) const montant = brancheInViewport ? partPatronale + partSalariale : 0 const styles = useSpring({ config: ANIMATION_SPRING, to: { flex: montant / distribution.cotisationMaximum, opacity: montant ? 1 : 0 } }) return (


{branche.summary}

) } let ChartItemBar = ({ styles, colour, montant }) => (
{montant}
) let BranchIcône = ({ icône }) => (
{emoji(icône)}
)