website cleanup

This commit is contained in:
2025-12-24 21:44:58 +01:00
parent 9b683a59d3
commit d78854a4c6
277 changed files with 6141 additions and 2693 deletions

View File

@@ -3,7 +3,9 @@
import { useState } from 'react';
import Modal from '@/components/ui/Modal';
import Button from '@/components/ui/Button';
import type { ProtestIncident } from '@core/racing/domain/entities/Protest';
import type { FileProtestCommandDTO } from '@/lib/types/generated/FileProtestCommandDTO';
import type { ProtestIncidentDTO } from '@/lib/types/generated/ProtestIncidentDTO';
import { useServices } from '@/lib/services/ServiceProvider';
import {
AlertTriangle,
Video,
@@ -37,6 +39,7 @@ export default function FileProtestModal({
protestingDriverId,
participants,
}: FileProtestModalProps) {
const { raceService } = useServices();
const [step, setStep] = useState<'form' | 'submitting' | 'success' | 'error'>('form');
const [errorMessage, setErrorMessage] = useState<string | null>(null);
@@ -69,14 +72,10 @@ export default function FileProtestModal({
setErrorMessage(null);
try {
const useCase = getFileProtestUseCase();
const incident: ProtestIncident = {
const incident: ProtestIncidentDTO = {
lap: parseInt(lap, 10),
description: description.trim(),
...(timeInRace
? { timeInRace: parseInt(timeInRace, 10) }
: {}),
...(timeInRace ? { timeInRace: parseInt(timeInRace, 10) } : {}),
};
const command = {
@@ -84,15 +83,11 @@ export default function FileProtestModal({
protestingDriverId,
accusedDriverId,
incident,
...(comment.trim()
? { comment: comment.trim() }
: {}),
...(proofVideoUrl.trim()
? { proofVideoUrl: proofVideoUrl.trim() }
: {}),
};
...(comment.trim() ? { comment: comment.trim() } : {}),
...(proofVideoUrl.trim() ? { proofVideoUrl: proofVideoUrl.trim() } : {}),
} satisfies FileProtestCommandDTO;
await useCase.execute(command);
await raceService.fileProtest(command);
setStep('success');
} catch (err) {
@@ -290,4 +285,4 @@ export default function FileProtestModal({
</div>
</Modal>
);
}
}

View File

@@ -1,8 +1,15 @@
import Card from '@/components/ui/Card';
import type { RaceWithResultsDTO } from '@core/testing-support';
type RaceWithResults = {
raceId: string;
track: string;
car: string;
winnerName: string;
scheduledAt: string | Date;
};
interface LatestResultsSidebarProps {
results: RaceWithResultsDTO[];
results: RaceWithResults[];
}
export default function LatestResultsSidebar({ results }: LatestResultsSidebarProps) {
@@ -14,7 +21,10 @@ export default function LatestResultsSidebar({ results }: LatestResultsSidebarPr
<Card className="bg-iron-gray/80">
<h3 className="text-sm font-semibold text-white mb-3">Latest results</h3>
<ul className="space-y-3">
{results.slice(0, 4).map(result => (
{results.slice(0, 4).map((result) => {
const scheduledAt = typeof result.scheduledAt === 'string' ? new Date(result.scheduledAt) : result.scheduledAt;
return (
<li key={result.raceId} className="flex items-start justify-between gap-3 text-xs">
<div className="flex-1 min-w-0">
<p className="text-white truncate">{result.track}</p>
@@ -23,14 +33,15 @@ export default function LatestResultsSidebar({ results }: LatestResultsSidebarPr
</p>
</div>
<div className="text-right text-gray-500 whitespace-nowrap">
{result.scheduledAt.toLocaleDateString(undefined, {
{scheduledAt.toLocaleDateString(undefined, {
month: 'short',
day: 'numeric'
})}
</div>
</li>
))}
);
})}
</ul>
</Card>
);
}
}

View File

@@ -1,9 +1,15 @@
import type { Race } from '@core/racing/domain/entities/Race';
import Card from '@/components/ui/Card';
import Button from '@/components/ui/Button';
type UpcomingRace = {
id: string;
track: string;
car: string;
scheduledAt: string | Date;
};
interface UpcomingRacesSidebarProps {
races: Race[];
races: UpcomingRace[];
}
export default function UpcomingRacesSidebar({ races }: UpcomingRacesSidebarProps) {
@@ -25,21 +31,25 @@ export default function UpcomingRacesSidebar({ races }: UpcomingRacesSidebarProp
</Button>
</div>
<ul className="space-y-3">
{races.slice(0, 4).map(race => (
{races.slice(0, 4).map((race) => {
const scheduledAt = typeof race.scheduledAt === 'string' ? new Date(race.scheduledAt) : race.scheduledAt;
return (
<li key={race.id} className="flex items-start justify-between gap-3 text-xs">
<div className="flex-1 min-w-0">
<p className="text-white truncate">{race.track}</p>
<p className="text-gray-400 truncate">{race.car}</p>
</div>
<div className="text-right text-gray-500 whitespace-nowrap">
{race.scheduledAt.toLocaleDateString(undefined, {
{scheduledAt.toLocaleDateString(undefined, {
month: 'short',
day: 'numeric'
})}
</div>
</li>
))}
);
})}
</ul>
</Card>
);
}
}