fix: il ne faut pas enregistrer les objectifs saisis comme des questions répondues

pull/3115/head
Jalil Arfaoui 2024-08-28 19:57:21 +02:00
parent 5bdbeb4038
commit 738a6162bc
3 changed files with 17 additions and 12 deletions

View File

@ -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]

View File

@ -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<DottedName, SimpleRuleEvaluation>)
)
}}
/>

View File

@ -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,