wip
This commit is contained in:
@@ -11,6 +11,7 @@ import { Race } from '@gridpilot/racing/domain/entities/Race';
|
||||
import { League } from '@gridpilot/racing/domain/entities/League';
|
||||
import { Result } from '@gridpilot/racing/domain/entities/Result';
|
||||
import { Driver } from '@gridpilot/racing/domain/entities/Driver';
|
||||
import type { PenaltyType } from '@gridpilot/racing/domain/entities/Penalty';
|
||||
import {
|
||||
getRaceRepository,
|
||||
getLeagueRepository,
|
||||
@@ -18,7 +19,14 @@ import {
|
||||
getStandingRepository,
|
||||
getDriverRepository,
|
||||
getGetRaceWithSOFQuery,
|
||||
getGetRacePenaltiesQuery,
|
||||
} from '@/lib/di-container';
|
||||
|
||||
interface PenaltyData {
|
||||
driverId: string;
|
||||
type: PenaltyType;
|
||||
value?: number;
|
||||
}
|
||||
import { ArrowLeft, Zap, Trophy, Users, Clock, Calendar } from 'lucide-react';
|
||||
|
||||
export default function RaceResultsPage() {
|
||||
@@ -30,7 +38,9 @@ export default function RaceResultsPage() {
|
||||
const [league, setLeague] = useState<League | null>(null);
|
||||
const [results, setResults] = useState<Result[]>([]);
|
||||
const [drivers, setDrivers] = useState<Driver[]>([]);
|
||||
const [currentDriverId, setCurrentDriverId] = useState<string | undefined>(undefined);
|
||||
const [raceSOF, setRaceSOF] = useState<number | null>(null);
|
||||
const [penalties, setPenalties] = useState<PenaltyData[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [importing, setImporting] = useState(false);
|
||||
@@ -71,6 +81,26 @@ export default function RaceResultsPage() {
|
||||
// Load drivers
|
||||
const driversData = await driverRepo.findAll();
|
||||
setDrivers(driversData);
|
||||
|
||||
// Get current driver (first driver in demo mode)
|
||||
if (driversData.length > 0) {
|
||||
setCurrentDriverId(driversData[0].id);
|
||||
}
|
||||
|
||||
// Load penalties for this race
|
||||
try {
|
||||
const penaltiesQuery = getGetRacePenaltiesQuery();
|
||||
const penaltiesData = await penaltiesQuery.execute(raceId);
|
||||
// Map the DTO to the PenaltyData interface expected by ResultsTable
|
||||
setPenalties(penaltiesData.map(p => ({
|
||||
driverId: p.driverId,
|
||||
type: p.type,
|
||||
value: p.value,
|
||||
})));
|
||||
} catch (penaltyErr) {
|
||||
console.error('Failed to load penalties:', penaltyErr);
|
||||
// Don't fail the whole page if penalties fail to load
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to load race data');
|
||||
} finally {
|
||||
@@ -268,6 +298,8 @@ export default function RaceResultsPage() {
|
||||
drivers={drivers}
|
||||
pointsSystem={getPointsSystem()}
|
||||
fastestLapTime={getFastestLapTime()}
|
||||
penalties={penalties}
|
||||
currentDriverId={currentDriverId}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user