import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, } from '@angular/core'; import { DesignTemplatesContentInterface, } from './../../models/index'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, selector: 'product-care-and-print-area-content-component', styleUrls: [ './product-care-and-print-area-content.component.scss', ], templateUrl: './product-care-and-print-area-content.component.template.pug', }) export class ProductCareAndPrintAreaContentComponent { @Input() public title: string = 'Care Instructions and Print Area'; @Input() public singleSkuSubtitle = 'Care instructions'; @Input() public unitsOfMeasure: Map = new Map( [ ['inch', true], ['cm', false], ], ); @Input() public careInstructionsByDisplaySku: { [key: string]: string } = {}; @Input() public designTemplateForDisplaySku: { [key: string]: DesignTemplatesContentInterface, }; @Output() public onChangeUnitsOfMeasure = new EventEmitter(); public get showContent() { return Boolean( (this.careInstructionsByDisplaySku && Object.entries( this.careInstructionsByDisplaySku, ).length > 0) || (this.designTemplateForDisplaySku && Object.entries( this.designTemplateForDisplaySku, ).length > 0), ); } public get getUnitsOfMeasureAsArray(): Array<[string, boolean]> { return Array.from(this.unitsOfMeasure); } public get getCareInstructionsAsArray(): Array<[string, string]> { return Object.entries(this.careInstructionsByDisplaySku); } public get designTemplatesAsArray(): Array<[ string, DesignTemplatesContentInterface ]> { return Object.entries(this.designTemplateForDisplaySku); } public changeSelectedUnitsOfMeasure(unit: string) { this.onChangeUnitsOfMeasure.emit(unit); } public isBrandTitleVisible() { return this.getCareInstructionsAsArray.length > 1; } }