diff --git a/src/app/hirebike/hirebike.page.ts b/src/app/hirebike/hirebike.page.ts index 219a0b40d436bb75dd6efce104826006c457e416..789c3eea88a9eb1dbef50067bc75c0fc67bbcde2 100644 --- a/src/app/hirebike/hirebike.page.ts +++ b/src/app/hirebike/hirebike.page.ts @@ -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") }); });