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
@@ -646,5 +646,5 @@ When('I click on a matchup', async function () {
Then('I should be on the match result entry page', async function () { Then('I should be on the match result entry page', async function () {
const currentUrl = world.page.url(); const currentUrl = world.page.url();
console.log(`🌍 Checking current URL: ${currentUrl}`); console.log(`🌍 Checking current URL: ${currentUrl}`);
expect(currentUrl).toMatch(/\/matches\/|\/admin\/tournaments\/\d+\/results/); expect(currentUrl).toMatch(/\/matches\/|\/admin\/tournaments\/\d+\/(entry|results)/);
}); });
+21 -1
View File
@@ -73,7 +73,7 @@ export default function TournamentEntryPage({ params }: { params: Promise<{ id:
const [team1Score, setTeam1Score] = useState("") const [team1Score, setTeam1Score] = useState("")
const [team2Score, setTeam2Score] = useState("") const [team2Score, setTeam2Score] = useState("")
// Parse params and validate tournamentId // Parse params and validate tournamentId, check for matchup query param
useEffect(() => { useEffect(() => {
async function parseParams() { async function parseParams() {
const { id } = await params const { id } = await params
@@ -87,6 +87,26 @@ export default function TournamentEntryPage({ params }: { params: Promise<{ id:
parseParams() parseParams()
}, [params, router]) }, [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 // Load tournament, schedule, and matches
useEffect(() => { useEffect(() => {
if (tournamentId) { if (tournamentId) {