This commit is contained in:
2025-12-10 18:28:32 +01:00
parent 6d61be9c51
commit 1303a14493
108 changed files with 3366 additions and 1559 deletions

View File

@@ -25,10 +25,10 @@ import {
getLeagueRepository,
getRaceRepository,
getDriverRepository,
getGetLeagueScoringConfigQuery,
getGetLeagueScoringConfigUseCase,
getDriverStats,
getAllDriverRankings,
getGetLeagueStatsQuery,
getGetLeagueStatsUseCase,
getSeasonRepository,
getSponsorRepository,
getSeasonSponsorshipRepository,
@@ -104,7 +104,7 @@ export default function LeagueDetailPage() {
const leagueRepo = getLeagueRepository();
const raceRepo = getRaceRepository();
const driverRepo = getDriverRepository();
const leagueStatsQuery = getGetLeagueStatsQuery();
const leagueStatsUseCase = getGetLeagueStatsUseCase();
const seasonRepo = getSeasonRepository();
const sponsorRepo = getSponsorRepository();
const sponsorshipRepo = getSeasonSponsorshipRepository();
@@ -124,9 +124,10 @@ export default function LeagueDetailPage() {
setOwner(ownerData);
// Load scoring configuration for the active season
const getLeagueScoringConfigQuery = getGetLeagueScoringConfigQuery();
const scoring = await getLeagueScoringConfigQuery.execute({ leagueId });
setScoringConfig(scoring);
const getLeagueScoringConfigUseCase = getGetLeagueScoringConfigUseCase();
await getLeagueScoringConfigUseCase.execute({ leagueId });
const scoringViewModel = getLeagueScoringConfigUseCase.presenter.getViewModel();
setScoringConfig(scoringViewModel);
// Load all drivers for standings and map to DTOs for UI components
const allDrivers = await driverRepo.findAll();
@@ -136,11 +137,12 @@ export default function LeagueDetailPage() {
setDrivers(driverDtos);
// Load league stats including average SOF from application query
const leagueStats = await leagueStatsQuery.execute({ leagueId });
if (leagueStats) {
setAverageSOF(leagueStats.averageSOF);
setCompletedRacesCount(leagueStats.completedRaces);
// Load league stats including average SOF from application use case
await leagueStatsUseCase.execute({ leagueId });
const leagueStatsViewModel = leagueStatsUseCase.presenter.getViewModel();
if (leagueStatsViewModel) {
setAverageSOF(leagueStatsViewModel.averageSOF);
setCompletedRacesCount(leagueStatsViewModel.completedRaces);
} else {
// Fallback: count completed races manually
const leagueRaces = await raceRepo.findByLeagueId(leagueId);

View File

@@ -5,7 +5,7 @@ import { useParams } from 'next/navigation';
import Card from '@/components/ui/Card';
import {
getLeagueRepository,
getGetLeagueScoringConfigQuery
getGetLeagueScoringConfigUseCase
} from '@/lib/di-container';
import type { LeagueScoringConfigDTO } from '@gridpilot/racing/application/dto/LeagueScoringConfigDTO';
import type { League } from '@gridpilot/racing/domain/entities/League';
@@ -25,7 +25,7 @@ export default function LeagueRulebookPage() {
async function loadData() {
try {
const leagueRepo = getLeagueRepository();
const scoringQuery = getGetLeagueScoringConfigQuery();
const scoringUseCase = getGetLeagueScoringConfigUseCase();
const leagueData = await leagueRepo.findById(leagueId);
if (!leagueData) {
@@ -35,8 +35,9 @@ export default function LeagueRulebookPage() {
setLeague(leagueData);
const scoring = await scoringQuery.execute({ leagueId });
setScoringConfig(scoring);
await scoringUseCase.execute({ leagueId });
const scoringViewModel = scoringUseCase.presenter.getViewModel();
setScoringConfig(scoringViewModel);
} catch (err) {
console.error('Failed to load scoring config:', err);
} finally {

View File

@@ -7,11 +7,11 @@ import Button from '@/components/ui/Button';
import {
getLeagueRepository,
getDriverRepository,
getGetLeagueFullConfigQuery,
getGetLeagueFullConfigUseCase,
getLeagueMembershipRepository,
getDriverStats,
getAllDriverRankings,
getListLeagueScoringPresetsQuery,
getListLeagueScoringPresetsUseCase,
getTransferLeagueOwnershipUseCase
} from '@/lib/di-container';
import { useEffectiveDriverId } from '@/lib/currentDriver';
@@ -59,8 +59,8 @@ export default function LeagueSettingsPage() {
try {
const leagueRepo = getLeagueRepository();
const driverRepo = getDriverRepository();
const query = getGetLeagueFullConfigQuery();
const presetsQuery = getListLeagueScoringPresetsQuery();
const useCase = getGetLeagueFullConfigUseCase();
const presetsUseCase = getListLeagueScoringPresetsUseCase();
const leagueData = await leagueRepo.findById(leagueId);
if (!leagueData) {
@@ -70,11 +70,13 @@ export default function LeagueSettingsPage() {
setLeague(leagueData);
const form = await query.execute({ leagueId });
setConfigForm(form);
await useCase.execute({ leagueId });
const configViewModel = useCase.presenter.getViewModel();
setConfigForm(configViewModel);
const presetsData = await presetsQuery.execute();
setPresets(presetsData);
await presetsUseCase.execute();
const presetsViewModel = presetsUseCase.presenter.getViewModel();
setPresets(presetsViewModel);
const entity = await driverRepo.findById(leagueData.ownerId);
if (entity) {

View File

@@ -10,7 +10,7 @@ import {
type LeagueDriverSeasonStatsDTO,
} from '@gridpilot/racing';
import {
getGetLeagueDriverSeasonStatsQuery,
getGetLeagueDriverSeasonStatsUseCase,
getDriverRepository,
getLeagueMembershipRepository
} from '@/lib/di-container';
@@ -32,12 +32,13 @@ export default function LeagueStandingsPage() {
const loadData = useCallback(async () => {
try {
const getLeagueDriverSeasonStatsQuery = getGetLeagueDriverSeasonStatsQuery();
const getLeagueDriverSeasonStatsUseCase = getGetLeagueDriverSeasonStatsUseCase();
const driverRepo = getDriverRepository();
const membershipRepo = getLeagueMembershipRepository();
const leagueStandings = await getLeagueDriverSeasonStatsQuery.execute({ leagueId });
setStandings(leagueStandings);
await getLeagueDriverSeasonStatsUseCase.execute({ leagueId });
const standingsViewModel = getLeagueDriverSeasonStatsUseCase.presenter.getViewModel();
setStandings(standingsViewModel);
const allDrivers = await driverRepo.findAll();
const driverDtos: DriverDTO[] = allDrivers

View File

@@ -31,7 +31,7 @@ import Card from '@/components/ui/Card';
import Input from '@/components/ui/Input';
import Heading from '@/components/ui/Heading';
import type { LeagueSummaryDTO } from '@gridpilot/racing/application/dto/LeagueSummaryDTO';
import { getGetAllLeaguesWithCapacityAndScoringQuery } from '@/lib/di-container';
import { getGetAllLeaguesWithCapacityAndScoringUseCase } from '@/lib/di-container';
// ============================================================================
// TYPES
@@ -389,9 +389,10 @@ export default function LeaguesPage() {
const loadLeagues = async () => {
try {
const query = getGetAllLeaguesWithCapacityAndScoringQuery();
const allLeagues = await query.execute();
setRealLeagues(allLeagues);
const useCase = getGetAllLeaguesWithCapacityAndScoringUseCase();
await useCase.execute();
const viewModel = useCase.presenter.getViewModel();
setRealLeagues(viewModel);
} catch (error) {
console.error('Failed to load leagues:', error);
} finally {