|
|
|
@@ -1,6 +1,8 @@ |
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
import { Location } from '@angular/common'; |
|
|
|
import { Router } from '@angular/router'; |
|
|
|
import { AuthService } from '../services/auth.service'; |
|
|
|
import { ToastService } from '../services/toast.service'; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
selector: 'app-profile', |
|
|
|
@@ -10,15 +12,36 @@ import { Router } from '@angular/router'; |
|
|
|
export class ProfilePage implements OnInit { |
|
|
|
selected_tab: string = 'MY ORDERS'; |
|
|
|
userInfo: any; |
|
|
|
showEdit: boolean = false; |
|
|
|
|
|
|
|
constructor( |
|
|
|
private location: Location, |
|
|
|
private router: Router |
|
|
|
private router: Router, |
|
|
|
private authService: AuthService, |
|
|
|
private toastService: ToastService |
|
|
|
) { } |
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
this.userInfo = JSON.parse(localStorage.userInfo)['User Info']; |
|
|
|
console.log(this.userInfo); |
|
|
|
} |
|
|
|
|
|
|
|
updateUserInfo() { |
|
|
|
let tempUserInfo = { |
|
|
|
id: this.userInfo.id, |
|
|
|
name: this.userInfo.name, |
|
|
|
username: this.userInfo.username, |
|
|
|
email: this.userInfo.email, |
|
|
|
mobile: this.userInfo.mobile, |
|
|
|
address: [] |
|
|
|
} |
|
|
|
|
|
|
|
this.authService.updateUser(tempUserInfo).then((data) => { |
|
|
|
console.log(data); |
|
|
|
this.toastService.presentToast("Updated!", "success"); |
|
|
|
}, (err) => { |
|
|
|
console.log(err); |
|
|
|
this.toastService.presentToast("Failed to update", "danger"); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
ionViewDidEnter() { |
|
|
|
|