Skip to content

Commit

Permalink
upgrade lunatic/lunatic-dsfr and type ajustment
Browse files Browse the repository at this point in the history
  • Loading branch information
ddecrulle committed Mar 29, 2024
1 parent 140e0e4 commit f032839
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 193 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
"format:check": "npm run _format -- --list-different",
"postinstall": "copy-dsfr-to-public",
"predev": "only-include-used-icons",
"prebuild": "only-include-used-icons && npx @inseefr/lunatic"
"prebuild": "only-include-used-icons"
},
"dependencies": {
"@codegouvfr/react-dsfr": "^1.9.3",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.0",
"@inseefr/lunatic": "3.0.0-rc.13",
"@inseefr/lunatic-dsfr": "2.0.0-rc.7",
"@inseefr/lunatic": "3.0.0-rc.21",
"@inseefr/lunatic-dsfr": "2.0.0-rc.8",
"@mui/material": "^5.15.14",
"@tanstack/react-query": "^5.28.6",
"@tanstack/react-router": "^1.20.0",
Expand Down
6 changes: 4 additions & 2 deletions src/components/Orchestrator/Orchestrator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import type { SurveyUnitData } from 'model/SurveyUnitData'
import type { StateData } from 'model/StateData'
import { isBlockingError, isSameErrors } from './utils/controls'
import { slotComponents } from './slotComponents'
import type { LunaticGetReferentiel } from './utils/lunaticType'

export function Orchestrator(props: {
source: LunaticSource
surveyUnitData?: SurveyUnitData
getReferentiel?: (name: string) => Promise<Array<unknown>>
getReferentiel: LunaticGetReferentiel
}) {
const { source, surveyUnitData, getReferentiel } = props

const navigate = useNavigate()

const initialCurrentPage = surveyUnitData?.stateData?.currentPage
Expand Down Expand Up @@ -118,7 +120,7 @@ export function Orchestrator(props: {
stateData: getCurrentStateData(),
personalization: surveyUnitData?.personalization,
},
//The label of source is not dynamic
//The label of source is not dynamic
filename: `${source.label.value}-${new Date().toLocaleDateString()}`,
})
}
Expand Down
11 changes: 7 additions & 4 deletions src/components/Orchestrator/useStromaeNavigation.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { useState } from 'react'
import { assert, type Equals } from 'tsafe/assert'
import type { useLunatic } from '@inseefr/lunatic'
import type { InternalPageType, PageType, StromaePage } from 'model/Page'
import type {
LunaticGoNextPage,
LunaticGoPreviousPage,
LunaticGoToPage,
} from './utils/lunaticType'

type LunaticGoToPage = ReturnType<typeof useLunatic>['goToPage']
type Params = {
isFirstPage: boolean
isLastPage: boolean
initialCurrentPage: PageType | undefined
goNextLunatic: ReturnType<typeof useLunatic>['goNextPage']
goPrevLunatic: ReturnType<typeof useLunatic>['goPreviousPage']
goNextLunatic: LunaticGoNextPage
goPrevLunatic: LunaticGoPreviousPage
openValidationModal: () => Promise<void>
goToLunaticPage: LunaticGoToPage
}
Expand Down
16 changes: 16 additions & 0 deletions src/components/Orchestrator/utils/lunaticType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { useLunatic } from '@inseefr/lunatic'

export type LunaticGetReferentiel = Parameters<
typeof useLunatic
>[2]['getReferentiel']

export type Nomenclature = Awaited<
ReturnType<NonNullable<LunaticGetReferentiel>>
>

export type LunaticGoToPage = ReturnType<typeof useLunatic>['goToPage']

export type LunaticGoPreviousPage = ReturnType<
typeof useLunatic
>['goPreviousPage']
export type LunaticGoNextPage = ReturnType<typeof useLunatic>['goNextPage']
4 changes: 3 additions & 1 deletion src/pages/Visualize/Visualize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { VisualizeForm } from './Form/VisualizeForm'
import { visualizeRoute } from './route'
import { axiosGet } from 'utils/axios'
import { queryOptions, useQueryClient } from '@tanstack/react-query'
import type { Nomenclature } from 'components/Orchestrator/utils/lunaticType'


export function VisualizePage() {
const loaderResults = visualizeRoute.useLoaderData()
Expand All @@ -26,7 +28,7 @@ export function VisualizePage() {
return queryClient.ensureQueryData(
queryOptions({
queryKey: [name],
queryFn: () => axiosGet<Array<unknown>>(nomenclature[name]),
queryFn: () => axiosGet<Nomenclature>(nomenclature[name]),
})
)
}
Expand Down
Loading

0 comments on commit f032839

Please sign in to comment.