diff --git a/src/app/components/busqueda-productos/busqueda-productos.component.html b/src/app/components/busqueda-productos/busqueda-productos.component.html index 0797032..723f7d2 100644 --- a/src/app/components/busqueda-productos/busqueda-productos.component.html +++ b/src/app/components/busqueda-productos/busqueda-productos.component.html @@ -14,7 +14,7 @@
-
+

Buscar por Categoría

diff --git a/src/app/components/busqueda-productos/busqueda-productos.component.ts b/src/app/components/busqueda-productos/busqueda-productos.component.ts index dfb758f..b84c6dc 100644 --- a/src/app/components/busqueda-productos/busqueda-productos.component.ts +++ b/src/app/components/busqueda-productos/busqueda-productos.component.ts @@ -17,7 +17,7 @@ export class BusquedaProductosComponent implements OnInit { private searchTerm: string = ''; private categoriaActive: number = null; private showSpinner: boolean = true; - private verCategorias: boolean = true; + private queMostrar: string = 'todo'; private apiUrl: string = appSettings.apiUrl; private categorias: Categoria[] = []; private blurFocus = new EventEmitter(); @@ -28,12 +28,32 @@ export class BusquedaProductosComponent implements OnInit { ngOnInit() { - this.verCategorias = this.productoService.verCategoriasProductos; + this.queMostrar = this.productoService.mostrar; this.productoService.getCategorias() .subscribe((categorias: Categoria[]) => { this.categorias = categorias; - this.categoriaActive = this.verCategorias ? 1 : categorias[0].id; + + switch (this.queMostrar) { + case 'todos': + this.categoriaActive = 1; + break; + case 'promociones': + this.categoriaActive = 1; + break; + case 'ordenar': + + this.categorias = this.categorias.filter((categoria: Categoria) => { + return categoria.ES_PEDIDO; + }); + + this.categoriaActive = this.categorias[0].id; + + break; + default: + break; + } + }); this.productoService.productoAcargar = undefined; diff --git a/src/app/components/inicio/inicio.component.html b/src/app/components/inicio/inicio.component.html index a5e76fc..214b0b7 100644 --- a/src/app/components/inicio/inicio.component.html +++ b/src/app/components/inicio/inicio.component.html @@ -13,7 +13,7 @@
@@ -45,7 +45,8 @@
-
+
@@ -184,7 +185,7 @@
-
diff --git a/src/app/components/inicio/inicio.component.ts b/src/app/components/inicio/inicio.component.ts index 87b83cf..ea0b42c 100644 --- a/src/app/components/inicio/inicio.component.ts +++ b/src/app/components/inicio/inicio.component.ts @@ -85,9 +85,9 @@ export class InicioComponent implements OnInit { }); } - irBusquedaProductos(verPromociones) { + irBusquedaProductos(value) { - this.productoService.verCategoriasProductos = verPromociones; + this.productoService.mostrar = value; this.router.navigate(['busqueda-productos']); } diff --git a/src/app/services/producto.service.ts b/src/app/services/producto.service.ts index 457681f..5c17a58 100644 --- a/src/app/services/producto.service.ts +++ b/src/app/services/producto.service.ts @@ -12,7 +12,7 @@ export class ProductoService { productos: Producto[] = []; productoAcargar: Producto; promoAcargar: Producto; - verCategoriasProductos: boolean = true; + mostrar: string; constructor(private http: HttpClient) { } diff --git a/src/app/wrappers/categoria.ts b/src/app/wrappers/categoria.ts index 0dd7119..b8d3141 100644 --- a/src/app/wrappers/categoria.ts +++ b/src/app/wrappers/categoria.ts @@ -3,5 +3,6 @@ export interface Categoria { detalle: string, es_promocion: boolean, vigencia_desde: Date, - vigencia_hasta: Date + vigencia_hasta: Date, + ES_PEDIDO: boolean } \ No newline at end of file