view models
This commit is contained in:
@@ -1,15 +1,31 @@
|
||||
import { RaceDetailDto, RaceDetailRaceDto, RaceDetailLeagueDto, RaceDetailEntryDto, RaceDetailRegistrationDto, RaceDetailUserResultDto } from '../dtos';
|
||||
import { RaceDetailRaceDTO } from '../types/generated/RaceDetailRaceDTO';
|
||||
import { RaceDetailLeagueDTO } from '../types/generated/RaceDetailLeagueDTO';
|
||||
import { RaceDetailEntryDTO } from '../types/generated/RaceDetailEntryDTO';
|
||||
import { RaceDetailRegistrationDTO } from '../types/generated/RaceDetailRegistrationDTO';
|
||||
import { RaceDetailUserResultDTO } from '../types/generated/RaceDetailUserResultDTO';
|
||||
|
||||
export class RaceDetailViewModel implements RaceDetailDto {
|
||||
race: RaceDetailRaceDto | null;
|
||||
league: RaceDetailLeagueDto | null;
|
||||
entryList: RaceDetailEntryDto[];
|
||||
registration: RaceDetailRegistrationDto;
|
||||
userResult: RaceDetailUserResultDto | null;
|
||||
export class RaceDetailViewModel {
|
||||
race: RaceDetailRaceDTO | null;
|
||||
league: RaceDetailLeagueDTO | null;
|
||||
entryList: RaceDetailEntryDTO[];
|
||||
registration: RaceDetailRegistrationDTO;
|
||||
userResult: RaceDetailUserResultDTO | null;
|
||||
error?: string;
|
||||
|
||||
constructor(dto: RaceDetailDto) {
|
||||
Object.assign(this, dto);
|
||||
constructor(dto: {
|
||||
race: RaceDetailRaceDTO | null;
|
||||
league: RaceDetailLeagueDTO | null;
|
||||
entryList: RaceDetailEntryDTO[];
|
||||
registration: RaceDetailRegistrationDTO;
|
||||
userResult: RaceDetailUserResultDTO | null;
|
||||
error?: string;
|
||||
}) {
|
||||
this.race = dto.race;
|
||||
this.league = dto.league;
|
||||
this.entryList = dto.entryList;
|
||||
this.registration = dto.registration;
|
||||
this.userResult = dto.userResult;
|
||||
this.error = dto.error;
|
||||
}
|
||||
|
||||
/** UI-specific: Whether user is registered */
|
||||
@@ -35,7 +51,7 @@ export class RaceDetailViewModel implements RaceDetailDto {
|
||||
|
||||
/** UI-specific: Formatted scheduled time */
|
||||
get formattedScheduledTime(): string {
|
||||
return this.race ? new Date(this.race.scheduledTime).toLocaleString() : '';
|
||||
return this.race ? new Date(this.race.scheduledAt).toLocaleString() : '';
|
||||
}
|
||||
|
||||
/** UI-specific: Entry list count */
|
||||
|
||||
Reference in New Issue
Block a user