import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { AuthService } from '@services/auth/auth.service'; import { MatchesService } from '@services/matches/matches.service'; @Component({ selector: 'app-matches-del', standalone: false, templateUrl: './matches-del.component.html', styleUrl: './matches-del.component.css', }) export class MatchesDelComponent { constructor( private route: ActivatedRoute, public authService: AuthService, private router: Router, private matchService: MatchesService ) {} ngOnInit(): void { const id = Number(this.route.snapshot.paramMap.get('id')); if (!isNaN(id)) { this.matchService.deleteMatch(id).subscribe({ next: () => { console.log(`Match ${id} supprimé`); this.router.navigate(['/matches']); // redirection après suppression }, error: (err) => { console.error('Erreur lors de la suppression :', err); }, }); } else { console.error('ID de match invalide'); } } }