71 lines
2.4 KiB
TypeScript
71 lines
2.4 KiB
TypeScript
import { ChangeDetectorRef, Component, Inject, OnInit } from '@angular/core';
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
import { Router, ActivatedRoute } from '@angular/router';
|
|
import { tap, catchError, throwError, lastValueFrom, filter, switchMap } from 'rxjs';
|
|
import { IDialogConfigData } from 'src/app/@common/interface/Dialog';
|
|
import { EAction, EText } from 'src/app/@config/app';
|
|
import { AppService } from 'src/app/app.service';
|
|
import { BaseForm } from 'src/app/core/base/base-form';
|
|
import { PromotionService } from 'src/app/core/service/common/promotion.service';
|
|
import { UploadService } from 'src/app/core/service/common/upload.service';
|
|
import { DialogComponent } from '../../../kyc/presenter/dialog/dialog.component';
|
|
import { Location } from '@angular/common';
|
|
import { SathonCathayPayService } from 'src/app/sathon-cathay-pay.service';
|
|
|
|
@Component({
|
|
selector: 'app-modal',
|
|
templateUrl: './modal.component.html',
|
|
styleUrls: ['./modal.component.scss']
|
|
})
|
|
export class ModalComponent implements OnInit {
|
|
IsRefresh: boolean = false
|
|
constructor(
|
|
public dialogRef: MatDialogRef<DialogComponent>,
|
|
@Inject(MAT_DIALOG_DATA) public dialog: any,
|
|
private sathonSV: SathonCathayPayService,
|
|
private appsv: AppService
|
|
) { }
|
|
|
|
ngOnInit(): void {
|
|
}
|
|
|
|
changeUserLock({ checked },) {
|
|
let userId = this.dialog.id
|
|
console.log(checked)
|
|
const msg = checked ? 'Unlock' : 'Lock'
|
|
this.sathonSV.lockUnlockUser(userId).pipe(
|
|
tap(event => {
|
|
this.appsv.message(EAction.SUCCESS, `${msg} สำเร็จแล้ว`)
|
|
this.IsRefresh = true
|
|
}),
|
|
tap(() => this.closeDialog()),
|
|
catchError(err => {
|
|
this.IsRefresh = false
|
|
return throwError(err)
|
|
})
|
|
).subscribe()
|
|
}
|
|
|
|
save() {
|
|
let userId = this.dialog.id
|
|
this.appsv.confirm(EAction.UPDATE).pipe(
|
|
filter(r => r.isConfirmed),
|
|
switchMap(() => this.sathonSV.convertToCoperate(userId)),
|
|
tap(() => this.IsRefresh = true),
|
|
tap(() => this.closeDialog()),
|
|
catchError(err => {
|
|
this.IsRefresh = false
|
|
this.appsv.message('error', 'เกิดข้อผิดพลาด')
|
|
return throwError(err)
|
|
})
|
|
).subscribe()
|
|
// this.sathonSV.convertToCoperate(userId).subscribe()
|
|
}
|
|
|
|
closeDialog() {
|
|
this.dialogRef.close(this.IsRefresh)
|
|
}
|
|
|
|
}
|