Show set end time above match banner next to start time

This commit is contained in:
Kalle 2026-07-27 14:43:53 +03:00
parent b94b5fd503
commit bb374145c1
3 changed files with 46 additions and 11 deletions

View File

@ -1,21 +1,43 @@
import { LocaleTime } from "~/components/LocaleTime";
import { LocaleTimeRange } from "~/components/LocaleTimeRange";
const FORMAT_OPTIONS: Intl.DateTimeFormatOptions = {
month: "numeric",
year: "2-digit",
day: "numeric",
hour: "numeric",
minute: "numeric",
};
const CLASS_NAME = "text-lighter font-semi-bold";
interface MatchBannerStartedAtProps {
time: Date;
/** When given, the time the match ended, shown as a range together with the start time */
endTime?: Date | null;
}
export function MatchBannerStartedAt({ time }: MatchBannerStartedAtProps) {
export function MatchBannerStartedAt({
time,
endTime,
}: MatchBannerStartedAtProps) {
if (endTime) {
return (
<LocaleTimeRange
from={time}
to={endTime}
options={FORMAT_OPTIONS}
className={CLASS_NAME}
inline
/>
);
}
return (
<LocaleTime
date={time}
options={{
month: "numeric",
year: "2-digit",
day: "numeric",
hour: "numeric",
minute: "numeric",
}}
className="text-lighter font-semi-bold"
options={FORMAT_OPTIONS}
className={CLASS_NAME}
inline
/>
);

View File

@ -154,7 +154,14 @@ function SendouQMatchBannerTopRow({
}}
>
{data.match.isLocked || awaitingConfirmation ? (
<MatchBannerStartedAt time={startedAt} />
<MatchBannerStartedAt
time={startedAt}
endTime={
lastMapReportedAt
? databaseTimestampToDate(lastMapReportedAt)
: null
}
/>
) : (
<MatchBannerTimer
time={{

View File

@ -245,6 +245,12 @@ function TournamentMatchBannerTopRow({
const startedAt = databaseTimestampToDate(data.match.startedAt);
const totalMinutes = differenceInMinutes(currentTime, startedAt);
const lastResultCreatedAt = data.results.at(-1)?.createdAt;
const endedAt =
typeof lastResultCreatedAt === "number"
? databaseTimestampToDate(lastResultCreatedAt)
: null;
const currentMinutes = resolveCurrentMinutes({
data,
tournament,
@ -262,7 +268,7 @@ function TournamentMatchBannerTopRow({
}}
>
{data.matchIsOver ? (
<MatchBannerStartedAt time={startedAt} />
<MatchBannerStartedAt time={startedAt} endTime={endedAt} />
) : (
<MatchBannerTimer time={{ currentMinutes, totalMinutes }} />
)}