Skip to content

Commit a0f0170

Browse files
committed
Fixed hotel routes
1 parent 421f686 commit a0f0170

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

src/app/hotel-view-card/hotel-view-card.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</div>
1515
<div class="card-content">
1616
<div class="card-header">
17-
<span class="card-title" routerLink="/login">{{ title }}</span>
17+
<span class="card-title" (click)="redirectToHotelPage()">{{ title }}</span>
1818
<span class="card-location">{{ location }}</span>
1919
</div>
2020
<div class="card-footer">

src/app/hotel-view-card/hotel-view-card.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {HttpClient, HttpHeaders} from '@angular/common/http';
33
import {HotelsService} from '../hotels.service';
44
import {ApiUrls} from '../api-urls';
55
import {TokenService} from '../token.service';
6+
import {Router} from '@angular/router';
67

78
@Component({
89
selector: 'app-hotel-view-card',
@@ -25,6 +26,7 @@ export class HotelViewCardComponent implements OnInit {
2526

2627
constructor(
2728
private hotelsService: HotelsService,
29+
private router: Router,
2830
) {}
2931

3032
ngOnInit() {
@@ -50,4 +52,8 @@ export class HotelViewCardComponent implements OnInit {
5052
this.hotelsService.removeFromFavourites(+this.hotelId);
5153
}
5254
}
55+
redirectToHotelPage() {
56+
this.router.navigate(['/hotel', this.hotelId]);
57+
}
58+
5359
}

src/app/my-bookings-page/my-bookings-page.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
</div>
6666
<div class="hotel-price-container">
6767
<span *ngIf="booking.payment != null" id="new-price">USD {{booking.payment.amount}}</span>
68-
<input class="view-button" type="button" value="View" (click)="redirectToHotelPage(hotel.id)"/>
68+
<input class="view-button" type="button" value="View" (click)="redirectToHotelPage()"/>
6969
<input class="cancel-button" type="button" value="Cancel" (click)="deleteBooking(booking)"/>
7070
</div>
7171
</div>

src/app/my-bookings-page/my-bookings-page.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {ApiUrls} from '../api-urls';
1616
})
1717
export class MyBookingsPageComponent {
1818
hotelsList: any = null;
19+
hotelRouteId: any;
1920
hotel = {
2021
id: 1,
2122
mainImageUrl: "https://orbistayblob.blob.core.windows.net/hotels/cozy-ny-hotel-main.svg",
@@ -90,6 +91,7 @@ export class MyBookingsPageComponent {
9091
this.hotelService.getHotelById(booking.hotelId).subscribe(
9192
(hotel) => {
9293
this.hotelsList[index].hotel = hotel;
94+
this.hotelRouteId = hotel.id;
9395
this.hotelsList[index].hotelGrade = this.getHotelGrade(hotel.avgRate);
9496
},
9597
(error) => {
@@ -161,7 +163,7 @@ export class MyBookingsPageComponent {
161163
return '';
162164
}
163165

164-
redirectToHotelPage(hotelId: number) {
165-
this.router.navigate(['/hotel', hotelId]);
166+
redirectToHotelPage() {
167+
this.router.navigate(['/hotel', this.hotelRouteId]);
166168
}
167169
}

0 commit comments

Comments
 (0)