Commit 221d2907 authored by Ratnadeep Rajendra Kharade's avatar Ratnadeep Rajendra Kharade
Browse files

displayed loading page on hire bike page for api call

parent e4d71808
......@@ -160,6 +160,7 @@ export class HirebikePage implements OnInit {
}
getReservedBike() {
this.loadingService.showLoader();
this.storage.get('token').then((token) => {
const headers = new HttpHeaders().set("Authorization", "Bearer " + token);
//call reserved bike api
......@@ -181,24 +182,34 @@ export class HirebikePage implements OnInit {
//pass reserved bike subject here map
this.gotReservedBikeSubject.next(resp.data);
}, (reservedBikeError) => console.log(reservedBikeError));
this.loadingService.hideLoader();
}, (reservedBikeError) => {
console.log(reservedBikeError);
this.loadingService.hideLoader();
});
}
}, (bikeDetailsError) => console.log(bikeDetailsError));
}, (bikeDetailsError) => {
console.log(bikeDetailsError);
this.loadingService.hideLoader();
});
});
}
startTrip1() {
this.loadingService.showLoader();
this.storage.get('token').then((token) => {
let url = 'http://193.196.52.237:8081/rent' + '?bikeId=' + this.bikeDetails.id;
const headers = new HttpHeaders().set("Authorization", "Bearer " + token);
let bikeApi = this.httpClient.get(url, { headers });
bikeApi.subscribe((resp) => {
console.log('my data: ', resp);
this.loadingService.hideLoader();
this.toastService.showToast("Trip Started");
this.isBikeHired = true;
}, (error) => {
console.log(error)
this.toastService.showToast("This is ongoing Trip")
console.log(error);
this.loadingService.hideLoader();
this.toastService.showToast("This is ongoing Trip");
});
});
......@@ -210,15 +221,18 @@ export class HirebikePage implements OnInit {
}
CancelTrip() {
this.loadingService.showLoader();
this.storage.get('token').then((token) => {
let url = 'http://193.196.52.237:8081/rent' + '?bikeId=' + this.bikeDetails.id;
const headers = new HttpHeaders().set("Authorization", "Bearer " + token);
let bikeApi = this.httpClient.delete(url, { headers });
bikeApi.subscribe((resp) => {
console.log('my data: ', resp);
this.loadingService.hideLoader();
this.toastService.showToast("Trip Ended!");
}, (error) => {
console.log(error)
console.log(error);
this.loadingService.hideLoader();
this.toastService.showToast("No Ongong Trip to End")
});
});
......
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