import { Component, Input, OnChanges } from '@angular/core'; import { NonprofitTopLevelStats } from '@core/typings/organization.typing'; import { NonprofitResources } from '@features/nonprofit/nonprofit.resources'; import { I18nService } from '@yourcause/common/i18n'; @Component({ selector: 'gc-organization-top-level-block', templateUrl: './organization-top-level-block.component.html', styleUrls: ['./organization-top-level-block.component.scss'] }) export class OrganizationTopLevelBlockComponent implements OnChanges { @Input() cycleIds: number[] = []; nonprofitTopLevelStats: NonprofitTopLevelStats; totalApplicationsString = ''; totalAwardsString = ''; totalPaymentsString = ''; constructor ( private i18n: I18nService, private nonprofitResources: NonprofitResources ) { } async ngOnChanges () { this.nonprofitTopLevelStats = await this.nonprofitResources.getNonprofitStats( this.cycleIds ); this.totalApplicationsString = this.i18n.translate( 'common:textNumberOfApplications', { number: this.nonprofitTopLevelStats.numberOfApplications }, '__number__ applications' ); this.totalAwardsString = this.i18n.translate( 'common:textNumberOfAwards', { number: this.nonprofitTopLevelStats.numberOfAwards }, '__number__ awards' ); this.totalPaymentsString = this.i18n.translate( 'common:textNumberOfPayments', { number: this.nonprofitTopLevelStats.numberOfPayments }, '__number__ payments' ); } }