resolve todos in website and api
This commit is contained in:
@@ -10,45 +10,64 @@ export class LeagueConfigPresenter implements Presenter<LeagueFullConfigOutputPo
|
||||
}
|
||||
|
||||
present(dto: LeagueFullConfigOutputPort) {
|
||||
// Map from LeagueFullConfigOutputPort to LeagueConfigFormModelDTO
|
||||
const league = dto.league;
|
||||
const settings = league.settings;
|
||||
const stewarding = settings.stewarding;
|
||||
const stewarding = dto.activeSeason?.stewardingConfig;
|
||||
const dropPolicy = dto.activeSeason?.dropPolicy;
|
||||
const schedule = dto.activeSeason?.schedule;
|
||||
const scoringConfig = dto.scoringConfig;
|
||||
|
||||
const visibility: 'public' | 'private' = 'public';
|
||||
|
||||
const championships = scoringConfig?.championships ?? [];
|
||||
|
||||
const firstChampionship = championships[0];
|
||||
const firstSessionType = firstChampionship?.sessionTypes[0];
|
||||
const firstPointsTable = firstSessionType
|
||||
? firstChampionship.pointsTableBySessionType[firstSessionType]
|
||||
: undefined;
|
||||
const pointsForWin = firstPointsTable?.getPointsForPosition(1) ?? 0;
|
||||
|
||||
const raceDayOfWeek = schedule?.startDate
|
||||
? schedule.startDate.toLocaleDateString('en-US', { weekday: 'long' }).toLowerCase()
|
||||
: 'sunday';
|
||||
const raceTimeHour = schedule?.timeOfDay?.hour ?? 20;
|
||||
const raceTimeMinute = schedule?.timeOfDay?.minute ?? 0;
|
||||
|
||||
this.result = {
|
||||
leagueId: league.id,
|
||||
basics: {
|
||||
name: league.name,
|
||||
description: league.description,
|
||||
visibility: 'public', // TODO: Map visibility from league
|
||||
visibility,
|
||||
},
|
||||
structure: {
|
||||
mode: 'solo', // TODO: Map from league settings
|
||||
mode: 'solo',
|
||||
},
|
||||
championships: [], // TODO: Map championships
|
||||
championships,
|
||||
scoring: {
|
||||
type: 'standard', // TODO: Map scoring type
|
||||
points: 25, // TODO: Map points
|
||||
type: settings.pointsSystem,
|
||||
points: pointsForWin,
|
||||
},
|
||||
dropPolicy: {
|
||||
strategy: 'none', // TODO: Map
|
||||
n: 0,
|
||||
strategy: dropPolicy?.strategy === 'none' ? 'none' : 'worst_n',
|
||||
n: dropPolicy?.n,
|
||||
},
|
||||
timings: {
|
||||
raceDayOfWeek: 'sunday', // TODO: Map from timings
|
||||
raceTimeHour: 20,
|
||||
raceTimeMinute: 0,
|
||||
raceDayOfWeek,
|
||||
raceTimeHour,
|
||||
raceTimeMinute,
|
||||
},
|
||||
stewarding: {
|
||||
decisionMode: stewarding?.decisionMode === 'steward_vote' ? 'committee_vote' : 'single_steward',
|
||||
requireDefense: stewarding?.requireDefense || false,
|
||||
defenseTimeLimit: stewarding?.defenseTimeLimit || 48,
|
||||
voteTimeLimit: stewarding?.voteTimeLimit || 72,
|
||||
protestDeadlineHours: stewarding?.protestDeadlineHours || 48,
|
||||
stewardingClosesHours: stewarding?.stewardingClosesHours || 168,
|
||||
notifyAccusedOnProtest: stewarding?.notifyAccusedOnProtest || true,
|
||||
notifyOnVoteRequired: stewarding?.notifyOnVoteRequired || true,
|
||||
requiredVotes: stewarding?.requiredVotes || 0,
|
||||
requireDefense: stewarding?.requireDefense ?? false,
|
||||
defenseTimeLimit: stewarding?.defenseTimeLimit ?? 48,
|
||||
voteTimeLimit: stewarding?.voteTimeLimit ?? 72,
|
||||
protestDeadlineHours: stewarding?.protestDeadlineHours ?? 48,
|
||||
stewardingClosesHours: stewarding?.stewardingClosesHours ?? 168,
|
||||
notifyAccusedOnProtest: stewarding?.notifyAccusedOnProtest ?? true,
|
||||
notifyOnVoteRequired: stewarding?.notifyOnVoteRequired ?? true,
|
||||
requiredVotes: stewarding?.requiredVotes,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user