view data fixes
This commit is contained in:
@@ -1,26 +1,19 @@
|
||||
// Note: No generated DTO available for Sponsor yet
|
||||
interface SponsorDTO {
|
||||
id: string;
|
||||
name: string;
|
||||
logoUrl?: string;
|
||||
websiteUrl?: string;
|
||||
}
|
||||
|
||||
import { ViewModel } from "../contracts/view-models/ViewModel";
|
||||
import type { SponsorViewData } from "../view-data/SponsorViewData";
|
||||
|
||||
export class SponsorViewModel extends ViewModel {
|
||||
id: string;
|
||||
name: string;
|
||||
declare logoUrl?: string;
|
||||
declare websiteUrl?: string;
|
||||
private readonly data: SponsorViewData;
|
||||
|
||||
constructor(dto: SponsorDTO) {
|
||||
this.id = dto.id;
|
||||
this.name = dto.name;
|
||||
if (dto.logoUrl !== undefined) this.logoUrl = dto.logoUrl;
|
||||
if (dto.websiteUrl !== undefined) this.websiteUrl = dto.websiteUrl;
|
||||
constructor(data: SponsorViewData) {
|
||||
super();
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
get id(): string { return this.data.id; }
|
||||
get name(): string { return this.data.name; }
|
||||
get logoUrl(): string | undefined { return this.data.logoUrl; }
|
||||
get websiteUrl(): string | undefined { return this.data.websiteUrl; }
|
||||
|
||||
/** UI-specific: Display name */
|
||||
get displayName(): string {
|
||||
return this.name;
|
||||
@@ -35,4 +28,4 @@ export class SponsorViewModel extends ViewModel {
|
||||
get websiteLinkText(): string {
|
||||
return 'Visit Website';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user