From f58286bddfc4907a57031e18e0f1753e2a75273d Mon Sep 17 00:00:00 2001 From: Alice Dahan Date: Thu, 6 Feb 2025 12:24:55 +0100 Subject: [PATCH] fix(pam): correction de l'affichage des questions de l'assistant PAM --- .../EngineValue/WhenAlreadyDefinedMulti.tsx | 30 +++++++++++++++++++ .../components/Formulaire.tsx | 13 ++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 site/source/components/EngineValue/WhenAlreadyDefinedMulti.tsx diff --git a/site/source/components/EngineValue/WhenAlreadyDefinedMulti.tsx b/site/source/components/EngineValue/WhenAlreadyDefinedMulti.tsx new file mode 100644 index 000000000..1973efb51 --- /dev/null +++ b/site/source/components/EngineValue/WhenAlreadyDefinedMulti.tsx @@ -0,0 +1,30 @@ +import { DottedName } from 'modele-social' +import Engine from 'publicodes' +import React from 'react' + +import { useEngine } from '../utils/EngineContext' + +export function WhenAlreadyDefinedMulti({ + dottedNames, + children, + engine, +}: { + dottedNames: DottedName[] + children: React.ReactNode + engine?: Engine +}) { + const defaultEngine = useEngine() + + const engineValue = engine ?? defaultEngine + + const notAllAlreadyDefined = dottedNames.some( + (dottedName) => + engineValue.evaluate({ 'est non défini': dottedName }).nodeValue + ) + + if (notAllAlreadyDefined) { + return null + } + + return <>{children} +} diff --git a/site/source/pages/assistants/declaration-revenus-pamc/components/Formulaire.tsx b/site/source/pages/assistants/declaration-revenus-pamc/components/Formulaire.tsx index d0557add0..9e85a422e 100644 --- a/site/source/pages/assistants/declaration-revenus-pamc/components/Formulaire.tsx +++ b/site/source/pages/assistants/declaration-revenus-pamc/components/Formulaire.tsx @@ -1,5 +1,6 @@ import { AssistantGoal } from '@/components/Assistant/AssistantGoal' import { WhenAlreadyDefined } from '@/components/EngineValue/WhenAlreadyDefined' +import { WhenAlreadyDefinedMulti } from '@/components/EngineValue/WhenAlreadyDefinedMulti' import { WhenApplicable } from '@/components/EngineValue/WhenApplicable' import { H2 } from '@/design-system/typography/heading' @@ -10,9 +11,17 @@ export default function Formulaire() { <>

Profession

- + + + +

Recettes

@@ -56,7 +65,7 @@ export default function Formulaire() {

Revenus de remplacement

- +
) }