import { ViewModel } from "../contracts/view-models/ViewModel"; import { CurrencyFormatter } from "../formatters/CurrencyFormatter"; import type { SponsorshipPricingViewData } from "../view-data/SponsorshipPricingViewData"; export class SponsorshipPricingViewModel extends ViewModel { mainSlotPrice: number; secondarySlotPrice: number; currency: string; constructor(data: SponsorshipPricingViewData) { super(); this.mainSlotPrice = data.mainSlotPrice; this.secondarySlotPrice = data.secondarySlotPrice; this.currency = data.currency; } /** UI-specific: Formatted main slot price */ get formattedMainSlotPrice(): string { return CurrencyFormatter.format(this.mainSlotPrice, this.currency); } /** UI-specific: Formatted secondary slot price */ get formattedSecondarySlotPrice(): string { return CurrencyFormatter.format(this.secondarySlotPrice, this.currency); } /** UI-specific: Price difference */ get priceDifference(): number { return this.mainSlotPrice - this.secondarySlotPrice; } /** UI-specific: Formatted price difference */ get formattedPriceDifference(): string { return CurrencyFormatter.format(this.priceDifference, this.currency); } /** 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); } }