diff --git a/src/app/modules/pago-tarjeta/pago-tarjeta.component.ts b/src/app/modules/pago-tarjeta/pago-tarjeta.component.ts index c37a33f..93343ca 100644 --- a/src/app/modules/pago-tarjeta/pago-tarjeta.component.ts +++ b/src/app/modules/pago-tarjeta/pago-tarjeta.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, TemplateRef, OnDestroy, ViewChild } from '@angular/core'; import { ArticuloService } from 'src/app/services/articulo/articulo.service'; import { Router } from '@angular/router'; -import { BsModalService } from 'ngx-bootstrap/modal'; +import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component'; @Component({ @@ -12,6 +12,7 @@ import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-f export class PagoTarjetaComponent implements OnInit, OnDestroy { timer: any; @ViewChild('template', {static: true}) public template: TemplateRef; + modalRef: BsModalRef; constructor( private articuloService: ArticuloService, @@ -30,9 +31,11 @@ export class PagoTarjetaComponent implements OnInit, OnDestroy { }; this.articuloService.pay(dataPago) .subscribe((res: any) => { + this.modalRef.hide(); this.articuloService.idComanda = res.data; this.router.navigate(['mensaje-final']); }, (err) => { + this.modalRef.hide(); this.modalService.show(ErrorFormaPagoComponent, { class: 'modal-lg modal-dialog-centered', ignoreBackdropClick: true, @@ -55,9 +58,6 @@ export class PagoTarjetaComponent implements OnInit, OnDestroy { } openModalEspera(templateRef: TemplateRef) { - const modalRef = this.modalService.show(templateRef, { class: 'modal-lg modal-dialog-centered' }); - this.timer = setTimeout(() => { - modalRef.hide(); - }, 5000); + this.modalRef = this.modalService.show(templateRef, { class: 'modal-lg modal-dialog-centered' }); } }