51 lines
1.5 KiB
TypeScript
51 lines
1.5 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.
|
|
*/
|
|
import { ViewModel } from "../contracts/view-models/ViewModel";
|
|
|
|
export class SponsorshipPricingViewModel extends ViewModel {
|
|
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);
|
|
}
|
|
} |