import { CurrencyDisplay } from '../display-objects/CurrencyDisplay'; import { DateDisplay } from '../display-objects/DateDisplay'; import { NumberDisplay } from '../display-objects/NumberDisplay'; /** * Interface for sponsorship data input */ export interface SponsorshipDataInput { id: string; type: 'leagues' | 'teams' | 'drivers' | 'races' | 'platform'; entityId: string; entityName: string; tier?: 'main' | 'secondary'; status: 'active' | 'pending_approval' | 'approved' | 'rejected' | 'expired'; applicationDate?: string | Date; approvalDate?: string | Date; rejectionReason?: string; startDate: string | Date; endDate: string | Date; price: number; impressions: number; impressionsChange?: number; engagement?: number; details?: string; entityOwner?: string; applicationMessage?: string; } /** * Sponsorship View Model * * View model for individual sponsorship data. */ export class SponsorshipViewModel { id: string; type: 'leagues' | 'teams' | 'drivers' | 'races' | 'platform'; entityId: string; entityName: string; tier?: 'main' | 'secondary'; status: 'active' | 'pending_approval' | 'approved' | 'rejected' | 'expired'; applicationDate?: Date; approvalDate?: Date; rejectionReason?: string; startDate: Date; endDate: Date; price: number; impressions: number; impressionsChange?: number; engagement?: number; details?: string; entityOwner?: string; applicationMessage?: string; constructor(data: SponsorshipDataInput) { this.id = data.id; this.type = data.type; this.entityId = data.entityId; this.entityName = data.entityName; this.tier = data.tier; this.status = data.status; this.applicationDate = data.applicationDate ? new Date(data.applicationDate) : undefined; this.approvalDate = data.approvalDate ? new Date(data.approvalDate) : undefined; this.rejectionReason = data.rejectionReason; this.startDate = new Date(data.startDate); this.endDate = new Date(data.endDate); this.price = data.price; this.impressions = data.impressions; this.impressionsChange = data.impressionsChange; this.engagement = data.engagement; this.details = data.details; this.entityOwner = data.entityOwner; this.applicationMessage = data.applicationMessage; } get formattedImpressions(): string { return NumberDisplay.format(this.impressions); } get formattedPrice(): string { return CurrencyDisplay.format(this.price); } get daysRemaining(): number { const now = new Date(); const diffTime = this.endDate.getTime() - now.getTime(); return Math.ceil(diffTime / (1000 * 60 * 60 * 24)); } get isExpiringSoon(): boolean { return this.daysRemaining > 0 && this.daysRemaining <= 30; } get statusLabel(): string { const labels = { active: 'Active', pending_approval: 'Awaiting Approval', approved: 'Approved', rejected: 'Declined', expired: 'Expired', }; return labels[this.status] || this.status; } get typeLabel(): string { const labels = { leagues: 'League', teams: 'Team', drivers: 'Driver', races: 'Race', platform: 'Platform', }; return labels[this.type] || this.type; } get periodDisplay(): string { const start = DateDisplay.formatMonthYear(this.startDate); const end = DateDisplay.formatMonthYear(this.endDate); return `${start} - ${end}`; } }