Commit 675b3e76 authored by Priyanka Vivekanand Upadhye's avatar Priyanka Vivekanand Upadhye
Browse files

Merge branch '36-cancel-hired-bike' into 'master'

Resolve "Cancel Hired Bike"

Closes #36

See merge request 92khra1mst/hft_awado_app!20
parents 4fc81488 d4429a26
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<div #mapElement style="width: 100%; height: 100%" id="mapContainer"></div> <div #mapElement style="width: 100%; height: 100%" id="mapContainer"></div>
</ion-content> </ion-content>
<ion-footer> <ion-footer>
<div class="bike-details-container" *ngIf="!isBikeHired"> <div class="bike-details-container">
<div class="inner"> <div class="inner">
<div class="button-container"> <div class="button-container">
<ion-grid> <ion-grid>
...@@ -33,31 +33,20 @@ ...@@ -33,31 +33,20 @@
<ion-col>Bike Location</ion-col> <ion-col>Bike Location</ion-col>
<ion-col>{{bikeDetails.address}}</ion-col> <ion-col>{{bikeDetails.address}}</ion-col>
</ion-row> </ion-row>
<ion-row> <ion-row *ngIf="!isBikeHired">
<ion-col> <ion-col>
<ion-button size="medium" expand="block" (click)="startTrip()">Start Trip</ion-button> <ion-button size="medium" expand="block" (click)="startTrip()">Start Trip</ion-button>
</ion-col> </ion-col>
</ion-row> </ion-row>
</ion-grid>
</div> <ion-row *ngIf="isBikeHired">
</div>
</div>
<div class="problem-container" *ngIf="isBikeHired">
<div class="inner">
<div class="button-container">
<ion-grid>
<ion-row>
<ion-col>Any Problems?</ion-col>
</ion-row>
<ion-row>
<ion-col> <ion-col>
<ion-button size="medium" expand="block" (click)="CancelTrip()">Cancel Trip</ion-button> <ion-button size="medium" expand="block" (click)="CancelTrip()">End Trip</ion-button>
</ion-col> </ion-col>
</ion-row> </ion-row>
</ion-grid> </ion-grid>
</div> </div>
</div> </div>
</div> </div>
</ion-footer> </ion-footer>
\ No newline at end of file
...@@ -102,6 +102,7 @@ export class HirebikePage implements OnInit { ...@@ -102,6 +102,7 @@ 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("This is ongoing Trip") this.toastService.showToast("This is ongoing Trip")
...@@ -110,7 +111,23 @@ export class HirebikePage implements OnInit { ...@@ -110,7 +111,23 @@ export class HirebikePage implements OnInit {
} }
CancelTrip(){
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.toastService.showToast("Trip Ended!");
}, (error) => {
console.log(error)
this.toastService.showToast("No Ongong Trip to End")
});
});
}
loadmap() { loadmap() {
var defaultLayers = this.platform.createDefaultLayers(); var defaultLayers = this.platform.createDefaultLayers();
......
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