From 8a6068ec727f4bcabb3065da4390df41766c9211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Thu, 24 Mar 2022 18:37:31 +0100 Subject: [PATCH] Fix type error --- .../Simulateurs/ExonerationCovid/FormulaireS1S1Bis.tsx | 9 +++------ site/source/pages/Simulateurs/ExonerationCovid/Table.tsx | 2 +- site/source/pages/Simulateurs/ExonerationCovid/index.tsx | 8 ++++++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/site/source/pages/Simulateurs/ExonerationCovid/FormulaireS1S1Bis.tsx b/site/source/pages/Simulateurs/ExonerationCovid/FormulaireS1S1Bis.tsx index fe2f426fe..9f33cd5f1 100644 --- a/site/source/pages/Simulateurs/ExonerationCovid/FormulaireS1S1Bis.tsx +++ b/site/source/pages/Simulateurs/ExonerationCovid/FormulaireS1S1Bis.tsx @@ -1,8 +1,5 @@ import Value from '@/components/EngineValue' -import { - Situation, - useSituationState, -} from '@/components/utils/SituationContext' +import { Situation } from '@/components/utils/SituationContext' import { Spacing } from '@/design-system/layout' import { H3 } from '@/design-system/typography/heading' import { Li, Ul } from '@/design-system/typography/list' @@ -11,7 +8,7 @@ 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 { useExoCovidEngine, useExoCovidSituationState } from '.' import { Bold, GridTotal, Italic, Recap, RecapExpert, Total } from './Recap' import { Row, Table, Tbody, Th, Thead, Tr } from './Table' @@ -61,7 +58,7 @@ interface Props { export const FormulaireS1S1Bis = ({ onChange }: Props) => { const engine = useExoCovidEngine() - const { situation = {} } = useSituationState() + const { situation = {} } = useExoCovidSituationState() const selectedKey = useRef<{ [key: string]: Key | undefined }>({}) diff --git a/site/source/pages/Simulateurs/ExonerationCovid/Table.tsx b/site/source/pages/Simulateurs/ExonerationCovid/Table.tsx index c5d6af94d..78ed25352 100644 --- a/site/source/pages/Simulateurs/ExonerationCovid/Table.tsx +++ b/site/source/pages/Simulateurs/ExonerationCovid/Table.tsx @@ -174,7 +174,7 @@ export const Row = ({ return hideChoice1 }) .map((text, i) => ({ - key: (node.dottedName as string) + `.${i}`, + key: node.dottedName + `.${i}`, text, })) }) diff --git a/site/source/pages/Simulateurs/ExonerationCovid/index.tsx b/site/source/pages/Simulateurs/ExonerationCovid/index.tsx index 924955f0a..f0622755e 100644 --- a/site/source/pages/Simulateurs/ExonerationCovid/index.tsx +++ b/site/source/pages/Simulateurs/ExonerationCovid/index.tsx @@ -1,5 +1,6 @@ import { EngineContext, EngineProvider } from '@/components/utils/EngineContext' -import exonerationCovid from 'exoneration-covid' +import { useSituationState } from '@/components/utils/SituationContext' +import exonerationCovid, { ExoCovidDottedNames } from 'exoneration-covid' import Engine from 'publicodes' import { useContext, useRef } from 'react' import { ExonérationCovid } from './ExonérationCovid' @@ -7,7 +8,10 @@ import { ExonérationCovid } from './ExonérationCovid' const exoCovidEngine = new Engine(exonerationCovid) export const useExoCovidEngine = () => - useContext(EngineContext) as typeof exoCovidEngine + useContext(EngineContext) as Engine + +export const useExoCovidSituationState = () => + useSituationState() /** * Use this hooks to keep state of engine with the react fast refresh