Client - fix record order in dashboard cards

This commit is contained in:
Sam
2022-07-03 16:19:59 +02:00
parent fe1d691626
commit f9e03dd139
4 changed files with 38 additions and 6 deletions

View File

@ -1,6 +1,6 @@
import { ITranslatedSport } from '@/types/sports'
import { TUnit } from '@/types/units'
import { IRecord, IRecordsBySports } from '@/types/workouts'
import { ICardRecord, IRecord, IRecordsBySports } from '@/types/workouts'
import { formatWorkoutDate, getDateWithTZ } from '@/utils/dates'
import { convertDistance, units } from '@/utils/units'
@ -45,6 +45,12 @@ export const formatRecord = (
}
}
export const sortRecords = (a: ICardRecord, b: ICardRecord): number => {
const recordALabel = a.label.toLowerCase()
const recordBLabel = b.label.toLowerCase()
return recordALabel > recordBLabel ? 1 : recordALabel < recordBLabel ? -1 : 0
}
export const getRecordsBySports = (
records: IRecord[],
translatedSports: ITranslatedSport[],