From ee7a4c995fc484579ff248a940d2e14d54656908 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Tue, 26 Nov 2024 09:00:26 +0100 Subject: [PATCH] feat(hotel-details): add delete button and functionality --- src/app/hotel-details/hotel-details.component.html | 1 + src/app/hotel-details/hotel-details.component.ts | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/app/hotel-details/hotel-details.component.html b/src/app/hotel-details/hotel-details.component.html index 9185215..4ceeab2 100644 --- a/src/app/hotel-details/hotel-details.component.html +++ b/src/app/hotel-details/hotel-details.component.html @@ -1,4 +1,5 @@ @if (hotel != null) { + } diff --git a/src/app/hotel-details/hotel-details.component.ts b/src/app/hotel-details/hotel-details.component.ts index 2227551..5adc141 100644 --- a/src/app/hotel-details/hotel-details.component.ts +++ b/src/app/hotel-details/hotel-details.component.ts @@ -20,6 +20,13 @@ export class HotelDetailsComponent implements OnInit { constructor(private route: ActivatedRoute, private http: HttpClient, private router: Router) { } + delete(): void { + if (confirm("Are u sure u want to delete this hotel")) { + this.http.delete("/api/hotels/" + this.route.snapshot.paramMap.get("id")).subscribe(); + this.router.navigate(["/"]); + } + } + ngOnInit(): void { const routeParams = this.route.snapshot.paramMap; const hotelId = routeParams.get("id");