Commit a36af12088b923bf3fe10ab499a88897f5885285
1 parent
ba057a4f1e
Exists in
develop
saco timeout y espera a respuesta del servicio
Showing
1 changed file
with
5 additions
and
5 deletions
Show diff stats
src/app/modules/pago-tarjeta/pago-tarjeta.component.ts
| 1 | 1 | import { Component, OnInit, TemplateRef, OnDestroy, ViewChild } from '@angular/core'; |
| 2 | 2 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
| 3 | 3 | import { Router } from '@angular/router'; |
| 4 | -import { BsModalService } from 'ngx-bootstrap/modal'; | |
| 4 | +import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; | |
| 5 | 5 | import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component'; |
| 6 | 6 | |
| 7 | 7 | @Component({ |
| ... | ... | @@ -12,6 +12,7 @@ import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-f |
| 12 | 12 | export class PagoTarjetaComponent implements OnInit, OnDestroy { |
| 13 | 13 | timer: any; |
| 14 | 14 | @ViewChild('template', {static: true}) public template: TemplateRef<any>; |
| 15 | + modalRef: BsModalRef; | |
| 15 | 16 | |
| 16 | 17 | constructor( |
| 17 | 18 | private articuloService: ArticuloService, |
| ... | ... | @@ -30,9 +31,11 @@ export class PagoTarjetaComponent implements OnInit, OnDestroy { |
| 30 | 31 | }; |
| 31 | 32 | this.articuloService.pay(dataPago) |
| 32 | 33 | .subscribe((res: any) => { |
| 34 | + this.modalRef.hide(); | |
| 33 | 35 | this.articuloService.idComanda = res.data; |
| 34 | 36 | this.router.navigate(['mensaje-final']); |
| 35 | 37 | }, (err) => { |
| 38 | + this.modalRef.hide(); | |
| 36 | 39 | this.modalService.show(ErrorFormaPagoComponent, { |
| 37 | 40 | class: 'modal-lg modal-dialog-centered', |
| 38 | 41 | ignoreBackdropClick: true, |
| ... | ... | @@ -55,9 +58,6 @@ export class PagoTarjetaComponent implements OnInit, OnDestroy { |
| 55 | 58 | } |
| 56 | 59 | |
| 57 | 60 | openModalEspera(templateRef: TemplateRef<any>) { |
| 58 | - const modalRef = this.modalService.show(templateRef, { class: 'modal-lg modal-dialog-centered' }); | |
| 59 | - this.timer = setTimeout(() => { | |
| 60 | - modalRef.hide(); | |
| 61 | - }, 5000); | |
| 61 | + this.modalRef = this.modalService.show(templateRef, { class: 'modal-lg modal-dialog-centered' }); | |
| 62 | 62 | } |
| 63 | 63 | } |