diff --git a/apps/frontend/src/app/features/dashboard/dashboard.spec.ts b/apps/frontend/src/app/features/dashboard/dashboard.spec.ts
index f55c10b..1f285b3 100644
--- a/apps/frontend/src/app/features/dashboard/dashboard.spec.ts
+++ b/apps/frontend/src/app/features/dashboard/dashboard.spec.ts
@@ -164,6 +164,7 @@ describe('Dashboard', () => {
providers: [
{ provide: StatsService, useValue: statsMock },
{ provide: AlertsService, useValue: alertsMock },
+ provideRouter([]),
],
});
diff --git a/apps/frontend/src/app/features/sites/site-detail-placeholder/site-detail-placeholder.html b/apps/frontend/src/app/features/sites/site-detail-placeholder/site-detail-placeholder.html
index 7811f28..9533177 100644
--- a/apps/frontend/src/app/features/sites/site-detail-placeholder/site-detail-placeholder.html
+++ b/apps/frontend/src/app/features/sites/site-detail-placeholder/site-detail-placeholder.html
@@ -9,7 +9,7 @@
-
Site {{ siteId }}
+ Site {{ siteId() }}
diff --git a/apps/frontend/src/app/features/sites/site-detail-placeholder/site-detail-placeholder.spec.ts b/apps/frontend/src/app/features/sites/site-detail-placeholder/site-detail-placeholder.spec.ts
index ecf28c1..f229e36 100644
--- a/apps/frontend/src/app/features/sites/site-detail-placeholder/site-detail-placeholder.spec.ts
+++ b/apps/frontend/src/app/features/sites/site-detail-placeholder/site-detail-placeholder.spec.ts
@@ -1,17 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { ActivatedRoute, convertToParamMap, provideRouter } from '@angular/router';
+import { BehaviorSubject } from 'rxjs';
import { SiteDetailPlaceholder } from './site-detail-placeholder';
describe('SiteDetailPlaceholder', () => {
it("affiche l'identifiant du site depuis la route", () => {
+ const paramMap = new BehaviorSubject(convertToParamMap({ siteId: 'SITE001' }));
TestBed.configureTestingModule({
imports: [SiteDetailPlaceholder],
providers: [
provideRouter([]),
- {
- provide: ActivatedRoute,
- useValue: { snapshot: { paramMap: convertToParamMap({ siteId: 'SITE001' }) } },
- },
+ { provide: ActivatedRoute, useValue: { paramMap } },
],
});
@@ -20,4 +19,24 @@ describe('SiteDetailPlaceholder', () => {
expect(fixture.nativeElement.textContent).toContain('SITE001');
});
+
+ it('met à jour l\'affichage quand le paramètre change sans recréer le composant', () => {
+ const paramMap = new BehaviorSubject(convertToParamMap({ siteId: 'SITE001' }));
+ TestBed.configureTestingModule({
+ imports: [SiteDetailPlaceholder],
+ providers: [
+ provideRouter([]),
+ { provide: ActivatedRoute, useValue: { paramMap } },
+ ],
+ });
+
+ const fixture = TestBed.createComponent(SiteDetailPlaceholder);
+ fixture.detectChanges();
+
+ paramMap.next(convertToParamMap({ siteId: 'SITE002' }));
+ fixture.detectChanges();
+
+ expect(fixture.nativeElement.textContent).toContain('SITE002');
+ expect(fixture.nativeElement.textContent).not.toContain('SITE001');
+ });
});
diff --git a/apps/frontend/src/app/features/sites/site-detail-placeholder/site-detail-placeholder.ts b/apps/frontend/src/app/features/sites/site-detail-placeholder/site-detail-placeholder.ts
index 2474a7d..39e53dc 100644
--- a/apps/frontend/src/app/features/sites/site-detail-placeholder/site-detail-placeholder.ts
+++ b/apps/frontend/src/app/features/sites/site-detail-placeholder/site-detail-placeholder.ts
@@ -1,5 +1,7 @@
import { Component, inject } from '@angular/core';
+import { toSignal } from '@angular/core/rxjs-interop';
import { ActivatedRoute, RouterLink } from '@angular/router';
+import { map } from 'rxjs';
import { Card } from '../../../shared/components/ui/card/card';
import { Brand } from '../../../shared/components/ui/brand/brand';
@@ -13,5 +15,5 @@ import { Brand } from '../../../shared/components/ui/brand/brand';
export class SiteDetailPlaceholder {
private route = inject(ActivatedRoute);
- siteId = this.route.snapshot.paramMap.get('siteId');
+ siteId = toSignal(this.route.paramMap.pipe(map((params) => params.get('siteId'))));
}
diff --git a/apps/frontend/src/app/features/sites/site-list/site-list.html b/apps/frontend/src/app/features/sites/site-list/site-list.html
index f53b506..9998066 100644
--- a/apps/frontend/src/app/features/sites/site-list/site-list.html
+++ b/apps/frontend/src/app/features/sites/site-list/site-list.html
@@ -34,10 +34,10 @@
| {{ site.site_name }} |
{{ site.site_type }} |
- {{ site.location ?? '-' }} |
+ {{ site.location || '-' }} |
{{ site.capacity_kw ?? '-' }} |
{{ site.status ?? '-' }} |
- Détail |
+ Détail |
}
diff --git a/apps/frontend/src/app/features/sites/site-list/site-list.scss b/apps/frontend/src/app/features/sites/site-list/site-list.scss
index d253de5..9fa25a2 100644
--- a/apps/frontend/src/app/features/sites/site-list/site-list.scss
+++ b/apps/frontend/src/app/features/sites/site-list/site-list.scss
@@ -61,13 +61,3 @@
border-bottom: none;
}
}
-
-.site-list__detail-link {
- color: var(--color-primary);
- font-weight: 600;
- text-decoration: none;
-
- &:hover {
- text-decoration: underline;
- }
-}