From 57b9371d2a478e733287772cd89ac0a9eb2cbc1f Mon Sep 17 00:00:00 2001 From: Phet Date: Tue, 13 Aug 2024 17:14:28 +0700 Subject: [PATCH] [feat] - add delete kyc --- .../kyc/container/kyc/kyc.container.html | 4 +- .../manage/kyc/container/kyc/kyc.container.ts | 92 +++++---- .../kyc/presenter/list/list.component.html | 184 +++++++++--------- .../kyc/presenter/list/list.component.ts | 80 ++++---- 4 files changed, 196 insertions(+), 164 deletions(-) diff --git a/src/app/pages/manage/kyc/container/kyc/kyc.container.html b/src/app/pages/manage/kyc/container/kyc/kyc.container.html index a99c818..ffa13e7 100644 --- a/src/app/pages/manage/kyc/container/kyc/kyc.container.html +++ b/src/app/pages/manage/kyc/container/kyc/kyc.container.html @@ -1,4 +1,2 @@ - + \ No newline at end of file diff --git a/src/app/pages/manage/kyc/container/kyc/kyc.container.ts b/src/app/pages/manage/kyc/container/kyc/kyc.container.ts index 1bdd246..8d477c2 100644 --- a/src/app/pages/manage/kyc/container/kyc/kyc.container.ts +++ b/src/app/pages/manage/kyc/container/kyc/kyc.container.ts @@ -1,5 +1,5 @@ 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 { EAction, EText } from 'src/app/@config/app'; import { KycService } from 'src/app/core/service/common/kyc.service'; @@ -7,40 +7,66 @@ import { DialogComponent } from '../../presenter/dialog/dialog.component'; import { MatDialog } from '@angular/material/dialog'; import { AppService } from 'src/app/app.service'; + + @Component({ - selector: 'app-kyc', - templateUrl: './kyc.container.html', - styleUrls: ['./kyc.container.scss'] + selector: 'app-kyc', + templateUrl: './kyc.container.html', + styleUrls: ['./kyc.container.scss'] }) export class KycContainer { - dialogConfig: IDialogConfig = CDialogConfig - kyc$ = new Observable(); - constructor( - private kycService: KycService, - private dialog: MatDialog, - private appService: AppService, - private cdr: ChangeDetectorRef - ) { - this.kyc$ = this.kycService.getAll(); - } + dialogConfig: IDialogConfig = CDialogConfig + kyc$ = new Observable(); + constructor( + private kycService: KycService, + private dialog: MatDialog, + private appService: AppService, + private cdr: ChangeDetectorRef + ) { + this.kyc$ = this.kycService.getAll(); + } - edit(uid){ - this.dialogConfig.data.action = EAction.UPDATE; - this.dialogConfig.data.ids = uid - const dialogRef = this.dialog.open(DialogComponent,this.dialogConfig); - const edit$ = dialogRef.afterClosed().pipe( - switchMap((res) => { - if(res === 'success'){ - return this.kyc$ = this.kycService.getAll().pipe( - catchError((err) => { - this.appService.message(EAction.ERROR, EText.ERROR); - return throwError(() => err) - }), - tap(() => this.cdr.detectChanges()) - ) - } - }) - ); - return edit$.subscribe(); - } + edit(uid) { + this.dialogConfig.data.action = EAction.UPDATE; + this.dialogConfig.data.ids = uid + const dialogRef = this.dialog.open(DialogComponent, this.dialogConfig); + const edit$ = dialogRef.afterClosed().pipe( + switchMap((res) => { + if (res === 'success') { + return this.kyc$ = this.kycService.getAll().pipe( + catchError((err) => { + this.appService.message(EAction.ERROR, EText.ERROR); + return throwError(() => err) + }), + tap(() => this.cdr.detectChanges()) + ) + } + }) + ); + 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() + } } diff --git a/src/app/pages/manage/kyc/presenter/list/list.component.html b/src/app/pages/manage/kyc/presenter/list/list.component.html index 8e586ad..e8de85e 100644 --- a/src/app/pages/manage/kyc/presenter/list/list.component.html +++ b/src/app/pages/manage/kyc/presenter/list/list.component.html @@ -1,105 +1,107 @@
-
-
-
- - - - -
-
- - - - -
-
+
+
+
+ + + + +
+
+ + + + +
+
-
-
- - - +
+
+
+ + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - -
ลำดับ{{getIndex(i)}}ลำดับ{{getIndex(i)}}เลขบัตรประชาชน - {{item.id_card}} - เลขบัตรประชาชน + {{item.id_card}} + เลขหลังบัตร{{item.code_back_card}}เลขหลังบัตร{{item.code_back_card}}วันหมดอายุ{{item.exp_date | thaidate}}วันหมดอายุ{{item.exp_date | thaidate}}คำนำหน้า{{item.prefix_name}}คำนำหน้า{{item.prefix_name}}ชื่อ - นามสกุล - {{item.first_name}} - ชื่อ - นามสกุล + {{item.first_name}} + นามสกุล{{item.last_name}}นามสกุล{{item.last_name}}วัน เดือน ปีเกิด -
{{item.birth_date | thaidate}}
-
เบอร์โทรศัพท์ -
{{item.phone}}
-
E-mail -
{{item.email}}
-
More Detail -
-
- -
-
-
สถานะ -
Approve
-
Reject
-
-
- - + + วัน เดือน ปีเกิด + +
{{item.birth_date | thaidate}}
+ +
+ + เบอร์โทรศัพท์ + +
{{item.phone}}
+ +
+ + E-mail + +
{{item.email}}
+ +
+ + More Detail + +
+
+ + +
+
+ +
+ + สถานะ + +
Approve
+
Reject
+ +
+
+ + +
\ No newline at end of file diff --git a/src/app/pages/manage/kyc/presenter/list/list.component.ts b/src/app/pages/manage/kyc/presenter/list/list.component.ts index d5846f2..cf97d96 100644 --- a/src/app/pages/manage/kyc/presenter/list/list.component.ts +++ b/src/app/pages/manage/kyc/presenter/list/list.component.ts @@ -3,49 +3,55 @@ import { Subject, debounceTime, distinctUntilChanged } from 'rxjs'; import { BaseList } from 'src/app/core/base/base-list'; @Component({ - selector: 'app-list', - templateUrl: './list.component.html', - styleUrls: ['./list.component.scss'] + selector: 'app-list', + templateUrl: './list.component.html', + styleUrls: ['./list.component.scss'] }) export class ListComponent extends BaseList implements OnChanges { - @Input() kycList: any = []; - @Output() edit = new EventEmitter(); - @Output() search = new EventEmitter(); - query = { - name: null, - card: null - } - name: string; - filterCard: Subject = new Subject(); - constructor() { - super() - this.filterCard.pipe( - debounceTime(500), - distinctUntilChanged() - ).subscribe(() => this.onSearch()) - } + @Input() kycList: any = []; + @Output() edit = new EventEmitter(); + @Output() search = new EventEmitter(); + @Output() OnDelete = new EventEmitter() + query = { + name: null, + card: null + } + name: string; + filterCard: Subject = new Subject(); + constructor() { + super() + this.filterCard.pipe( + debounceTime(500), + distinctUntilChanged() + ).subscribe(() => this.onSearch()) + } - ngOnChanges(): void { - this.kycList = this.updateMatTable(this.kycList? this.kycList:[]) - } + ngOnChanges(): void { + this.kycList = this.updateMatTable(this.kycList ? this.kycList : []) + } - onEdit(uid){ - this.edit.emit(uid) - } + onEdit(uid) { + this.edit.emit(uid) + } - onFilterCard($event) { - const filterValue = this.query.card; - this.kycList.filter = filterValue.trim().toLowerCase(); - } + onDeleteKyc(uid: string) { + // console.log(uid) + this.OnDelete.emit(uid) + } - onFilterName($event){ - const filterValue = this.query.name; - this.kycList.filter = filterValue.trim().toLowerCase(); - } + onFilterCard($event) { + const filterValue = this.query.card; + this.kycList.filter = filterValue.trim().toLowerCase(); + } - onSearch(){ - const filterValue = this.query.card; - this.kycList.filter = filterValue.trim().toLowerCase(); - } + onFilterName($event) { + const filterValue = this.query.name; + this.kycList.filter = filterValue.trim().toLowerCase(); + } + + onSearch() { + const filterValue = this.query.card; + this.kycList.filter = filterValue.trim().toLowerCase(); + } }