import { Pipe, PipeTransform } from '@angular/core'; import { ReferenceFieldAPI } from '@core/typings/api/reference-fields.typing'; import { I18nService } from '@yourcause/common/i18n'; @Pipe({ name: 'gcDataSetCollectionLabel' }) export class DataSetCollectionLabelPipe implements PipeTransform { constructor ( private i18n: I18nService ) { } transform (collectionType: ReferenceFieldAPI.DataSetCollectionType) { let collectionLabel: string; switch (collectionType) { case ReferenceFieldAPI.DataSetCollectionType.Number: collectionLabel = this.i18n.translate('common:textNumber', {}, 'Number'); break; case ReferenceFieldAPI.DataSetCollectionType.Percent: collectionLabel = this.i18n.translate('common:textPercentage', {}, 'Percentage'); break; default: case ReferenceFieldAPI.DataSetCollectionType.YesOrNo: collectionLabel = this.i18n.translate('common:textSelectIfApplicable', {}, 'Select if applicable'); break; } return collectionLabel; } }