diff --git a/backend/src/modules/verify-module/controller/verify.controller.ts b/backend/src/modules/verify-module/controller/verify.controller.ts index c68389f..d10f070 100644 --- a/backend/src/modules/verify-module/controller/verify.controller.ts +++ b/backend/src/modules/verify-module/controller/verify.controller.ts @@ -6,6 +6,7 @@ import { HttpStatus, Query, UseGuards, + Post, } from '@nestjs/common'; import { ApiCreatedResponse, ApiTags } from '@nestjs/swagger'; import { Request } from 'express'; @@ -22,11 +23,11 @@ export class VerifyController { ) {} @ApiCreatedResponse({ - description: 'Email verified successfully', + description: 'Verify email', type: Boolean, }) @Public() - @Get() + @Post() @HttpCode(HttpStatus.OK) public async verifyEmail( @Query('token') tokenToVerify: string diff --git a/frontend/src/app/pages/event-root/event-empty-state/event-empty-state.component.html b/frontend/src/app/pages/event-root/event-empty-state/event-empty-state.component.html index 2505cd9..aed332d 100644 --- a/frontend/src/app/pages/event-root/event-empty-state/event-empty-state.component.html +++ b/frontend/src/app/pages/event-root/event-empty-state/event-empty-state.component.html @@ -22,3 +22,28 @@ + + + + diff --git a/frontend/src/app/pages/event-root/event-empty-state/event-empty-state.component.ts b/frontend/src/app/pages/event-root/event-empty-state/event-empty-state.component.ts index bae31d8..59f79bc 100644 --- a/frontend/src/app/pages/event-root/event-empty-state/event-empty-state.component.ts +++ b/frontend/src/app/pages/event-root/event-empty-state/event-empty-state.component.ts @@ -1,6 +1,13 @@ -import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { + ChangeDetectionStrategy, + Component, + ElementRef, + ViewChild, +} from '@angular/core'; import { Router } from '@angular/router'; +import { VerifyApiService } from '../../../api'; + @Component({ selector: 'app-event-empty-state', standalone: true, @@ -9,9 +16,33 @@ import { Router } from '@angular/router'; changeDetection: ChangeDetectionStrategy.OnPush, }) export class EventEmptyStateComponent { - public constructor(private readonly router: Router) {} + @ViewChild('emailVerificationModal') + public emailVerificationModal!: ElementRef; + + public constructor( + private readonly router: Router, + private readonly verifyApi: VerifyApiService + ) {} public navigateToCreateEvent(): void { - this.router.navigate(['/event/create']); + this.verifyApi + .verifyControllerIsEmailVerified() + .subscribe((isVerified: boolean) => { + if (!isVerified) { + this.openEmailVerificationModal(); + } else { + this.router.navigate(['/event/create']); + } + }); + } + + public closeEmailVerificationModal(): void { + (this.emailVerificationModal.nativeElement as HTMLDialogElement).close(); + } + + private openEmailVerificationModal(): void { + ( + this.emailVerificationModal.nativeElement as HTMLDialogElement + ).showModal(); } }