diff --git a/src/app/profile/dashboard/orientation-details/orientation-details.component.ts b/src/app/profile/dashboard/orientation-details/orientation-details.component.ts index 6b7ad813e20f6c27391e43255a8e35809969a9ae..7d2946bc5a605fd46620353981149854b2855806 100644 --- a/src/app/profile/dashboard/orientation-details/orientation-details.component.ts +++ b/src/app/profile/dashboard/orientation-details/orientation-details.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, SecurityContext, ViewChild } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { User } from '../../../models/user.model'; import { NotificationService } from '../../../services/notification.service'; import { OrientationService } from '../../../services/orientation.service'; @@ -19,7 +19,13 @@ export class OrientationDetailsComponent implements OnInit { private notificationService: NotificationService, private profileService: ProfileService, private sanitizer: DomSanitizer, - ) {} + private router: Router, + ) { + const navigation = this.router.getCurrentNavigation(); + if (navigation?.extras?.state) { + this.from = navigation.extras.state['from']; + } + } @ViewChild('comment', { static: false }) commentTextarea: TextareaComponent; @@ -33,10 +39,6 @@ export class OrientationDetailsComponent implements OnInit { private closedStatuses = ['completed', 'uncompleted', 'expired']; ngOnInit(): void { - this.route.queryParams.subscribe((params) => { - this.from = params['from']; - }); - this.route.params.subscribe((urlParams) => { const orientationId = urlParams.id || ''; if (orientationId) { diff --git a/src/app/profile/dashboard/orientations-table/orientations-table.component.ts b/src/app/profile/dashboard/orientations-table/orientations-table.component.ts index 969d3b62abaf34be94483fb284fc9cf3dacb823f..e0aaca3f6f7b9680a292188f3d137f7026e2d30c 100644 --- a/src/app/profile/dashboard/orientations-table/orientations-table.component.ts +++ b/src/app/profile/dashboard/orientations-table/orientations-table.component.ts @@ -31,6 +31,8 @@ export class OrientationsTableComponent { public navigateToDetails(event: Event, orientationId: string): void { event.preventDefault(); - this.router.navigate(['/profil/details-orientation', orientationId], { queryParams: { from: this.from } }); + this.router.navigate(['/profil/details-orientation', orientationId], { + state: { from: this.from }, + }); } }