Commit af388a7e authored by Priyanka Upadhye's avatar Priyanka Upadhye
Browse files

Fixed issue in hire navigation flow

parent 145c011f
...@@ -28,6 +28,11 @@ export class AppComponent { ...@@ -28,6 +28,11 @@ export class AppComponent {
url: '/myreservation', url: '/myreservation',
icon: 'clipboard' icon: 'clipboard'
}, },
{
title: 'My Rides',
url: '/hirebike',
icon: 'clipboard'
},
{ {
title: 'Logout', title: 'Logout',
url: '/login', url: '/login',
......
...@@ -4,16 +4,19 @@ ...@@ -4,16 +4,19 @@
<ion-menu-button></ion-menu-button> <ion-menu-button></ion-menu-button>
</ion-buttons> </ion-buttons>
<ion-title slot="start"> <ion-title slot="start">
Hire Bike My Ride
</ion-title> </ion-title>
</ion-toolbar> </ion-toolbar>
</ion-header> </ion-header>
<ion-content> <ion-content>
<div> <div>
<ion-item> <ion-item *ngIf="!isBikeHired">
<ion-input type="text" [(ngModel)]="Destination" placeholder="Enter Destination"></ion-input> <ion-input type="text" [(ngModel)]="Destination" placeholder="Enter Destination"></ion-input>
</ion-item> </ion-item>
<ion-item *ngIf="isBikeHired">
<ion-input type="text" [(ngModel)]="Destination" placeholder="Ongoing Trip" readonly></ion-input>
</ion-item>
</div> </div>
<div #mapElement style="width: 100%; height: 100%" id="mapContainer"></div> <div #mapElement style="width: 100%; height: 100%" id="mapContainer"></div>
</ion-content> </ion-content>
......
...@@ -74,6 +74,7 @@ export class HirebikePage implements OnInit { ...@@ -74,6 +74,7 @@ export class HirebikePage implements OnInit {
console.log('Reserved Bike', resp); console.log('Reserved Bike', resp);
if (resp.data) { if (resp.data) {
this.reservedBike = resp.data; this.reservedBike = resp.data;
this.isBikeHired=this.reservedBike.rented;
//Call Bike Details api //Call Bike Details api
let bikeDetailsUrl = 'http://193.196.52.237:8081/bikes/' + this.reservedBike.bikeId; let bikeDetailsUrl = 'http://193.196.52.237:8081/bikes/' + this.reservedBike.bikeId;
let bikeDetailsApi = this.httpClient.get(bikeDetailsUrl, { headers }); let bikeDetailsApi = this.httpClient.get(bikeDetailsUrl, { headers });
...@@ -101,10 +102,9 @@ export class HirebikePage implements OnInit { ...@@ -101,10 +102,9 @@ export class HirebikePage implements OnInit {
bikeApi.subscribe((resp) => { bikeApi.subscribe((resp) => {
console.log('my data: ', resp); console.log('my data: ', resp);
this.toastService.showToast("Trip Started"); this.toastService.showToast("Trip Started");
this.isBikeHired=true;
}, (error) => { }, (error) => {
console.log(error) console.log(error)
this.toastService.showToast("Unable to Hire Bike") this.toastService.showToast("This is ongoing Trip")
}); });
}); });
......
...@@ -23,6 +23,7 @@ export class MyreservationPage implements OnInit { ...@@ -23,6 +23,7 @@ export class MyreservationPage implements OnInit {
reservedBike: any = {}; reservedBike: any = {};
bikeDetails: any = {}; bikeDetails: any = {};
isBikeHired=false;
noReservation = true; noReservation = true;
...@@ -74,6 +75,7 @@ export class MyreservationPage implements OnInit { ...@@ -74,6 +75,7 @@ export class MyreservationPage implements OnInit {
console.log('Reserved Bike', resp); console.log('Reserved Bike', resp);
if (resp.data) { if (resp.data) {
this.reservedBike = resp.data; this.reservedBike = resp.data;
this.isBikeHired = this.reservedBike.rented;
//Call Bike Details api //Call Bike Details api
let bikeDetailsUrl = 'http://193.196.52.237:8081/bikes/' + this.reservedBike.bikeId; let bikeDetailsUrl = 'http://193.196.52.237:8081/bikes/' + this.reservedBike.bikeId;
let bikeDetailsApi = this.httpClient.get(bikeDetailsUrl, { headers }); let bikeDetailsApi = this.httpClient.get(bikeDetailsUrl, { headers });
...@@ -261,6 +263,9 @@ export class MyreservationPage implements OnInit { ...@@ -261,6 +263,9 @@ export class MyreservationPage implements OnInit {
} }
}; };
hireBike() { hireBike() {
if (this.isBikeHired)
this.toastService.showToast("You already Hired this bike");
else
this.router.navigateByUrl('/hirebike'); this.router.navigateByUrl('/hirebike');
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment