From 9e15f7a2d0683ecb21d424ae345f451f00f38f4d Mon Sep 17 00:00:00 2001 From: Aldo Giambelluca Date: Thu, 5 Dec 2024 12:05:54 +0000 Subject: [PATCH] Questions controller reduce errors (#286) * Refactor: Set steps/fields in `populateReport()` This is so that these are available from the `QuestionsController` as well. * Don't look up conditional fields as questions This is to avoid unnecessary false errors in the logs. When questions/answers are submitted the submitted values' keys are fields names. However these field names can be either a question ID or a conditional field name (e.g. comment/date) This change only look up question IDs in the report config. NOTE: This does not change what we post to the API. Conditional fields values are still submitted when the question's answers require date/comment. --- server/controllers/wip/questionsController.ts | 14 ++++++++++++++ server/middleware/populateReport.ts | 4 ++++ server/routes/questions/router.ts | 6 +----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/server/controllers/wip/questionsController.ts b/server/controllers/wip/questionsController.ts index 92ea1c75..06807c67 100644 --- a/server/controllers/wip/questionsController.ts +++ b/server/controllers/wip/questionsController.ts @@ -108,9 +108,23 @@ export default class QuestionsController extends BaseController { const reportId = req.params.id - const steps = generateSteps(res.locals.reportConfig) - const fields = generateFields(res.locals.reportConfig) - - const wizardRouter = wizard(steps, fields, { + const wizardRouter = wizard(res.locals.reportSteps, res.locals.reportFields, { name: `${reportId}-questions`, templatePath: 'pages/wip/questions', // Needs to be false, session already handled by application