aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2021-02-08 17:55:46 +0200
committerGravatar ks129 <[email protected]>2021-02-08 17:55:46 +0200
commitee94923ffbe84361d1b8d219a8ed2e1d7a08e6a2 (patch)
treedad1ae31d166f2090271fd44e996ceab9edf9f7d
parentAdd nullability check for ref (diff)
Improve submit data gathering
-rw-r--r--src/pages/FormPage.tsx16
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");
}