Commit dd83d1edbda55ba400bed93536c051e5189135f2
1 parent
3d1313517b
Exists in
develop
and in
1 other branch
Agregado pago electronico, agregada validacion cuando el carrito este vacio
Showing
8 changed files
with
46 additions
and
8 deletions
Show diff stats
src/app/modules/carrito/carrito.component.ts
... | ... | @@ -4,6 +4,7 @@ import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
4 | 4 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
5 | 5 | import { trigger, state, style, transition, animate } from '@angular/animations'; |
6 | 6 | import { IArticulo } from 'src/app/interfaces/IArticulo'; |
7 | +import { Router } from '@angular/router'; | |
7 | 8 | |
8 | 9 | @Component({ |
9 | 10 | selector: 'app-carrito', |
... | ... | @@ -27,11 +28,17 @@ export class CarritoComponent implements OnInit { |
27 | 28 | maxCantidad = 50; |
28 | 29 | |
29 | 30 | constructor( |
30 | - private location: Location, | |
31 | 31 | public articuloService: ArticuloService, |
32 | + private location: Location, | |
33 | + private router: Router, | |
32 | 34 | ) { } |
33 | 35 | |
34 | - ngOnInit() { } | |
36 | + ngOnInit() { | |
37 | + if (!this.articuloService.carrito.length) { | |
38 | + this.router.navigate(['']); | |
39 | + return; | |
40 | + } | |
41 | + } | |
35 | 42 | |
36 | 43 | deleteArticulo(index: number) { |
37 | 44 | this.articuloService.carrito.splice(index, 1); |
src/app/modules/forma-pago/forma-pago.component.html
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | <div class="col-auto px-0 h-auto align-self-start"> |
23 | 23 | <div |
24 | 24 | class="btn-effect col-auto align-self-center px-0 bg-white" |
25 | - [routerLink]="['/pago-electronico']"> | |
25 | + (click)="medioPago(9)"> | |
26 | 26 | <div class="row mx-0 bg-primary badge-pill"> |
27 | 27 | <div class="col-auto p-0"> |
28 | 28 | <img |
src/app/modules/forma-pago/forma-pago.component.ts
src/app/modules/pago-electronico/pago-electronico.component.html
src/app/modules/pago-electronico/pago-electronico.component.ts
1 | 1 | import { Component, OnInit } from '@angular/core'; |
2 | +import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | |
3 | +import { Router } from '@angular/router'; | |
4 | +import { APP_SETTINGS } from 'src/etc/AppSettings'; | |
2 | 5 | |
3 | 6 | @Component({ |
4 | 7 | selector: 'app-pago-electronico', |
... | ... | @@ -6,10 +9,26 @@ import { Component, OnInit } from '@angular/core'; |
6 | 9 | styleUrls: ['./pago-electronico.component.scss'] |
7 | 10 | }) |
8 | 11 | export class PagoElectronicoComponent implements OnInit { |
12 | + urlQr = `${APP_SETTINGS.apiDeboSuite}/qr/dev/${APP_SETTINGS.codigoP}/tienda/${APP_SETTINGS.terminal}`; | |
9 | 13 | |
10 | - constructor() { } | |
14 | + constructor( | |
15 | + private articuloService: ArticuloService, | |
16 | + private router: Router, | |
17 | + ) { } | |
11 | 18 | |
12 | 19 | ngOnInit() { |
20 | + if (!this.articuloService.carrito.length) { | |
21 | + this.router.navigate(['']); | |
22 | + return; | |
23 | + } | |
24 | + let dataPago = { | |
25 | + pedidoAnombreDe: '' | |
26 | + } | |
27 | + this.articuloService.pay(dataPago) | |
28 | + .subscribe((res: any) => { | |
29 | + this.articuloService.idComanda = res.data; | |
30 | + this.router.navigate(['mensaje-final']); | |
31 | + }, err => console.error(err)); | |
13 | 32 | } |
14 | 33 | |
15 | 34 | } |
src/app/modules/pago-tarjeta/pago-tarjeta.component.ts
src/app/services/articulo/articulo.service.ts
... | ... | @@ -48,7 +48,7 @@ export class ArticuloService { |
48 | 48 | return new Observable((observer) => { |
49 | 49 | this.clienteService.getById(-1) |
50 | 50 | .subscribe(cliente => { |
51 | - let puntoVenta = 9998; | |
51 | + let puntoVenta = APP_SETTINGS.puntoVenta; | |
52 | 52 | this.markArticuloInPromoAsRemoved(); |
53 | 53 | this.http.post(`${this.urlDeboSuite}/comprobante/guardar/${this.medioPago}`, { |
54 | 54 | productos: this.carrito, |
... | ... | @@ -57,7 +57,7 @@ export class ArticuloService { |
57 | 57 | codigoVendedor: 5, |
58 | 58 | puntoVenta: this.medioPago === 9 ? -1 * puntoVenta : puntoVenta, |
59 | 59 | pedidoAnombreDe: dataPago.pedidoAnombreDe, |
60 | - numeroPlanilla: '11111', | |
60 | + numeroPlanilla: APP_SETTINGS.numeroPlanilla, | |
61 | 61 | }) |
62 | 62 | .subscribe((data) => { |
63 | 63 | observer.next(data); |
src/etc/AppSettings.ejemplo.ts