import { Component, OnInit } from '@angular/core'; import { BsModalRef } from 'ngx-bootstrap/modal'; import { TypeOfModals } from '../../../../utils/enums'; @Component({ selector: 'esp-confirm-modal', templateUrl: './confirm.modal.html', styleUrls: ['./confirm.modal.scss'], }) export class ConfirmModalComponent implements OnInit { data: any; isConfirm = true; message: string; title: string; confirmMessage: string; inputData: any; reEnteredValue: number; inputError: boolean = false; constructor(public bsModalRef: BsModalRef) {} ngOnInit() { if (this.data) { this.message = this.data.message; this.isConfirm = this.data.disableContinue; this.title = this.data.title; this.data.type === TypeOfModals.UNSAVED ? (this.confirmMessage = this.data.i18n['continue-wo-saving']) : (this.confirmMessage = this.data.i18n['confirm-continue']); this.confirmMessage = this.data.confirmMessage ? this.data.confirmMessage : this.confirmMessage; setTimeout(() => { this.isConfirm = false; }, 5000); } } onConfirm(): void { if(this.data.inputData && this.data.gridCommand) { if((+this.data.gridCommand.newValue === this.reEnteredValue) || (+this.data.gridCommand.value === this.reEnteredValue)) { this.bsModalRef.content.onClose.next({ status: true, callbackParams: this.data.callbackParams }); this.bsModalRef.hide(); } else { this.inputError = true; } } else { this.bsModalRef.content.onClose.next({ status: true, callbackParams: this.data.callbackParams }); this.bsModalRef.hide(); } } onCancel(): void { this.bsModalRef.content.onClose.next({ status: false, data: null }); this.bsModalRef.hide(); } }