From 18a3965a3c910dd320b8a50182fe005bcfeefa35 Mon Sep 17 00:00:00 2001 From: aviupadhyayula Date: Sun, 15 Sep 2024 14:43:37 -0400 Subject: [PATCH] Check for empty responses before application submission --- .../club/[club]/application/[application]/index.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/frontend/pages/club/[club]/application/[application]/index.tsx b/frontend/pages/club/[club]/application/[application]/index.tsx index 69e8bd1ee..da60c5fa9 100644 --- a/frontend/pages/club/[club]/application/[application]/index.tsx +++ b/frontend/pages/club/[club]/application/[application]/index.tsx @@ -203,6 +203,18 @@ const ApplicationPage = ({ onSubmit={(values: { [id: number]: any }, actions) => { let submitErrors: string | null = null + // check for unanswered questions + const unansweredQuestions = questions.filter( + (question) => + question.question_type !== ApplicationQuestionType.InfoText && + (!values[question.id] || values[question.id].trim() === ''), + ) + + if (unansweredQuestions.length > 0) { + setErrors('Please answer all questions before submitting.') + return + } + // word count error check for (const [questionId, text] of Object.entries(values)) { const question = questions.find(