import { Component, Input, OnChanges } from '@angular/core'; import { ProgramTopLevelStats } from '@core/typings/program.typing'; import { ProgramResources } from '@features/programs/program.resources'; import { I18nService } from '@yourcause/common/i18n'; @Component({ selector: 'gc-program-top-level-block', templateUrl: './program-top-level-block.component.html', styleUrls: ['./program-top-level-block.component.scss'] }) export class ProgramTopLevelBlockComponent implements OnChanges { @Input() cycleIds: number[] = []; @Input() programId: number; @Input() isArchived: boolean; programTopLevelStats: ProgramTopLevelStats; totalAwardsString: string; totalPaymentsString: string; constructor ( private i18n: I18nService, private programResources: ProgramResources ) { } get isNomination () { return location.pathname.includes('nomination'); } async ngOnChanges () { this.programTopLevelStats = await this.programResources.getProgramInsightStats( this.cycleIds, this.programId, this.isArchived ); this.totalAwardsString = this.programTopLevelStats.numberOfAwards === 1 ? this.i18n.translate( 'common:textOneAward', {}, '1 award' ) : this.i18n.translate( 'common:textNumberOfAwards', { number: this.programTopLevelStats.numberOfAwards }, '__number__ awards' ); this.totalPaymentsString = this.programTopLevelStats.numberOfPayments === 1 ? this.i18n.translate( 'common:textOnePayment', {}, '1 payment' ) : this.i18n.translate( 'common:textNumberOfPayments', { number: this.programTopLevelStats.numberOfPayments }, '__number__ payments' ); } }