diff --git a/src/app/components/inicio/inicio.component.ts b/src/app/components/inicio/inicio.component.ts index dbaf20e..1fb66d8 100644 --- a/src/app/components/inicio/inicio.component.ts +++ b/src/app/components/inicio/inicio.component.ts @@ -21,7 +21,7 @@ export class InicioComponent implements OnInit, AfterViewInit { private productos: Producto[] = []; private promociones: Producto[] = []; private sinonimos: Sinonimo[] = []; - private apiUrl: string = appSettings.apiUrl + private apiUrl: string = appSettings.apiUrl; @ViewChild('pop', { static: false }) popoverDirective: PopoverDirective; @@ -104,7 +104,7 @@ export class InicioComponent implements OnInit, AfterViewInit { this.productoService.getProductoById($event.id) .subscribe((res: Producto) => { - + $event.imagenes = res.imagenes.length == 0 ? [{ imagen: 'noImage.jpg' }] : res.imagenes; this.promoAcargar = $event; @@ -127,18 +127,18 @@ export class InicioComponent implements OnInit, AfterViewInit { res.forEach(sinonimo => { - sinonimo.productos.forEach(productoSinonimo => { + sinonimo.cantidad = 0; + this.promoAcargar.productos.forEach(productoPromo => { - this.promoAcargar.productos.forEach(productoPromo => { + sinonimo.productos.forEach(productoSinonimo => { if (productoSinonimo.id === productoPromo.id) { - sinonimo.cantidad = productoPromo.cantidad; - sinonimo.productoPadre = productoPromo.id; + productoSinonimo.cantidad = productoPromo.cantidad; + sinonimo.cantidad += productoPromo.cantidad; } }) }) }) - this.sinonimos = res; (this.sinonimos.length > 0) ? this.popoverDirective.show() : this.popoverDirective.hide(); }) diff --git a/src/app/components/popover-sinonimos/popover-sinonimos.component.html b/src/app/components/popover-sinonimos/popover-sinonimos.component.html index 886eaa0..3ee3f79 100644 --- a/src/app/components/popover-sinonimos/popover-sinonimos.component.html +++ b/src/app/components/popover-sinonimos/popover-sinonimos.component.html @@ -61,10 +61,10 @@