🔧 Added a condition to display the pin detail only if the pin is loaded (console errors) + remove commented code.

master
Alix JEUDI--LEMOINE 10 hours ago
parent d13f34d570
commit e04e4bdef5

@ -2,7 +2,7 @@
<div class="min-h-screen bg-gray-100 px-4 py-12 overflow-y-auto">
<!-- .pin-detail agit comme conteneur vertical -->
<div class="pin-detail">
<div class="card-pin-detail">
<div class="card-pin-detail" *ngIf="pin">
<!-- Bouton retour à gauche -->
<div class="mb-6">
<button

@ -4,12 +4,10 @@ import { Pin } from '../../model/Pin';
import { PinService } from '../../services/pin/pin.service';
import { RouterModule } from '@angular/router';
import { ActivatedRoute } from '@angular/router';
import { AuthService } from '../../services/auth/auth.service';
import { UserService } from '../../services/user/user.service';
import { ImageService } from '../../services/image/image.service';
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
import { Router } from '@angular/router';
import { Renderer2 } from '@angular/core';
import { CookiesService } from '../../services/cookies/cookies.service';
@Component({
@ -41,18 +39,14 @@ export class PinDetailComponent {
constructor(
private pinService: PinService,
private route: ActivatedRoute,
private authService: AuthService,
private userService: UserService,
private imageService: ImageService,
private sanitizer: DomSanitizer,
private router: Router,
private renderer: Renderer2,
private cookiesService: CookiesService
) {}
ngOnInit(): void {
// this.renderer.addClass(document.body, 'no-scroll-body');
const pinId = this.route.snapshot.paramMap.get('id');
this.username_session = this.cookiesService.getUsername() || '';
@ -87,7 +81,7 @@ export class PinDetailComponent {
loadUsername(userId: string) {
this.userService.getUserById(userId).subscribe({
next: (user) => {
this.username = user.username; // ou user.name selon ton backend
this.username = user.username;
},
error: (err) => {
console.error('Erreur lors de la récupération du pseudo :', err);
@ -121,10 +115,6 @@ export class PinDetailComponent {
});
}
// toggleDescription(): void {
// this.expandedDescription = !this.expandedDescription;
// }
ngAfterViewInit(): void {
this.checkIfDescriptionIsTruncated();
}
@ -153,10 +143,6 @@ export class PinDetailComponent {
this.currentIndex = (this.currentIndex + 1) % this.imageUrls.length;
}
ngOnDestroy() {
// this.renderer.removeClass(document.body, 'no-scroll-body');
}
goBack() {
this.router.navigate(['/map'], { queryParams: { pin: this.pin.id } });
}

Loading…
Cancel
Save