Fix type error

pull/2077/head
Jérémy Rialland 2022-03-24 18:37:31 +01:00 committed by Johan Girod
parent 6838b0480d
commit 8a6068ec72
3 changed files with 10 additions and 9 deletions

View File

@ -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<ExoCovidDottedNames>()
const { situation = {} } = useExoCovidSituationState()
const selectedKey = useRef<{ [key: string]: Key | undefined }>({})

View File

@ -174,7 +174,7 @@ export const Row = ({
return hideChoice1
})
.map((text, i) => ({
key: (node.dottedName as string) + `.${i}`,
key: node.dottedName + `.${i}`,
text,
}))
})

View File

@ -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<ExoCovidDottedNames>
export const useExoCovidSituationState = () =>
useSituationState<ExoCovidDottedNames>()
/**
* Use this hooks to keep state of engine with the react fast refresh