Commit 554a319682906d00b271f89e85dec8c30a1de148
Exists in
develop
Merge branch 'develop' of git.focasoftware.com:angular/autoservicio-axion into develop
Showing
1 changed file
 
Show diff stats
src/app/modules/pago-tarjeta/pago-tarjeta.component.ts
| 1 | import { Component, OnInit, TemplateRef, OnDestroy, ViewChild } from '@angular/core'; | 1 | import { Component, OnInit, TemplateRef, OnDestroy, ViewChild } from '@angular/core'; | 
| 2 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | 2 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | 
| 3 | import { Router } from '@angular/router'; | 3 | import { Router } from '@angular/router'; | 
| 4 | import { BsModalService } from 'ngx-bootstrap/modal'; | 4 | import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; | 
| 5 | import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component'; | 5 | import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component'; | 
| 6 | import { Subscription } from 'rxjs'; | 6 | import { Subscription } from 'rxjs'; | 
| 7 | 7 | ||
| 8 | @Component({ | 8 | @Component({ | 
| 9 | selector: 'app-pago-tarjeta', | 9 | selector: 'app-pago-tarjeta', | 
| 10 | templateUrl: './pago-tarjeta.component.html', | 10 | templateUrl: './pago-tarjeta.component.html', | 
| 11 | styleUrls: ['./pago-tarjeta.component.scss'] | 11 | styleUrls: ['./pago-tarjeta.component.scss'] | 
| 12 | }) | 12 | }) | 
| 13 | export class PagoTarjetaComponent implements OnInit, OnDestroy { | 13 | export class PagoTarjetaComponent implements OnInit, OnDestroy { | 
| 14 | timer: any; | 14 | timer: any; | 
| 15 | <<<<<<< HEAD | ||
| 15 | subscription: Subscription; | 16 | subscription: Subscription; | 
| 16 | @ViewChild('template', { static: true }) public template: TemplateRef<any>; | 17 | @ViewChild('template', { static: true }) public template: TemplateRef<any>; | 
| 17 | 18 | ======= | |
| 18 | constructor( | 19 | @ViewChild('template', {static: true}) public template: TemplateRef<any>; | 
| 19 | private articuloService: ArticuloService, | 20 | modalRef: BsModalRef; | 
| 20 | private router: Router, | 21 | >>>>>>> 94610cc5cc92408a3384da70848a2722dc5b6bc5 | 
| 21 | private modalService: BsModalService, | 22 | |
| 22 | ) { } | 23 | constructor( | 
| 23 | 24 | private articuloService: ArticuloService, | |
| 24 | ngOnInit() { | 25 | private router: Router, | 
| 25 | if (!this.articuloService.carrito.length) { | 26 | private modalService: BsModalService, | 
| 26 | this.router.navigate(['']); | 27 | ) { } | 
| 27 | return; | 28 | |
| 28 | } | 29 | ngOnInit() { | 
| 29 | this.openModalEspera(this.template); | 30 | if (!this.articuloService.carrito.length) { | 
| 30 | const dataPago = { | 31 | this.router.navigate(['']); | 
| 31 | pedidoAnombreDe: '' | 32 | return; | 
| 32 | }; | 33 | } | 
| 34 | this.openModalEspera(this.template); | ||
| 33 | this.subscription = this.articuloService.pay(dataPago) | 35 | const dataPago = { | 
| 34 | .subscribe((res: any) => { | 36 | pedidoAnombreDe: '' | 
| 35 | this.articuloService.idComanda = res.data; | 37 | }; | 
| 38 | this.subscription = this.articuloService.pay(dataPago) | ||
| 36 | this.router.navigate(['mensaje-final']); | 39 | .subscribe((res: any) => { | 
| 37 | }, (err) => { | 40 | this.modalRef.hide(); | 
| 38 | this.modalService.show(ErrorFormaPagoComponent, { | 41 | this.articuloService.idComanda = res.data; | 
| 39 | class: 'modal-lg modal-dialog-centered', | 42 | this.router.navigate(['mensaje-final']); | 
| 40 | ignoreBackdropClick: true, | 43 | }, (err) => { | 
| 41 | }); | 44 | this.modalRef.hide(); | 
| 42 | }); | 45 | this.modalService.show(ErrorFormaPagoComponent, { | 
| 43 | this.mediaPantalla(); | 46 | class: 'modal-lg modal-dialog-centered', | 
| 44 | } | 47 | ignoreBackdropClick: true, | 
| 45 | 48 | }); | |
| 46 | ngOnDestroy() { | 49 | }); | 
| 47 | if (this.subscription) this.subscription.unsubscribe(); | 50 | this.mediaPantalla(); | 
| 48 | if (this.timer) clearTimeout(this.timer); | 51 | } | 
| 49 | for (let i = 1; i <= this.modalService.getModalsCount(); i++) { | 52 | |
| 50 | this.modalService.hide(i); | 53 | ngOnDestroy() { | 
| 51 | } | 54 | if (this.subscription) this.subscription.unsubscribe(); | 
| 52 | } | 55 | if (this.timer) clearTimeout(this.timer); | 
| 53 | 56 | for (let i = 1; i <= this.modalService.getModalsCount(); i++) { | |
| 54 | mediaPantalla() { | 57 | this.modalService.hide(i); | 
| 55 | if ($('body').hasClass('media-pantalla')) { | 58 | } | 
| 56 | $('.pago-tarjeta').addClass('media-pantalla'); | 59 | } | 
| 57 | } | 60 | |
| 58 | } | 61 | mediaPantalla() { | 
| 59 | |||
| 60 | openModalEspera(templateRef: TemplateRef<any>) { | ||
| 61 | const modalRef = this.modalService.show(templateRef, { class: 'modal-lg modal-dialog-centered' }); | ||
| 62 | this.timer = setTimeout(() => { | 62 | if ($('body').hasClass('media-pantalla')) { | 
| 63 | modalRef.hide(); | 63 | $('.pago-tarjeta').addClass('media-pantalla'); | 
| 64 | }, 5000); | 64 | } | 
| 65 | } | 65 | } | 
| 66 | } | 66 | |
| 67 | 67 | openModalEspera(templateRef: TemplateRef<any>) { | |
| 68 | this.modalRef = this.modalService.show(templateRef, { class: 'modal-lg modal-dialog-centered' }); |