import { ThemeColorsContext } from 'Components/utils/colors' import useDisplayOnIntersecting from 'Components/utils/useDisplayOnIntersecting' import Value from 'Components/Value' import React, { useContext } from 'react' import emoji from 'react-easy-emoji' import { useSelector } from 'react-redux' import { animated, config, useSpring } from 'react-spring' import { DottedName } from 'Rules' import { parsedRulesSelector } from 'Selectors/analyseSelectors' import répartitionSelector from 'Selectors/repartitionSelectors' import { isIE } from '../utils' import './Distribution.css' import './PaySlip' import RuleLink from './RuleLink' export default function Distribution() { const distribution = useSelector(répartitionSelector) as any if (!Object.values(distribution).length) { return null } return ( <>
{distribution.répartition.map( ([brancheDottedName, { partPatronale, partSalariale }]) => ( ) )}
) } type DistributionBranchProps = { dottedName: DottedName value: number distribution: { maximum: number; total: number } icon?: string } const ANIMATION_SPRING = config.gentle export function DistributionBranch({ dottedName, value, icon, distribution }: DistributionBranchProps) { const rules = useSelector(parsedRulesSelector) const [intersectionRef, brancheInViewport] = useDisplayOnIntersecting({ threshold: 0.5 }) const { color } = useContext(ThemeColorsContext) const branche = rules[dottedName] const montant = brancheInViewport ? value : 0 const styles = useSpring({ config: ANIMATION_SPRING, to: { flex: montant / distribution.maximum, opacity: montant ? 1 : 0 } }) as { flex: number; opacity: number } // TODO: problème avec les types de react-spring ? return (


{branche.summary}

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