"use client"; import * as React from "react"; import { cn } from "./lib/utils"; export interface BracketMatch { id: string; a: string; b: string; winner?: "a" | "b"; } export interface TournamentBracketProps extends React.HTMLAttributes { rounds?: BracketMatch[][]; } /** Tournament bracket: rounds of head to head match cards. */ export function TournamentBracket({ rounds, className, ...props }: TournamentBracketProps) { const fallback: BracketMatch[][] = [ [ { id: "q1", a: "ADA", b: "REX", winner: "a" }, { id: "q2", a: "ROW C", b: "MAX", winner: "b" }, ], [{ id: "f1", a: "ADA", b: "MAX" }], ]; const data = rounds ?? fallback; return (
{data.map((round, ri) => (

Round {ri + 1}

{round.map((m) => (
{([["a", m.a], ["b", m.b]] as const).map(([side, name]) => (
{name} {m.winner === side && ( W )}
))}
))}
))}
); }