diff --git a/src/app/modules/pago-electronico/pago-electronico.component.ts b/src/app/modules/pago-electronico/pago-electronico.component.ts index 7ea7134..69994aa 100644 --- a/src/app/modules/pago-electronico/pago-electronico.component.ts +++ b/src/app/modules/pago-electronico/pago-electronico.component.ts @@ -1,19 +1,22 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, OnDestroy } from '@angular/core'; import { ArticuloService } from 'src/app/services/articulo/articulo.service'; import { Router } from '@angular/router'; import { APP_SETTINGS } from 'src/etc/AppSettings'; +import { BsModalService } from 'ngx-bootstrap/modal'; +import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component'; @Component({ selector: 'app-pago-electronico', templateUrl: './pago-electronico.component.html', styleUrls: ['./pago-electronico.component.scss'] }) -export class PagoElectronicoComponent implements OnInit { +export class PagoElectronicoComponent implements OnInit, OnDestroy { urlQr = `${APP_SETTINGS.apiImagenes}/qr/${APP_SETTINGS.deploy}/${APP_SETTINGS.codigoP}/tienda/${APP_SETTINGS.terminal}`; constructor( private articuloService: ArticuloService, private router: Router, + private modalService: BsModalService, ) { } ngOnInit() { @@ -29,9 +32,21 @@ export class PagoElectronicoComponent implements OnInit { .subscribe((res: any) => { this.articuloService.idComanda = res.data; this.router.navigate(['mensaje-final']); - }, err => console.error(err)); + }, (err) => { + this.modalService.show(ErrorFormaPagoComponent, { + class: 'modal-lg modal-dialog-centered', + ignoreBackdropClick: true, + }); + }); this.mediaPantalla(); } + + ngOnDestroy() { + for (let i = 1; i <= this.modalService.getModalsCount(); i++) { + this.modalService.hide(i); + } + } + mediaPantalla() { if ($('body').hasClass('media-pantalla')) { $('.qr-mt').addClass('media-pantalla'); diff --git a/src/app/modules/pago-electronico/pago-electronico.module.ts b/src/app/modules/pago-electronico/pago-electronico.module.ts index 9656140..32215a8 100644 --- a/src/app/modules/pago-electronico/pago-electronico.module.ts +++ b/src/app/modules/pago-electronico/pago-electronico.module.ts @@ -3,13 +3,16 @@ import { CommonModule } from '@angular/common'; import { PagoElectronicoRoutingModule } from './pago-electronico-routing.module'; import { PagoElectronicoComponent } from './pago-electronico.component'; +import { PagoTarjetaModule } from '../pago-tarjeta/pago-tarjeta.module'; @NgModule({ declarations: [PagoElectronicoComponent], imports: [ CommonModule, - PagoElectronicoRoutingModule - ] + PagoElectronicoRoutingModule, + PagoTarjetaModule, + ], + entryComponents: [] }) export class PagoElectronicoModule { } diff --git a/src/app/modules/pago-tarjeta/pago-tarjeta.component.ts b/src/app/modules/pago-tarjeta/pago-tarjeta.component.ts index 7ff5207..681db50 100644 --- a/src/app/modules/pago-tarjeta/pago-tarjeta.component.ts +++ b/src/app/modules/pago-tarjeta/pago-tarjeta.component.ts @@ -1,17 +1,20 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, OnDestroy } from '@angular/core'; import { ArticuloService } from 'src/app/services/articulo/articulo.service'; import { Router } from '@angular/router'; +import { BsModalService } from 'ngx-bootstrap/modal'; +import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component'; @Component({ selector: 'app-pago-tarjeta', templateUrl: './pago-tarjeta.component.html', styleUrls: ['./pago-tarjeta.component.scss'] }) -export class PagoTarjetaComponent implements OnInit { +export class PagoTarjetaComponent implements OnInit, OnDestroy { constructor( private articuloService: ArticuloService, private router: Router, + private modalService: BsModalService, ) { } ngOnInit() { @@ -26,10 +29,21 @@ export class PagoTarjetaComponent implements OnInit { .subscribe((res: any) => { this.articuloService.idComanda = res.data; this.router.navigate(['mensaje-final']); - }, err => console.error(err)); + }, (err) => { + this.modalService.show(ErrorFormaPagoComponent, { + class: 'modal-lg modal-dialog-centered', + ignoreBackdropClick: true, + }); + }); this.mediaPantalla(); } + ngOnDestroy() { + for (let i = 1; i <= this.modalService.getModalsCount(); i++) { + this.modalService.hide(i); + } + } + mediaPantalla() { if ($('body').hasClass('media-pantalla')) { $('.pago-tarjeta').addClass('media-pantalla'); diff --git a/src/app/modules/pago-tarjeta/pago-tarjeta.module.ts b/src/app/modules/pago-tarjeta/pago-tarjeta.module.ts index baa9302..8cd0580 100644 --- a/src/app/modules/pago-tarjeta/pago-tarjeta.module.ts +++ b/src/app/modules/pago-tarjeta/pago-tarjeta.module.ts @@ -3,13 +3,20 @@ import { CommonModule } from '@angular/common'; import { PagoTarjetaRoutingModule } from './pago-tarjeta-routing.module'; import { PagoTarjetaComponent } from './pago-tarjeta.component'; +import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component'; +import { ModalModule } from 'ngx-bootstrap/modal'; @NgModule({ - declarations: [PagoTarjetaComponent], + declarations: [ + PagoTarjetaComponent, + ErrorFormaPagoComponent, + ], imports: [ CommonModule, - PagoTarjetaRoutingModule - ] + PagoTarjetaRoutingModule, + ModalModule.forRoot(), + ], + entryComponents: [ErrorFormaPagoComponent] }) export class PagoTarjetaModule { } diff --git a/src/app/services/articulo/articulo.service.ts b/src/app/services/articulo/articulo.service.ts index 8892332..7c61b79 100644 --- a/src/app/services/articulo/articulo.service.ts +++ b/src/app/services/articulo/articulo.service.ts @@ -91,6 +91,9 @@ export class ArticuloService { .subscribe((data) => { observer.next(data); observer.complete(); + }, err => { + observer.error(err); + observer.complete(); }); }); }); diff --git a/src/app/shared/error-forma-pago/error-forma-pago.component.html b/src/app/shared/error-forma-pago/error-forma-pago.component.html new file mode 100644 index 0000000..aa1c44e --- /dev/null +++ b/src/app/shared/error-forma-pago/error-forma-pago.component.html @@ -0,0 +1,22 @@ +
Algo salió mal, intentalo de nuevo o probá con otra forma de pago
+