move static data
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import type { CreateLeagueInputDTO } from '@/lib/types/generated/CreateLeagueInputDTO';
|
||||
import { LeagueWizardValidationMessages } from '@/lib/display-objects/LeagueWizardValidationMessages';
|
||||
import { ScoringPresetApplier } from '@/lib/utilities/ScoringPresetApplier';
|
||||
|
||||
export type WizardStep = 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
||||
|
||||
@@ -263,7 +262,7 @@ export class LeagueWizardCommandModel {
|
||||
patternId,
|
||||
customScoringEnabled: false,
|
||||
};
|
||||
this.timings = ScoringPresetApplier.applyToTimings(patternId, this.timings);
|
||||
// Timing defaults are applied by the UI using the selected preset's `defaultTimings` from the API.
|
||||
}
|
||||
|
||||
toCreateLeagueCommand(ownerId: string): CreateLeagueInputDTO {
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
import { ApplyPenaltyCommandDTO } from '../../types/generated/ApplyPenaltyCommandDTO';
|
||||
|
||||
export type PenaltyType = 'time_penalty' | 'grid_penalty' | 'points_deduction' | 'disqualification' | 'warning' | 'license_points';
|
||||
|
||||
export interface ProtestDecisionData {
|
||||
decision: 'uphold' | 'dismiss' | null;
|
||||
penaltyType: PenaltyType;
|
||||
penaltyValue: number;
|
||||
penaltyType: string;
|
||||
penaltyValue?: number;
|
||||
stewardNotes: string;
|
||||
}
|
||||
|
||||
const DEFAULT_PROTEST_REASON = 'Protest upheld';
|
||||
|
||||
export class ProtestDecisionCommandModel {
|
||||
decision: 'uphold' | 'dismiss' | null = null;
|
||||
penaltyType: PenaltyType = 'time_penalty';
|
||||
penaltyType: string = 'time_penalty';
|
||||
penaltyValue: number = 5;
|
||||
stewardNotes: string = '';
|
||||
|
||||
@@ -39,27 +35,37 @@ export class ProtestDecisionCommandModel {
|
||||
this.stewardNotes = '';
|
||||
}
|
||||
|
||||
toApplyPenaltyCommand(raceId: string, driverId: string, stewardId: string, protestId: string): ApplyPenaltyCommandDTO {
|
||||
const reason = this.decision === 'uphold'
|
||||
? DEFAULT_PROTEST_REASON
|
||||
: 'Protest dismissed';
|
||||
toApplyPenaltyCommand(
|
||||
raceId: string,
|
||||
driverId: string,
|
||||
stewardId: string,
|
||||
protestId: string,
|
||||
options?: {
|
||||
requiresValue?: boolean;
|
||||
defaultUpheldReason?: string;
|
||||
defaultDismissedReason?: string;
|
||||
},
|
||||
): ApplyPenaltyCommandDTO {
|
||||
const reason =
|
||||
this.decision === 'uphold'
|
||||
? (options?.defaultUpheldReason ?? 'Protest upheld')
|
||||
: (options?.defaultDismissedReason ?? 'Protest dismissed');
|
||||
|
||||
return {
|
||||
const base: ApplyPenaltyCommandDTO = {
|
||||
raceId,
|
||||
driverId,
|
||||
stewardId,
|
||||
enum: this.penaltyType, // Use penaltyType as enum
|
||||
enum: this.penaltyType,
|
||||
type: this.penaltyType,
|
||||
value: this.getPenaltyValue(),
|
||||
reason,
|
||||
protestId,
|
||||
notes: this.stewardNotes,
|
||||
};
|
||||
}
|
||||
|
||||
private getPenaltyValue(): number {
|
||||
// Some penalties don't require a value
|
||||
const penaltiesWithoutValue: PenaltyType[] = ['disqualification', 'warning'];
|
||||
return penaltiesWithoutValue.includes(this.penaltyType) ? 0 : this.penaltyValue;
|
||||
if (options?.requiresValue) {
|
||||
return { ...base, value: this.penaltyValue };
|
||||
}
|
||||
|
||||
return base;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user