some changes

This commit is contained in:
yohlo
2025-09-11 13:35:33 -05:00
parent c74da09bde
commit 22be6682dd
18 changed files with 113 additions and 68 deletions

View File

@@ -1,16 +1,16 @@
import React, { useCallback, useMemo } from "react";
import React, { useMemo } from "react";
import { Text, ScrollArea } from "@mantine/core";
import { MatchCard } from "./match-card";
import { BracketData } from "../types";
import { Bracket } from "./bracket";
import useAppShellHeight from "@/hooks/use-appshell-height";
import { Match } from "@/features/matches/types";
interface BracketViewProps {
bracket: BracketData;
onAnnounce?: (teamOne: any, teamTwo: any) => void;
onStartMatch?: (match: Match) => void;
}
const BracketView: React.FC<BracketViewProps> = ({ bracket, onAnnounce }) => {
const BracketView: React.FC<BracketViewProps> = ({ bracket, onStartMatch }) => {
const height = useAppShellHeight();
const orders = useMemo(() => {
const map: Record<number, number> = {};
@@ -32,14 +32,14 @@ const BracketView: React.FC<BracketViewProps> = ({ bracket, onAnnounce }) => {
<Text fw={600} size="md" m={16}>
Winners Bracket
</Text>
<Bracket rounds={bracket.winners} orders={orders} onAnnounce={onAnnounce} />
<Bracket rounds={bracket.winners} orders={orders} onStartMatch={onStartMatch} />
</div>
{bracket.losers && (
<div>
<Text fw={600} size="md" m={16}>
Losers Bracket
</Text>
<Bracket rounds={bracket.losers} orders={orders} onAnnounce={onAnnounce} />
<Bracket rounds={bracket.losers} orders={orders} onStartMatch={onStartMatch} />
</div>
)}
</ScrollArea>

View File

@@ -5,13 +5,13 @@ import { MatchCard } from "./match-card";
interface BracketProps {
rounds: Match[][];
orders: Record<number, number>;
onAnnounce?: (teamOne: any, teamTwo: any) => void;
onStartMatch?: (match: Match) => void;
}
export const Bracket: React.FC<BracketProps> = ({
rounds,
orders,
onAnnounce,
onStartMatch,
}) => {
return (
<Flex direction="row" gap={24} justify="left" p="xl">
@@ -32,7 +32,7 @@ export const Bracket: React.FC<BracketProps> = ({
<MatchCard
match={match}
orders={orders}
onAnnounce={onAnnounce}
onStartMatch={onStartMatch}
/>
</div>
);

View File

@@ -7,13 +7,13 @@ import { Match } from "@/features/matches/types";
interface MatchCardProps {
match: Match;
orders: Record<number, number>;
onAnnounce?: (teamOne: any, teamTwo: any) => void;
onStartMatch?: (match: Match) => void;
}
export const MatchCard: React.FC<MatchCardProps> = ({
match,
orders,
onAnnounce,
onStartMatch,
}) => {
const homeSlot = useMemo(
() => ({
@@ -35,13 +35,13 @@ export const MatchCard: React.FC<MatchCardProps> = ({
);
const showToolbar = useMemo(
() => match.home && match.away && onAnnounce,
() => match.home && match.away && onStartMatch,
[match.home, match.away]
);
const handleAnnounce = useCallback(
() => onAnnounce?.(match.home, match.away),
[onAnnounce, match.home, match.away]
() => onStartMatch?.(match),
[onStartMatch, match]
);
const handleEdit = useCallback(() => {