From 72a32b5d31bd29d3fed12bc7a0b576b14b0119e4 Mon Sep 17 00:00:00 2001 From: Art Date: Wed, 22 Sep 2021 12:30:24 +0300 Subject: [PATCH] 179. Update user / test user update (#26) --- .../app/component/user/user.component.html | 5 ++--- .../src/app/component/user/user.component.ts | 21 +++++++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/support-portal-frontend/src/app/component/user/user.component.html b/support-portal-frontend/src/app/component/user/user.component.html index 8c23655..d6ec990 100644 --- a/support-portal-frontend/src/app/component/user/user.component.html +++ b/support-portal-frontend/src/app/component/user/user.component.html @@ -168,9 +168,8 @@
-
+
diff --git a/support-portal-frontend/src/app/component/user/user.component.ts b/support-portal-frontend/src/app/component/user/user.component.ts index 3413261..1c85a17 100644 --- a/support-portal-frontend/src/app/component/user/user.component.ts +++ b/support-portal-frontend/src/app/component/user/user.component.ts @@ -200,8 +200,25 @@ export class UserComponent implements OnInit, OnDestroy { this.subscriptions.push(subscription); } - onUpdateCurrentUser(profileUserForm: any) { - + onUpdateCurrentUser(user: User) { + this.currentUsername = this.authenticationService.getUserFromLocalStorage().username; + this.refreshing = true; + const formData = this.userService.createUserFormData(this.currentUsername, user, this.profileImage); + let subscription = this.userService.updateUser(formData) + .subscribe( + (user: User) => { + this.authenticationService.addUserToLocalStorage(user); + this.getUsers(false); + this.invalidateVariables(); + this.notificationService.notify(NotificationType.SUCCESS, `User ${user.username} updated successfully`); + this.refreshing = false; + }, + (errorResponse: HttpErrorResponse) => { + this.sendErrorNotification(errorResponse.error.message); + this.refreshing = false; + } + ); + this.subscriptions.push(subscription); } onLogOut() {