wip
This commit is contained in:
@@ -17,11 +17,11 @@ import {
|
||||
getRaceRepository,
|
||||
getLeagueRepository,
|
||||
getDriverRepository,
|
||||
getGetRaceRegistrationsQuery,
|
||||
getIsDriverRegisteredForRaceQuery,
|
||||
getGetRaceRegistrationsUseCase,
|
||||
getIsDriverRegisteredForRaceUseCase,
|
||||
getRegisterForRaceUseCase,
|
||||
getWithdrawFromRaceUseCase,
|
||||
getGetRaceWithSOFQuery,
|
||||
getGetRaceWithSOFUseCase,
|
||||
getResultRepository,
|
||||
getImageService,
|
||||
} from '@/lib/di-container';
|
||||
@@ -80,7 +80,7 @@ export default function RaceDetailPage() {
|
||||
try {
|
||||
const raceRepo = getRaceRepository();
|
||||
const leagueRepo = getLeagueRepository();
|
||||
const raceWithSOFQuery = getGetRaceWithSOFQuery();
|
||||
const raceWithSOFUseCase = getGetRaceWithSOFUseCase();
|
||||
|
||||
const raceData = await raceRepo.findById(raceId);
|
||||
|
||||
@@ -92,10 +92,11 @@ export default function RaceDetailPage() {
|
||||
|
||||
setRace(raceData);
|
||||
|
||||
// Load race with SOF from application query
|
||||
const raceWithSOF = await raceWithSOFQuery.execute({ raceId });
|
||||
if (raceWithSOF) {
|
||||
setRaceSOF(raceWithSOF.strengthOfField);
|
||||
// Load race with SOF from application use case
|
||||
await raceWithSOFUseCase.execute({ raceId });
|
||||
const raceViewModel = raceWithSOFUseCase.presenter.getViewModel();
|
||||
if (raceViewModel) {
|
||||
setRaceSOF(raceViewModel.strengthOfField);
|
||||
}
|
||||
|
||||
// Load league data
|
||||
@@ -135,8 +136,10 @@ export default function RaceDetailPage() {
|
||||
try {
|
||||
const driverRepo = getDriverRepository();
|
||||
|
||||
const raceRegistrationsQuery = getGetRaceRegistrationsQuery();
|
||||
const registeredDriverIds = await raceRegistrationsQuery.execute({ raceId });
|
||||
const raceRegistrationsUseCase = getGetRaceRegistrationsUseCase();
|
||||
await raceRegistrationsUseCase.execute({ raceId });
|
||||
const registrationsViewModel = raceRegistrationsUseCase.presenter.getViewModel();
|
||||
const registeredDriverIds = registrationsViewModel.registeredDriverIds;
|
||||
|
||||
const drivers = await Promise.all(
|
||||
registeredDriverIds.map((id: string) => driverRepo.findById(id)),
|
||||
@@ -144,12 +147,13 @@ export default function RaceDetailPage() {
|
||||
const validDrivers = drivers.filter((d: Driver | null): d is Driver => d !== null);
|
||||
setEntryList(validDrivers);
|
||||
|
||||
const isRegisteredQuery = getIsDriverRegisteredForRaceQuery();
|
||||
const userIsRegistered = await isRegisteredQuery.execute({
|
||||
const isRegisteredUseCase = getIsDriverRegisteredForRaceUseCase();
|
||||
await isRegisteredUseCase.execute({
|
||||
raceId,
|
||||
driverId: currentDriverId,
|
||||
});
|
||||
setIsUserRegistered(userIsRegistered);
|
||||
const registrationViewModel = isRegisteredUseCase.presenter.getViewModel();
|
||||
setIsUserRegistered(registrationViewModel.isRegistered);
|
||||
|
||||
const membership = getMembership(leagueId, currentDriverId);
|
||||
const isUpcoming = race?.status === 'scheduled';
|
||||
|
||||
@@ -18,8 +18,8 @@ import {
|
||||
getResultRepository,
|
||||
getStandingRepository,
|
||||
getDriverRepository,
|
||||
getGetRaceWithSOFQuery,
|
||||
getGetRacePenaltiesQuery,
|
||||
getGetRaceWithSOFUseCase,
|
||||
getGetRacePenaltiesUseCase,
|
||||
} from '@/lib/di-container';
|
||||
|
||||
interface PenaltyData {
|
||||
@@ -52,7 +52,7 @@ export default function RaceResultsPage() {
|
||||
const leagueRepo = getLeagueRepository();
|
||||
const resultRepo = getResultRepository();
|
||||
const driverRepo = getDriverRepository();
|
||||
const raceWithSOFQuery = getGetRaceWithSOFQuery();
|
||||
const raceWithSOFUseCase = getGetRaceWithSOFUseCase();
|
||||
|
||||
const raceData = await raceRepo.findById(raceId);
|
||||
|
||||
@@ -64,10 +64,11 @@ export default function RaceResultsPage() {
|
||||
|
||||
setRace(raceData);
|
||||
|
||||
// Load race with SOF from application query
|
||||
const raceWithSOF = await raceWithSOFQuery.execute({ raceId });
|
||||
if (raceWithSOF) {
|
||||
setRaceSOF(raceWithSOF.strengthOfField);
|
||||
// Load race with SOF from application use case
|
||||
await raceWithSOFUseCase.execute({ raceId });
|
||||
const raceViewModel = raceWithSOFUseCase.presenter.getViewModel();
|
||||
if (raceViewModel) {
|
||||
setRaceSOF(raceViewModel.strengthOfField);
|
||||
}
|
||||
|
||||
// Load league data
|
||||
@@ -89,10 +90,11 @@ export default function RaceResultsPage() {
|
||||
|
||||
// Load penalties for this race
|
||||
try {
|
||||
const penaltiesQuery = getGetRacePenaltiesQuery();
|
||||
const penaltiesData = await penaltiesQuery.execute(raceId);
|
||||
const penaltiesUseCase = getGetRacePenaltiesUseCase();
|
||||
await penaltiesUseCase.execute(raceId);
|
||||
const penaltiesViewModel = penaltiesUseCase.presenter.getViewModel();
|
||||
// Map the DTO to the PenaltyData interface expected by ResultsTable
|
||||
setPenalties(penaltiesData.map(p => ({
|
||||
setPenalties(penaltiesViewModel.map(p => ({
|
||||
driverId: p.driverId,
|
||||
type: p.type,
|
||||
value: p.value,
|
||||
|
||||
Reference in New Issue
Block a user