Files
gridpilot.gg/apps/website/lib/view-models/SponsorshipPricingViewModel.ts
2025-12-18 00:08:47 +01:00

49 lines
1.4 KiB
TypeScript

// Note: No generated DTO available for SponsorshipPricing yet
interface SponsorshipPricingDTO {
mainSlotPrice: number;
secondarySlotPrice: number;
currency: string;
}
/**
* Sponsorship Pricing View Model
*
* View model for sponsorship pricing data with UI-specific transformations.
*/
export class SponsorshipPricingViewModel {
mainSlotPrice: number;
secondarySlotPrice: number;
currency: string;
constructor(dto: SponsorshipPricingDTO) {
this.mainSlotPrice = dto.mainSlotPrice;
this.secondarySlotPrice = dto.secondarySlotPrice;
this.currency = dto.currency;
}
/** UI-specific: Formatted main slot price */
get formattedMainSlotPrice(): string {
return `${this.currency} ${this.mainSlotPrice.toLocaleString()}`;
}
/** UI-specific: Formatted secondary slot price */
get formattedSecondarySlotPrice(): string {
return `${this.currency} ${this.secondarySlotPrice.toLocaleString()}`;
}
/** UI-specific: Price difference */
get priceDifference(): number {
return this.mainSlotPrice - this.secondarySlotPrice;
}
/** UI-specific: Formatted price difference */
get formattedPriceDifference(): string {
return `${this.currency} ${this.priceDifference.toLocaleString()}`;
}
/** UI-specific: Discount percentage for secondary slot */
get secondaryDiscountPercentage(): number {
if (this.mainSlotPrice === 0) return 0;
return Math.round((1 - this.secondarySlotPrice / this.mainSlotPrice) * 100);
}
}