Fix sorting of matches on dashboard (#1129)

fixes https://github.com/evroon/bracket/issues/979

also reverses the order so it is now in ascending order from oldest to
most recent match.
This commit is contained in:
Erik Vroon
2025-02-20 18:43:10 +01:00
committed by GitHub
parent 993aa44be0
commit c48686277d
2 changed files with 6 additions and 2 deletions

View File

@@ -13,3 +13,7 @@ export function Time({ datetime }: { datetime: string }) {
export function formatTime(datetime: string) {
return format(parseISO(datetime), 'HH:mm');
}
export function compareDateTime(datetime1: string, datetime2: string) {
return parseISO(datetime1) > parseISO(datetime2);
}

View File

@@ -9,7 +9,7 @@ import React from 'react';
import { DashboardFooter } from '../../../../components/dashboard/footer';
import { DoubleHeader, TournamentHeadTitle } from '../../../../components/dashboard/layout';
import { NoContent } from '../../../../components/no_content/empty_table_info';
import { Time, formatTime } from '../../../../components/utils/datetime';
import { Time, compareDateTime, formatTime } from '../../../../components/utils/datetime';
import { Translator } from '../../../../components/utils/types';
import { responseIsValid } from '../../../../components/utils/util';
import { formatMatchInput1, formatMatchInput2 } from '../../../../interfaces/match';
@@ -134,7 +134,7 @@ export function Schedule({
.filter((m1: any) => m1.match.start_time != null)
.sort(
(m1: any, m2: any) =>
-formatTime(m1.match.start_time).localeCompare(formatTime(m2.match.start_time)) ||
compareDateTime(m1.match.start_time, m2.match.start_time) ||
m1.match.court?.name.localeCompare(m2.match.court?.name)
);