refactor(rgcp): crée un composant RéductionGénéraleBasique
parent
674a2cbb2b
commit
be6d672d2d
|
@ -0,0 +1,54 @@
|
|||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
import { Condition } from '@/components/EngineValue/Condition'
|
||||
import { SimulationGoal } from '@/components/Simulation'
|
||||
import { SimulationValue } from '@/components/Simulation/SimulationValue'
|
||||
import { Message } from '@/design-system'
|
||||
import { Spacing } from '@/design-system/layout'
|
||||
import { Body } from '@/design-system/typography/paragraphs'
|
||||
|
||||
import Répartition from './components/Répartition'
|
||||
import Warnings from './components/Warnings'
|
||||
import WarningSalaireTrans from './components/WarningSalaireTrans'
|
||||
import {
|
||||
réductionGénéraleDottedName,
|
||||
rémunérationBruteDottedName,
|
||||
} from './utils'
|
||||
|
||||
type Props = {
|
||||
onUpdate: () => void
|
||||
}
|
||||
|
||||
export default function RéductionGénéraleBasique({ onUpdate }: Props) {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<>
|
||||
<SimulationGoal
|
||||
dottedName={rémunérationBruteDottedName}
|
||||
round={false}
|
||||
label={t('Rémunération brute')}
|
||||
onUpdateSituation={onUpdate}
|
||||
/>
|
||||
|
||||
<Warnings />
|
||||
<Condition expression={`${rémunérationBruteDottedName} > 1.6 * SMIC`}>
|
||||
<Message type="info">
|
||||
<Body>
|
||||
<WarningSalaireTrans />
|
||||
</Body>
|
||||
</Message>
|
||||
</Condition>
|
||||
|
||||
<Condition expression={`${réductionGénéraleDottedName} >= 0`}>
|
||||
<SimulationValue
|
||||
dottedName={réductionGénéraleDottedName}
|
||||
isInfoMode={true}
|
||||
round={false}
|
||||
/>
|
||||
<Spacing md />
|
||||
<Répartition />
|
||||
</Condition>
|
||||
</>
|
||||
)
|
||||
}
|
|
@ -1,25 +1,17 @@
|
|||
import { DottedName } from 'modele-social'
|
||||
import { PublicodesExpression } from 'publicodes'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useDispatch, useSelector } from 'react-redux'
|
||||
|
||||
import { Condition } from '@/components/EngineValue/Condition'
|
||||
import { SimulationGoal, SimulationGoals } from '@/components/Simulation'
|
||||
import { SimulationValue } from '@/components/Simulation/SimulationValue'
|
||||
import { SimulationGoals } from '@/components/Simulation'
|
||||
import { useEngine } from '@/components/utils/EngineContext'
|
||||
import useYear from '@/components/utils/useYear'
|
||||
import { Message } from '@/design-system'
|
||||
import { Spacing } from '@/design-system/layout'
|
||||
import { Body } from '@/design-system/typography/paragraphs'
|
||||
import { SimpleRuleEvaluation } from '@/domaine/engine/SimpleRuleEvaluation'
|
||||
import { Situation } from '@/domaine/Situation'
|
||||
import { ajusteLaSituation } from '@/store/actions/actions'
|
||||
import { situationSelector } from '@/store/selectors/simulationSelectors'
|
||||
|
||||
import Répartition from './components/Répartition'
|
||||
import Warnings from './components/Warnings'
|
||||
import WarningSalaireTrans from './components/WarningSalaireTrans'
|
||||
import RéductionGénéraleBasique from './Basique'
|
||||
import RéductionGénéraleMoisParMois from './MoisParMois'
|
||||
import {
|
||||
getInitialRéductionGénéraleMoisParMois,
|
||||
|
@ -27,7 +19,6 @@ import {
|
|||
heuresSupplémentairesDottedName,
|
||||
MonthState,
|
||||
Options,
|
||||
réductionGénéraleDottedName,
|
||||
reevaluateRéductionGénéraleMoisParMois,
|
||||
RégularisationMethod,
|
||||
rémunérationBruteDottedName,
|
||||
|
@ -57,7 +48,6 @@ export default function RéductionGénéraleSimulationGoals({
|
|||
}) {
|
||||
const engine = useEngine()
|
||||
const dispatch = useDispatch()
|
||||
const { t } = useTranslation()
|
||||
const [réductionGénéraleMoisParMoisData, setData] = useState<MonthState[]>([])
|
||||
const year = useYear()
|
||||
const situation = useSelector(situationSelector) as SituationType
|
||||
|
@ -196,33 +186,9 @@ export default function RéductionGénéraleSimulationGoals({
|
|||
onOptionsChange={onOptionsChange}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<SimulationGoal
|
||||
dottedName={rémunérationBruteDottedName}
|
||||
round={false}
|
||||
label={t('Rémunération brute')}
|
||||
onUpdateSituation={initializeRéductionGénéraleMoisParMoisData}
|
||||
/>
|
||||
|
||||
<Warnings />
|
||||
<Condition expression={`${rémunérationBruteDottedName} > 1.6 * SMIC`}>
|
||||
<Message type="info">
|
||||
<Body>
|
||||
<WarningSalaireTrans />
|
||||
</Body>
|
||||
</Message>
|
||||
</Condition>
|
||||
|
||||
<Condition expression={`${réductionGénéraleDottedName} >= 0`}>
|
||||
<SimulationValue
|
||||
dottedName={réductionGénéraleDottedName}
|
||||
isInfoMode={true}
|
||||
round={false}
|
||||
/>
|
||||
<Spacing md />
|
||||
<Répartition />
|
||||
</Condition>
|
||||
</>
|
||||
<RéductionGénéraleBasique
|
||||
onUpdate={initializeRéductionGénéraleMoisParMoisData}
|
||||
/>
|
||||
)}
|
||||
</SimulationGoals>
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue