Fix bug with null starttimes (#708)

This commit is contained in:
Erik Vroon
2024-05-07 20:31:29 +02:00
committed by GitHub
parent c141fd2cd0
commit ffa1f874be
2 changed files with 6 additions and 4 deletions

View File

@@ -129,7 +129,8 @@ export function Schedule({
const matches: any[] = Object.values(matchesLookup);
const sortedMatches = matches
.sort((m1: any, m2: any) => (m1.match.court.name > m2.match.court.name ? 1 : -1))
.filter((m1: any) => m1.match.start_time != null)
.sort((m1: any, m2: any) => (m1.match.court?.name > m2.match.court?.name ? 1 : -1))
.sort((m1: any, m2: any) => (m1.match.start_time > m2.match.start_time ? 1 : -1));
const rows: React.JSX.Element[] = [];
@@ -137,7 +138,7 @@ export function Schedule({
for (let c = 0; c < sortedMatches.length; c += 1) {
const data = sortedMatches[c];
if (c < 1 || (data.match.start_time && sortedMatches[c - 1].match.start_time)) {
if (c < 1 || sortedMatches[c - 1].match.start_time) {
const startTime = formatTime(data.match.start_time);
if (c < 1 || startTime !== formatTime(sortedMatches[c - 1].match.start_time)) {

View File

@@ -156,7 +156,8 @@ function Schedule({
const matches: any[] = Object.values(matchesLookup);
const sortedMatches = matches
.sort((m1: any, m2: any) => (m1.match.court.name > m2.match.court.name ? 1 : -1))
.filter((m1: any) => m1.match.start_time != null)
.sort((m1: any, m2: any) => (m1.match.court?.name > m2.match.court?.name ? 1 : -1))
.sort((m1: any, m2: any) => (m1.match.start_time > m2.match.start_time ? 1 : -1));
const rows: React.JSX.Element[] = [];
@@ -164,7 +165,7 @@ function Schedule({
for (let c = 0; c < sortedMatches.length; c += 1) {
const data = sortedMatches[c];
if (c < 1 || (data.match.start_time && sortedMatches[c - 1].match.start_time)) {
if (c < 1 || (sortedMatches[c - 1].match.start_time)) {
const startTime = formatTime(data.match.start_time);
if (c < 1 || startTime !== formatTime(sortedMatches[c - 1].match.start_time)) {