Client - add user sports preferences
+ minor refactor
This commit is contained in:
@ -44,6 +44,7 @@ export const getRecordsBySports = (
|
||||
if (sportList[sport.translatedLabel] === void 0) {
|
||||
sportList[sport.translatedLabel] = {
|
||||
label: sport.label,
|
||||
color: sport.color,
|
||||
records: [],
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ export const translateSports = (
|
||||
onlyActive = false
|
||||
): ITranslatedSport[] =>
|
||||
sports
|
||||
.filter((sport) => (onlyActive ? sport.is_active : true))
|
||||
.filter((sport) => (onlyActive ? sport.is_active_for_user : true))
|
||||
.map((sport) => ({
|
||||
...sport,
|
||||
translatedLabel: t(`sports.${sport.label}.LABEL`),
|
||||
@ -50,3 +50,12 @@ export const getSportLabel = (workout: IWorkout, sports: ISport[]): string => {
|
||||
.filter((sport) => sport.id === workout.sport_id)
|
||||
.map((sport) => sport.label)[0]
|
||||
}
|
||||
|
||||
export const getSportColor = (
|
||||
workout: IWorkout,
|
||||
sports: ISport[]
|
||||
): string | null => {
|
||||
return sports
|
||||
.filter((sport) => sport.id === workout.sport_id)
|
||||
.map((sport) => sport.color)[0]
|
||||
}
|
||||
|
Reference in New Issue
Block a user