view data fixes

This commit is contained in:
2026-01-23 15:30:23 +01:00
parent e22033be38
commit f8099f04bc
213 changed files with 3466 additions and 3003 deletions

View File

@@ -1,6 +1,7 @@
import type { SponsorshipRequestDTO } from '@/lib/types/generated/SponsorshipRequestDTO';
import { ViewModel } from "../contracts/view-models/ViewModel";
import { CurrencyDisplay } from "../display-objects/CurrencyDisplay";
import { DateDisplay } from "../display-objects/DateDisplay";
import type { SponsorshipRequestViewData } from "../view-data/SponsorshipRequestViewData";
export class SponsorshipRequestViewModel extends ViewModel {
id: string;
@@ -16,33 +17,30 @@ export class SponsorshipRequestViewModel extends ViewModel {
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;
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 this.createdAt.toLocaleDateString('en-US', {
month: 'short',
day: 'numeric',
});
return DateDisplay.formatMonthDay(this.createdAt);
}
/** UI-specific: Net amount in dollars */
get netAmountDollars(): string {
return `$${(this.netAmount / 100).toFixed(2)}`;
return CurrencyDisplay.format(this.netAmount / 100, 'USD');
}
/** UI-specific: Tier display */