import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { ReturnDTO } from '@swagger/remi';

@Component({
  selector: 'page-shipping-document-list-item',
  templateUrl: 'shipping-document-list-item.component.html',
  styleUrls: ['shipping-document-list-item.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ShippingDocumentListItemComponent implements OnInit {
  @Input()
  return: ReturnDTO;

  get firstReceipt() {
    return this.return.receipts?.find((_) => true)?.data;
  }

  get completed() {
    return !!this.return.completed;
  }

  get itemsCount() {
    return this.firstReceipt?.items?.length ?? 0;
  }

  get firstReceiptPackageNumber() {
    return this.firstReceipt?.packages?.find((_) => true)?.data?.packageNumber;
  }

  constructor() {}

  ngOnInit() {}
}
