Add SentComponent for form submission confirmation and integrate with email verification flow

This commit is contained in:
akastijn 2025-08-23 22:42:18 +02:00
parent 523bf3d43f
commit d1da1296bb
6 changed files with 85 additions and 3 deletions

View File

@ -106,6 +106,10 @@ export const routes: Routes = [
path: 'staffpowers', path: 'staffpowers',
loadComponent: () => import('./pages/reference/staffpowers/staffpowers.component').then(m => m.StaffpowersComponent) loadComponent: () => import('./pages/reference/staffpowers/staffpowers.component').then(m => m.StaffpowersComponent)
}, },
{
path: 'forms',
loadComponent: () => import('./pages/forms/forms.component').then(m => m.FormsComponent)
},
{ {
path: 'forms/appeal', path: 'forms/appeal',
loadComponent: () => import('./pages/forms/appeal/appeal.component').then(m => m.AppealComponent), loadComponent: () => import('./pages/forms/appeal/appeal.component').then(m => m.AppealComponent),
@ -115,8 +119,12 @@ export const routes: Routes = [
} }
}, },
{ {
path: 'forms', path: 'forms/sent',
loadComponent: () => import('./pages/forms/forms.component').then(m => m.FormsComponent) loadComponent: () => import('./pages/forms/sent/sent.component').then(m => m.SentComponent),
canActivate: [AuthGuard],
data: {
requiredAuthorizations: ['SCOPE_user']
}
}, },
{ {
path: 'community', path: 'community',

View File

@ -23,6 +23,7 @@ import {MatInputModule} from '@angular/material/input';
import {HistoryFormatService} from '@pages/reference/bans/history-format.service'; import {HistoryFormatService} from '@pages/reference/bans/history-format.service';
import {MatDialog} from '@angular/material/dialog'; import {MatDialog} from '@angular/material/dialog';
import {VerifyMailDialogComponent} from '@pages/forms/verify-mail-dialog/verify-mail-dialog.component'; import {VerifyMailDialogComponent} from '@pages/forms/verify-mail-dialog/verify-mail-dialog.component';
import {Router} from '@angular/router';
@Component({ @Component({
selector: 'app-appeal', selector: 'app-appeal',
@ -163,6 +164,8 @@ export class AppealComponent implements OnInit, OnDestroy, AfterViewInit {
} }
} }
private router = inject(Router)
private sendForm() { private sendForm() {
const rawValue = this.form.getRawValue(); const rawValue = this.form.getRawValue();
const uuid = this.authService.getUuid(); const uuid = this.authService.getUuid();
@ -177,7 +180,14 @@ export class AppealComponent implements OnInit, OnDestroy, AfterViewInit {
username: this.authService.username()!, username: this.authService.username()!,
uuid: uuid uuid: uuid
} }
this.appealsService.submitMinecraftAppeal(appeal).subscribe() this.appealsService.submitMinecraftAppeal(appeal).subscribe((result) => {
if (!result.verified_mail) {
throw new Error('Mail not verified');
}
this.router.navigate(['/form/sent'], {
state: {message: result.message}
}).then();
})
} }
public currentPageIndex: number = 0; public currentPageIndex: number = 0;

View File

@ -0,0 +1,13 @@
<div>
<app-header [current_page]="'appeal'" height="200px" background_image="/public/img/backgrounds/staff.png"
[overlay_gradient]="0.5">
<div class="title" header-content>
<h1>Form completed</h1>
</div>
</app-header>
<main>
<section class="darkmodeSection">
<p>{{ message }}</p>
</section>
</main>
</div>

View File

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SentComponent } from './sent.component';
describe('SentComponent', () => {
let component: SentComponent;
let fixture: ComponentFixture<SentComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [SentComponent]
})
.compileComponents();
fixture = TestBed.createComponent(SentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,28 @@
import {Component, OnInit} from '@angular/core';
import {Router} from '@angular/router';
import {HeaderComponent} from '@header/header.component';
@Component({
selector: 'app-sent',
imports: [
HeaderComponent
],
templateUrl: './sent.component.html',
styleUrl: './sent.component.scss',
standalone: true
})
export class SentComponent implements OnInit {
protected message: string = "The form is completed and has been sent";
constructor(private router: Router) {
}
ngOnInit() {
const navigation = this.router.getCurrentNavigation();
const state = navigation?.extras.state as { message: string };
if (state?.message) {
this.message = state.message;
}
}
}