aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2021-02-18 08:10:07 +0200
committerGravatar ks129 <[email protected]>2021-02-18 08:10:07 +0200
commit66d375b041a5d70a99b83d2101f0417f07457c31 (patch)
tree2b0a4c38d131f982bcc28cb21527c3e40c53a01d /src/pages
parentAdd blur handler to Radio and Range (diff)
Revert change of gathering checkbox values
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/FormPage.tsx21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/pages/FormPage.tsx b/src/pages/FormPage.tsx
index d5f37f4..516d937 100644
--- a/src/pages/FormPage.tsx
+++ b/src/pages/FormPage.tsx
@@ -247,6 +247,7 @@ function FormPage(): JSX.Element {
const answers: { [key: string]: unknown } = {};
questions.forEach(prop => {
const question: Question = prop.props.question;
+ const options: string | string[] = question.data["options"];
// TODO: Parse input from each question, and submit
switch (question.type) {
@@ -255,15 +256,17 @@ function FormPage(): JSX.Element {
break;
case QuestionType.Checkbox: {
- const parsed: { [key: string]: unknown } = {};
-
- prop.props.public_state.forEach((value: unknown, key: string) => {
- if (key !== "valid" && key !== "error") {
- parsed[key.slice(6)] = value;
- }
- });
-
- answers[question.id] = parsed;
+ if (typeof options !== "string") {
+ const keys: Map<string, string> = new Map();
+ options.forEach((val: string, index) => {
+ keys.set(val, `${("000" + index).slice(-4)}. ${val}`);
+ });
+ const pairs: { [key: string]: boolean } = { };
+ keys.forEach((val, key) => {
+ pairs[key] = !!prop.props.public_state.get(val);
+ });
+ answers[question.id] = pairs;
+ }
break;
}