view data fixes
This commit is contained in:
@@ -1,19 +1,6 @@
|
||||
import type { LeagueConfigFormModel } from '@/lib/types/LeagueConfigFormModel';
|
||||
import type { LeagueScoringPresetViewModel } from '@/lib/view-models/LeagueScoringPresetViewModel';
|
||||
|
||||
export interface CustomPointsConfig {
|
||||
racePoints: number[];
|
||||
poleBonusPoints: number;
|
||||
fastestLapPoints: number;
|
||||
leaderLapPoints: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* ScoringConfigurationViewModel
|
||||
*
|
||||
* View model for scoring configuration including presets and custom points
|
||||
*/
|
||||
import { ViewModel } from "../contracts/view-models/ViewModel";
|
||||
import { LeagueScoringPresetViewModel } from './LeagueScoringPresetViewModel';
|
||||
import type { ScoringConfigurationViewData, CustomPointsConfig } from "../view-data/ScoringConfigurationViewData";
|
||||
|
||||
export class ScoringConfigurationViewModel extends ViewModel {
|
||||
readonly patternId?: string;
|
||||
@@ -21,16 +8,13 @@ export class ScoringConfigurationViewModel extends ViewModel {
|
||||
readonly customPoints?: CustomPointsConfig;
|
||||
readonly currentPreset?: LeagueScoringPresetViewModel;
|
||||
|
||||
constructor(
|
||||
config: LeagueConfigFormModel['scoring'],
|
||||
presets: LeagueScoringPresetViewModel[],
|
||||
customPoints?: CustomPointsConfig
|
||||
) {
|
||||
this.patternId = config.patternId;
|
||||
this.customScoringEnabled = config.customScoringEnabled || false;
|
||||
this.customPoints = customPoints;
|
||||
this.currentPreset = config.patternId
|
||||
? presets.find(p => p.id === config.patternId)
|
||||
constructor(data: ScoringConfigurationViewData) {
|
||||
super();
|
||||
this.patternId = data.config.patternId;
|
||||
this.customScoringEnabled = data.config.customScoringEnabled || false;
|
||||
this.customPoints = data.customPoints;
|
||||
this.currentPreset = data.config.patternId
|
||||
? new LeagueScoringPresetViewModel(data.presets.find(p => p.id === data.config.patternId)!)
|
||||
: undefined;
|
||||
}
|
||||
|
||||
@@ -49,4 +33,4 @@ export class ScoringConfigurationViewModel extends ViewModel {
|
||||
leaderLapPoints: 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user