45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import type { SponsorDashboardDTO } from '../types/generated/SponsorDashboardDTO';
|
|
|
|
/**
|
|
* Sponsor Dashboard View Model
|
|
*
|
|
* View model for sponsor dashboard data with UI-specific transformations.
|
|
*/
|
|
export class SponsorDashboardViewModel implements SponsorDashboardDTO {
|
|
sponsorId: string;
|
|
sponsorName: string;
|
|
|
|
constructor(dto: SponsorDashboardDTO) {
|
|
this.sponsorId = dto.sponsorId;
|
|
this.sponsorName = dto.sponsorName;
|
|
}
|
|
|
|
// Note: The generated DTO doesn't include these fields yet
|
|
// These will need to be added when the OpenAPI spec is updated
|
|
totalSponsorships: number = 0;
|
|
activeSponsorships: number = 0;
|
|
totalInvestment: number = 0;
|
|
|
|
/** UI-specific: Formatted total investment */
|
|
get formattedTotalInvestment(): string {
|
|
return `$${this.totalInvestment.toLocaleString()}`;
|
|
}
|
|
|
|
/** UI-specific: Active percentage */
|
|
get activePercentage(): number {
|
|
if (this.totalSponsorships === 0) return 0;
|
|
return Math.round((this.activeSponsorships / this.totalSponsorships) * 100);
|
|
}
|
|
|
|
/** UI-specific: Has sponsorships */
|
|
get hasSponsorships(): boolean {
|
|
return this.totalSponsorships > 0;
|
|
}
|
|
|
|
/** UI-specific: Status text */
|
|
get statusText(): string {
|
|
if (this.activeSponsorships === 0) return 'No active sponsorships';
|
|
if (this.activeSponsorships === this.totalSponsorships) return 'All sponsorships active';
|
|
return `${this.activeSponsorships} of ${this.totalSponsorships} active`;
|
|
}
|
|
} |