import { Component, OnInit, ViewChild } from '@angular/core'; import { Cart } from 'app/shared/modal/cart' import { IShipping, IPayment } from 'app/shared/modal/common'; import * as Constants from '../../../shared/constants'; import { ORDER_STATUS } from 'app/shared/form.constants'; @Component({ selector: 'order-details', templateUrl: './order-details.component.html', styleUrls: ['./order-details.component.css'] }) export class OrderDetailsComponent implements OnInit { cart: Cart; shippingInfo: IShipping; payment: IPayment; orderStatusItems: any[]; constructor() { } ngOnInit() { this.orderStatusItems = ORDER_STATUS.filter(orderStatusItem => orderStatusItem); this.receiveShippingData(event); this.receivePaymentDetails(event); this.receiveCartDetails(event); } // Functions to be called on init receiving data from output prop of another comp receiveShippingData($event) { this.shippingInfo = $event; } receivePaymentDetails($event) { this.payment = $event; } receiveCartDetails($event) { this.cart = $event; } getStatusLabel(status: string): string { const METHOD_NAME: string = 'getStatusLabel()'; for (const item of this.orderStatusItems) { if (item.key === status) { return item.value; } } return Constants.NOT_FOUND; } }