From b301f6e5f59b0dffac52ec6d94fbc6bb02d24d0f Mon Sep 17 00:00:00 2001 From: Art Date: Fri, 8 Oct 2021 16:45:44 +0300 Subject: [PATCH] 31.8. Delete User in User Table Component (#31) --- .../users/users-table/users-table.component.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/support-portal-frontend/src/app/component/management/users/users-table/users-table.component.ts b/support-portal-frontend/src/app/component/management/users/users-table/users-table.component.ts index b00ffc3..5d9e56b 100644 --- a/support-portal-frontend/src/app/component/management/users/users-table/users-table.component.ts +++ b/support-portal-frontend/src/app/component/management/users/users-table/users-table.component.ts @@ -7,6 +7,7 @@ import {UserService} from "../../../../service/user.service"; import {NotificationService} from "../../../../service/notification.service"; import {AuthenticationService} from "../../../../service/authentication.service"; import {Router} from "@angular/router"; +import {CustomHttpResponse} from "../../../../dto/custom-http-response"; @Component({ selector: 'app-users-table', @@ -69,7 +70,15 @@ export class UsersTableComponent implements OnInit, OnDestroy { } onDeleteUser(user: User) { - console.log(`User ${user.username} is clicked to be deleted`); + this.subs.sink = this.userService.deleteUser(user.userId) + .subscribe( + (response: CustomHttpResponse) => { + this.getUsers(false); + this.notificationService.notify(NotificationType.SUCCESS, response.message); + }, + (errorResponse: HttpErrorResponse) => { + this.notificationService.notify(NotificationType.ERROR, errorResponse.error.message); + } + ); } - }