[feat] - add delete kyc
This commit is contained in:
@@ -1,4 +1,2 @@
|
|||||||
<app-list
|
<app-list (edit)="edit($event)" (OnDelete)="onDelete($event)" [kycList]="kyc$ | async">
|
||||||
(edit)="edit($event)"
|
|
||||||
[kycList]="kyc$ | async">
|
|
||||||
</app-list>
|
</app-list>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ChangeDetectorRef, Component } from '@angular/core';
|
import { ChangeDetectorRef, Component } from '@angular/core';
|
||||||
import { Observable, catchError, switchMap, tap, throwError } from 'rxjs';
|
import { Observable, catchError, concatMap, filter, switchMap, tap, throwError } from 'rxjs';
|
||||||
import { IDialogConfig, CDialogConfig } from 'src/app/@common/interface/Dialog';
|
import { IDialogConfig, CDialogConfig } from 'src/app/@common/interface/Dialog';
|
||||||
import { EAction, EText } from 'src/app/@config/app';
|
import { EAction, EText } from 'src/app/@config/app';
|
||||||
import { KycService } from 'src/app/core/service/common/kyc.service';
|
import { KycService } from 'src/app/core/service/common/kyc.service';
|
||||||
@@ -7,6 +7,8 @@ import { DialogComponent } from '../../presenter/dialog/dialog.component';
|
|||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { AppService } from 'src/app/app.service';
|
import { AppService } from 'src/app/app.service';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-kyc',
|
selector: 'app-kyc',
|
||||||
templateUrl: './kyc.container.html',
|
templateUrl: './kyc.container.html',
|
||||||
@@ -43,4 +45,28 @@ export class KycContainer {
|
|||||||
);
|
);
|
||||||
return edit$.subscribe();
|
return edit$.subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
onDelete(uid) {
|
||||||
|
// console.log(uid)
|
||||||
|
this.appService.confirm(
|
||||||
|
EAction.DELETE
|
||||||
|
).pipe(
|
||||||
|
filter(event => event.isConfirmed),
|
||||||
|
switchMap(event => {
|
||||||
|
return this.kycService.deleteData(uid).pipe(
|
||||||
|
concatMap(() => {
|
||||||
|
return this.kyc$ = this.kycService.getAll().pipe(
|
||||||
|
catchError((err) => {
|
||||||
|
this.appService.message(EAction.ERROR, EText.ERROR);
|
||||||
|
return throwError(() => err)
|
||||||
|
}),
|
||||||
|
tap(() => this.cdr.detectChanges())
|
||||||
|
)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
|
).subscribe()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
<div class="col-span-3 md:col-span-5 md:order-2">
|
<div class="col-span-3 md:col-span-5 md:order-2">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<i matTextPrefix class="bi bi-search"></i>
|
<i matTextPrefix class="bi bi-search"></i>
|
||||||
<input matInput placeholder="เลขบัตรประชาชน/เลขหลังบัตร" [(ngModel)]="query.card" (ngModelChange)="onFilterCard($event)">
|
<input matInput placeholder="เลขบัตรประชาชน/เลขหลังบัตร" [(ngModel)]="query.card"
|
||||||
|
(ngModelChange)="onFilterCard($event)">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-span-5 md:col-span-7 md:order-2">
|
<div class="col-span-5 md:col-span-7 md:order-2">
|
||||||
@@ -86,6 +87,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.kyc_uid)"></i>
|
<i class="bi bi-pencil-square icon-edit mr-2" (click)="onEdit(item.kyc_uid)"></i>
|
||||||
|
<i class="bi bi-trash3 icon-delete mr-2" (click)="onDeleteKyc(item.kyc_uid)"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export class ListComponent extends BaseList implements OnChanges {
|
|||||||
@Input() kycList: any = [];
|
@Input() kycList: any = [];
|
||||||
@Output() edit = new EventEmitter();
|
@Output() edit = new EventEmitter();
|
||||||
@Output() search = new EventEmitter();
|
@Output() search = new EventEmitter();
|
||||||
|
@Output() OnDelete = new EventEmitter<string>()
|
||||||
query = {
|
query = {
|
||||||
name: null,
|
name: null,
|
||||||
card: null
|
card: null
|
||||||
@@ -33,6 +34,11 @@ export class ListComponent extends BaseList implements OnChanges {
|
|||||||
this.edit.emit(uid)
|
this.edit.emit(uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDeleteKyc(uid: string) {
|
||||||
|
// console.log(uid)
|
||||||
|
this.OnDelete.emit(uid)
|
||||||
|
}
|
||||||
|
|
||||||
onFilterCard($event) {
|
onFilterCard($event) {
|
||||||
const filterValue = this.query.card;
|
const filterValue = this.query.card;
|
||||||
this.kycList.filter = filterValue.trim().toLowerCase();
|
this.kycList.filter = filterValue.trim().toLowerCase();
|
||||||
|
|||||||
Reference in New Issue
Block a user