diff --git a/src/components/Survey.tsx b/src/components/Survey.tsx index c3e26f6..1762cb7 100644 --- a/src/components/Survey.tsx +++ b/src/components/Survey.tsx @@ -35,7 +35,7 @@ const GreetingPage = ({updatePage}: { /** * Single question component for a guided survey */ -const QuestionPage = ({isLastPage, page, question, updatePage, formData, updateFormData, submitForm}: { +const QuestionPage = ({isLastPage, page, question, updatePage, formData, updateFormData}: { isLastPage: boolean, page: number, question: Question, @@ -99,21 +99,13 @@ const QuestionPage = ({isLastPage, page, question, updatePage, formData, updateF :
- +
} ) }; - const htmlOptions: JSX.Element[] = [] - const optionButtons: JSX.Element[] = [] - - question.options.forEach((option, index) => { - optionButtons.push() - htmlOptions.push() - }); - return (
@@ -121,13 +113,12 @@ const QuestionPage = ({isLastPage, page, question, updatePage, formData, updateF

{question.question}

- {/** Hidden selector html */} - -
- {optionButtons} + {question.options.map((option, index) => { + return ( + + ); + })}
@@ -181,18 +172,36 @@ const GuidedSurvey = ({questions}: { ); } - const question = questions[pageNumber]; + const question = questions[pageNumber-1]; if (!question) { return null; } - const isLastPage = pageNumber === questions.length - 1 + const isLastPage = pageNumber === questions.length return ( ); } + /** + * Renders the hidden html form selectors + */ + const HTMLQuestion = ({question}: {question: Question}) => { + return ( + + ); + } + const lastPage = ; const currentPage = ; @@ -203,6 +212,13 @@ const GuidedSurvey = ({questions}: { + + {/** Hidden html */} +
+ {questions.map((question, index) => { + return + })} + ) }