restarting brackets

This commit is contained in:
yohlo
2025-09-03 21:57:47 -05:00
parent 1a21171ae8
commit 2f6950ee9e
20 changed files with 307 additions and 230 deletions

View File

@@ -1,46 +0,0 @@
import { Flex } from '@mantine/core';
import React, { useCallback } from 'react';
import { BracketMaps } from '../utils/bracket-maps';
import { BracketRound } from './bracket-round';
import { Match } from '../types';
interface BracketViewProps {
bracket: Match[][];
bracketMaps: BracketMaps;
onAnnounce?: (teamOne: any, teamTwo: any) => void;
}
const BracketView: React.FC<BracketViewProps> = ({
bracket,
bracketMaps,
onAnnounce,
}) => {
const getParentMatchOrder = useCallback((parentLid: number): number | string => {
const parentMatch = bracketMaps.matchByLid.get(parentLid);
if (
parentMatch &&
parentMatch.order !== null &&
parentMatch.order !== undefined
) {
return parentMatch.order;
}
return `Match ${parentLid}`;
}, [bracketMaps]);
return (
<Flex direction="row" gap={24} justify="left" pos="relative" p="xl">
{bracket.map((round, roundIndex) => (
<BracketRound
key={roundIndex}
matches={round}
roundIndex={roundIndex}
getParentMatchOrder={getParentMatchOrder}
onAnnounce={onAnnounce}
/>
))}
</Flex>
);
};
export default BracketView;