diff --git a/publicode/rules/salarié.yaml b/publicode/rules/salarié.yaml index 16d2e0ebd..627b04c3f 100644 --- a/publicode/rules/salarié.yaml +++ b/publicode/rules/salarié.yaml @@ -1230,7 +1230,6 @@ contrat salarié . rémunération . primes . activité: contrat salarié . rémunération . primes . activité . base: titre: primes d'activité unité: €/mois - question: Quel est le montant des primes liées à l'activité du salarié ? par défaut: 0 @@ -3136,6 +3135,7 @@ contrat salarié . taxe sur les salaires . barème: contrat salarié . profession spécifique: question: Le salarié exerce t-il l'une des professions suivantes ? + par défaut: non formule: une possibilité: possibilités: diff --git a/source/components/Distribution.tsx b/source/components/Distribution.tsx index f6d1a0b5d..ce35eac17 100644 --- a/source/components/Distribution.tsx +++ b/source/components/Distribution.tsx @@ -1,12 +1,11 @@ import { ThemeColorsContext } from 'Components/utils/colors' import useDisplayOnIntersecting from 'Components/utils/useDisplayOnIntersecting' 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 { animated, config, useSpring } from 'react-spring' -import { flatRulesSelector } from 'Selectors/analyseSelectors' +import { parsedRulesSelector } from 'Selectors/analyseSelectors' import répartitionSelector from 'Selectors/repartitionSelectors' import { Rule } from 'Types/rule' import { isIE } from '../utils' @@ -53,12 +52,12 @@ export function DistributionBranch({ icon, distribution }: DistributionBranchProps) { - const rules = useSelector(flatRulesSelector) + const rules = useSelector(parsedRulesSelector) const [intersectionRef, brancheInViewport] = useDisplayOnIntersecting({ threshold: 0.5 }) const { color } = useContext(ThemeColorsContext) - const branche = findRuleByDottedName(rules, dottedName) + const branche = rules[dottedName] const montant = brancheInViewport ? value : 0 const styles = useSpring({ config: ANIMATION_SPRING, diff --git a/source/components/PaySlip.tsx b/source/components/PaySlip.tsx index 7eda9358d..4159c270e 100644 --- a/source/components/PaySlip.tsx +++ b/source/components/PaySlip.tsx @@ -1,6 +1,6 @@ import { ThemeColorsContext } from 'Components/utils/colors' import Value from 'Components/Value' -import { findRuleByDottedName, getRuleFromAnalysis } from 'Engine/rules' +import { getRuleFromAnalysis } from 'Engine/ruleUtils' import React, { Fragment, useContext } from 'react' import { Trans } from 'react-i18next' import { useSelector } from 'react-redux' @@ -64,7 +64,7 @@ export default function PaySlip() { Part salarié {cotisations.map(([brancheDottedName, cotisationList]) => { - let branche = findRuleByDottedName(parsedRules, brancheDottedName) + let branche = parsedRules[brancheDottedName] return (
diff --git a/source/components/PaySlipSections.tsx b/source/components/PaySlipSections.tsx index e7b4dde09..4c1675053 100644 --- a/source/components/PaySlipSections.tsx +++ b/source/components/PaySlipSections.tsx @@ -92,15 +92,15 @@ export let SalaireNetSection = ({ getRule }) => { Salaire net
{netImposable && } - {(avantagesEnNature.nodeValue || retenueTitresRestaurant.nodeValue) && ( + {(avantagesEnNature?.nodeValue || retenueTitresRestaurant?.nodeValue) && ( )} - {!!avantagesEnNature.nodeValue && ( + {!!avantagesEnNature?.nodeValue && ( )} - {!!retenueTitresRestaurant.nodeValue && ( + {!!retenueTitresRestaurant?.nodeValue && ( )} diff --git a/source/components/RuleLink.tsx b/source/components/RuleLink.tsx index 37fcca80d..53fd75e96 100644 --- a/source/components/RuleLink.tsx +++ b/source/components/RuleLink.tsx @@ -1,6 +1,6 @@ import { ThemeColorsContext } from 'Components/utils/colors' import { SitePathsContext } from 'Components/utils/withSitePaths' -import { nameLeaf } from 'Engine/rules' +import { nameLeaf } from 'Engine/ruleUtils' import React, { useContext } from 'react' import { Link } from 'react-router-dom' import { Rule } from 'Types/rule' diff --git a/source/components/RulePage.tsx b/source/components/RulePage.tsx index 97e9840e5..003bb5d08 100644 --- a/source/components/RulePage.tsx +++ b/source/components/RulePage.tsx @@ -1,13 +1,13 @@ import { goBackToSimulation } from 'Actions/actions' import { ScrollToTop } from 'Components/utils/Scroll' -import { decodeRuleName, findRuleByDottedName } from 'Engine/rules.js' +import { decodeRuleName } from 'Engine/ruleUtils.js' import React from 'react' import { Trans } from 'react-i18next' import { connect, useSelector } from 'react-redux' import { Redirect } from 'react-router-dom' import { - flatRulesSelector, noUserInputSelector, + parsedRulesSelector, situationBranchNameSelector } from 'Selectors/analyseSelectors' import { DottedName } from 'Types/rule' @@ -16,7 +16,7 @@ import './RulePage.css' import SearchButton from './SearchButton' export default function RulePage({ match }) { - const flatRules = useSelector(flatRulesSelector) + const parsedRules = useSelector(parsedRulesSelector) const brancheName = useSelector(situationBranchNameSelector) const valuesToShow = !useSelector(noUserInputSelector) let name = match?.params?.name, @@ -36,8 +36,7 @@ export default function RulePage({ match }) { ) } - if (!findRuleByDottedName(flatRules, decodedRuleName)) - return + if (!parsedRules[decodedRuleName]) return return renderRule(decodedRuleName as DottedName) } diff --git a/source/components/SalaryExplanation.tsx b/source/components/SalaryExplanation.tsx index b4c8b3cd9..94ce70af2 100644 --- a/source/components/SalaryExplanation.tsx +++ b/source/components/SalaryExplanation.tsx @@ -2,7 +2,7 @@ import Distribution from 'Components/Distribution' import PaySlip from 'Components/PaySlip' import StackedBarChart from 'Components/StackedBarChart' import { ThemeColorsContext } from 'Components/utils/colors' -import { getRuleFromAnalysis } from 'Engine/rules' +import { getRuleFromAnalysis } from 'Engine/ruleUtils' import React, { useContext, useRef } from 'react' import emoji from 'react-easy-emoji' import { Trans, useTranslation } from 'react-i18next' diff --git a/source/components/SchemeComparaison.tsx b/source/components/SchemeComparaison.tsx index 147077a9e..30b1db75b 100644 --- a/source/components/SchemeComparaison.tsx +++ b/source/components/SchemeComparaison.tsx @@ -10,7 +10,7 @@ import PeriodSwitch from 'Components/PeriodSwitch' import ComparaisonConfig from 'Components/simulationConfigs/rémunération-dirigeant.yaml' import { SitePathsContext } from 'Components/utils/withSitePaths' import Value from 'Components/Value' -import { getRuleFromAnalysis } from 'Engine/rules.js' +import { getRuleFromAnalysis } from 'Engine/ruleUtils.js' import revenusSVG from 'Images/revenus.svg' import { default as React, useCallback, useContext, useState } from 'react' import emoji from 'react-easy-emoji' diff --git a/source/components/SearchBar.tsx b/source/components/SearchBar.tsx index 3abc4f327..22b4e024f 100644 --- a/source/components/SearchBar.tsx +++ b/source/components/SearchBar.tsx @@ -1,11 +1,11 @@ import { SitePathsContext } from 'Components/utils/withSitePaths' -import { parentName } from 'Engine/rules.js' +import { parentName } from 'Engine/ruleUtils.js' import { pick, sortBy, take } from 'ramda' import React, { useContext, useEffect, useState } from 'react' import FuzzyHighlighter, { Highlighter } from 'react-fuzzy-highlighter' import { useTranslation } from 'react-i18next' import { Link, Redirect, useHistory } from 'react-router-dom' -import { Rule } from 'Types/rule' +import { DottedName, Rule } from 'Types/rule' import Worker from 'worker-loader!./SearchBar.worker.js' import { capitalise0 } from '../utils' import './SearchBar.css' @@ -13,7 +13,7 @@ import './SearchBar.css' const worker = new Worker() type SearchBarProps = { - rules: Array + rules: { [name in DottedName]: Rule } showDefaultList: boolean finally?: () => void } @@ -60,7 +60,7 @@ export default function SearchBar({ useEffect(() => { worker.postMessage({ - rules: rules.map( + rules: Object.values(rules).map( pick(['title', 'espace', 'description', 'name', 'dottedName']) ) }) @@ -256,7 +256,9 @@ export default function SearchBar({ i18n.t('noresults', { defaultValue: "Nous n'avons rien trouvé…" })} - {showDefaultList && !input ? renderOptions(rules) : renderOptions()} + {showDefaultList && !input + ? renderOptions(Object.values(rules)) + : renderOptions()} ) } diff --git a/source/components/SearchButton.tsx b/source/components/SearchButton.tsx index 440ec99c8..8e91b1d03 100644 --- a/source/components/SearchButton.tsx +++ b/source/components/SearchButton.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react' import emoji from 'react-easy-emoji' import { Trans } from 'react-i18next' import { useSelector } from 'react-redux' -import { flatRulesSelector } from 'Selectors/analyseSelectors' +import { parsedRulesSelector } from 'Selectors/analyseSelectors' import Overlay from './Overlay' import SearchBar from './SearchBar' @@ -11,7 +11,7 @@ type SearchButtonProps = { } export default function SearchButton({ invisibleButton }: SearchButtonProps) { - const flatRules = useSelector(flatRulesSelector) + const rules = useSelector(parsedRulesSelector) const [visible, setVisible] = useState(false) useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { @@ -34,7 +34,7 @@ export default function SearchButton({ invisibleButton }: SearchButtonProps) {

Chercher dans la documentation

- + ) : invisibleButton ? null : (