Files
gridpilot.gg/apps/website/lib/view-models/SponsorshipRequestViewModel.ts
2026-01-24 01:07:43 +01:00

56 lines
1.7 KiB
TypeScript

import { ViewModel } from "../contracts/view-models/ViewModel";
import { CurrencyFormatter } from "../formatters/CurrencyFormatter";
import { DateFormatter } from "../formatters/DateFormatter";
import type { SponsorshipRequestViewData } from "../view-data/SponsorshipRequestViewData";
export class SponsorshipRequestViewModel extends ViewModel {
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(data: SponsorshipRequestViewData) {
super();
this.id = data.id;
this.sponsorId = data.sponsorId;
this.sponsorName = data.sponsorName;
this.sponsorLogo = data.sponsorLogo;
this.tier = data.tier;
this.offeredAmount = data.offeredAmount;
this.currency = data.currency;
this.formattedAmount = data.formattedAmount;
this.message = data.message;
this.createdAt = new Date(data.createdAt);
this.platformFee = data.platformFee;
this.netAmount = data.netAmount;
}
/** UI-specific: Formatted date */
get formattedDate(): string {
return DateFormatter.formatMonthDay(this.createdAt);
}
/** UI-specific: Net amount in dollars */
get netAmountDollars(): string {
return CurrencyFormatter.format(this.netAmount / 100, 'USD');
}
/** 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';
}
}