Skip to content

Commit

Permalink
Add toArray util function to send answers as array to backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewy-gh committed Dec 6, 2024
1 parent 2c6098d commit ed992e1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions frontend/front/src/util/surveyUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,15 @@ export const buildSurveyVisitData = (
};
};

export const surveyAnswersToArray = (answers) => {
return Object.keys(answers).reduce((acc, key) => {
if (Array.isArray(answers[key])) {
acc[key] = answers[key];
} else {
acc[key] = answers[key].trim() ? [answers[key]] : [];
}
return acc;
}, {});
};

export const surveyRenderRules = {};

0 comments on commit ed992e1

Please sign in to comment.