Skip to content

Commit

Permalink
fix(rgcp/lodeom): correction de la sélection d'onglet après navigatio…
Browse files Browse the repository at this point in the history
…n dans la documentation
  • Loading branch information
liliced committed Jan 22, 2025
1 parent 76d9b1d commit 845efe2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 24 deletions.
6 changes: 2 additions & 4 deletions site/source/components/PeriodSwitch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 (
Expand Down
10 changes: 7 additions & 3 deletions site/source/pages/simulateurs/lodeom/Goals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand Down
9 changes: 2 additions & 7 deletions site/source/pages/simulateurs/lodeom/Lodeom.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useState } from 'react'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'

import PeriodSwitch from '@/components/PeriodSwitch'
Expand All @@ -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 = [
{
Expand All @@ -35,9 +34,6 @@ export default function LodeomSimulation() {
unit: '€',
},
]
const onPeriodSwitch = useCallback((unit: string) => {
setMonthByMonth(unit === '€')
}, [])

const [régularisationMethod, setRégularisationMethod] =
useState<RégularisationMethod>('progressive')
Expand All @@ -47,7 +43,6 @@ export default function LodeomSimulation() {
<Simulation afterQuestionsSlot={<SelectSimulationYear />}>
<SimulateurWarning simulateur="lodeom" />
<LodeomSimulationGoals
monthByMonth={monthByMonth}
legend={t(
'pages.simulateurs.lodeom.legend',
'Rémunération brute du salarié et exonération Lodeom applicable'
Expand All @@ -65,7 +60,7 @@ export default function LodeomSimulation() {
<EffectifSwitch />
</>
)}
<PeriodSwitch periods={periods} onSwitch={onPeriodSwitch} />
<PeriodSwitch periods={periods} />
</>
}
régularisationMethod={
Expand Down
10 changes: 7 additions & 3 deletions site/source/pages/simulateurs/reduction-generale/Goals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useState } from 'react'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'

import PeriodSwitch from '@/components/PeriodSwitch'
Expand All @@ -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(
Expand All @@ -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<RégularisationMethod>('progressive')
Expand All @@ -50,7 +46,6 @@ export default function RéductionGénéraleSimulation() {
<Simulation afterQuestionsSlot={<SelectSimulationYear />}>
<SimulateurWarning simulateur="réduction-générale" />
<RéductionGénéraleSimulationGoals
monthByMonth={monthByMonth}
legend={t(
'pages.simulateurs.réduction-générale.legend',
'Salaire brut du salarié et réduction générale applicable'
Expand All @@ -63,7 +58,7 @@ export default function RéductionGénéraleSimulation() {
/>
<EffectifSwitch />
<CongésPayésSwitch />
<PeriodSwitch periods={periods} onSwitch={onPeriodSwitch} />
<PeriodSwitch periods={periods} />
</>
}
régularisationMethod={régularisationMethod}
Expand Down

0 comments on commit 845efe2

Please sign in to comment.