From 9a1421ccfc911f3b75a32ed5e62b95934ab4ad3e Mon Sep 17 00:00:00 2001 From: Benjamin Date: Wed, 15 Jan 2020 16:14:42 -0300 Subject: [PATCH] cancelar-compra y timeout --- src/app/app-routing.module.ts | 4 ++ src/app/app.component.html | 4 +- src/app/app.component.ts | 33 +++++++++++++- .../cancelar-compra-routing.module.ts | 14 ++++++ .../cancelar-compra/cancelar-compra.component.html | 53 ++++++++++++++++++++++ .../cancelar-compra/cancelar-compra.component.scss | 3 ++ .../cancelar-compra.component.spec.ts | 25 ++++++++++ .../cancelar-compra/cancelar-compra.component.ts | 33 ++++++++++++++ .../cancelar-compra/cancelar-compra.module.ts | 15 ++++++ src/assets/img/icono-cancelar-color.svg | 19 ++++++++ 10 files changed, 200 insertions(+), 3 deletions(-) create mode 100644 src/app/modules/cancelar-compra/cancelar-compra-routing.module.ts create mode 100644 src/app/modules/cancelar-compra/cancelar-compra.component.html create mode 100644 src/app/modules/cancelar-compra/cancelar-compra.component.scss create mode 100644 src/app/modules/cancelar-compra/cancelar-compra.component.spec.ts create mode 100644 src/app/modules/cancelar-compra/cancelar-compra.component.ts create mode 100644 src/app/modules/cancelar-compra/cancelar-compra.module.ts create mode 100644 src/assets/img/icono-cancelar-color.svg diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 13c2c01..1307097 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -51,6 +51,10 @@ const routes: Routes = [ path: 'comanda', loadChildren: () => import('./modules/comanda/comanda.module').then(m => m.ComandaModule) }, + { + path: 'cancelar-compra', + loadChildren: () => import('./modules/cancelar-compra/cancelar-compra.module').then(m => m.CancelarCompraModule) + }, { path: '**', redirectTo: '', pathMatch: 'full' }, ]; diff --git a/src/app/app.component.html b/src/app/app.component.html index 0680b43..7972b71 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1 +1,3 @@ - +
+ +
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 459968a..4e0e6f7 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,10 +1,39 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; +import { Router, RouterModule, RoutesRecognized, RouterLink, RouterState, ActivatedRoute, RouterLinkActive } from '@angular/router'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) -export class AppComponent { +export class AppComponent implements OnInit { title = 'autoservicio-axion'; + timerReposo: any; + + constructor ( + private router: Router, + ) { } + + ngOnInit(): void { + if ( + window.location.href !== 'http://localhost:4206/#/' && + window.location.href !== 'http://localhost:4206/#/comanda' && + window.location.href !== 'http://localhost:4206/#/pedidos-salientes' + ) { + this.startTimeOutInactividad(); + } else { + console.log(window.location.href) + } + } + + restartTimer() { + clearTimeout(this.timerReposo); + this.startTimeOutInactividad(); + } + + startTimeOutInactividad() { + setTimeout(() => { + this.router.navigate(['cancelar-compra']); + }, 1000); + } } diff --git a/src/app/modules/cancelar-compra/cancelar-compra-routing.module.ts b/src/app/modules/cancelar-compra/cancelar-compra-routing.module.ts new file mode 100644 index 0000000..e41ed93 --- /dev/null +++ b/src/app/modules/cancelar-compra/cancelar-compra-routing.module.ts @@ -0,0 +1,14 @@ +import { NgModule, Component } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; +import { CancelarCompraComponent } from './cancelar-compra.component'; + + +const routes: Routes = [ + { path: '', component: CancelarCompraComponent } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class CancelarCompraRoutingModule { } diff --git a/src/app/modules/cancelar-compra/cancelar-compra.component.html b/src/app/modules/cancelar-compra/cancelar-compra.component.html new file mode 100644 index 0000000..6650233 --- /dev/null +++ b/src/app/modules/cancelar-compra/cancelar-compra.component.html @@ -0,0 +1,53 @@ +
+ +
+
+
+
+
NECESITA
+

más tiempo

+
PARA SU PEDIDO?
+
+
+
+ +
+
+
+
+
+
continuar compra
+
+ +
+
+
+
+
+
+
+
+
+
cancelar compra
+
+ +
+
+
+
+
+
diff --git a/src/app/modules/cancelar-compra/cancelar-compra.component.scss b/src/app/modules/cancelar-compra/cancelar-compra.component.scss new file mode 100644 index 0000000..d5c6941 --- /dev/null +++ b/src/app/modules/cancelar-compra/cancelar-compra.component.scss @@ -0,0 +1,3 @@ +.cancelar-compra { + background-color: rgb(212, 212, 212); +} diff --git a/src/app/modules/cancelar-compra/cancelar-compra.component.spec.ts b/src/app/modules/cancelar-compra/cancelar-compra.component.spec.ts new file mode 100644 index 0000000..55b8d04 --- /dev/null +++ b/src/app/modules/cancelar-compra/cancelar-compra.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CancelarCompraComponent } from './cancelar-compra.component'; + +describe('CancelarCompraComponent', () => { + let component: CancelarCompraComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CancelarCompraComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CancelarCompraComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/modules/cancelar-compra/cancelar-compra.component.ts b/src/app/modules/cancelar-compra/cancelar-compra.component.ts new file mode 100644 index 0000000..434f245 --- /dev/null +++ b/src/app/modules/cancelar-compra/cancelar-compra.component.ts @@ -0,0 +1,33 @@ +import { Component, OnInit } from '@angular/core'; +import { Location } from '@angular/common'; +import { ArticuloService } from 'src/app/services/articulo/articulo.service'; +import { Router } from '@angular/router'; + +@Component({ + selector: 'app-cancelar-compra', + templateUrl: './cancelar-compra.component.html', + styleUrls: ['./cancelar-compra.component.scss'] +}) +export class CancelarCompraComponent implements OnInit { + + constructor( + private location: Location, + private router: Router, + private articuloService: ArticuloService + ) { } + + ngOnInit() { + setTimeout(() => { + this.limpiarCarritoYvolver(); + }, 90000); + } + + volverPreviousPage() { + this.location.back(); + } + + limpiarCarritoYvolver() { + this.articuloService.carrito = undefined; + this.router.navigate(['/']); + } +} diff --git a/src/app/modules/cancelar-compra/cancelar-compra.module.ts b/src/app/modules/cancelar-compra/cancelar-compra.module.ts new file mode 100644 index 0000000..0895ae8 --- /dev/null +++ b/src/app/modules/cancelar-compra/cancelar-compra.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + +import { CancelarCompraRoutingModule } from './cancelar-compra-routing.module'; +import { CancelarCompraComponent } from './cancelar-compra.component'; + + +@NgModule({ + declarations: [CancelarCompraComponent], + imports: [ + CommonModule, + CancelarCompraRoutingModule + ] +}) +export class CancelarCompraModule { } diff --git a/src/assets/img/icono-cancelar-color.svg b/src/assets/img/icono-cancelar-color.svg new file mode 100644 index 0000000..21a0cf0 --- /dev/null +++ b/src/assets/img/icono-cancelar-color.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + -- 1.9.1