some changes
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user