Skip to content

Commit

Permalink
Check for empty responses before application submission
Browse files Browse the repository at this point in the history
  • Loading branch information
aviupadhyayula committed Sep 15, 2024
1 parent c62603f commit 18a3965
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions frontend/pages/club/[club]/application/[application]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 18a3965

Please sign in to comment.