mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-26 01:09:02 -05:00
* 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
59 lines
1.3 KiB
TypeScript
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>
|
|
);
|
|
}
|