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

master
Alix JEUDI--LEMOINE 2 days ago
parent d13f34d570
commit e04e4bdef5

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

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

Loading…
Cancel
Save