view data fixes
This commit is contained in:
@@ -1,34 +1,27 @@
|
||||
interface UpcomingRaceCardDTO {
|
||||
id: string;
|
||||
track: string;
|
||||
car: string;
|
||||
scheduledAt: string;
|
||||
}
|
||||
import { ViewModel } from "../contracts/view-models/ViewModel";
|
||||
import { DateDisplay } from "../display-objects/DateDisplay";
|
||||
import type { UpcomingRaceCardViewData } from "../view-data/UpcomingRaceCardViewData";
|
||||
|
||||
/**
|
||||
* Upcoming race card view model
|
||||
* UI representation of an upcoming race on the landing page.
|
||||
*/
|
||||
import { ViewModel } from "../contracts/view-models/ViewModel";
|
||||
|
||||
export class UpcomingRaceCardViewModel extends ViewModel {
|
||||
readonly id: string;
|
||||
readonly track: string;
|
||||
readonly car: string;
|
||||
readonly scheduledAt: string;
|
||||
|
||||
constructor(dto: UpcomingRaceCardDTO) {
|
||||
this.id = dto.id;
|
||||
this.track = dto.track;
|
||||
this.car = dto.car;
|
||||
this.scheduledAt = dto.scheduledAt;
|
||||
constructor(data: UpcomingRaceCardViewData) {
|
||||
super();
|
||||
this.id = data.id;
|
||||
this.track = data.track;
|
||||
this.car = data.car;
|
||||
this.scheduledAt = data.scheduledAt;
|
||||
}
|
||||
|
||||
/** UI-specific: formatted date label */
|
||||
get formattedDate(): string {
|
||||
return new Date(this.scheduledAt).toLocaleDateString(undefined, {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
});
|
||||
return DateDisplay.formatMonthDay(this.scheduledAt);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user