Commit bb26145167375b229a3fe7e7d226468c6e2368e2

Authored by Marcelo Puebla
1 parent bab0235720
Exists in master and in 1 other branch validar_pve

Arreglo con timeout.

src/app/components/cancelar-compra/cancelar-compra.component.ts
1 import { Component, OnInit } from '@angular/core'; 1 import { Component, OnInit, OnDestroy } from '@angular/core';
2 import { appSettings } from 'src/etc/AppSettings'; 2 import { appSettings } from 'src/etc/AppSettings';
3 import { Location } from '@angular/common'; 3 import { Location } from '@angular/common';
4 import { Router } from '@angular/router'; 4 import { Router } from '@angular/router';
5 import { ProductoService } from 'src/app/services/producto.service'; 5 import { ProductoService } from 'src/app/services/producto.service';
6 6
7 @Component({ 7 @Component({
8 selector: 'app-cancelar-compra', 8 selector: 'app-cancelar-compra',
9 templateUrl: './cancelar-compra.component.html', 9 templateUrl: './cancelar-compra.component.html',
10 styleUrls: ['./cancelar-compra.component.scss'] 10 styleUrls: ['./cancelar-compra.component.scss']
11 }) 11 })
12 export class CancelarCompraComponent implements OnInit { 12 export class CancelarCompraComponent implements OnInit, OnDestroy {
13 13
14 private apiUrl: string = appSettings.apiUrl; 14 private apiUrl: string = appSettings.apiUrl;
15 private timer: any;
15 16
16 constructor( 17 constructor(
17 private location: Location, 18 private location: Location,
18 private router: Router, 19 private router: Router,
19 private productoService: ProductoService 20 private productoService: ProductoService
20 ) { } 21 ) { }
21 22
22 ngOnInit() { 23 ngOnInit() {
23 24
24 setTimeout(() => { 25 this.timer = setTimeout(() => {
25 this.limpiarCarritoYvolver(); 26 this.limpiarCarritoYvolver();
26 }, 30000) 27 }, 30000)
27 } 28 }
28 29
30 ngOnDestroy() {
31
32 clearTimeout(this.timer);
33 }
34
29 volverPreviousPage() { 35 volverPreviousPage() {
30 36
31 this.location.back(); 37 this.location.back();
32 } 38 }
33 39
34 limpiarCarritoYvolver() { 40 limpiarCarritoYvolver() {
35 41
36 this.productoService.productoAcargar = undefined; 42 this.productoService.productoAcargar = undefined;
37 this.productoService.promoAcargar = undefined; 43 this.productoService.promoAcargar = undefined;
38 this.productoService.productos = []; 44 this.productoService.productos = [];
39 this.router.navigate(['/home']); 45 this.router.navigate(['/home']);
40 } 46 }
41 47
42 } 48 }
43 49