fix: FINNALY FIXED AND COMPILABLE

This commit is contained in:
2026-06-24 11:37:56 +01:00
parent e9555c9f74
commit 426c1c50a0
13 changed files with 56 additions and 62 deletions
+2 -2
View File
@@ -4,7 +4,7 @@
import { query } from '@/lib/db'; import { query } from '@/lib/db';
import { LiveDotIcon } from '@/components/ui/icons'; import { LiveDotIcon } from '@/components/ui/icons';
import DashboardClient from '@/components/dashboard/DashboardClient'; import DashboardClient from '@/components/dashboard/DashboardClient';
import { Driver, DriverServerRow } from '@/types/racing'; import { DashboardDriver } from '@/components/dashboard/DashboardClient';
export const dynamic = "force-dynamic"; export const dynamic = "force-dynamic";
async function getConnectedDrivers() { async function getConnectedDrivers() {
@@ -37,7 +37,7 @@ async function getConnectedDrivers() {
const rows = await query(sql); const rows = await query(sql);
const drivers: Driver[] = rows.map((row: DriverServerRow) => ({ const drivers: DashboardDriver[] = rows.map((row: any) => ({
driver_guid: row.driver_guid, driver_guid: row.driver_guid,
driver_name: row.driver_name, driver_name: row.driver_name,
driver_team: row.driver_team, driver_team: row.driver_team,
+18 -17
View File
@@ -2,15 +2,15 @@
// Event detail page with registration form // Event detail page with registration form
import { query } from '@/lib/db'; import { query } from '@/lib/db';
import { Event, EventRegistration } from '@/types/racing'; import { EventWithRegistrations, EventRegistrationWithDriver } from '@/types/racing';
import { notFound } from 'next/navigation'; import { notFound } from 'next/navigation';
import { TrophyIcon, MapPinIcon, UsersIcon, ClockIcon, CalendarIcon } from '@/components/ui/icons'; import { TrophyIcon, MapPinIcon, UsersIcon, ClockIcon, CalendarIcon } from '@/components/ui/icons';
import EventRegistrationForm from '@/components/events/EventRegistrationForm'; import EventRegistrationForm from '@/components/events/EventRegistrationForm';
import EventResultClient from '@/components/events/EventResultsClient'; import EventResultsClient, { TeamStanding } from '@/components/events/EventResultsClient';
export const dynamic = "force-dynamic"; export const dynamic = "force-dynamic";
async function getEventResults(eventId: number) { async function getEventResults(eventId: number): Promise<{ event: Event | null; standings: TeamStanding[] }> {
if (eventId == undefined) { if (eventId == undefined) {
return { event: null, standings: [] }; return { event: null, standings: [] };
@@ -27,7 +27,7 @@ async function getEventResults(eventId: number) {
WHERE event_id = $1 WHERE event_id = $1
`; `;
const events = await query(eventSql, [String(eventId)]); const events = await query(eventSql, [String(eventId)]);
const event = events[0]; const event = (events[0] as Event) ?? null;
// Get team standings with driver details // Get team standings with driver details
const standingsSql = ` const standingsSql = `
@@ -58,11 +58,11 @@ async function getEventResults(eventId: number) {
const standings = await query(standingsSql, [eventId]); const standings = await query(standingsSql, [eventId]);
return { event, standings }; return { event, standings: standings as TeamStanding[] };
} }
async function getEvent(eventId: number): Promise<Event | null> { async function getEvent(eventId: number): Promise<EventWithRegistrations | null> {
const sql = ` const sql = `
SELECT e.*, COUNT(er.registration_id) as registrations_count SELECT e.*, COUNT(er.registration_id) as registrations_count
FROM events e FROM events e
@@ -72,10 +72,10 @@ async function getEvent(eventId: number): Promise<Event | null> {
`; `;
const rows = await query(sql, [eventId]); const rows = await query(sql, [eventId]);
return rows.length > 0 ? rows[0] as Event : null; return rows.length > 0 ? rows[0] as EventWithRegistrations : null;
} }
async function getEventRegistrations(eventId: number): Promise<EventRegistration[]> { async function getEventRegistrations(eventId: number): Promise<EventRegistrationWithDriver[]> {
const sql = ` const sql = `
SELECT SELECT
er.*, er.*,
@@ -87,7 +87,7 @@ async function getEventRegistrations(eventId: number): Promise<EventRegistration
`; `;
const rows = await query(sql, [eventId]); const rows = await query(sql, [eventId]);
return rows as EventRegistration[]; return rows as EventRegistrationWithDriver[];
} }
function formatDate(date: Date): string { function formatDate(date: Date): string {
@@ -104,19 +104,20 @@ function formatDate(date: Date): string {
export default async function EventDetailPage({ export default async function EventDetailPage({
params, params,
}: { }: {
params: Promise<{ event_id: number }>; params: Promise<{ event_id: string }>;
}) { }) {
const { event_id } = await params; const { event_id } = await params;
const event: unknown = await getEvent(event_id); const eventId = parseInt(event_id, 10);
const event = await getEvent(eventId);
if (!event) { if (!event) {
notFound(); notFound();
} }
const registrations = await getEventRegistrations(event_id); const registrations = await getEventRegistrations(eventId);
// Fetch initial event results/standings // Fetch initial event results/standings
const { standings } = await getEventResults(event_id); const { standings } = await getEventResults(eventId);
const isOpen = event.event_status === 'OPEN'; const isOpen = event.event_status === 'OPEN';
@@ -176,8 +177,8 @@ export default async function EventDetailPage({
{event.event_status === 'CLOSED' && !isFull && !deadlinePassed && 'Registration is closed for this event.'} {event.event_status === 'CLOSED' && !isFull && !deadlinePassed && 'Registration is closed for this event.'}
</p> </p>
<div className="mt-6"> <div className="mt-6">
<EventResultClient <EventResultsClient
eventId={event_id} eventId={eventId}
initialStandings={standings} initialStandings={standings}
/> />
</div> </div>
@@ -205,11 +206,11 @@ export default async function EventDetailPage({
{registrations.length === 0 ? ( {registrations.length === 0 ? (
<p className="text-white/40 text-sm">No registrations yet</p> <p className="text-white/40 text-sm">No registrations yet</p>
) : ( ) : (
registrations.map((reg: unknown, index: number) => ( registrations.map((reg, index) => (
<div key={reg.registration_id} className="border border-white/10 p-3"> <div key={reg.registration_id} className="border border-white/10 p-3">
<div className="flex items-start justify-between mb-2"> <div className="flex items-start justify-between mb-2">
<div className="flex items-center space-x-2"> <div className="flex items-center space-x-2">
<span className="text-xs font-bold text-white/40"> <span className="text-xs font-bold text-white/41">
#{String(index + 1).padStart(2, '0')} #{String(index + 1).padStart(2, '0')}
</span> </span>
<span className="font-semibold text-sm">{reg.driver_name}</span> <span className="font-semibold text-sm">{reg.driver_name}</span>
+8 -7
View File
@@ -4,10 +4,11 @@
import { query } from '@/lib/db'; import { query } from '@/lib/db';
import Link from 'next/link'; import Link from 'next/link';
import EventResultsClient from '@/components/events/EventResultsClient'; import EventResultsClient from '@/components/events/EventResultsClient';
import { Event } from '@/types/racing';
export const dynamic = "force-dynamic"; export const dynamic = "force-dynamic";
async function getEventResults(eventId: number) { async function getEventResults(eventId: string) {
if (eventId == undefined) { if (eventId == undefined) {
return { event: null, standings: [] }; return { event: null, standings: [] };
@@ -23,8 +24,8 @@ async function getEventResults(eventId: number) {
FROM events FROM events
WHERE event_id = $1 WHERE event_id = $1
`; `;
const events = await query(eventSql, [String(eventId)]); const events = await query(eventSql, [eventId]);
const event = events[0]; const event = (events[0] as Event) ?? null;
// Get team standings with driver details // Get team standings with driver details
const standingsSql = ` const standingsSql = `
@@ -55,20 +56,20 @@ async function getEventResults(eventId: number) {
const standings = await query(standingsSql, [eventId]); const standings = await query(standingsSql, [eventId]);
return { event, standings }; return { event, standings: standings as any[] };
} }
export default async function EventResultsPage({ export default async function EventResultsPage({
params, params,
}: { }: {
params: Promise<{ event_id: number }>; params: Promise<{ event_id: string }>;
}) { }) {
const { event_id } = await params; const { event_id } = await params;
const eventId = parseInt(event_id, 10);
console.log('Fetching results for event ID:', event_id); console.log('Fetching results for event ID:', event_id);
const { event, standings } = await getEventResults(event_id); const { event, standings } = await getEventResults(event_id);
if (!event) { if (!event) {
return ( return (
<div className="max-w-7xl mx-auto px-6 py-16"> <div className="max-w-7xl mx-auto px-6 py-16">
@@ -110,7 +111,7 @@ export default async function EventResultsPage({
{/* Team Championship Standings */} {/* Team Championship Standings */}
<div className="max-w-7xl mx-auto px-6 py-12"> <div className="max-w-7xl mx-auto px-6 py-12">
<EventResultsClient <EventResultsClient
eventId={event_id} eventId={eventId}
initialStandings={standings} initialStandings={standings}
/> />
+4 -4
View File
@@ -2,13 +2,13 @@
// Events listing page // Events listing page
import { query } from '@/lib/db'; import { query } from '@/lib/db';
import { Event } from '@/types/racing'; import { EventWithRegistrations } from '@/types/racing';
import Link from 'next/link'; import Link from 'next/link';
import Image from "next/image"; import Image from "next/image";
import { TrophyIcon, UsersIcon, MapPinIcon, ClockIcon, CalendarIcon } from '@/components/ui/icons'; import { TrophyIcon, UsersIcon, MapPinIcon, ClockIcon, CalendarIcon } from '@/components/ui/icons';
export const dynamic = "force-dynamic"; export const dynamic = "force-dynamic";
async function getEvents(): Promise<Event[]> { async function getEvents(): Promise<EventWithRegistrations[]> {
const sql = ` const sql = `
SELECT SELECT
e.*, e.*,
@@ -21,7 +21,7 @@ async function getEvents(): Promise<Event[]> {
`; `;
const rows = await query(sql); const rows = await query(sql);
return rows as Event[]; return rows as EventWithRegistrations[];
} }
function formatDate(date: Date): string { function formatDate(date: Date): string {
@@ -67,7 +67,7 @@ export default async function EventsPage() {
<p className="text-white/20 text-sm mt-2">Check back soon for new racing events</p> <p className="text-white/20 text-sm mt-2">Check back soon for new racing events</p>
</div> </div>
) : ( ) : (
events.map((event: unknown) => { events.map((event) => {
const isOpen = event.event_status === 'OPEN'; const isOpen = event.event_status === 'OPEN';
const isFull = event.registrations_count >= event.max_participants; const isFull = event.registrations_count >= event.max_participants;
const deadlinePassed = event.registration_deadline && new Date(event.registration_deadline) < new Date(); const deadlinePassed = event.registration_deadline && new Date(event.registration_deadline) < new Date();
+2 -2
View File
@@ -32,7 +32,7 @@ async function getLiveData(): Promise<LiveData[]> {
// For each server, get connected cars with their positions // For each server, get connected cars with their positions
const liveData = await Promise.all( const liveData = await Promise.all(
servers.map(async (server: unknown) => { servers.map(async (server: any) => {
const carsSql = ` const carsSql = `
SELECT SELECT
u.driver_guid, u.driver_guid,
@@ -47,7 +47,7 @@ async function getLiveData(): Promise<LiveData[]> {
const cars = await query(carsSql, [server.server_id]); const cars = await query(carsSql, [server.server_id]);
// Add mock data for positions (real data will come from telemetry stream) // Add mock data for positions (real data will come from telemetry stream)
const carsWithPositions = cars.map((car: unknown, index: number) => ({ const carsWithPositions = cars.map((car: any, index: number) => ({
...car, ...car,
carID: index, carID: index,
position: index + 1, position: index + 1,
+3 -15
View File
@@ -112,19 +112,7 @@ export default function MusicPage() {
}; };
useEffect(() => { useEffect(() => {
let active = true; fetchTracks();
const run = async () => {
const data = await fetchTracks();
if (!active) return;
setTracks(data);
};
void run();
return () => {
active = false;
};
}, [isPlaying]); }, [isPlaying]);
// Group tracks by theme // Group tracks by theme
@@ -349,7 +337,7 @@ export default function MusicPage() {
<div className="border border-white/10 bg-black overflow-hidden"> <div className="border border-white/10 bg-black overflow-hidden">
{isVideo ? ( {isVideo ? (
<video <video
ref={mediaRef as unknown} ref={mediaRef as React.RefObject<HTMLVideoElement>}
onTimeUpdate={handleTimeUpdate} onTimeUpdate={handleTimeUpdate}
onEnded={nextTrack} onEnded={nextTrack}
onPlay={() => setIsPlaying(true)} onPlay={() => setIsPlaying(true)}
@@ -390,7 +378,7 @@ export default function MusicPage() {
{/* Audio element (hidden) */} {/* Audio element (hidden) */}
<audio <audio
ref={mediaRef as unknown} ref={mediaRef as React.RefObject<HTMLAudioElement>}
onTimeUpdate={handleTimeUpdate} onTimeUpdate={handleTimeUpdate}
onEnded={nextTrack} onEnded={nextTrack}
onPlay={() => setIsPlaying(true)} onPlay={() => setIsPlaying(true)}
+3 -3
View File
@@ -26,9 +26,9 @@ async function getStats() {
`); `);
return { return {
driversOnline: driversOnline[0]?.count || 0, driversOnline: (driversOnline[0] as { count: number })?.count || 0,
totalDrivers: totalDrivers[0]?.count || 0, totalDrivers: (totalDrivers[0] as { count: number })?.count || 0,
activeServers: activeServers[0]?.count || 0, activeServers: (activeServers[0] as { count: number })?.count || 0,
}; };
} }
+3 -3
View File
@@ -44,8 +44,8 @@ async function getFilterOptions(): Promise<FilterOptions> {
const cars = await query(carsQuery); const cars = await query(carsQuery);
return { return {
teams: teams.map((t: unknown) => t.driver_team), teams: teams.map((t: any) => t.driver_team),
carModels: cars.map((c: unknown) => c.car_model) carModels: cars.map((c: any) => c.car_model)
}; };
} }
@@ -100,7 +100,7 @@ async function getRankings(
// Get total count // Get total count
const countResult = await query(`SELECT COUNT(*) as count FROM users ${whereClause}`); const countResult = await query(`SELECT COUNT(*) as count FROM users ${whereClause}`);
const totalCount = countResult[0]?.count || 0; const totalCount = (countResult[0] as { count: number })?.count || 0;
// Get paginated results // Get paginated results
const sql = ` const sql = `
+4 -4
View File
@@ -5,7 +5,7 @@ import { useEffect, useState } from 'react';
import { UsersIcon, ServerIcon, ActivityIcon, MapPinIcon, FlagIcon, LiveDotIcon, ClockIcon } from '@/components/ui/icons'; import { UsersIcon, ServerIcon, ActivityIcon, MapPinIcon, FlagIcon, LiveDotIcon, ClockIcon } from '@/components/ui/icons';
import { cleanTrackName, cleanTrackConfig } from '@/lib/trackUtils'; import { cleanTrackName, cleanTrackConfig } from '@/lib/trackUtils';
interface Driver { export interface DashboardDriver {
driver_guid: string; driver_guid: string;
driver_name: string; driver_name: string;
driver_team: string; driver_team: string;
@@ -59,8 +59,8 @@ function formatElapsedTime(ms: number): string {
return `${minutes}:${String(seconds).padStart(2, '0')}`; return `${minutes}:${String(seconds).padStart(2, '0')}`;
} }
export default function DashboardClient({ initialDrivers }: { initialDrivers: Driver[] }) { export default function DashboardClient({ initialDrivers }: { initialDrivers: DashboardDriver[] }) {
const [drivers, setDrivers] = useState<Driver[]>(initialDrivers); const [drivers, setDrivers] = useState<DashboardDriver[]>(initialDrivers);
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
// Auto-refresh every 3 seconds // Auto-refresh every 3 seconds
@@ -90,7 +90,7 @@ export default function DashboardClient({ initialDrivers }: { initialDrivers: Dr
} }
acc[serverId].push(driver); acc[serverId].push(driver);
return acc; return acc;
}, {} as Record<number, Driver[]>); }, {} as Record<number, DashboardDriver[]>);
return ( return (
<> <>
+1 -1
View File
@@ -67,7 +67,7 @@ export default function EventRegistrationForm({ eventId }: { eventId: number })
setTimeout(() => { setTimeout(() => {
router.refresh(); router.refresh();
}, 1500); }, 1500);
} catch (err: unknown) { } catch (err: any) {
setError(err.message); setError(err.message);
} finally { } finally {
setLoading(false); setLoading(false);
+2 -2
View File
@@ -4,7 +4,7 @@
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { TrophyIcon, UsersIcon, FlagIcon } from '@/components/ui/icons'; import { TrophyIcon, UsersIcon, FlagIcon } from '@/components/ui/icons';
interface TeamStanding { export interface TeamStanding {
team_id: number; team_id: number;
team_name: string; team_name: string;
total_points: number; total_points: number;
@@ -111,7 +111,7 @@ export default function EventResultsClient({
{/* Driver Results */} {/* Driver Results */}
<div className="border-t border-white/10 pt-4 mt-4"> <div className="border-t border-white/10 pt-4 mt-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-3"> <div className="grid grid-cols-1 md:grid-cols-2 gap-3">
{team.drivers.map((driver: unknown) => ( {team.drivers.map((driver: any) => (
<div <div
key={driver.driver_guid} key={driver.driver_guid}
className="flex items-center justify-between p-3 bg-black/30 border border-white/5" className="flex items-center justify-between p-3 bg-black/30 border border-white/5"
+1 -1
View File
@@ -13,7 +13,7 @@ interface LiveSessionClientProps {
serverTrack: string; serverTrack: string;
serverConfig: string; serverConfig: string;
connectedPlayers: number; connectedPlayers: number;
initialCars: unknown[]; initialCars: any[];
} }
export default function LiveSessionClient({ export default function LiveSessionClient({
+4
View File
@@ -132,6 +132,10 @@ export interface EventRegistration {
notes: string | null; notes: string | null;
} }
export interface EventRegistrationWithDriver extends EventRegistration {
driver_name: string;
}
export interface EventWithRegistrations extends Event { export interface EventWithRegistrations extends Event {
registrations_count: number; registrations_count: number;
user_registered?: boolean; user_registered?: boolean;