Fix league sport-season page to show correct game times for FIFA World Cup
getUpcomingScoringEvents already fetched per-game scheduledAt times from playoffMatchGames for sorting, but discarded them from the return value. EventSchedule was showing eventStartsAt (event-level) instead of the accurate per-game times. Now getUpcomingScoringEvents includes earliestGameTime in each returned event, and EventSchedule prefers earliestGameTime over eventStartsAt — matching how UpcomingCalendarPanel works on the Upcoming Events page. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KiVGo8gSBXe3WuRniVNKsd
This commit is contained in:
parent
08ae2bb88a
commit
363413cd38
2 changed files with 17 additions and 7 deletions
|
|
@ -10,6 +10,7 @@ interface ScheduleEvent {
|
||||||
name: string;
|
name: string;
|
||||||
eventDate: string | null;
|
eventDate: string | null;
|
||||||
eventStartsAt?: Date | string | null;
|
eventStartsAt?: Date | string | null;
|
||||||
|
earliestGameTime?: string | null;
|
||||||
eventType: string;
|
eventType: string;
|
||||||
isComplete: boolean;
|
isComplete: boolean;
|
||||||
completedAt?: Date | string | null;
|
completedAt?: Date | string | null;
|
||||||
|
|
@ -52,10 +53,13 @@ function getEventTypeLabel(eventType: string): string {
|
||||||
export function EventSchedule({ upcomingEvents, recentEvents, leagueId, sportsSeasonId }: EventScheduleProps) {
|
export function EventSchedule({ upcomingEvents, recentEvents, leagueId, sportsSeasonId }: EventScheduleProps) {
|
||||||
const isMounted = useHasMounted();
|
const isMounted = useHasMounted();
|
||||||
|
|
||||||
function getDisplayDate(event: Pick<ScheduleEvent, "eventDate" | "eventStartsAt">): string {
|
function getDisplayDate(event: Pick<ScheduleEvent, "eventDate" | "eventStartsAt" | "earliestGameTime">): string {
|
||||||
if (isMounted && event.eventStartsAt) {
|
if (isMounted) {
|
||||||
const d = new Date(event.eventStartsAt as string);
|
const ts = event.earliestGameTime ?? (event.eventStartsAt as string | null | undefined);
|
||||||
if (!isNaN(d.getTime())) return format(d, "MMM d, yyyy");
|
if (ts) {
|
||||||
|
const d = new Date(ts);
|
||||||
|
if (!isNaN(d.getTime())) return format(d, "MMM d, yyyy");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return formatEventDate(event.eventDate);
|
return formatEventDate(event.eventDate);
|
||||||
}
|
}
|
||||||
|
|
@ -109,8 +113,8 @@ export function EventSchedule({ upcomingEvents, recentEvents, leagueId, sportsSe
|
||||||
<p className="text-xs text-muted-foreground flex items-center gap-1 mt-0.5">
|
<p className="text-xs text-muted-foreground flex items-center gap-1 mt-0.5">
|
||||||
<Calendar className="h-3 w-3" />
|
<Calendar className="h-3 w-3" />
|
||||||
<span>{getDisplayDate(event)}</span>
|
<span>{getDisplayDate(event)}</span>
|
||||||
{isMounted && event.eventStartsAt && (
|
{isMounted && (event.earliestGameTime ?? event.eventStartsAt) && (
|
||||||
<span>· {format(new Date(event.eventStartsAt), "h:mm a")}</span>
|
<span>· {new Date(event.earliestGameTime ?? (event.eventStartsAt as string)).toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" })}</span>
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -353,7 +353,13 @@ export async function getUpcomingScoringEvents(
|
||||||
return candidates.length > 0 ? Math.min(...candidates) : Infinity;
|
return candidates.length > 0 ? Math.min(...candidates) : Infinity;
|
||||||
};
|
};
|
||||||
|
|
||||||
return events.toSorted((a, b) => getEffectiveMs(a) - getEffectiveMs(b)).slice(0, limit);
|
return events
|
||||||
|
.toSorted((a, b) => getEffectiveMs(a) - getEffectiveMs(b))
|
||||||
|
.slice(0, limit)
|
||||||
|
.map((e) => ({
|
||||||
|
...e,
|
||||||
|
earliestGameTime: earliestGameById.get(e.id)?.toISOString() ?? null,
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue