view data fixes
This commit is contained in:
@@ -1,21 +1,18 @@
|
||||
import { RaceDetailEntryDTO } from '@/lib/types/generated/RaceDetailEntryDTO';
|
||||
|
||||
import { ViewModel } from "../contracts/view-models/ViewModel";
|
||||
import type { RaceDetailEntryViewData } from "../view-data/RaceDetailEntryViewData";
|
||||
|
||||
export class RaceDetailEntryViewModel extends ViewModel {
|
||||
id: string;
|
||||
name: string;
|
||||
country: string;
|
||||
avatarUrl: string;
|
||||
isCurrentUser: boolean;
|
||||
rating: number | null;
|
||||
private readonly data: RaceDetailEntryViewData;
|
||||
|
||||
constructor(dto: RaceDetailEntryDTO, currentDriverId: string, rating?: number) {
|
||||
this.id = dto.id;
|
||||
this.name = dto.name;
|
||||
this.country = dto.country;
|
||||
this.avatarUrl = dto.avatarUrl || '';
|
||||
this.isCurrentUser = dto.id === currentDriverId;
|
||||
this.rating = rating ?? null;
|
||||
constructor(data: RaceDetailEntryViewData) {
|
||||
super();
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
get id(): string { return this.data.id; }
|
||||
get name(): string { return this.data.name; }
|
||||
get country(): string { return this.data.country; }
|
||||
get avatarUrl(): string { return this.data.avatarUrl; }
|
||||
get isCurrentUser(): boolean { return this.data.isCurrentUser; }
|
||||
get rating(): number | null { return this.data.rating; }
|
||||
}
|
||||
Reference in New Issue
Block a user