diff options
author | 2021-02-08 17:55:46 +0200 | |
---|---|---|
committer | 2021-02-08 17:55:46 +0200 | |
commit | ee94923ffbe84361d1b8d219a8ed2e1d7a08e6a2 (patch) | |
tree | dad1ae31d166f2090271fd44e996ceab9edf9f7d /src/pages | |
parent | Add nullability check for ref (diff) |
Improve submit data gathering
Diffstat (limited to 'src/pages')
-rw-r--r-- | src/pages/FormPage.tsx | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/pages/FormPage.tsx b/src/pages/FormPage.tsx index e8d1a4b..ab74be9 100644 --- a/src/pages/FormPage.tsx +++ b/src/pages/FormPage.tsx @@ -229,10 +229,9 @@ function FormPage(): JSX.Element { setSending(true); - const answers = {}; + const answers: { [key: string]: unknown } = {}; questions.forEach(prop => { - const question = prop.props.question; - const options: string | string[] = prop.props.question.data["options"]; + const question: Question = prop.props.question; // TODO: Parse input from each question, and submit switch (question.type) { @@ -240,16 +239,12 @@ function FormPage(): JSX.Element { answers[question.id] = false; break; - case QuestionType.Code: - answers[question.id] = ""; - break; - case QuestionType.Checkbox: { - const parsed = new Map(); + const parsed: { [key: string]: unknown } = {}; - prop.props.public_state.forEach((value, key) => { + prop.props.public_state.forEach((value: unknown, key: string) => { if (key !== "valid" && key !== "error") { - answers.set(key.slice(6), value); + parsed[key.slice(6)] = value; } }); @@ -257,6 +252,7 @@ function FormPage(): JSX.Element { break; } + case QuestionType.Code: default: answers[question.id] = prop.props.public_state.get("value"); } |