From 3a574594033c017596307f20ad0e9d8dd2959ed1 Mon Sep 17 00:00:00 2001 From: Matt DelSordo Date: Wed, 8 Nov 2023 19:45:34 -0500 Subject: [PATCH] support conditional rendering for survey questions --- .../src/components/SurveyComponent/SurveyComponent.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/front/src/components/SurveyComponent/SurveyComponent.js b/frontend/front/src/components/SurveyComponent/SurveyComponent.js index bd693fa4..ab19227c 100644 --- a/frontend/front/src/components/SurveyComponent/SurveyComponent.js +++ b/frontend/front/src/components/SurveyComponent/SurveyComponent.js @@ -37,7 +37,7 @@ const SurveyComponent = ({ }) => { const navigate = useNavigate(); - const { handleSubmit, reset, control, watch } = useForm({ + const { handleSubmit, reset, control, watch, getValues } = useForm({ defaultValues: formDefault, }); @@ -201,6 +201,13 @@ const SurveyComponent = ({ > {surveyStructure?.survey_questions.map((q) => { + if ( + q.conditional_on && + getValues(q.conditional_on.id) !== q.conditional_on.value + ) { + return null; + } + switch (q.response_type) { case "radio": return (