import { Component, Input, OnInit, Output, EventEmitter, OnChanges, OnDestroy } from '@angular/core'; import { IOrderItemRateplan } from '../../../../shared/modal/common'; import { User } from '../../../../shared/modal/user'; import { UserService } from '../../../../services/user.service'; import { SharedService } from '../../../../shared/shared.service'; import * as Constants from '../../../../shared/constants'; @Component({ selector: 'rateplan-cmp', moduleId: module.id, templateUrl: 'rateplan.component.html' }) export class RateplanComponent implements OnInit, OnChanges, OnDestroy { private COMPONENT_NAME: string = 'RateplanComponent'; @Input() orderItem: IOrderItemRateplan; @Input() val: Number; @Output() onItemChange = new EventEmitter(false); user: User; storeId: number; rtStoreId: number = Constants.STORE_ID_RT; constructor(public userService: UserService, public sharedService: SharedService) { } ngOnInit() { const METHOD_NAME: string = 'ngOnInit()'; } ngOnChanges(): void { const METHOD_NAME: string = 'ngOnChanges()'; this.user = this.userService.getUser(); this.sharedService.storeId.subscribe((val: number) => { this.storeId = val; }); } ngOnDestroy(): void { const METHOD_NAME: string = 'ngOnDestroy()'; this.user = null; } }