wip
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import Button from '@/components/ui/Button';
|
||||
import Card from '@/components/ui/Card';
|
||||
import RaceCard from '@/components/alpha/RaceCard';
|
||||
@@ -12,12 +12,12 @@ import { getRaceRepository, getLeagueRepository } from '@/lib/di-container';
|
||||
|
||||
export default function RacesPage() {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const [races, setRaces] = useState<Race[]>([]);
|
||||
const [leagues, setLeagues] = useState<Map<string, League>>(new Map());
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [showScheduleForm, setShowScheduleForm] = useState(false);
|
||||
const [preselectedLeagueId, setPreselectedLeagueId] = useState<string | undefined>(undefined);
|
||||
|
||||
// Filters
|
||||
const [statusFilter, setStatusFilter] = useState<RaceStatus | 'all'>('all');
|
||||
@@ -48,6 +48,14 @@ export default function RacesPage() {
|
||||
|
||||
useEffect(() => {
|
||||
loadRaces();
|
||||
|
||||
try {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const leagueId = params.get('leagueId') || undefined;
|
||||
setPreselectedLeagueId(leagueId || undefined);
|
||||
} catch {
|
||||
setPreselectedLeagueId(undefined);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const filteredRaces = races.filter(race => {
|
||||
@@ -101,7 +109,7 @@ export default function RacesPage() {
|
||||
<Card>
|
||||
<h1 className="text-2xl font-bold text-white mb-6">Schedule New Race</h1>
|
||||
<ScheduleRaceForm
|
||||
preSelectedLeagueId={searchParams.get('leagueId') || undefined}
|
||||
preSelectedLeagueId={preselectedLeagueId}
|
||||
onSuccess={(race) => {
|
||||
router.push(`/races/${race.id}`);
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user