From e005f8be5474b7d1baaae75b9ab70824986c6200 Mon Sep 17 00:00:00 2001 From: Ela <103253928+ela-codes@users.noreply.github.com> Date: Sun, 14 Dec 2025 13:18:10 -0600 Subject: [PATCH 1/4] fix(forms): improve conditional question logic in StepperForm Refactors StepperForm to filter and validate only visible questions based on conditional dependencies. Updates form validation mode to 'onSubmit', disables immediate validation on select fields, and ensures navigation buttons are enabled only when all required visible fields are filled. Also adds a helper for conditional question visibility and improves navigation and error handling. --- app/api/forms/[role]/route.ts | 3 +- components/forms/SelectField.tsx | 2 +- components/multi-step-form/StepperForm.tsx | 162 ++++++++++++++------- 3 files changed, 109 insertions(+), 58 deletions(-) diff --git a/app/api/forms/[role]/route.ts b/app/api/forms/[role]/route.ts index 9d861031..159050e1 100644 --- a/app/api/forms/[role]/route.ts +++ b/app/api/forms/[role]/route.ts @@ -53,7 +53,8 @@ export async function POST( // Get role and questions - const roleSlug = context.params.role; + const params = await context.params; + const roleSlug = params.role; console.log(`Processing application for role: ${roleSlug}`); diff --git a/components/forms/SelectField.tsx b/components/forms/SelectField.tsx index 21b7bd3c..954c3327 100644 --- a/components/forms/SelectField.tsx +++ b/components/forms/SelectField.tsx @@ -68,7 +68,7 @@ const SelectField = memo(function SelectField({