diff --git a/frontend/src/components/utils/datetime.tsx b/frontend/src/components/utils/datetime.tsx index a91d2300..d47c610d 100644 --- a/frontend/src/components/utils/datetime.tsx +++ b/frontend/src/components/utils/datetime.tsx @@ -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); +} diff --git a/frontend/src/pages/tournaments/[id]/dashboard/index.tsx b/frontend/src/pages/tournaments/[id]/dashboard/index.tsx index b4dbaded..4b78d7ac 100644 --- a/frontend/src/pages/tournaments/[id]/dashboard/index.tsx +++ b/frontend/src/pages/tournaments/[id]/dashboard/index.tsx @@ -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) );