Client - display only active sports in application in user preferences

+ fixes
This commit is contained in:
Sam
2021-11-13 12:12:22 +01:00
parent 529adb0403
commit 50094d1fda
34 changed files with 327 additions and 66 deletions

View File

@ -38,10 +38,17 @@ const sortSports = (a: ITranslatedSport, b: ITranslatedSport): number => {
export const translateSports = (
sports: ISport[],
t: CallableFunction,
onlyActive = false
onlyActive = false,
userSports: number[] | null = null
): ITranslatedSport[] =>
sports
.filter((sport) => (onlyActive ? sport.is_active_for_user : true))
.filter((sport) =>
onlyActive
? userSports === null
? sport.is_active_for_user
: userSports.includes(sport.id) || sport.is_active
: true
)
.map((sport) => ({
...sport,
translatedLabel: t(`sports.${sport.label}.LABEL`),