From f6f6b187a9224b51e5f1357bd721a1cb799c881e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Thu, 24 Mar 2022 17:14:31 +0100 Subject: [PATCH] =?UTF-8?q?Garde=20en=20memoire=20les=20choix=20selectionn?= =?UTF-8?q?=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/Simulateurs/ExonerationCovid/FormulaireS1S1Bis.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/site/source/pages/Simulateurs/ExonerationCovid/FormulaireS1S1Bis.tsx b/site/source/pages/Simulateurs/ExonerationCovid/FormulaireS1S1Bis.tsx index e8081ffcf..ad719ccf9 100644 --- a/site/source/pages/Simulateurs/ExonerationCovid/FormulaireS1S1Bis.tsx +++ b/site/source/pages/Simulateurs/ExonerationCovid/FormulaireS1S1Bis.tsx @@ -9,6 +9,7 @@ import { Li, Ul } from '@/design-system/typography/list' import { Grid } from '@mui/material' import { ExoCovidDottedNames } from 'exoneration-covid' import Engine, { EvaluatedNode, PublicodesExpression } from 'publicodes' +import { Key, useRef } from 'react' import { Trans } from 'react-i18next' import { useExoCovidEngine } from '.' import { Bold, GridTotal, Italic, Recap, RecapExpert, Total } from './Recap' @@ -54,6 +55,8 @@ export const FormulaireS1S1Bis = ({ onChange }: Props) => { const engine = useExoCovidEngine() const { situation = {} } = useSituationState() + const selectedKey = useRef<{ [key: string]: Key | undefined }>({}) + const totalByMonth = getTotalByMonth(engine, situation) ?? {} if (!engine.evaluate('mois').nodeValue) { @@ -111,7 +114,9 @@ export const FormulaireS1S1Bis = ({ onChange }: Props) => { dottedNames={['LFSS 600', 'LFSS 300', 'LFR1']} title={node.title} total={totalByMonth[dotName]} + defaultSelectedKey={selectedKey.current[dotName]} onSelectionChange={(key) => { + selectedKey.current[dotName] = key const val = (key as string).replace(/\.\d+$/, '') onChange?.(dotName as ExoCovidDottedNames, `'${val}'`) }}