Skip to content

Commit

Permalink
refactor(publicodes-state): sync with preprod
Browse files Browse the repository at this point in the history
  • Loading branch information
EmileRolley committed Nov 6, 2023
1 parent d6b27cb commit d0ed2e1
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/publicodes-state/hooks/useRule/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import { captureException } from '@sentry/react'
import { useContext, useMemo } from 'react'
import simulationContext from '../simulationProvider/context'
import { NGCEvaluatedNode, NGCRuleNode, RuleName } from '../types'
import simulationContext from '../../providers/simulationProvider/context'
import { NGCEvaluatedNode, NGCRuleNode, RuleName } from '../../types'
import useChoices from './useChoices'
import useContent from './useContent'
import useMissing from './useMissing'
Expand Down
4 changes: 2 additions & 2 deletions src/publicodes-state/hooks/useRule/useMissing.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use client'

import { useMemo } from 'react'
import getIsMissing from '../helpers/getIsMissing'
import { RuleName, Situation } from '../types'
import getIsMissing from '../../helpers/getIsMissing'
import { RuleName, Situation } from '../../types'

type Props = {
dottedName: RuleName
Expand Down
4 changes: 2 additions & 2 deletions src/publicodes-state/hooks/useRule/useType.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use client'

import { useMemo } from 'react'
import getType from '../helpers/getType'
import getType from '../../helpers/getType'
import {
NGCEvaluatedNode,
NGCQuestionType,
NGCRuleNode,
RuleName,
} from '../types'
} from '../../types'

type Props = {
dottedName: RuleName
Expand Down
4 changes: 2 additions & 2 deletions src/publicodes-state/hooks/useRule/useValue.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use client'

import { useMemo } from 'react'
import getType from '../helpers/getType'
import getType from '../../helpers/getType'
import {
NGCEvaluatedNode,
NGCQuestionType,
NGCRuleNode,
NodeValue,
RuleName,
Situation,
} from '../types'
} from '../../types'
type Props = {
dottedName: RuleName
safeGetRule: (rule: RuleName) => NGCRuleNode | null
Expand Down
5 changes: 2 additions & 3 deletions src/publicodes-state/providers/simulationProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { PropsWithChildren } from 'react'

import { RuleName, Rules, Situation } from '../types'
import { RuleName, Rules, Situation } from '../../types'
import SimulationContext from './context'
import useCategories from './useCategories'
import useEngine from './useEngine'
Expand Down Expand Up @@ -107,8 +107,7 @@ export default function SimulationProvider({
everyMosaicChildWhoIsReallyInMosaic,
categories,
subcategories,
}}
>
}}>
{initialized ? children : null}
</SimulationContext.Provider>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Engine from 'publicodes'
import { useMemo } from 'react'
import { safeEvaluateHelper } from '../helpers/safeEvaluateHelper'
import { NGCEvaluatedNode, NGCRuleNode, RuleName, Rules } from '../types'
import { safeEvaluateHelper } from '../../helpers/safeEvaluateHelper'
import { NGCEvaluatedNode, NGCRuleNode, RuleName, Rules } from '../../types'

/**
* Initiate the engine based on the rules we pass
Expand Down
6 changes: 3 additions & 3 deletions src/publicodes-state/providers/simulationProvider/useRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export default function useRules({ engine }: { engine: Engine }): {
// FIXME(@EmileRolley): refactoring not tested yet
const everyMosaicChildWhoIsReallyInMosaic = useMemo<RuleName[]>(
() =>
everyQuestions.filter((question: RuleName) =>
everyMosaicEntries.find(([mosaicName, mosaicRule]) => {
everyQuestions.filter((question: RuleName) => {
return everyMosaicEntries.find(([mosaicName, mosaicRule]) => {
const mosaicNode = mosaicRule.rawNode?.mosaique
if (!mosaicNode) {
return false
Expand All @@ -70,7 +70,7 @@ export default function useRules({ engine }: { engine: Engine }): {
question.includes(key)
)
})
),
}),
[everyQuestions, everyMosaicEntries]
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react'
import { safeGetSituation } from '../helpers/safeGetSituation'
import { Engine, RuleName, Situation } from '../types'
import { safeGetSituation } from '../../helpers/safeGetSituation'
import { Engine, RuleName, Situation } from '../../types'

type Props = {
engine: Engine
Expand Down

0 comments on commit d0ed2e1

Please sign in to comment.