From 9154eef55ce29d73a44f8e09b71af495cc5a03c3 Mon Sep 17 00:00:00 2001 From: anonym-HPI <68286419+anonym-HPI@users.noreply.github.com> Date: Fri, 17 Nov 2023 17:30:56 +0100 Subject: [PATCH] don't allow joining the exercise without ticking the checkbox Signed-off-by: anonym-HPI <68286419+anonym-HPI@users.noreply.github.com> --- .../join-exercise-modal.component.ts | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/pages/exercises/shared/join-exercise-modal/join-exercise-modal.component.ts b/frontend/src/app/pages/exercises/shared/join-exercise-modal/join-exercise-modal.component.ts index ab67d0855..c0443bd14 100644 --- a/frontend/src/app/pages/exercises/shared/join-exercise-modal/join-exercise-modal.component.ts +++ b/frontend/src/app/pages/exercises/shared/join-exercise-modal/join-exercise-modal.component.ts @@ -3,6 +3,7 @@ import { Component } from '@angular/core'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { Subject } from 'rxjs'; import { ApplicationService } from 'src/app/core/application.service'; +import { MessageService } from 'src/app/core/messages/message.service'; @Component({ selector: 'app-join-exercise-modal', @@ -21,7 +22,8 @@ export class JoinExerciseModalComponent implements OnDestroy { constructor( private readonly applicationService: ApplicationService, - private readonly activeModal: NgbActiveModal + private readonly activeModal: NgbActiveModal, + private readonly messageService: MessageService ) {} public toggleAgreedToTermsAndPrivacyPolicy(event: boolean) { @@ -29,12 +31,20 @@ export class JoinExerciseModalComponent implements OnDestroy { } public async joinExercise() { - const successfullyJoined = await this.applicationService.joinExercise( - this.exerciseId, - this.clientName - ); - this.exerciseJoined$.next(successfullyJoined); - this.activeModal.close(); + if (this.agreedToTermsAndPrivacyPolicy) { + const successfullyJoined = + await this.applicationService.joinExercise( + this.exerciseId, + this.clientName + ); + this.exerciseJoined$.next(successfullyJoined); + this.activeModal.close(); + } else { + this.messageService.postMessage({ + title: 'Fehler: Bedinungen nicht zugestimmt', + color: 'warning', + }); + } } public close() {