diff --git a/src/app/components/inicio/inicio.component.ts b/src/app/components/inicio/inicio.component.ts index 0c68d7e..96be6b9 100644 --- a/src/app/components/inicio/inicio.component.ts +++ b/src/app/components/inicio/inicio.component.ts @@ -5,8 +5,6 @@ import { Producto } from 'src/app/wrappers/producto'; import { ProductoService } from 'src/app/services/producto.service'; import { Router } from '@angular/router'; import { Promocion } from 'src/app/wrappers/promocion'; -import { Sinonimo } from 'src/app/wrappers/sinonimo'; - @Component({ selector: 'app-inicio', @@ -18,10 +16,10 @@ export class InicioComponent implements OnInit { @ViewChild('pop', { static: false }) popoverDirective: PopoverDirective; private productoAcargar: Producto; private promoAcargar: Promocion; - private sinonimoAcargar: Sinonimo; + private sinonimoAcargar: Producto; promociones: Promocion[] = []; - sinonimos: Sinonimo[] = []; + sinonimos: Producto[] = []; apiUrl: string = appSettings.apiUrl constructor( @@ -31,6 +29,10 @@ export class InicioComponent implements OnInit { ngOnInit() { this.productoAcargar = this.productoService.productoAcargar; + this.getPromociones(); + } + + getPromociones() { if (this.productoAcargar) { var sector = this.productoAcargar.CodSec; var codigo = this.productoAcargar.CodArt; @@ -88,15 +90,21 @@ export class InicioComponent implements OnInit { var sector = this.promoAcargar.sector; var codigo = this.promoAcargar.codigo; this.productoService.getPromocionSinonimos(sector, codigo) - .subscribe((res: Sinonimo[]) => { - + .subscribe((res: Producto[]) => { + res.forEach(resSinonimo => { + this.promoAcargar.productos.forEach(producto => { + if (producto.id === resSinonimo.id) { + resSinonimo.esPadre = true; + } + }); + }) this.sinonimos = res; this.showPopover(); }) } } - sinonimoSeleccionado($event: Sinonimo) { + sinonimoSeleccionado($event: Producto) { this.sinonimoAcargar = $event; }