api client refactor
This commit is contained in:
41
apps/website/lib/view-models/SponsorshipDetailViewModel.ts
Normal file
41
apps/website/lib/view-models/SponsorshipDetailViewModel.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { SponsorshipDetailDto } from '../dtos';
|
||||
|
||||
export class SponsorshipDetailViewModel implements SponsorshipDetailDto {
|
||||
id: string;
|
||||
leagueId: string;
|
||||
leagueName: string;
|
||||
seasonId: string;
|
||||
tier: 'main' | 'secondary';
|
||||
status: string;
|
||||
amount: number;
|
||||
currency: string;
|
||||
|
||||
constructor(dto: SponsorshipDetailDto) {
|
||||
Object.assign(this, dto);
|
||||
}
|
||||
|
||||
/** UI-specific: Formatted amount */
|
||||
get formattedAmount(): string {
|
||||
return `${this.currency} ${this.amount.toLocaleString()}`;
|
||||
}
|
||||
|
||||
/** UI-specific: Tier badge variant */
|
||||
get tierBadgeVariant(): string {
|
||||
return this.tier === 'main' ? 'primary' : 'secondary';
|
||||
}
|
||||
|
||||
/** UI-specific: Status color */
|
||||
get statusColor(): string {
|
||||
switch (this.status) {
|
||||
case 'active': return 'green';
|
||||
case 'pending': return 'yellow';
|
||||
case 'expired': return 'red';
|
||||
default: return 'gray';
|
||||
}
|
||||
}
|
||||
|
||||
/** UI-specific: Status display */
|
||||
get statusDisplay(): string {
|
||||
return this.status.charAt(0).toUpperCase() + this.status.slice(1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user