Skip to content

Commit

Permalink
Add submit completion snackbar and invalid email snackbar
Browse files Browse the repository at this point in the history
  • Loading branch information
JayBae9903 committed Feb 12, 2024
1 parent 9b0cedb commit 722b394
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/views/HousingLottery/studentView/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,29 @@ const StudentView = () => {
return;
}

const invalidEmail = studentApplicantResult.some((email) => !email.endsWith('@gordon.edu'));
if (invalidEmail) {
setSnackbar({
message:
'One or more emails are not valid Gordon emails. Please correct them before submitting.',
severity: 'error',
open: true,
});
return; // Stop the submission process if there's an invalid email
}

try {
console.log(application_id);
await housingService.addApplicant(application_id, studentApplicantResult);
await housingService.addHall(application_id, preferredHallResult);
await housingService.addPreference(application_id, preferenceResult);
} catch {
setSnackbar({
message: 'Application submitted successfully!',
severity: 'success',
open: true,
});
} catch (error) {
console.error('Error submitting application:', error);
setSnackbar({
message: 'Application fail to submit. Please check your information or contact CTS.',
severity: 'error',
Expand Down

1 comment on commit 722b394

@JayBae9903
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the email validation is not working, and I need more time to fix it. I might work on this this week.

Please sign in to comment.