some changes

This commit is contained in:
yohlo
2025-09-11 13:35:33 -05:00
parent c74da09bde
commit 22be6682dd
18 changed files with 113 additions and 68 deletions

View File

@@ -39,30 +39,24 @@ function RouteComponent() {
if (!tournament.matches || tournament.matches.length === 0) {
return { winners: [], losers: [] }
}
console.log('Tournament Matches:', tournament.matches)
const winnersMap = new Map<number, Match[]>()
const losersMap = new Map<number, Match[]>()
tournament.matches.sort((a, b) => a.lid - b.lid).forEach((match) => {
console.log('Processing Match:', match)
if (!match.is_losers_bracket) {
if (!winnersMap.has(match.round)) {
winnersMap.set(match.round, [])
}
winnersMap.get(match.round)!.push(match)
console.log('Added to Winners Bracket:', match)
} else {
if (!losersMap.has(match.round)) {
losersMap.set(match.round, [])
}
losersMap.get(match.round)!.push(match)
console.log('Added to Losers Bracket:', match)
}
})
// Convert to dense arrays sorted by round (0, 1, 2, 3...)
const winners = Array.from(winnersMap.entries())
.sort(([a], [b]) => a - b)
.map(([, matches]) => matches)
@@ -70,15 +64,10 @@ function RouteComponent() {
const losers = Array.from(losersMap.entries())
.sort(([a], [b]) => a - b)
.map(([, matches]) => matches)
console.log('Winners Bracket (fixed):', winners)
console.log('Losers Bracket (fixed):', losers)
return { winners, losers }
}, [tournament.matches])
console.log('Bracket Data:', bracket)
const handleSuccess = () => {
router.navigate({
to: '/admin/tournaments/$id',
@@ -86,13 +75,15 @@ function RouteComponent() {
})
}
console.log('Tournament:', tournament)
const handleStartMatch = (match: Match) => {
}
return (
<Container size="md">
{
tournament.matches?.length ?
<BracketView bracket={bracket} onAnnounce={console.log} />
<BracketView bracket={bracket} onStartMatch={console.log} />
: (
<SeedTournament
tournamentId={tournament.id}