diff --git a/src/app/orders/orders.component.ts b/src/app/orders/orders.component.ts index f73f582..8025bd0 100644 --- a/src/app/orders/orders.component.ts +++ b/src/app/orders/orders.component.ts @@ -38,7 +38,6 @@ export class OrdersComponent implements OnInit { submitFeedbackForOrder() { this.tempReview.app_user.user_id = this.userInfo.id; this.selectedOrder.rating = this.tempReview; - console.log(this.selectedOrder); this.orderService.updateOrder(this.selectedOrder).then(() => { this.selectedOrder = null; this.tempReview = { @@ -64,7 +63,6 @@ export class OrdersComponent implements OnInit { }); this.orderService.getAllOrderStatus().then((data) => { - console.log(data); this.allOrderStatus = data; }, (err) => { console.log(err); diff --git a/src/app/profile/profile.page.html b/src/app/profile/profile.page.html index 2352fc9..a41842d 100644 --- a/src/app/profile/profile.page.html +++ b/src/app/profile/profile.page.html @@ -4,9 +4,9 @@
-
+
- {{ userInfo.name }} + {{ userInfo.name }} ({{ userInfo.username }}) @@ -20,6 +20,7 @@ {{ userInfo.email }}

+
diff --git a/src/app/profile/profile.page.ts b/src/app/profile/profile.page.ts index b1fd661..2c94bc2 100644 --- a/src/app/profile/profile.page.ts +++ b/src/app/profile/profile.page.ts @@ -21,8 +21,7 @@ export class ProfilePage implements OnInit { private toastService: ToastService ) { } - ngOnInit() { - this.userInfo = JSON.parse(localStorage.userInfo)['User Info']; + ngOnInit() { } updateUserInfo() { @@ -33,16 +32,28 @@ export class ProfilePage implements OnInit { email: this.userInfo.email, } - this.authService.updateUser(tempUserInfo).then((data) => { - console.log(data); + this.authService.updateUser(tempUserInfo).then(() => { this.toastService.presentToast("Updated!", "success"); - }, (err) => { - console.log(err); + }, () => { this.toastService.presentToast("Failed to update", "danger"); }); } ionViewDidEnter() { + this.userInfo = JSON.parse(localStorage.userInfo)['User Info']; + + this.authService.getUserDetails(this.userInfo.id).then((data: any) => { + this.userInfo.mobile = data.mobile; + this.userInfo.email = data.email; + + let info = JSON.parse(localStorage.userInfo); + info['User Info'] = this.userInfo; + localStorage.userInfo = JSON.stringify(info); + }, () => { + this.toastService.presentToast("Failed to get user data"); + }); + + this.selected_tab = ''; setTimeout(() => { this.selected_tab = 'MY ORDERS'; diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 620d1f3..e341a57 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -46,4 +46,16 @@ export class AuthService { return this.http.put(URL + '/api/maioraservice/user/v1/update', userData, httpOptions).toPromise(); } + + getUserDetails(userId: string) { + const httpOptions = { + headers: new HttpHeaders({ + 'Access-Control-Allow-Origin': '*', + 'Content-Type': 'application/json', + 'Authorization': 'Bearer ' + localStorage.access_Token + }) + }; + + return this.http.get(URL + '/api/maioraservice/user/v1/user_id/' + userId + '/', httpOptions).toPromise(); + } }