mirror of
https://github.com/betagouv/mon-entreprise
synced 2025-02-10 13:55:03 +00:00
fix(rgcp/lodeom): correction de la sélection d'onglet après navigation dans la documentation
This commit is contained in:
parent
76d9b1d810
commit
2215caeb4b
5 changed files with 20 additions and 24 deletions
|
@ -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 (
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<RégularisationMethod>('progressive')
|
||||
|
@ -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'
|
||||
|
@ -65,7 +60,7 @@ export default function LodeomSimulation() {
|
|||
<EffectifSwitch />
|
||||
</>
|
||||
)}
|
||||
<PeriodSwitch periods={periods} onSwitch={onPeriodSwitch} />
|
||||
<PeriodSwitch periods={periods} />
|
||||
</>
|
||||
}
|
||||
régularisationMethod={
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<RégularisationMethod>('progressive')
|
||||
|
@ -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'
|
||||
|
@ -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}
|
||||
|
|
Loading…
Add table
Reference in a new issue