Commit b96a90a4b347d409fb9a4405af06ab36347a0e5f

Authored by Marcelo Puebla
1 parent bd8d9956da
Exists in master

Le agrego cantidad de uno al primer producto.

src/app/components/busqueda-productos/busqueda-productos.component.ts
1 import { Component, OnInit } from '@angular/core'; 1 import { Component, OnInit } from '@angular/core';
2 import { ProductoService } from 'src/app/services/producto.service'; 2 import { ProductoService } from 'src/app/services/producto.service';
3 import { Producto } from 'src/app/wrappers/producto'; 3 import { Producto } from 'src/app/wrappers/producto';
4 import { appSettings } from 'src/etc/AppSettings'; 4 import { appSettings } from 'src/etc/AppSettings';
5 5
6 @Component({ 6 @Component({
7 selector: 'app-busqueda-productos', 7 selector: 'app-busqueda-productos',
8 templateUrl: './busqueda-productos.component.html', 8 templateUrl: './busqueda-productos.component.html',
9 styleUrls: ['./busqueda-productos.component.scss'] 9 styleUrls: ['./busqueda-productos.component.scss']
10 }) 10 })
11 export class BusquedaProductosComponent implements OnInit { 11 export class BusquedaProductosComponent implements OnInit {
12 12
13 private productos: Producto[] = []; 13 private productos: Producto[] = [];
14 private auxProductos: Producto[] = []; 14 private auxProductos: Producto[] = [];
15 private searchTerm: string = ''; 15 private searchTerm: string = '';
16 private showSpinner: boolean = true; 16 private showSpinner: boolean = true;
17 private categoria: Categorias = Categorias.todos; 17 private categoria: Categorias = Categorias.todos;
18 private apiUrl: string = appSettings.apiUrl; 18 private apiUrl: string = appSettings.apiUrl;
19 19
20 20
21 constructor(private productoService: ProductoService) { } 21 constructor(private productoService: ProductoService) { }
22 22
23 ngOnInit() { 23 ngOnInit() {
24 24
25 this.productoService.getAll() 25 this.productoService.getAll()
26 .subscribe((data: Producto[]) => { 26 .subscribe((data: Producto[]) => {
27 27
28 this.auxProductos = this.productos = data; 28 this.auxProductos = this.productos = data;
29 }, (error) => { 29 }, (error) => {
30 this.showSpinner = false; 30 this.showSpinner = false;
31 console.error(error); 31 console.error(error);
32 }); 32 });
33 } 33 }
34 34
35 filterItems() { 35 filterItems() {
36 36
37 this.auxProductos = this.productos.filter(x => { 37 this.auxProductos = this.productos.filter(x => {
38 return x.DetArt.toLowerCase().includes(this.searchTerm.toLowerCase()) 38 return x.DetArt.toLowerCase().includes(this.searchTerm.toLowerCase())
39 }); 39 });
40 } 40 }
41 41
42 agregarAlCarrito(producto: Producto) { 42 agregarAlCarrito(producto: Producto) {
43 43
44 producto.cantidad = 1;
44 this.productoService.setProductos(producto); 45 this.productoService.setProductos(producto);
45 } 46 }
46 47
47 } 48 }
48 49
49 enum Categorias { 50 enum Categorias {
50 promosCombos = 1, 51 promosCombos = 1,
51 todos = 2, 52 todos = 2,
52 bebidas = 3, 53 bebidas = 3,
53 sandwicheria = 4, 54 sandwicheria = 4,
54 panaderia = 5, 55 panaderia = 5,
55 golosinas = 6, 56 golosinas = 6,
56 tabaqueria = 7, 57 tabaqueria = 7,
57 } 58 }
58 59