more bracket refactoring again
This commit is contained in:
@@ -16,20 +16,14 @@ export const BracketRound: React.FC<BracketRoundProps> = ({
|
||||
getParentMatchOrder,
|
||||
onAnnounce,
|
||||
}) => {
|
||||
const isMatchType = (type: string, expected: string) => {
|
||||
return type?.toLowerCase() === expected.toLowerCase();
|
||||
};
|
||||
const isBye = (type: string) => type?.toLowerCase() === 'bye';
|
||||
|
||||
return (
|
||||
<Flex direction="column" key={roundIndex} gap={24} justify="space-around">
|
||||
{matches.map((match, matchIndex) => {
|
||||
if (!match) return null;
|
||||
|
||||
// Handle bye matches
|
||||
if (isMatchType(match.type, 'bye') || isMatchType(match.type, 'tbye')) {
|
||||
return <Flex key={matchIndex}></Flex>;
|
||||
}
|
||||
|
||||
if (isBye(match.type)) return <></>; // for spacing
|
||||
|
||||
return (
|
||||
<Flex
|
||||
direction="row"
|
||||
|
||||
@@ -13,7 +13,7 @@ interface BracketProps {
|
||||
const Bracket: React.FC<BracketProps> = ({ winners, losers, bracketMaps }) => {
|
||||
const height = useAppShellHeight();
|
||||
|
||||
if (!bracketMaps) return <p>Data not available.</p>
|
||||
if (!bracketMaps) return <p>Bracket not available.</p>
|
||||
|
||||
return (
|
||||
<ScrollArea
|
||||
|
||||
@@ -34,13 +34,13 @@ export const MatchCard: React.FC<MatchCardProps> = ({
|
||||
{match.reset && (
|
||||
<Text
|
||||
pos="absolute"
|
||||
top={-8}
|
||||
top={-20}
|
||||
left={8}
|
||||
size="xs"
|
||||
c="orange"
|
||||
c="dimmed"
|
||||
fw="bold"
|
||||
>
|
||||
IF NECESSARY
|
||||
* If necessary
|
||||
</Text>
|
||||
)}
|
||||
|
||||
|
||||
@@ -1,17 +1,4 @@
|
||||
interface Match {
|
||||
lid: number;
|
||||
round: number;
|
||||
order: number | null;
|
||||
type: string;
|
||||
home: any;
|
||||
away?: any;
|
||||
reset?: boolean;
|
||||
}
|
||||
|
||||
interface BracketData {
|
||||
winners: Match[][];
|
||||
losers: Match[][];
|
||||
}
|
||||
import { BracketData, Match } from "../types";
|
||||
|
||||
export interface BracketMaps {
|
||||
matchByLid: Map<number, Match>;
|
||||
|
||||
Reference in New Issue
Block a user