diff --git a/frontend/src/app/eventpage/event-banner/event-banner.component.html b/frontend/src/app/eventpage/event-banner/event-banner.component.html index 394b816..b3d762e 100644 --- a/frontend/src/app/eventpage/event-banner/event-banner.component.html +++ b/frontend/src/app/eventpage/event-banner/event-banner.component.html @@ -12,7 +12,7 @@ edit Bearbeiten - diff --git a/frontend/src/app/eventpage/event-banner/event-banner.component.ts b/frontend/src/app/eventpage/event-banner/event-banner.component.ts index 137bf80..52ad4f2 100644 --- a/frontend/src/app/eventpage/event-banner/event-banner.component.ts +++ b/frontend/src/app/eventpage/event-banner/event-banner.component.ts @@ -5,6 +5,7 @@ import {MatDialog} from "@angular/material/dialog"; import {EventService} from "../../../services/event.service"; import {CreateEventDialogComponent} from "../../create-event/create-event-dialog.component"; import {InvitationDialogComponent} from "../invitation-dialog/invitation-dialog.component"; +import {Router} from "@angular/router"; @Component({ @@ -19,6 +20,9 @@ export class EventBannerComponent implements OnInit { @Output() onEventUpdated = new EventEmitter(); + @Output() + onEventLeft = new EventEmitter(); + @Output() showParticipantsClicked = new EventEmitter(); @@ -27,7 +31,8 @@ export class EventBannerComponent implements OnInit { constructor( private breakpointObserver: BreakpointObserver, private dialog: MatDialog, - private service: EventService + private service: EventService, + private router: Router ) { } @@ -47,7 +52,7 @@ export class EventBannerComponent implements OnInit { dialogRef.afterClosed().subscribe(updateCommand => { if (!updateCommand) return; this.service.updateEvent(this.eventData.id, updateCommand).subscribe((event) => { - //TODO: Update Eventpage and navbar + this.onEventUpdated.emit(event); } ); }); @@ -63,4 +68,11 @@ export class EventBannerComponent implements OnInit { }); dialogRef.afterClosed().subscribe(() => subscription.unsubscribe()); } + + leaveEvent() { + this.service.leaveEvent(this.eventData.id).subscribe(() => { + this.router.navigateByUrl("/"); + this.onEventLeft.emit(); + }); + } } diff --git a/frontend/src/app/eventpage/eventpage.component.html b/frontend/src/app/eventpage/eventpage.component.html index 7fa73aa..ee58923 100644 --- a/frontend/src/app/eventpage/eventpage.component.html +++ b/frontend/src/app/eventpage/eventpage.component.html @@ -5,6 +5,7 @@
diff --git a/frontend/src/app/eventpage/eventpage.component.ts b/frontend/src/app/eventpage/eventpage.component.ts index 2614d87..8398882 100644 --- a/frontend/src/app/eventpage/eventpage.component.ts +++ b/frontend/src/app/eventpage/eventpage.component.ts @@ -51,6 +51,11 @@ export class EventpageComponent implements OnInit, OnDestroy { onEventUpdated(event: Event) { this.eventData = event; + this.updateEventList(); + } + + updateEventList() { + // TODO: trigger an update for the event list in the sidebar } private loadEventData(eventId: string) { diff --git a/frontend/src/services/event.service.ts b/frontend/src/services/event.service.ts index 37a3f23..09e72f1 100644 --- a/frontend/src/services/event.service.ts +++ b/frontend/src/services/event.service.ts @@ -31,4 +31,8 @@ export class EventService { generateInvitationLink(eventId: string): Observable { return this.http.get(`${environment.api}/event/${eventId}/generateInvitationLink`, {withCredentials: true}); } + + leaveEvent(eventId: string): Observable { + return this.http.get(`${environment.api}/event/${eventId}/leave`, {withCredentials: true}); + } }