import { Component, OnInit } from '@angular/core';
import { catchError, map } from 'rxjs/operators';
import { OrderShipping } from 'src/app/models/order-shipping.model';
import { OrderService } from 'src/app/services/order.service';

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

  ordersShipping: OrderShipping[];
  public loading = false;
  constructor(
    private readonly orderService: OrderService
  ) { }

  ngOnInit() {
    this.loading = true;
    this.orderService.getOrdersShipping()
      .pipe(
        map(orders => {
          this.ordersShipping = orders;
          this.loading = false;
        }),
        )
        .subscribe();
  }

}
