/* @flow */ import Observer from '@researchgate/react-intersection-observer' import withColours from 'Components/utils/withColours' import Value from 'Components/Value' import { findRuleByDottedName } from 'Engine/rules' import React, { useState } from 'react' import emoji from 'react-easy-emoji' import { connect } from 'react-redux' import { config, Spring } from 'react-spring' import { compose } from 'redux' 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 type { ThemeColours } from 'Components/utils/withColours' import type { Répartition } from 'Types/ResultViewTypes.js' type Props = ?Répartition & { colours: ThemeColours } const ANIMATION_SPRING = config.gentle function Distribution({ colours: { colour }, rules, // $FlowFixMe ...distribution }: Props) { const [branchesInViewport, setBranchesInViewport] = useState([]) const handleBrancheInViewport = branche => (event, unobserve) => { if (!event.isIntersecting) { return } unobserve() setBranchesInViewport(branchesInViewport => [ branche, ...branchesInViewport ]) } if (!Object.values(distribution).length) { return null } const { répartition, cotisationMaximum, total, cotisations, salaireChargé, salaireNet } = distribution return ( <>
{branche.summary}