Commit 3283fb1b0faf59bdae744f9d110a7c43b6ba2244

Authored by Marcelo Puebla
Exists in develop

Merge branch 'develop' into 'develop'

Develop

See merge request !99
src/app/modules/pago-electronico/pago-electronico.component.ts
1   -import { Component, OnInit } from '@angular/core';
  1 +import { Component, OnInit, OnDestroy } from '@angular/core';
2 2 import { ArticuloService } from 'src/app/services/articulo/articulo.service';
3 3 import { Router } from '@angular/router';
4 4 import { APP_SETTINGS } from 'src/etc/AppSettings';
  5 +import { BsModalService } from 'ngx-bootstrap/modal';
  6 +import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component';
5 7  
6 8 @Component({
7 9 selector: 'app-pago-electronico',
8 10 templateUrl: './pago-electronico.component.html',
9 11 styleUrls: ['./pago-electronico.component.scss']
10 12 })
11   -export class PagoElectronicoComponent implements OnInit {
  13 +export class PagoElectronicoComponent implements OnInit, OnDestroy {
12 14 urlQr = `${APP_SETTINGS.apiImagenes}/qr/${APP_SETTINGS.deploy}/${APP_SETTINGS.codigoP}/tienda/${APP_SETTINGS.terminal}`;
13 15  
14 16 constructor(
15 17 private articuloService: ArticuloService,
16 18 private router: Router,
  19 + private modalService: BsModalService,
17 20 ) { }
18 21  
19 22 ngOnInit() {
... ... @@ -29,9 +32,21 @@ export class PagoElectronicoComponent implements OnInit {
29 32 .subscribe((res: any) => {
30 33 this.articuloService.idComanda = res.data;
31 34 this.router.navigate(['mensaje-final']);
32   - }, err => console.error(err));
  35 + }, (err) => {
  36 + this.modalService.show(ErrorFormaPagoComponent, {
  37 + class: 'modal-lg modal-dialog-centered',
  38 + ignoreBackdropClick: true,
  39 + });
  40 + });
33 41 this.mediaPantalla();
34 42 }
  43 +
  44 + ngOnDestroy() {
  45 + for (let i = 1; i <= this.modalService.getModalsCount(); i++) {
  46 + this.modalService.hide(i);
  47 + }
  48 + }
  49 +
35 50 mediaPantalla() {
36 51 if ($('body').hasClass('media-pantalla')) {
37 52 $('.qr-mt').addClass('media-pantalla');
src/app/modules/pago-electronico/pago-electronico.module.ts
... ... @@ -3,13 +3,16 @@ import { CommonModule } from &#39;@angular/common&#39;;
3 3  
4 4 import { PagoElectronicoRoutingModule } from './pago-electronico-routing.module';
5 5 import { PagoElectronicoComponent } from './pago-electronico.component';
  6 +import { PagoTarjetaModule } from '../pago-tarjeta/pago-tarjeta.module';
6 7  
7 8  
8 9 @NgModule({
9 10 declarations: [PagoElectronicoComponent],
10 11 imports: [
11 12 CommonModule,
12   - PagoElectronicoRoutingModule
13   - ]
  13 + PagoElectronicoRoutingModule,
  14 + PagoTarjetaModule,
  15 + ],
  16 + entryComponents: []
14 17 })
15 18 export class PagoElectronicoModule { }
src/app/modules/pago-tarjeta/pago-tarjeta.component.ts
1   -import { Component, OnInit } from '@angular/core';
  1 +import { Component, OnInit, OnDestroy } 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';
  5 +import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component';
4 6  
5 7 @Component({
6 8 selector: 'app-pago-tarjeta',
7 9 templateUrl: './pago-tarjeta.component.html',
8 10 styleUrls: ['./pago-tarjeta.component.scss']
9 11 })
10   -export class PagoTarjetaComponent implements OnInit {
  12 +export class PagoTarjetaComponent implements OnInit, OnDestroy {
11 13  
12 14 constructor(
13 15 private articuloService: ArticuloService,
14 16 private router: Router,
  17 + private modalService: BsModalService,
15 18 ) { }
16 19  
17 20 ngOnInit() {
... ... @@ -26,10 +29,21 @@ export class PagoTarjetaComponent implements OnInit {
26 29 .subscribe((res: any) => {
27 30 this.articuloService.idComanda = res.data;
28 31 this.router.navigate(['mensaje-final']);
29   - }, err => console.error(err));
  32 + }, (err) => {
  33 + this.modalService.show(ErrorFormaPagoComponent, {
  34 + class: 'modal-lg modal-dialog-centered',
  35 + ignoreBackdropClick: true,
  36 + });
  37 + });
30 38 this.mediaPantalla();
31 39 }
32 40  
  41 + ngOnDestroy() {
  42 + for (let i = 1; i <= this.modalService.getModalsCount(); i++) {
  43 + this.modalService.hide(i);
  44 + }
  45 + }
  46 +
33 47 mediaPantalla() {
34 48 if ($('body').hasClass('media-pantalla')) {
35 49 $('.pago-tarjeta').addClass('media-pantalla');
src/app/modules/pago-tarjeta/pago-tarjeta.module.ts
... ... @@ -3,13 +3,20 @@ import { CommonModule } from &#39;@angular/common&#39;;
3 3  
4 4 import { PagoTarjetaRoutingModule } from './pago-tarjeta-routing.module';
5 5 import { PagoTarjetaComponent } from './pago-tarjeta.component';
  6 +import { ErrorFormaPagoComponent } from 'src/app/shared/error-forma-pago/error-forma-pago.component';
  7 +import { ModalModule } from 'ngx-bootstrap/modal';
6 8  
7 9  
8 10 @NgModule({
9   - declarations: [PagoTarjetaComponent],
  11 + declarations: [
  12 + PagoTarjetaComponent,
  13 + ErrorFormaPagoComponent,
  14 + ],
10 15 imports: [
11 16 CommonModule,
12   - PagoTarjetaRoutingModule
13   - ]
  17 + PagoTarjetaRoutingModule,
  18 + ModalModule.forRoot(),
  19 + ],
  20 + entryComponents: [ErrorFormaPagoComponent]
14 21 })
15 22 export class PagoTarjetaModule { }
src/app/services/articulo/articulo.service.ts
... ... @@ -91,6 +91,9 @@ export class ArticuloService {
91 91 .subscribe((data) => {
92 92 observer.next(data);
93 93 observer.complete();
  94 + }, err => {
  95 + observer.error(err);
  96 + observer.complete();
94 97 });
95 98 });
96 99 });
src/app/shared/error-forma-pago/error-forma-pago.component.html
... ... @@ -0,0 +1,22 @@
  1 +<div class="bg-primary text-center rounded">
  2 + <div class="modal-body">
  3 + <img
  4 + draggable="false"
  5 + ondragstart="return false;"
  6 + (contextmenu)="false"
  7 + class="d-block mx-auto icon-50"
  8 + src="assets/img/x-amarilla.svg">
  9 + <p class="text-white text-center m-3">Algo saliรณ mal, intentalo de nuevo o probรก con otra forma de pago</p>
  10 + <div
  11 + class="d-inline-block py-1 btn-effect bg-white badge-pill"
  12 + (click)="continuar()">
  13 + CONTINUAR
  14 + <img
  15 + draggable="false"
  16 + ondragstart="return false;"
  17 + (contextmenu)="false"
  18 + class="icon-30"
  19 + src="assets/img/ir-color.svg">
  20 + </div>
  21 + </div>
  22 +</div>
src/app/shared/error-forma-pago/error-forma-pago.component.scss
src/app/shared/error-forma-pago/error-forma-pago.component.spec.ts
... ... @@ -0,0 +1,25 @@
  1 +import { async, ComponentFixture, TestBed } from '@angular/core/testing';
  2 +
  3 +import { ErrorFormaPagoComponent } from './error-forma-pago.component';
  4 +
  5 +describe('ErrorFormaPagoComponent', () => {
  6 + let component: ErrorFormaPagoComponent;
  7 + let fixture: ComponentFixture<ErrorFormaPagoComponent>;
  8 +
  9 + beforeEach(async(() => {
  10 + TestBed.configureTestingModule({
  11 + declarations: [ ErrorFormaPagoComponent ]
  12 + })
  13 + .compileComponents();
  14 + }));
  15 +
  16 + beforeEach(() => {
  17 + fixture = TestBed.createComponent(ErrorFormaPagoComponent);
  18 + component = fixture.componentInstance;
  19 + fixture.detectChanges();
  20 + });
  21 +
  22 + it('should create', () => {
  23 + expect(component).toBeTruthy();
  24 + });
  25 +});
src/app/shared/error-forma-pago/error-forma-pago.component.ts
... ... @@ -0,0 +1,24 @@
  1 +import { Component, OnInit } from '@angular/core';
  2 +import { Router } from '@angular/router';
  3 +import { BsModalRef } from 'ngx-bootstrap/modal';
  4 +
  5 +@Component({
  6 + selector: 'app-error-forma-pago',
  7 + templateUrl: './error-forma-pago.component.html',
  8 + styleUrls: ['./error-forma-pago.component.scss']
  9 +})
  10 +export class ErrorFormaPagoComponent implements OnInit {
  11 +
  12 + constructor(
  13 + private router: Router,
  14 + private modalRef: BsModalRef,
  15 + ) { }
  16 +
  17 + ngOnInit() { }
  18 +
  19 + continuar() {
  20 + this.router.navigate(['forma-pago']);
  21 + this.modalRef.hide();
  22 + }
  23 +
  24 +}
src/assets/img/x-amarilla.svg
... ... @@ -0,0 +1,19 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
  3 +<!-- Creator: CorelDRAW X7 -->
  4 +<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="28.6378mm" height="28.6378mm" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
  5 +viewBox="0 0 1704 1704"
  6 + xmlns:xlink="http://www.w3.org/1999/xlink">
  7 + <defs>
  8 + <style type="text/css">
  9 + <![CDATA[
  10 + .fil0 {fill:#F4B223;fill-rule:nonzero}
  11 + ]]>
  12 + </style>
  13 + </defs>
  14 + <g id="Capa_x0020_1">
  15 + <metadata id="CorelCorpID_0Corel-Layer"/>
  16 + <polygon class="fil0" points="510,422 852,790 1194,422 1252,471 910,852 1252,1233 1194,1283 852,914 510,1283 452,1233 794,852 452,471 "/>
  17 + <path class="fil0" d="M852 0c235,0 448,95 603,250 154,154 249,367 249,602 0,235 -95,448 -249,603 -155,154 -368,249 -603,249 -235,0 -448,-95 -602,-249 -155,-155 -250,-368 -250,-603 0,-235 95,-448 250,-602 154,-155 367,-250 602,-250zm562 290c-144,-143 -343,-232 -562,-232 -219,0 -418,89 -562,232 -143,144 -232,343 -232,562 0,219 89,418 232,562 144,144 343,232 562,232 219,0 418,-88 562,-232 144,-144 232,-343 232,-562 0,-219 -88,-418 -232,-562z"/>
  18 + </g>
  19 +</svg>