From 845efe2db6afa4b1d33f9d495f006a34952d5a64 Mon Sep 17 00:00:00 2001 From: Alice Dahan Date: Tue, 21 Jan 2025 17:13:11 +0100 Subject: [PATCH] =?UTF-8?q?fix(rgcp/lodeom):=20correction=20de=20la=20s?= =?UTF-8?q?=C3=A9lection=20d'onglet=20apr=C3=A8s=20navigation=20dans=20la?= =?UTF-8?q?=20documentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/source/components/PeriodSwitch.tsx | 6 ++---- site/source/pages/simulateurs/lodeom/Goals.tsx | 10 +++++++--- site/source/pages/simulateurs/lodeom/Lodeom.tsx | 9 ++------- .../pages/simulateurs/reduction-generale/Goals.tsx | 10 +++++++--- .../R\303\251ductionG\303\251n\303\251rale.tsx" | 9 ++------- 5 files changed, 20 insertions(+), 24 deletions(-) diff --git a/site/source/components/PeriodSwitch.tsx b/site/source/components/PeriodSwitch.tsx index 49792f95c4..e42a1e715c 100644 --- a/site/source/components/PeriodSwitch.tsx +++ b/site/source/components/PeriodSwitch.tsx @@ -11,10 +11,9 @@ type Props = { label: string unit: string }> - onSwitch?: (unit: string) => void } -export default function PeriodSwitch({ periods, onSwitch }: Props) { +export default function PeriodSwitch({ periods }: Props) { const dispatch = useDispatch() const currentUnit = useSelector(targetUnitSelector) @@ -34,9 +33,8 @@ export default function PeriodSwitch({ periods, onSwitch }: Props) { const onChange = useCallback( (unit: string) => { dispatch(updateUnit(unit)) - onSwitch?.(unit) }, - [dispatch, onSwitch] + [dispatch] ) return ( diff --git a/site/source/pages/simulateurs/lodeom/Goals.tsx b/site/source/pages/simulateurs/lodeom/Goals.tsx index 22449f0197..b2f26d9b79 100644 --- a/site/source/pages/simulateurs/lodeom/Goals.tsx +++ b/site/source/pages/simulateurs/lodeom/Goals.tsx @@ -12,7 +12,10 @@ import { Message } from '@/design-system' import { Body } from '@/design-system/typography/paragraphs' import { useBarèmeLodeom } from '@/hooks/useBarèmeLodeom' import { useZoneLodeom } from '@/hooks/useZoneLodeom' -import { situationSelector } from '@/store/selectors/simulationSelectors' +import { + situationSelector, + targetUnitSelector, +} from '@/store/selectors/simulationSelectors' import { getDataAfterOptionsChange, getDataAfterRémunérationChange, @@ -29,12 +32,10 @@ import Warnings from './components/Warnings' import WarningSalaireTrans from './components/WarningSalaireTrans' export default function LodeomSimulationGoals({ - monthByMonth, toggles, legend, régularisationMethod, }: { - monthByMonth: boolean toggles?: React.ReactNode legend: string régularisationMethod?: RégularisationMethod @@ -49,6 +50,9 @@ export default function LodeomSimulationGoals({ const currentBarème = useBarèmeLodeom() const { t } = useTranslation() + const currentUnit = useSelector(targetUnitSelector) + const monthByMonth = currentUnit === '€' + const codeRéduction = engine.evaluate( 'salarié . cotisations . exonérations . lodeom . code réduction' ).nodeValue as string diff --git a/site/source/pages/simulateurs/lodeom/Lodeom.tsx b/site/source/pages/simulateurs/lodeom/Lodeom.tsx index 8db5f1c67b..461fa12176 100644 --- a/site/source/pages/simulateurs/lodeom/Lodeom.tsx +++ b/site/source/pages/simulateurs/lodeom/Lodeom.tsx @@ -1,4 +1,4 @@ -import { useCallback, useState } from 'react' +import { useState } from 'react' import { useTranslation } from 'react-i18next' import PeriodSwitch from '@/components/PeriodSwitch' @@ -16,7 +16,6 @@ import LodeomSimulationGoals from './Goals' export default function LodeomSimulation() { const currentZone = useZoneLodeom() - const [monthByMonth, setMonthByMonth] = useState(false) const { t } = useTranslation() const periods = [ { @@ -35,9 +34,6 @@ export default function LodeomSimulation() { unit: '€', }, ] - const onPeriodSwitch = useCallback((unit: string) => { - setMonthByMonth(unit === '€') - }, []) const [régularisationMethod, setRégularisationMethod] = useState('progressive') @@ -47,7 +43,6 @@ export default function LodeomSimulation() { }> )} - + } régularisationMethod={ diff --git a/site/source/pages/simulateurs/reduction-generale/Goals.tsx b/site/source/pages/simulateurs/reduction-generale/Goals.tsx index 9e161995ca..09bdac5ef1 100644 --- a/site/source/pages/simulateurs/reduction-generale/Goals.tsx +++ b/site/source/pages/simulateurs/reduction-generale/Goals.tsx @@ -7,7 +7,10 @@ import RéductionMoisParMois from '@/components/RéductionDeCotisations/Réducti import { SimulationGoals } from '@/components/Simulation' import { useEngine } from '@/components/utils/EngineContext' import useYear from '@/components/utils/useYear' -import { situationSelector } from '@/store/selectors/simulationSelectors' +import { + situationSelector, + targetUnitSelector, +} from '@/store/selectors/simulationSelectors' import { getDataAfterOptionsChange, getDataAfterRémunérationChange, @@ -25,12 +28,10 @@ import Warnings from './components/Warnings' import WarningSalaireTrans from './components/WarningSalaireTrans' export default function RéductionGénéraleSimulationGoals({ - monthByMonth, toggles, legend, régularisationMethod, }: { - monthByMonth: boolean toggles?: React.ReactNode legend: string régularisationMethod: RégularisationMethod @@ -43,6 +44,9 @@ export default function RéductionGénéraleSimulationGoals({ const previousSituation = useRef(situation) const { t } = useTranslation() + const currentUnit = useSelector(targetUnitSelector) + const monthByMonth = currentUnit === '€' + const initializeRéductionGénéraleMoisParMoisData = useCallback(() => { const data = getInitialRéductionMoisParMois( réductionGénéraleDottedName, diff --git "a/site/source/pages/simulateurs/reduction-generale/R\303\251ductionG\303\251n\303\251rale.tsx" "b/site/source/pages/simulateurs/reduction-generale/R\303\251ductionG\303\251n\303\251rale.tsx" index 2ef6f294df..0da6b7494f 100644 --- "a/site/source/pages/simulateurs/reduction-generale/R\303\251ductionG\303\251n\303\251rale.tsx" +++ "b/site/source/pages/simulateurs/reduction-generale/R\303\251ductionG\303\251n\303\251rale.tsx" @@ -1,4 +1,4 @@ -import { useCallback, useState } from 'react' +import { useState } from 'react' import { useTranslation } from 'react-i18next' import PeriodSwitch from '@/components/PeriodSwitch' @@ -14,7 +14,6 @@ import RéductionGénéraleSimulationGoals from './Goals' export default function RéductionGénéraleSimulation() { const { t } = useTranslation() - const [monthByMonth, setMonthByMonth] = useState(false) const periods = [ { label: t( @@ -38,9 +37,6 @@ export default function RéductionGénéraleSimulation() { unit: '€', }, ] - const onPeriodSwitch = useCallback((unit: string) => { - setMonthByMonth(unit === '€') - }, []) const [régularisationMethod, setRégularisationMethod] = useState('progressive') @@ -50,7 +46,6 @@ export default function RéductionGénéraleSimulation() { }> - + } régularisationMethod={régularisationMethod}