Removed some ghost bracket, hidden rest match and better rendering and score submitting
This commit is contained in:
@@ -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} />)}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// frontend/src/components/Tournament/ScoreModal.jsx
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { Eraser, Clock, MapPin, Trophy } from 'lucide-react';
|
||||
import { stringToColor } from '../../utils/helpers';
|
||||
import { Clock, Eraser, MapPin, Trophy } from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
import Modal from '../UI/Modal';
|
||||
|
||||
const ScoreForm = ({ match, isAdmin, onSubmit, onClear }) => {
|
||||
|
||||
Reference in New Issue
Block a user