Removed some ghost bracket, hidden rest match and better rendering and score submitting

This commit is contained in:
2026-02-23 01:04:27 +01:00 Verified
parent b152f6fd85
commit 0b3f857f50
5 changed files with 91 additions and 61 deletions
@@ -70,28 +70,10 @@ export default function BracketView({ matches, onMatchClick }) {
const renderRound = (list) => {
const rounds = {};
list.forEach(m => (rounds[m.round] = rounds[m.round] || []).push(m));
const roundKeys = Object.keys(rounds).sort((a, b) => Number(a) - Number(b));
let prevRoundMap = new Map();
return roundKeys.map((r, rIdx) => {
return roundKeys.map((r) => {
let matchesInRound = rounds[r];
if (rIdx === 0) {
matchesInRound.sort((a, b) => a.number - b.number);
} else {
matchesInRound.sort((a, b) => {
const getSourceAvg = (match) => {
const sources = list.filter(x => x.winner_next_match_id === match.id);
if (sources.length === 0) return 9999;
const indices = sources.map(s => prevRoundMap.get(s.id)).filter(i => i !== undefined);
if (indices.length === 0) return 9999;
return indices.reduce((sum, val) => sum + val, 0) / indices.length;
};
return getSourceAvg(a) - getSourceAvg(b);
});
}
matchesInRound.forEach((m, idx) => prevRoundMap.set(m.id, idx));
matchesInRound.sort((a, b) => a.number - b.number);
return (
<div key={r} className="flex flex-col gap-10 z-10 w-64 shrink-0 justify-around">
{matchesInRound.map(m => <MatchCard key={m.id} match={m} onClick={onMatchClick} />)}