From e246e1f1e2237d9f762175d229dfa339e72e6ba8 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 3 Oct 2023 18:24:41 +0200 Subject: [PATCH] feat: disable next question instead of input --- src/components/form/Navigation.tsx | 14 ++++++++++++-- src/components/form/Question.tsx | 11 ++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/components/form/Navigation.tsx b/src/components/form/Navigation.tsx index 5dc16460d..d8bb115dc 100644 --- a/src/components/form/Navigation.tsx +++ b/src/components/form/Navigation.tsx @@ -14,11 +14,21 @@ type Props = { onComplete?: () => void } +//TODO: It should maayyybe be described in the model... +const questionsThatCantBeZero = [ + 'transport . voiture . saisie voyageurs', + 'logement . saisie habitants', + 'logement . surface', +] + export default function Navigation({ question, onComplete = () => '' }: Props) { const { gotoPrevQuestion, gotoNextQuestion, noPrevQuestion, noNextQuestion } = useForm() - const { isMissing, setDefaultAsValue } = useRule(question) + const { isMissing, setDefaultAsValue, numericValue } = useRule(question) const [isSettingDefaultValue, setIsSettingDefaultValue] = useState(false) + + const nextDisabled = + questionsThatCantBeZero.includes(question) && numericValue < 1 return (
{!noPrevQuestion ? ( @@ -36,7 +46,7 @@ export default function Navigation({ question, onComplete = () => '' }: Props) { ) : null}