From 373f21783b178dc1aabdf3cd751a413e975d8afc Mon Sep 17 00:00:00 2001
From: Marlene Simondant <msimondant@grandlyon.com>
Date: Wed, 19 Mar 2025 17:30:57 +0100
Subject: [PATCH] Hide "from" parameter in  url

---
 .../orientation-details.component.ts               | 14 ++++++++------
 .../orientations-table.component.ts                |  4 +++-
 2 files changed, 11 insertions(+), 7 deletions(-)

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 6b7ad813e..7d2946bc5 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 969d3b62a..e0aaca3f6 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 },
+    });
   }
 }
-- 
GitLab