Client - display records on Dashboard (wip)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { ISport } from '@/types/sports'
|
||||
|
||||
export const sportColors: Record<string, string> = {
|
||||
'Cycling (Sport)': '#55A8A3',
|
||||
'Cycling (Transport)': '#98C3A9',
|
||||
@@ -6,3 +8,22 @@ export const sportColors: Record<string, string> = {
|
||||
Running: '#926692',
|
||||
Walking: '#929292',
|
||||
}
|
||||
|
||||
const sortSports = (a: ISport, b: ISport): number => {
|
||||
const sportALabel = a.label.toLowerCase()
|
||||
const sportBLabel = b.label.toLowerCase()
|
||||
return sportALabel > sportBLabel ? 1 : sportALabel < sportBLabel ? -1 : 0
|
||||
}
|
||||
|
||||
export const translateSports = (
|
||||
sports: ISport[],
|
||||
t: CallableFunction,
|
||||
onlyActive = false
|
||||
): ISport[] =>
|
||||
sports
|
||||
.filter((sport) => (onlyActive ? sport.is_active : true))
|
||||
.map((sport) => ({
|
||||
...sport,
|
||||
label: t(`sports.${sport.label}.LABEL`),
|
||||
}))
|
||||
.sort(sortSports)
|
||||
|
||||
Reference in New Issue
Block a user