Compare commits

...

2 commits

4 changed files with 16 additions and 8 deletions

BIN
bun.lockb

Binary file not shown.

View file

@ -10,14 +10,14 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^18.2.3",
"@angular/common": "^18.2.3",
"@angular/compiler": "^18.2.3",
"@angular/core": "^18.2.3",
"@angular/forms": "^18.2.3",
"@angular/platform-browser": "^18.2.3",
"@angular/platform-browser-dynamic": "^18.2.3",
"@angular/router": "^18.2.3",
"@angular/animations": "^19.0.0",
"@angular/common": "^19.0.0",
"@angular/compiler": "^19.0.0",
"@angular/core": "^19.0.0",
"@angular/forms": "^19.0.0",
"@angular/platform-browser": "^19.0.0",
"@angular/platform-browser-dynamic": "^19.0.0",
"@angular/router": "^19.0.0",
"angular-in-memory-web-api": "^0.18.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",

View file

@ -1,4 +1,5 @@
@if (hotel != null) {
<app-hotel-item [hotel]="hotel" [isDetail]="true"></app-hotel-item>
<app-hotel-form [hotel]="hotel"></app-hotel-form>
<button (click)="delete()">DELETE</button>
}

View file

@ -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<Hotel>("/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");