From 7199925f3b0783e2e383af9e3542bbffaedefe62 Mon Sep 17 00:00:00 2001 From: Leonardo Montini Date: Sun, 28 Apr 2024 18:06:19 +0200 Subject: [PATCH] Add required question functionality --- .../question-blocks/choice.tsx | 13 +++++++++++++ .../survey-generator/question-blocks/text.tsx | 19 ++++++++++++++++++- .../survey-generator/question-card.tsx | 2 +- src/types/survey.ts | 2 ++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/components/survey-generator/question-blocks/choice.tsx b/src/components/survey-generator/question-blocks/choice.tsx index 477e398..c4f40ab 100644 --- a/src/components/survey-generator/question-blocks/choice.tsx +++ b/src/components/survey-generator/question-blocks/choice.tsx @@ -119,6 +119,19 @@ export const ChoiceFormField = ({ questionIndex, form }: Props) => { }} /> Choice Question + ( + + )} + /> { form.removeFieldValue(`questions`, questionIndex)} /> - Text Question + + Text Question + ( + + )} + /> + ( diff --git a/src/components/survey-generator/question-card.tsx b/src/components/survey-generator/question-card.tsx index 704526a..707a86e 100644 --- a/src/components/survey-generator/question-card.tsx +++ b/src/components/survey-generator/question-card.tsx @@ -30,7 +30,7 @@ const QuestionCardHeader = React.forwardRef<
; @@ -37,6 +38,7 @@ export const ChoiceQuestion = v.merge([ }), [v.minLength(2, "There must be at least 2 options")] ), + required: v.boolean(), // Added required field }), ]); export type ChoiceQuestion = v.Output;