import { Pipe, PipeTransform } from '@angular/core'; import { I18nService } from '@yourcause/common/i18n'; import { Dashboards } from '../dashboards.typing'; @Pipe({ name: 'gcDashboardTypeDisplay' }) export class DashboardTypeDisplayPipe implements PipeTransform { constructor ( public i18n: I18nService ) { } transform (type: Dashboards.WidgetType): string { switch (type) { case 'bar': default: return this.i18n.translate( 'common:textBar', {}, 'Bar' ); case 'pie': return this.i18n.translate( 'common:textPie', {}, 'Pie' ); case 'table': return this.i18n.translate( 'FORMS:textTable', {}, 'Table' ); case 'stat': return this.i18n.translate( 'common:textStat', {}, 'Stat' ); case 'line': return this.i18n.translate( 'common:textLine', {}, 'Line' ); } } }