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