diff --git a/frontend/src/app/pages/forms/staff-application/staff-application.component.html b/frontend/src/app/pages/forms/staff-application/staff-application.component.html
index 0d53b43..9ac18fd 100644
--- a/frontend/src/app/pages/forms/staff-application/staff-application.component.html
+++ b/frontend/src/app/pages/forms/staff-application/staff-application.component.html
@@ -287,7 +287,7 @@
diff --git a/frontend/src/app/pages/forms/staff-application/staff-application.component.ts b/frontend/src/app/pages/forms/staff-application/staff-application.component.ts
index 36c3260..0a87833 100644
--- a/frontend/src/app/pages/forms/staff-application/staff-application.component.ts
+++ b/frontend/src/app/pages/forms/staff-application/staff-application.component.ts
@@ -57,6 +57,7 @@ export class StaffApplicationComponent implements OnInit, OnDestroy, AfterViewIn
public staffApplicationService = inject(ApplicationsService)
private resizeObserver: ResizeObserver | null = null;
private boundHandleResize: any;
+ protected isSubmitting = signal(false);
protected form: FormGroup;
private emails = signal([]);
@@ -219,9 +220,11 @@ export class StaffApplicationComponent implements OnInit, OnDestroy, AfterViewIn
}
public onSubmit() {
+ this.isSubmitting.set(true);
if (this.form === undefined) {
console.error('Form is undefined');
this.matSnackBar.open('An error occurred, please try again later')
+ this.isSubmitting.set(false);
return
}
if (this.form.valid) {
@@ -233,6 +236,7 @@ export class StaffApplicationComponent implements OnInit, OnDestroy, AfterViewIn
control?.markAsTouched();
});
this.matSnackBar.open('Please fill out all required fields')
+ this.isSubmitting.set(false);
}
}
@@ -246,14 +250,27 @@ export class StaffApplicationComponent implements OnInit, OnDestroy, AfterViewIn
private sendForm() {
const staffApplication: StaffApplication = this.mapToStaffApplication(this.form.getRawValue());
- this.staffApplicationService.submitStaffApplication(staffApplication).subscribe(result => {
- if (!result.verified_mail) {
- throw new Error('Submitted a form with an e-mail that was not verified.');
+ this.staffApplicationService.submitStaffApplication(staffApplication).subscribe({
+ next: result => {
+ if (!result.verified_mail) {
+ this.isSubmitting.set(false);
+ this.matSnackBar.open('Your email has not been verified. Please verify your email before submitting.', 'Close', {
+ duration: 5000
+ });
+ return;
+ }
+ this.router.navigate(['/forms/sent'], {
+ state: {message: result.message}
+ }).then();
+ },
+ error: (error) => {
+ this.isSubmitting.set(false);
+ console.error('Error submitting application:', error);
+ this.matSnackBar.open('An error occurred while submitting your application. Please try again later.', 'Close', {
+ duration: 5000
+ });
}
- this.router.navigate(['/forms/sent'], {
- state: {message: result.message}
- }).then();
- })
+ });
}
public currentPageIndex: number = 0;