Commit 797574ed9dfa11e5b722c4fc711bd7c53bf3e95c
1 parent
9b79dc0e51
Exists in
master
and in
1 other branch
Logica para volver al home.
Showing
1 changed file
with
24 additions
and
1 deletions
Show diff stats
src/app/components/mensaje-final/mensaje-final.component.ts
1 | 1 | import { Component, OnInit } from '@angular/core'; |
2 | 2 | import { appSettings } from 'src/etc/AppSettings'; |
3 | +import { ProductoService } from 'src/app/services/producto.service'; | |
4 | +import { Router } from '@angular/router'; | |
3 | 5 | |
4 | 6 | @Component({ |
5 | 7 | selector: 'app-mensaje-final', |
... | ... | @@ -9,10 +11,31 @@ import { appSettings } from 'src/etc/AppSettings'; |
9 | 11 | export class MensajeFinalComponent implements OnInit { |
10 | 12 | |
11 | 13 | private apiUrl: string = appSettings.apiUrl; |
14 | + private timer: any; | |
12 | 15 | |
13 | - constructor() { } | |
16 | + constructor( | |
17 | + private productoService: ProductoService, | |
18 | + private router: Router | |
19 | + ) { } | |
14 | 20 | |
15 | 21 | ngOnInit() { |
22 | + | |
23 | + this.timer = setTimeout(() => { | |
24 | + this.limpiarCarritoYvolver(); | |
25 | + }, 30000) | |
26 | + } | |
27 | + | |
28 | + ngOnDestroy() { | |
29 | + | |
30 | + clearTimeout(this.timer); | |
31 | + } | |
32 | + | |
33 | + limpiarCarritoYvolver() { | |
34 | + | |
35 | + this.productoService.productoAcargar = undefined; | |
36 | + this.productoService.promoAcargar = undefined; | |
37 | + this.productoService.productos = []; | |
38 | + this.router.navigate(['/home']); | |
16 | 39 | } |
17 | 40 | |
18 | 41 | } |