diff --git a/site/source/components/Simulation/SimulationGoal.tsx b/site/source/components/Simulation/SimulationGoal.tsx index 1b87226b5..49673179d 100644 --- a/site/source/components/Simulation/SimulationGoal.tsx +++ b/site/source/components/Simulation/SimulationGoal.tsx @@ -8,7 +8,8 @@ import { ForceThemeProvider } from '@/components/utils/DarkModeContext' import { Grid } from '@/design-system/layout' import { Strong } from '@/design-system/typography' import { Body, SmallBody } from '@/design-system/typography/paragraphs' -import { enregistreLaRéponse } from '@/store/actions/actions' +import { SimpleRuleEvaluation } from '@/domaine/engine/SimpleRuleEvaluation' +import { ajusteLaSituation } from '@/store/actions/actions' import { targetUnitSelector } from '@/store/selectors/simulationSelectors' import { ExplicableRule } from '../conversation/Explicable' @@ -60,7 +61,12 @@ export function SimulationGoal({ const [isFocused, setFocused] = useState(false) const onChange = useCallback( (x?: PublicodesExpression) => { - dispatch(enregistreLaRéponse(dottedName, x)) + dispatch( + ajusteLaSituation({ [dottedName]: x } as Record< + DottedName, + SimpleRuleEvaluation + >) + ) onUpdateSituation?.(dottedName, x) }, [dispatch, onUpdateSituation, dottedName] diff --git a/site/source/pages/simulateurs/indépendant/Indépendant.tsx b/site/source/pages/simulateurs/indépendant/Indépendant.tsx index 1111c03fd..e2452fb9b 100644 --- a/site/source/pages/simulateurs/indépendant/Indépendant.tsx +++ b/site/source/pages/simulateurs/indépendant/Indépendant.tsx @@ -1,3 +1,4 @@ +import { DottedName } from 'modele-social' import { Trans } from 'react-i18next' import { useDispatch } from 'react-redux' @@ -17,7 +18,8 @@ import { Message } from '@/design-system' import { Emoji } from '@/design-system/emoji' import { H2 } from '@/design-system/typography/heading' import { Body } from '@/design-system/typography/paragraphs' -import { enregistreLaRéponse } from '@/store/actions/actions' +import { SimpleRuleEvaluation } from '@/domaine/engine/SimpleRuleEvaluation' +import { ajusteLaSituation } from '@/store/actions/actions' export function IndépendantPLSimulation() { return ( @@ -135,7 +137,9 @@ export default function IndépendantSimulation() { dottedName="entreprise . imposition" onChange={(imposition) => { dispatch( - enregistreLaRéponse('entreprise . imposition', imposition) + ajusteLaSituation({ + 'entreprise . imposition': imposition, + } as Record) ) }} /> diff --git a/site/source/store/reducers/simulation.reducer.ts b/site/source/store/reducers/simulation.reducer.ts index 26c6ce718..58e9abaf3 100644 --- a/site/source/store/reducers/simulation.reducer.ts +++ b/site/source/store/reducers/simulation.reducer.ts @@ -1,7 +1,5 @@ import { DottedName } from 'modele-social' -import { estObjectifExclusifDeLaSimulation } from '@/domaine/estObjectifExclusifDeLaSimulation' -import { estQuestionEnListeNoire } from '@/domaine/estQuestionEnListeNoire' import { SimulationConfig } from '@/domaine/SimulationConfig' import { Situation } from '@/domaine/Situation' import { updateSituation } from '@/domaine/updateSituation' @@ -73,12 +71,9 @@ export function simulationReducer( action.fieldName ) - const answeredQuestions = - déjàDansLesQuestionsRépondues || - estQuestionEnListeNoire(state.config)(action.fieldName) || - estObjectifExclusifDeLaSimulation(state.config)(action.fieldName) - ? state.answeredQuestions - : [...state.answeredQuestions, action.fieldName] + const answeredQuestions = déjàDansLesQuestionsRépondues + ? state.answeredQuestions + : [...state.answeredQuestions, action.fieldName] return { ...state,