Commit b5b898acf93aff6433c3c155936db7e063d7b7d2
1 parent
c36524ad1e
Exists in
master
Agregada logica para pantalla inactiva.
Showing
2 changed files
with
29 additions
and
6 deletions
Show diff stats
src/app/components/confirmacion-carrito/confirmacion-carrito.component.html
src/app/components/confirmacion-carrito/confirmacion-carrito.component.ts
1 | -import { Component, OnInit } from '@angular/core'; | |
1 | +import { Component, OnInit, OnDestroy } from '@angular/core'; | |
2 | 2 | import { appSettings } from 'src/etc/AppSettings'; |
3 | 3 | import { Location } from '@angular/common'; |
4 | 4 | import { ProductoService } from 'src/app/services/producto.service'; |
5 | 5 | import { Producto } from 'src/app/wrappers/producto'; |
6 | +import { Router } from '@angular/router'; | |
6 | 7 | |
7 | 8 | @Component({ |
8 | 9 | selector: 'app-confirmacion-carrito', |
9 | 10 | templateUrl: './confirmacion-carrito.component.html', |
10 | 11 | styleUrls: ['./confirmacion-carrito.component.scss'] |
11 | 12 | }) |
12 | -export class ConfirmacionCarritoComponent implements OnInit { | |
13 | +export class ConfirmacionCarritoComponent implements OnInit, OnDestroy { | |
13 | 14 | |
14 | - productos: Producto[] = []; | |
15 | - total: number = 0; | |
15 | + private productos: Producto[] = []; | |
16 | + private total: number = 0; | |
16 | 17 | private apiUrl: string = appSettings.apiUrl; |
18 | + private timerReposo: any; | |
17 | 19 | |
18 | 20 | constructor( |
19 | 21 | private location: Location, |
20 | - private productoService: ProductoService | |
22 | + private productoService: ProductoService, | |
23 | + private router: Router | |
21 | 24 | ) { } |
22 | 25 | |
23 | 26 | ngOnInit() { |
24 | 27 | |
28 | + this.timerReposo = setTimeout(() => { | |
29 | + | |
30 | + this.router.navigate(['cancelar-compra']); | |
31 | + }, 90000) | |
25 | 32 | this.productos = this.productoService.productos; |
26 | 33 | } |
27 | 34 | |
35 | + ngOnDestroy() { | |
36 | + | |
37 | + clearTimeout(this.timerReposo); | |
38 | + } | |
39 | + | |
28 | 40 | volverPreviousPage() { |
29 | 41 | |
30 | 42 | this.location.back(); |
... | ... | @@ -40,4 +52,13 @@ export class ConfirmacionCarritoComponent implements OnInit { |
40 | 52 | return this.total = subTotal; |
41 | 53 | } |
42 | 54 | |
55 | + reiniciarTimer() { | |
56 | + | |
57 | + clearTimeout(this.timerReposo); | |
58 | + this.timerReposo = setTimeout(() => { | |
59 | + | |
60 | + this.router.navigate(['cancelar-compra']); | |
61 | + }, 90000) | |
62 | + } | |
63 | + | |
43 | 64 | } |