fix: support matchup query param for direct navigation to entry page
Pull Request / unit-tests (pull_request) Successful in 1m36s
Pull Request / e2e-tests (pull_request) Failing after 2m44s
Pull Request / analyze-bump-type (pull_request) Has been skipped

- Add useEffect to parse 'matchup' query parameter and pre-select matchup
- Update test pattern to accept /entry route for match result entry
- This enables clicking on a matchup in schedule view to directly navigate to entry page
This commit is contained in:
2026-05-01 16:43:40 -07:00
parent 4794588034
commit 4977043003
2 changed files with 22 additions and 2 deletions
+21 -1
View File
@@ -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) {