Commit d5898928bc5fd6ad4805386fdc02f742fdfc9143
1 parent
aa655fc0f9
Exists in
master
categorias
Showing
5 changed files
with
30 additions
and
55 deletions
Show diff stats
src/app/components/busqueda-productos/busqueda-productos.component.html
... | ... | @@ -20,49 +20,14 @@ |
20 | 20 | </div> |
21 | 21 | <ul class="list-group"> |
22 | 22 | <li |
23 | - [ngClass]="{active: categoria == 1}" | |
24 | - (click)="categoria = 1" | |
23 | + *ngFor="let categoria of categorias" | |
24 | + [ngClass]="{active: categoriaActive == categoria.id}" | |
25 | + (click)="categoriaActive = categoria.id; filterItems()" | |
25 | 26 | class="list-group-item list-group-item-action text-center my-1 p-2 h6"> |
26 | - Combos y Promociones | |
27 | - </li> | |
28 | - <li | |
29 | - [ngClass]="{active: categoria == 2}" | |
30 | - (click)="categoria = 2" | |
31 | - class="list-group-item list-group-item-action text-center my-1 p-2 h6 shadow-sm"> | |
32 | - Todos | |
33 | - </li> | |
34 | - <li | |
35 | - [ngClass]="{active: categoria == 3}" | |
36 | - (click)="categoria = 3" | |
37 | - class="list-group-item list-group-item-action text-center my-1 p-2 h6 shadow-sm"> | |
38 | - Bebidas | |
39 | - </li> | |
40 | - <li | |
41 | - [ngClass]="{active: categoria == 4}" | |
42 | - (click)="categoria = 4" | |
43 | - class="list-group-item list-group-item-action text-center my-1 p-2 h6 shadow-sm"> | |
44 | - SandwicherÃa | |
45 | - </li> | |
46 | - <li | |
47 | - [ngClass]="{active: categoria == 5}" | |
48 | - (click)="categoria = 5" | |
49 | - class="list-group-item list-group-item-action text-center my-1 p-2 h6 shadow-sm"> | |
50 | - Panaderia | |
51 | - </li> | |
52 | - <li | |
53 | - [ngClass]="{active: categoria == 6}" | |
54 | - (click)="categoria = 6" | |
55 | - class="list-group-item list-group-item-action text-center my-1 p-2 h6 shadow-sm"> | |
56 | - Golosinas | |
57 | - </li> | |
58 | - <li | |
59 | - [ngClass]="{active: categoria == 7}" | |
60 | - (click)="categoria = 7" | |
61 | - class="list-group-item list-group-item-action text-center my-1 p-2 h6 shadow-sm"> | |
62 | - Tabaqueria | |
27 | + {{categoria.detalle}} | |
63 | 28 | </li> |
64 | 29 | </ul> |
65 | - </div> | |
30 | + </div> | |
66 | 31 | |
67 | 32 | <!-- SEARCH INPUT --> |
68 | 33 | <div *ngIf="productos.length > 0" class="fade-in col-sm-10"> |
src/app/components/busqueda-productos/busqueda-productos.component.ts
... | ... | @@ -14,17 +14,24 @@ export class BusquedaProductosComponent implements OnInit { |
14 | 14 | private productos: Producto[] = []; |
15 | 15 | private auxProductos: Producto[] = []; |
16 | 16 | private searchTerm: string = ''; |
17 | + private categoriaActive: number = null; | |
17 | 18 | private showSpinner: boolean = true; |
18 | - private categoria: Categorias = Categorias.todos; | |
19 | 19 | private apiUrl: string = appSettings.apiUrl; |
20 | 20 | private showBtnCargarProducto: boolean = false; |
21 | + private categorias: Categoria[] = []; | |
21 | 22 | |
22 | 23 | constructor( |
23 | 24 | private productoService: ProductoService, |
24 | 25 | private router: Router) { } |
25 | 26 | |
26 | 27 | ngOnInit() { |
27 | - | |
28 | + | |
29 | + this.productoService.getCategorias() | |
30 | + .subscribe((categorias: Categoria[]) => { | |
31 | + this.categorias = categorias; | |
32 | + this.categoriaActive = categorias[0].id; | |
33 | + }); | |
34 | + | |
28 | 35 | this.productoService.productoAcargar = undefined; |
29 | 36 | this.productoService.getAll() |
30 | 37 | .subscribe((data: Producto[]) => { |
... | ... | @@ -39,7 +46,8 @@ export class BusquedaProductosComponent implements OnInit { |
39 | 46 | filterItems() { |
40 | 47 | |
41 | 48 | this.auxProductos = this.productos.filter(x => { |
42 | - return x.DetArt.toLowerCase().includes(this.searchTerm.toLowerCase()) | |
49 | + return x.DetArt.toLowerCase().includes(this.searchTerm.toLowerCase()) && | |
50 | + x.categoria_selfservice == this.categoriaActive; | |
43 | 51 | }); |
44 | 52 | } |
45 | 53 | |
... | ... | @@ -66,12 +74,10 @@ export class BusquedaProductosComponent implements OnInit { |
66 | 74 | } |
67 | 75 | } |
68 | 76 | |
69 | -enum Categorias { | |
70 | - promosCombos = 1, | |
71 | - todos = 2, | |
72 | - bebidas = 3, | |
73 | - sandwicheria = 4, | |
74 | - panaderia = 5, | |
75 | - golosinas = 6, | |
76 | - tabaqueria = 7, | |
77 | +interface Categoria { | |
78 | + id: number, | |
79 | + detalle: string, | |
80 | + es_promocion: boolean, | |
81 | + vigencia_desde: Date, | |
82 | + vigencia_hasta: Date | |
77 | 83 | } |
src/app/components/pago/pago.component.html
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | |
12 | 12 | <div class="row m-3 d-flex align-items-center"> |
13 | 13 | <div class="col-4"> |
14 | - <h1>Mi Compra <i class="fa fa-shopping-cart "></i></h1> | |
14 | + <h1>Mi Compra <i class="fa fa-shopping-cart"></i></h1> | |
15 | 15 | </div> |
16 | 16 | <div class="col-8"> |
17 | 17 | <h2>Seleccione medio de pago</h2> |
src/app/services/producto.service.ts
... | ... | @@ -25,14 +25,14 @@ export class ProductoService { |
25 | 25 | } |
26 | 26 | |
27 | 27 | getPromocion(sector, codigo): Observable<any> { |
28 | - | |
28 | + | |
29 | 29 | var url = `${appSettings.apiUrl}/promociones/incluir-articulo/${sector}/${codigo}`; |
30 | 30 | // var url = `${appSettings.apiUrl}/promociones/incluir-articulo/${2}/${1306}`; |
31 | 31 | return this.http.get(url); |
32 | 32 | } |
33 | 33 | |
34 | 34 | getPromocionSinonimos(sector, codigo): Observable<any> { |
35 | - | |
35 | + | |
36 | 36 | var url = `${appSettings.apiUrl}/promociones/incluir-articulo/${sector}/${codigo}`; |
37 | 37 | // var url = `${appSettings.apiUrl}/sinonimos/promo/${2}/${7}`; |
38 | 38 | return this.http.get(url); |
... | ... | @@ -42,4 +42,8 @@ export class ProductoService { |
42 | 42 | return this.http.post(`${appSettings.apiUrl}/imagenes/guardar`, body); |
43 | 43 | } |
44 | 44 | |
45 | + getCategorias() { | |
46 | + return this.http.get(`${appSettings.apiUrl}/categorias`); | |
47 | + } | |
48 | + | |
45 | 49 | } |