diff --git a/e2e/cucumber/step-definitions/common-steps.ts b/e2e/cucumber/step-definitions/common-steps.ts index 8164b2d..c10d7e9 100644 --- a/e2e/cucumber/step-definitions/common-steps.ts +++ b/e2e/cucumber/step-definitions/common-steps.ts @@ -646,5 +646,5 @@ When('I click on a matchup', async function () { Then('I should be on the match result entry page', async function () { const currentUrl = world.page.url(); console.log(`🌍 Checking current URL: ${currentUrl}`); - expect(currentUrl).toMatch(/\/matches\/|\/admin\/tournaments\/\d+\/results/); + expect(currentUrl).toMatch(/\/matches\/|\/admin\/tournaments\/\d+\/(entry|results)/); }); diff --git a/src/app/admin/tournaments/[id]/entry/page.tsx b/src/app/admin/tournaments/[id]/entry/page.tsx index 4d637b8..9a8ba48 100644 --- a/src/app/admin/tournaments/[id]/entry/page.tsx +++ b/src/app/admin/tournaments/[id]/entry/page.tsx @@ -73,7 +73,7 @@ export default function TournamentEntryPage({ params }: { params: Promise<{ id: const [team1Score, setTeam1Score] = useState("") const [team2Score, setTeam2Score] = useState("") - // Parse params and validate tournamentId + // Parse params and validate tournamentId, check for matchup query param useEffect(() => { async function parseParams() { const { id } = await params @@ -87,6 +87,26 @@ export default function TournamentEntryPage({ params }: { params: Promise<{ id: parseParams() }, [params, router]) + // Handle pre-selection of matchup from query param + useEffect(() => { + if (schedule && selectedMatchupId === null) { + const searchParams = new URLSearchParams(window.location.search) + const matchupIdParam = searchParams.get('matchup') + if (matchupIdParam) { + const matchupId = parseInt(matchupIdParam, 10) + // Find which round contains this matchup + for (const round of schedule.rounds) { + const matchup = round.matchups.find(m => m.id === matchupId) + if (matchup) { + setSelectedRoundId(round.id) + setSelectedMatchupId(matchupId) + break + } + } + } + } + }, [schedule, selectedMatchupId]) + // Load tournament, schedule, and matches useEffect(() => { if (tournamentId) {