sendou.ink/app/features/tournament-bracket/components/Bracket/RoundHeader.tsx
Kalle eae3d529e2
Bracket component rewrite (#1653)
* Remove old code

* Add prefetching

* Elim bracket initial

* Hide rounds with only byes

* Round hiding logic

* Align stuff

* Add TODO

* Adjustments

* Deadline

* Compactify button

* Simulations

* Round robin bracket initial

* eventId -> tournamentId

* seedByTeamId removed

* Couple more TODOs

* RR placements table

* Locking matches

* Extract TournamentStream component

* Bracket streams

* Remove extras for tournament-manager, misc

* Fix E2E tests

* Fix SKALOP_SYSTEM_MESSAGE_URL in env.example

* TODOs

* TODO moved to GitHub

* Handle team changing in match cache invalidation

* Fix streamer seeing undo last score button

* Show "Sub" badge on team roster page

* Show who didn't play yet on match teams preview

* Ranked/unranked badge

* Bracket hover show roster

* Add lock/unlock match test

* Fix score reporting
2024-02-11 10:49:12 +02:00

59 lines
1.3 KiB
TypeScript

import clsx from "clsx";
import { useIsMounted } from "~/hooks/useIsMounted";
import { useDeadline } from "./useDeadline";
import { useAutoRerender } from "~/hooks/useAutoRerender";
export function RoundHeader({
roundId,
name,
bestOf,
showInfos,
}: {
roundId: number;
name: string;
bestOf?: 3 | 5 | 7;
showInfos?: boolean;
}) {
const hasDeadline = !["WB Finals", "Grand Finals", "Bracket Reset"].includes(
name,
);
return (
<div>
<div className="elim-bracket__round-header">{name}</div>
{showInfos && bestOf ? (
<div className="elim-bracket__round-header__infos">
<div>Bo{bestOf}</div>
{hasDeadline ? <Deadline roundId={roundId} bestOf={bestOf} /> : null}
</div>
) : (
<div className="elim-bracket__round-header__infos invisible">
Hidden
</div>
)}
</div>
);
}
function Deadline({ roundId, bestOf }: { roundId: number; bestOf: 3 | 5 | 7 }) {
useAutoRerender("ten seconds");
const isMounted = useIsMounted();
const deadline = useDeadline(roundId, bestOf);
if (!deadline) return null;
return (
<div
className={clsx({
"text-warning": isMounted && deadline < new Date(),
})}
>
DL{" "}
{deadline.toLocaleTimeString("en-US", {
hour: "numeric",
minute: "numeric",
})}
</div>
);
}