From 2dacc5d7df8da14fde15c11883854978a2c6bb5b Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Tue, 11 May 2021 14:47:32 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Supporte=20la=20r=C3=A9initialis?= =?UTF-8?q?ation=20de=20champ=20sur=20le=20formulaire=20de=20demande=20de?= =?UTF-8?q?=20mobilit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/pages/Gérer/DemandeMobilite/index.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mon-entreprise/source/pages/Gérer/DemandeMobilite/index.tsx b/mon-entreprise/source/pages/Gérer/DemandeMobilite/index.tsx index c39ced1ca..89c379eb3 100644 --- a/mon-entreprise/source/pages/Gérer/DemandeMobilite/index.tsx +++ b/mon-entreprise/source/pages/Gérer/DemandeMobilite/index.tsx @@ -8,7 +8,7 @@ import { Markdown } from 'Components/utils/markdown' import { usePersistingState } from 'Components/utils/persistState' import { DottedName } from 'modele-social' import Engine, { UNSAFE_isNotApplicable } from 'publicodes' -import { equals, isEmpty } from 'ramda' +import { equals, isEmpty, omit } from 'ramda' import { createElement, lazy, @@ -123,10 +123,14 @@ function FormulairePublicodes() { ) const onChange = useCallback( (dottedName, value) => { - setSituation((situation) => ({ - ...situation, - [dottedName]: value, - })) + if (value === undefined) { + setSituation((situation) => omit([dottedName], situation)) + } else { + setSituation((situation) => ({ + ...situation, + [dottedName]: value, + })) + } }, [setSituation] )