comanda.component.ts 1.04 KB
import { Component, OnInit } from '@angular/core';
import { appSettings } from 'src/etc/AppSettings';
import { ComandaService } from 'src/app/services/comanda.service';
import { Comanda } from 'src/app/wrappers/comanda';

@Component({
  selector: 'app-comanda',
  templateUrl: './comanda.component.html',
  styleUrls: ['./comanda.component.scss']
})
export class ComandaComponent implements OnInit {

  private apiImagenes = appSettings.apiImagenes;
  private comandas: Comanda[] = [];

  constructor(
    private comandaService: ComandaService
  ) { }

  ngOnInit() {

    this.comandaService.getAll()
      .subscribe((res: Comanda[]) => {

        this.comandas = res;
      }, e => console.error(e))
  }

  updateComanda(comanda: Comanda, estadoNuevo: number, observacionNueva: string) {

    this.comandaService.updateComanda(comanda.id, estadoNuevo, observacionNueva)
      .subscribe(res => {

        if (res.data) {
          comanda.estado = estadoNuevo;
          comanda.observacion = observacionNueva;
        }
      }, e => console.error(e))
  }

}