diff --git a/src/app/profile/profile.page.html b/src/app/profile/profile.page.html
index 4fb7941..742e46e 100644
--- a/src/app/profile/profile.page.html
+++ b/src/app/profile/profile.page.html
@@ -5,14 +5,20 @@
diff --git a/src/app/profile/profile.page.scss b/src/app/profile/profile.page.scss
index 0a1f2b9..2e4bb39 100644
--- a/src/app/profile/profile.page.scss
+++ b/src/app/profile/profile.page.scss
@@ -56,6 +56,14 @@
.content {
width: calc(100% - 55px);
+
+ input {
+ background-color: transparent;
+ border: 1px solid white;
+ font-size: 14px;
+ padding: 10px;
+ border-radius: 5px;
+ }
}
}
diff --git a/src/app/profile/profile.page.ts b/src/app/profile/profile.page.ts
index 22dffb3..99ffe29 100644
--- a/src/app/profile/profile.page.ts
+++ b/src/app/profile/profile.page.ts
@@ -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() {
diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts
index 05787b6..fa9ba22 100644
--- a/src/app/services/auth.service.ts
+++ b/src/app/services/auth.service.ts
@@ -22,4 +22,16 @@ export class AuthService {
signupUser(credentials: any) {
return this.http.post(URL + '/api/auth/signup/', credentials).toPromise();
}
+
+ updateUser(userData: any) {
+ const httpOptions = {
+ headers: new HttpHeaders({
+ 'Access-Control-Allow-Origin': '*',
+ 'Content-Type': 'application/json',
+ 'Authorization': 'Bearer ' + localStorage.access_Token
+ })
+ };
+
+ return this.http.post(URL + '/api/maioraservice/user/v1/update', userData, httpOptions).toPromise();
+ }
}