[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>
|
</app-user-list>
|
||||||
@@ -19,10 +19,11 @@ export class UsersContainer {
|
|||||||
constructor(
|
constructor(
|
||||||
private sathonSV: SathonCathayPayService,
|
private sathonSV: SathonCathayPayService,
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
private appService: AppService,
|
private appSV: AppService,
|
||||||
private cdr: ChangeDetectorRef
|
private cdr: ChangeDetectorRef
|
||||||
) {
|
) {
|
||||||
this.userList$ = this.sathonSV.getAllUsers()
|
this.userList$ = this.sathonSV.getAllUsers()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -38,4 +39,19 @@ export class UsersContainer {
|
|||||||
})
|
})
|
||||||
).subscribe()
|
).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="action flex justify-center">
|
||||||
<div class="item cursor-pointer">
|
<div class="item cursor-pointer">
|
||||||
<i class="bi bi-pencil-square icon-edit mr-2" (click)="onEdit(item)"></i>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export class UserListComponent extends BaseList implements OnChanges {
|
|||||||
@Input() userList: any = [];
|
@Input() userList: any = [];
|
||||||
@Output() edit = new EventEmitter();
|
@Output() edit = new EventEmitter();
|
||||||
@Output() search = new EventEmitter();
|
@Output() search = new EventEmitter();
|
||||||
@Output() OnDelete = new EventEmitter<string>()
|
@Output() OnDeleteUser = new EventEmitter<string>()
|
||||||
query = {
|
query = {
|
||||||
name: null,
|
name: null,
|
||||||
card: null
|
card: null
|
||||||
@@ -34,9 +34,8 @@ export class UserListComponent extends BaseList implements OnChanges {
|
|||||||
this.edit.emit(user)
|
this.edit.emit(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
onDeleteKyc(uid: string) {
|
onDeleteUser(uid: string) {
|
||||||
// console.log(uid)
|
this.OnDeleteUser.emit(uid)
|
||||||
this.OnDelete.emit(uid)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onFilterCard($event) {
|
onFilterCard($event) {
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ export class SathonCathayPayService {
|
|||||||
return this.http.get<[]>(`${this.endpoint}/v1/user`).pipe(map((d: any) => d.data))
|
return this.http.get<[]>(`${this.endpoint}/v1/user`).pipe(map((d: any) => d.data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteUser(userId) {
|
||||||
|
return this.http.delete<[]>(`${this.endpoint}/v1/user/${userId}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
lockUnlockUser(id: string): Observable<any> {
|
lockUnlockUser(id: string): Observable<any> {
|
||||||
|
|||||||
Reference in New Issue
Block a user