Skip to content

Commit

Permalink
feat: return to moderation view after changing event
Browse files Browse the repository at this point in the history
  • Loading branch information
gion-andri committed Nov 9, 2023
1 parent 2607716 commit 6606bcd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ export class ModeratorEventsComponent implements OnInit {

edit(event: Event) {
this.router.navigateByUrl('/user/event-form', {
state: {event},
state: {
event,
returnToModeratorView: true,
},
});
}

Expand Down
18 changes: 16 additions & 2 deletions src/app/user-area/pages/new-event/new-event.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class NewEventComponent implements OnInit {

private eventToChangeId?: string;
private eventToChange?: EventDto;
private returnToModeratorView = false;

constructor(
private authService: AuthenticationService,
Expand All @@ -54,6 +55,11 @@ export class NewEventComponent implements OnInit {
if (event) {
this.eventToChangeId = event.id;
}

const returnToModeratorView = navigation.extras.state['returnToModeratorView'];
if (returnToModeratorView) {
this.returnToModeratorView = true;
}
}
}

Expand Down Expand Up @@ -92,7 +98,11 @@ export class NewEventComponent implements OnInit {
"Ti has memorisà cun success l'occurrenza «" + event.title + "»."
);

this.router.navigateByUrl('/user/events');
if (this.returnToModeratorView) {
this.router.navigateByUrl('/moderator/events');
} else {
this.router.navigateByUrl('/user/events');
}
});
} else {
this.eventsService.createEvent(event).subscribe(event => {
Expand All @@ -103,7 +113,11 @@ export class NewEventComponent implements OnInit {
);

if (this.isLoggedIn) {
this.router.navigateByUrl('/user/events');
if (this.returnToModeratorView) {
this.router.navigateByUrl('/moderator/events');
} else {
this.router.navigateByUrl('/user/events');
}
} else {
this.router.navigateByUrl('/');
}
Expand Down

0 comments on commit 6606bcd

Please sign in to comment.