import type { SponsorshipRequestDTO } from '@/lib/types/generated/SponsorshipRequestDTO'; export class SponsorshipRequestViewModel { id: string; sponsorId: string; sponsorName: string; sponsorLogo?: string; tier: 'main' | 'secondary'; offeredAmount: number; currency: string; formattedAmount: string; message?: string; createdAt: Date; platformFee: number; netAmount: number; constructor(dto: SponsorshipRequestDTO) { this.id = dto.id; this.sponsorId = dto.sponsorId; this.sponsorName = dto.sponsorName; if (dto.sponsorLogo !== undefined) this.sponsorLogo = dto.sponsorLogo; // Backend currently returns tier as string; normalize to our supported tiers. this.tier = dto.tier === 'main' ? 'main' : 'secondary'; this.offeredAmount = dto.offeredAmount; this.currency = dto.currency; this.formattedAmount = dto.formattedAmount; if (dto.message !== undefined) this.message = dto.message; this.createdAt = new Date(dto.createdAt); this.platformFee = dto.platformFee; this.netAmount = dto.netAmount; } /** UI-specific: Formatted date */ get formattedDate(): string { return this.createdAt.toLocaleDateString('en-US', { month: 'short', day: 'numeric', }); } /** UI-specific: Net amount in dollars */ get netAmountDollars(): string { return `$${(this.netAmount / 100).toFixed(2)}`; } /** UI-specific: Tier display */ get tierDisplay(): string { return this.tier === 'main' ? 'Main Sponsor' : 'Secondary'; } /** UI-specific: Tier badge variant */ get tierBadgeVariant(): 'primary' | 'secondary' { return this.tier === 'main' ? 'primary' : 'secondary'; } }