31.8. Delete User in User Table Component (#31)

This commit is contained in:
Art
2021-10-08 16:45:44 +03:00
parent 494aa8c53b
commit b301f6e5f5

View File

@ -7,6 +7,7 @@ import {UserService} from "../../../../service/user.service";
import {NotificationService} from "../../../../service/notification.service"; import {NotificationService} from "../../../../service/notification.service";
import {AuthenticationService} from "../../../../service/authentication.service"; import {AuthenticationService} from "../../../../service/authentication.service";
import {Router} from "@angular/router"; import {Router} from "@angular/router";
import {CustomHttpResponse} from "../../../../dto/custom-http-response";
@Component({ @Component({
selector: 'app-users-table', selector: 'app-users-table',
@ -69,7 +70,15 @@ export class UsersTableComponent implements OnInit, OnDestroy {
} }
onDeleteUser(user: User) { 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);
}
);
} }
} }