/** * @Component Name: HardGoodsComponent * @Module: Home * @Module Functionality : To display the full cart section * @Creation Date: August 12,2017 * @Author: sbaireddy * @Version: 1.0 */ import { Component, Input, OnInit, OnDestroy, ViewChild } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import * as Constants from '../../../shared/constants'; import Utils from '../../../shared/utils'; import { ORDER_STATUS } from '../../../shared/form.constants'; import { Cart } from '../../../shared/modal/cart'; import { Customer } from '../../../shared/modal/customer'; import { SharedService } from '../../../shared/shared.service'; import { UserService } from '../../../services/user.service'; import { CartService } from '../../../services/cart.service'; @Component({ selector: 'soft-goods-cmp', moduleId: module.id, templateUrl: 'soft-goods.component.html', styleUrls: ['soft-goods.component.css'] }) export class SoftGoodsComponent implements OnInit, OnDestroy { private COMPONENT_NAME: string = 'SoftGoodsComponent'; storeId: number; // update storeid todayDate = new Date(); orderStatusItems: any[]; @Input() cart: Cart; @Input() customer: Customer; // canOverrideRemorse constructor( public router: Router, public sharedService: SharedService, public userService: UserService, public cartService: CartService) { } /** * This function is used to initialize the directive/component after Angular * first displays the data-bound properties.It is invoked only once when the * directive is instantiated.Here it is initializing all the states, payment methods and card types * @returns void */ ngOnInit(): void { const METHOD_NAME: string = 'ngOnInit()'; this.orderStatusItems = ORDER_STATUS.filter(orderStatusItem => orderStatusItem); } /** * Cleanup just before Angular destroys the directive/component. * Unsubscribe Observables and detach event handlers to avoid memory leaks. * @returns void */ ngOnDestroy(): void { this.cart = null; this.customer = null; this.orderStatusItems = null; } /** * This function is used to get the value of status label from key value pair * @param {string} status contains valid status of the cart. * @returns string */ 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; } mobileNumber(phoneNumber: string): string { return Utils.formatPhoneNumber(phoneNumber); } get isPartialSuccess(): boolean { const METHOD_NAME: string = 'isPartialSuccess()'; let isPartialSuccess: boolean = false; if (this.cart && this.cart.packages) { for (const item of this.cart.packages) { if (item && item.device && (!item.device.msisdn || item.device.activationError)) { isPartialSuccess = true; break; } } } return isPartialSuccess; } }