diff --git a/src/app/modules/carrito/carrito.component.ts b/src/app/modules/carrito/carrito.component.ts index 651badb..baec0e1 100644 --- a/src/app/modules/carrito/carrito.component.ts +++ b/src/app/modules/carrito/carrito.component.ts @@ -42,7 +42,7 @@ export class CarritoComponent implements OnInit, OnDestroy { this.router.navigate(['']); return; } - this.mediaPantallaP() + this.mediaPantallaP(); } ngOnDestroy() { @@ -50,8 +50,7 @@ export class CarritoComponent implements OnInit, OnDestroy { } deleteArticulo(index: number) { - this.articuloService.carrito.splice(index, 1); - this.articuloService.calcularTotal(); + this.articuloService.deleteArticulo(index); } substractCant(articulo: IArticulo) { @@ -76,6 +75,12 @@ export class CarritoComponent implements OnInit, OnDestroy { this.inactiveScreen.startTimeOutInactividad(); } + @HostListener('scroll', ['$event']) + scrollEvent(event: Event) { + clearTimeout(this.inactiveScreen.timerReposo); + this.inactiveScreen.startTimeOutInactividad(); + } + mediaPantallaP() { if ($('body').hasClass('media-pantalla')) { $('.carrito-content,.carrito-articulo').addClass('media-pantalla'); diff --git a/src/app/modules/forma-pago/forma-pago.component.ts b/src/app/modules/forma-pago/forma-pago.component.ts index 1a2b4b2..ba1680a 100644 --- a/src/app/modules/forma-pago/forma-pago.component.ts +++ b/src/app/modules/forma-pago/forma-pago.component.ts @@ -1,11 +1,11 @@ -import { Component, OnInit } from "@angular/core"; -import { ArticuloService } from "src/app/services/articulo/articulo.service"; -import { Router } from "@angular/router"; +import { Component, OnInit } from '@angular/core'; +import { ArticuloService } from 'src/app/services/articulo/articulo.service'; +import { Router } from '@angular/router'; @Component({ - selector: "app-forma-pago", - templateUrl: "./forma-pago.component.html", - styleUrls: ["./forma-pago.component.scss"] + selector: 'app-forma-pago', + templateUrl: './forma-pago.component.html', + styleUrls: ['./forma-pago.component.scss'] }) export class FormaPagoComponent implements OnInit { constructor( @@ -15,7 +15,7 @@ export class FormaPagoComponent implements OnInit { ngOnInit() { if (!this.articuloService.carrito.length) { - this.router.navigate([""]); + this.router.navigate(['']); return; } this.mediaPantalla(); @@ -25,10 +25,10 @@ export class FormaPagoComponent implements OnInit { this.articuloService.medioPago = medioPago; switch (medioPago) { case 4: - this.router.navigate(["pago-tarjeta"]); + this.router.navigate(['pago-tarjeta']); break; case 9: - this.router.navigate(["pago-electronico"]); + this.router.navigate(['pago-electronico']); break; } } diff --git a/src/app/modules/info-formas-pago/info-formas-pago.component.ts b/src/app/modules/info-formas-pago/info-formas-pago.component.ts index 04c0a67..d193166 100644 --- a/src/app/modules/info-formas-pago/info-formas-pago.component.ts +++ b/src/app/modules/info-formas-pago/info-formas-pago.component.ts @@ -7,13 +7,13 @@ import { Component, OnInit } from '@angular/core'; }) export class InfoFormasPagoComponent implements OnInit { mediaPantalla = false; - - constructor() {} + + constructor() { } ngOnInit() { this.reducirPantalla(); } - + reducirPantalla() { if ($('body').hasClass('media-pantalla')) { $('.reduce-card-1,.reduce-card-2').addClass('media-pantalla'); diff --git a/src/app/modules/seleccion-articulos/seleccion-articulos.component.ts b/src/app/modules/seleccion-articulos/seleccion-articulos.component.ts index beef7cf..7956984 100644 --- a/src/app/modules/seleccion-articulos/seleccion-articulos.component.ts +++ b/src/app/modules/seleccion-articulos/seleccion-articulos.component.ts @@ -154,10 +154,9 @@ export class SeleccionArticulosComponent implements OnInit, OnDestroy { if (res.length) { this.openModalSinonimos(res); } else { - articulo.cantidad = 1; this.articuloService.setArticulo(articulo); } - }) + }); } openModalPromos(articulo: IArticulo) { @@ -172,11 +171,15 @@ export class SeleccionArticulosComponent implements OnInit, OnDestroy { initialState: { sinonimos: sinonimosData }, class: 'modal-promo modal-dialog-centered' }); + + this.modalRef.content.onClose + .subscribe((articulo: IArticulo) => { + this.articuloService.setArticulo(articulo); + }); } deleteArticulo(index: number) { - this.articuloService.carrito.splice(index, 1); - this.articuloService.calcularTotal(); + this.articuloService.deleteArticulo(index); } increaseShow() { diff --git a/src/app/modules/splash-screen/splash-screen.component.ts b/src/app/modules/splash-screen/splash-screen.component.ts index c61cb55..19a6ee9 100644 --- a/src/app/modules/splash-screen/splash-screen.component.ts +++ b/src/app/modules/splash-screen/splash-screen.component.ts @@ -1,17 +1,17 @@ -import { Component, OnInit } from "@angular/core"; +import { Component, OnInit } from '@angular/core'; @Component({ - selector: "app-splash-screen", - templateUrl: "./splash-screen.component.html", - styleUrls: ["./splash-screen.component.scss"] + selector: 'app-splash-screen', + templateUrl: './splash-screen.component.html', + styleUrls: ['./splash-screen.component.scss'] }) export class SplashScreenComponent implements OnInit { timerSplashScreen = 2000; showSplashScreen = true; - textWelcome = "BIENVENIDO A SPOT!"; - textComoEstas = "¿cómo estás?"; - textInvitamos = "TE INVITAMOS A HACER"; - textTuPedido = "tu pedido acá"; + textWelcome = 'BIENVENIDO A SPOT!'; + textComoEstas = '¿cómo estás?'; + textInvitamos = 'TE INVITAMOS A HACER'; + textTuPedido = 'tu pedido acá'; constructor() {} diff --git a/src/app/services/articulo/articulo.service.ts b/src/app/services/articulo/articulo.service.ts index c12208f..b2f74ad 100644 --- a/src/app/services/articulo/articulo.service.ts +++ b/src/app/services/articulo/articulo.service.ts @@ -42,6 +42,7 @@ export class ArticuloService { } setArticulo(articulo: IArticulo) { + articulo.cantidad = 1; for (const articuloCarrito of this.carrito) { if (articuloCarrito.id === articulo.id) { articuloCarrito.cantidad++; @@ -54,6 +55,11 @@ export class ArticuloService { this.calcularTotal(); } + deleteArticulo(index: number) { + this.carrito.splice(index, 1); + this.calcularTotal(); + } + pay(dataPago: any) { return new Observable((observer) => { this.clienteService.getById(-1) diff --git a/src/app/shared/footer/footer.component.ts b/src/app/shared/footer/footer.component.ts index a8ccb59..fa71c96 100644 --- a/src/app/shared/footer/footer.component.ts +++ b/src/app/shared/footer/footer.component.ts @@ -7,15 +7,31 @@ import { Location } from '@angular/common'; styleUrls: ['./footer.component.scss'] }) export class FooterComponent implements OnInit { - constructor(private location: Location) {} + constructor(private location: Location) { } - ngOnInit() {} + ngOnInit() { } goBack() { this.location.back(); } reducirPantalla() { - $('body,.reduce-card-1,.reduce-card-2,#content,.cat-content,.cat-btn,.cat-box,#boxCarrito,#headerPublicidad,#headerPad,.img-categoria,.carrito-articulo,.carrito-content,.pago-tarjeta,.modal-promo').toggleClass('media-pantalla'); + $(` + body, + .reduce-card-1, + .reduce-card-2, + #content, + .cat-content, + .cat-btn, + .cat-box, + #boxCarrito, + #headerPublicidad, + #headerPad, + .img-categoria, + .carrito-articulo, + .carrito-content, + .pago-tarjeta, + .modal-promo`) + .toggleClass('media-pantalla'); } } diff --git a/src/app/shared/header-publicidad/header-publicidad.component.ts b/src/app/shared/header-publicidad/header-publicidad.component.ts index 15068bd..07d6af7 100644 --- a/src/app/shared/header-publicidad/header-publicidad.component.ts +++ b/src/app/shared/header-publicidad/header-publicidad.component.ts @@ -77,7 +77,6 @@ export class HeaderPublicidadComponent implements OnInit { class: 'modal-promo modal-dialog-centered' }); this.modalRef.content.onClose.subscribe(() => { - articulo.cantidad = 1; this.articuloService.setArticulo(articulo); }); } diff --git a/src/app/shared/promocion/promocion.component.ts b/src/app/shared/promocion/promocion.component.ts index ec6cda1..664c178 100644 --- a/src/app/shared/promocion/promocion.component.ts +++ b/src/app/shared/promocion/promocion.component.ts @@ -22,7 +22,7 @@ export class PromocionComponent implements OnInit { urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; constructor( - public modalRef: BsModalRef, + public modalPromocion: BsModalRef, private modalService: BsModalService, private articuloService: ArticuloService, private promocionService: PromocionService, @@ -44,17 +44,23 @@ export class PromocionComponent implements OnInit { } else { promo.cantidad = 1; this.articuloService.setArticulo(promo); - this.modalRef.hide(); + this.modalPromocion.hide(); } }, err => console.error(err)); this.mediaPantalla(); } openModalSinonimos(sinonimosData: ISinonimo[]) { - this.modalRef = this.modalService.show(SinonimoComponent, { + const modalSinonimo = this.modalService.show(SinonimoComponent, { initialState: { sinonimos: sinonimosData }, class: 'modal-promo modal-dialog-centered' }); + + modalSinonimo.content.onClose + .subscribe((articulo: IArticulo) => { + this.articuloService.setArticulo(articulo); + this.modalPromocion.hide(); + }); } getPromociones() { diff --git a/src/app/shared/sinonimo/sinonimo.component.html b/src/app/shared/sinonimo/sinonimo.component.html index 96a14bc..8773131 100644 --- a/src/app/shared/sinonimo/sinonimo.component.html +++ b/src/app/shared/sinonimo/sinonimo.component.html @@ -28,7 +28,8 @@