[feat] - add delete user
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
<app-user-list [userList]="userList$ | async" (edit)="edit($event)">
|
||||
<app-user-list [userList]="userList$ | async" (edit)="edit($event)" (OnDeleteUser)="onDeleteUser($event)">
|
||||
|
||||
</app-user-list>
|
||||
@@ -19,10 +19,11 @@ export class UsersContainer {
|
||||
constructor(
|
||||
private sathonSV: SathonCathayPayService,
|
||||
private dialog: MatDialog,
|
||||
private appService: AppService,
|
||||
private appSV: AppService,
|
||||
private cdr: ChangeDetectorRef
|
||||
) {
|
||||
this.userList$ = this.sathonSV.getAllUsers()
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -38,4 +39,19 @@ export class UsersContainer {
|
||||
})
|
||||
).subscribe()
|
||||
}
|
||||
|
||||
onDeleteUser(user) {
|
||||
this.appSV.confirm(EAction.DELETE).pipe(
|
||||
filter(r => r.isConfirmed),
|
||||
switchMap(() => this.sathonSV.deleteUser(user.id)),
|
||||
tap(() => {
|
||||
this.userList$ = this.sathonSV.getAllUsers()
|
||||
this.cdr.detectChanges()
|
||||
}),
|
||||
catchError(err => {
|
||||
this.appSV.message('error', 'เกิดข้อผิดพลาด')
|
||||
return throwError(err)
|
||||
})
|
||||
).subscribe()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
<div class="action flex justify-center">
|
||||
<div class="item cursor-pointer">
|
||||
<i class="bi bi-pencil-square icon-edit mr-2" (click)="onEdit(item)"></i>
|
||||
<i class="bi bi-trash3 icon-delete mr-2" (click)="onDeleteUser(item)"></i>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -11,7 +11,7 @@ export class UserListComponent extends BaseList implements OnChanges {
|
||||
@Input() userList: any = [];
|
||||
@Output() edit = new EventEmitter();
|
||||
@Output() search = new EventEmitter();
|
||||
@Output() OnDelete = new EventEmitter<string>()
|
||||
@Output() OnDeleteUser = new EventEmitter<string>()
|
||||
query = {
|
||||
name: null,
|
||||
card: null
|
||||
@@ -34,9 +34,8 @@ export class UserListComponent extends BaseList implements OnChanges {
|
||||
this.edit.emit(user)
|
||||
}
|
||||
|
||||
onDeleteKyc(uid: string) {
|
||||
// console.log(uid)
|
||||
this.OnDelete.emit(uid)
|
||||
onDeleteUser(uid: string) {
|
||||
this.OnDeleteUser.emit(uid)
|
||||
}
|
||||
|
||||
onFilterCard($event) {
|
||||
|
||||
Reference in New Issue
Block a user