From d5898928bc5fd6ad4805386fdc02f742fdfc9143 Mon Sep 17 00:00:00 2001 From: Eric Fernandez Date: Thu, 15 Aug 2019 16:36:45 -0300 Subject: [PATCH] categorias --- .../busqueda-productos.component.html | 45 +++------------------- .../busqueda-productos.component.ts | 28 ++++++++------ src/app/components/pago/pago.component.html | 2 +- src/app/services/producto.service.ts | 8 +++- src/app/wrappers/producto.ts | 2 +- 5 files changed, 30 insertions(+), 55 deletions(-) diff --git a/src/app/components/busqueda-productos/busqueda-productos.component.html b/src/app/components/busqueda-productos/busqueda-productos.component.html index 4fa7241..194fe80 100644 --- a/src/app/components/busqueda-productos/busqueda-productos.component.html +++ b/src/app/components/busqueda-productos/busqueda-productos.component.html @@ -20,49 +20,14 @@ - +
diff --git a/src/app/components/busqueda-productos/busqueda-productos.component.ts b/src/app/components/busqueda-productos/busqueda-productos.component.ts index a8b0ce7..17c669f 100644 --- a/src/app/components/busqueda-productos/busqueda-productos.component.ts +++ b/src/app/components/busqueda-productos/busqueda-productos.component.ts @@ -14,17 +14,24 @@ export class BusquedaProductosComponent implements OnInit { private productos: Producto[] = []; private auxProductos: Producto[] = []; private searchTerm: string = ''; + private categoriaActive: number = null; private showSpinner: boolean = true; - private categoria: Categorias = Categorias.todos; private apiUrl: string = appSettings.apiUrl; private showBtnCargarProducto: boolean = false; + private categorias: Categoria[] = []; constructor( private productoService: ProductoService, private router: Router) { } ngOnInit() { - + + this.productoService.getCategorias() + .subscribe((categorias: Categoria[]) => { + this.categorias = categorias; + this.categoriaActive = categorias[0].id; + }); + this.productoService.productoAcargar = undefined; this.productoService.getAll() .subscribe((data: Producto[]) => { @@ -39,7 +46,8 @@ export class BusquedaProductosComponent implements OnInit { filterItems() { this.auxProductos = this.productos.filter(x => { - return x.DetArt.toLowerCase().includes(this.searchTerm.toLowerCase()) + return x.DetArt.toLowerCase().includes(this.searchTerm.toLowerCase()) && + x.categoria_selfservice == this.categoriaActive; }); } @@ -66,12 +74,10 @@ export class BusquedaProductosComponent implements OnInit { } } -enum Categorias { - promosCombos = 1, - todos = 2, - bebidas = 3, - sandwicheria = 4, - panaderia = 5, - golosinas = 6, - tabaqueria = 7, +interface Categoria { + id: number, + detalle: string, + es_promocion: boolean, + vigencia_desde: Date, + vigencia_hasta: Date } diff --git a/src/app/components/pago/pago.component.html b/src/app/components/pago/pago.component.html index 91c4f56..2b22e06 100644 --- a/src/app/components/pago/pago.component.html +++ b/src/app/components/pago/pago.component.html @@ -11,7 +11,7 @@
-

Mi Compra

+

Mi Compra

Seleccione medio de pago

diff --git a/src/app/services/producto.service.ts b/src/app/services/producto.service.ts index e33c339..fbe4384 100644 --- a/src/app/services/producto.service.ts +++ b/src/app/services/producto.service.ts @@ -25,14 +25,14 @@ export class ProductoService { } getPromocion(sector, codigo): Observable { - + var url = `${appSettings.apiUrl}/promociones/incluir-articulo/${sector}/${codigo}`; // var url = `${appSettings.apiUrl}/promociones/incluir-articulo/${2}/${1306}`; return this.http.get(url); } getPromocionSinonimos(sector, codigo): Observable { - + var url = `${appSettings.apiUrl}/promociones/incluir-articulo/${sector}/${codigo}`; // var url = `${appSettings.apiUrl}/sinonimos/promo/${2}/${7}`; return this.http.get(url); @@ -42,4 +42,8 @@ export class ProductoService { return this.http.post(`${appSettings.apiUrl}/imagenes/guardar`, body); } + getCategorias() { + return this.http.get(`${appSettings.apiUrl}/categorias`); + } + } diff --git a/src/app/wrappers/producto.ts b/src/app/wrappers/producto.ts index 7bddfae..581935a 100644 --- a/src/app/wrappers/producto.ts +++ b/src/app/wrappers/producto.ts @@ -87,7 +87,7 @@ export interface Producto { IMP_IMP_INT: boolean; id: number; nombreImagen?: any; - + categoria_selfservice: number; cantidad?: number; showCargarProducto?: boolean; } -- 1.9.1