services refactor
This commit is contained in:
44
apps/website/lib/view-models/SponsorshipPricingViewModel.ts
Normal file
44
apps/website/lib/view-models/SponsorshipPricingViewModel.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import type { GetEntitySponsorshipPricingResultDto } from '../dtos';
|
||||
|
||||
/**
|
||||
* 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: GetEntitySponsorshipPricingResultDto) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user