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

@ -1 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><!--[if IE]><link rel="icon" href="/favicon.ico"><![endif]--><link rel="stylesheet" href="/static/css/fork-awesome.min.css"><link rel="stylesheet" href="/static/css/leaflet.css"><title>FitTrackee</title><link href="/static/css/admin.dc8b6d66.css" rel="prefetch"><link href="/static/css/main.411e7bd3.css" rel="prefetch"><link href="/static/css/main~workouts.c8c5694b.css" rel="prefetch"><link href="/static/css/profile.314b1d45.css" rel="prefetch"><link href="/static/css/reset.a71577d5.css" rel="prefetch"><link href="/static/css/workouts.811b57d6.css" rel="prefetch"><link href="/static/js/admin.2f1d393d.js" rel="prefetch"><link href="/static/js/chunk-2d0c9189.c81458cc.js" rel="prefetch"><link href="/static/js/chunk-2d0cf391.020c75ea.js" rel="prefetch"><link href="/static/js/chunk-2d0da8f3.c8c3e7e8.js" rel="prefetch"><link href="/static/js/chunk-2d2248b6.d84473c1.js" rel="prefetch"><link href="/static/js/chunk-2d22523a.4b710d99.js" rel="prefetch"><link href="/static/js/main.db9cee98.js" rel="prefetch"><link href="/static/js/main~workouts.a74990d7.js" rel="prefetch"><link href="/static/js/profile.62578012.js" rel="prefetch"><link href="/static/js/reset.518e646f.js" rel="prefetch"><link href="/static/js/workouts.f44fc0c9.js" rel="prefetch"><link href="/static/css/app.97115085.css" rel="preload" as="style"><link href="/static/js/app.1cea050c.js" rel="preload" as="script"><link href="/static/js/chunk-vendors.71654064.js" rel="preload" as="script"><link href="/static/css/app.97115085.css" rel="stylesheet"><link rel="icon" type="image/png" sizes="32x32" href="/img/icons/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/img/icons/favicon-16x16.png"><link rel="manifest" href="/manifest.json"><meta name="theme-color" content="#4DBA87"><meta name="apple-mobile-web-app-capable" content="no"><meta name="apple-mobile-web-app-status-bar-style" content="default"><meta name="apple-mobile-web-app-title" content="fittrackee_client"><link rel="apple-touch-icon" href="/img/icons/apple-touch-icon-152x152.png"><link rel="mask-icon" href="/img/icons/safari-pinned-tab.svg" color="#4DBA87"><meta name="msapplication-TileImage" content="/img/icons/msapplication-icon-144x144.png"><meta name="msapplication-TileColor" content="#000000"></head><body><noscript><strong>We're sorry but FitTrackee doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/static/js/chunk-vendors.71654064.js"></script><script src="/static/js/app.1cea050c.js"></script></body></html>
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><!--[if IE]><link rel="icon" href="/favicon.ico"><![endif]--><link rel="stylesheet" href="/static/css/fork-awesome.min.css"><link rel="stylesheet" href="/static/css/leaflet.css"><title>FitTrackee</title><link href="/static/css/admin.babfd43e.css" rel="prefetch"><link href="/static/css/main.7229c1ab.css" rel="prefetch"><link href="/static/css/main~workouts.0edb3403.css" rel="prefetch"><link href="/static/css/profile.05400f70.css" rel="prefetch"><link href="/static/css/reset.46776e72.css" rel="prefetch"><link href="/static/css/workouts.1b0a7916.css" rel="prefetch"><link href="/static/js/admin.2f1d393d.js" rel="prefetch"><link href="/static/js/chunk-2d0c9189.c81458cc.js" rel="prefetch"><link href="/static/js/chunk-2d0cf391.020c75ea.js" rel="prefetch"><link href="/static/js/chunk-2d0da8f3.c8c3e7e8.js" rel="prefetch"><link href="/static/js/chunk-2d2248b6.d84473c1.js" rel="prefetch"><link href="/static/js/chunk-2d22523a.4b710d99.js" rel="prefetch"><link href="/static/js/main.db9cee98.js" rel="prefetch"><link href="/static/js/main~workouts.a74990d7.js" rel="prefetch"><link href="/static/js/profile.62578012.js" rel="prefetch"><link href="/static/js/reset.518e646f.js" rel="prefetch"><link href="/static/js/workouts.d69cf48a.js" rel="prefetch"><link href="/static/css/app.f5a49827.css" rel="preload" as="style"><link href="/static/js/app.4af713c5.js" rel="preload" as="script"><link href="/static/js/chunk-vendors.71654064.js" rel="preload" as="script"><link href="/static/css/app.f5a49827.css" rel="stylesheet"><link rel="icon" type="image/png" sizes="32x32" href="/img/icons/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/img/icons/favicon-16x16.png"><link rel="manifest" href="/manifest.json"><meta name="theme-color" content="#4DBA87"><meta name="apple-mobile-web-app-capable" content="no"><meta name="apple-mobile-web-app-status-bar-style" content="default"><meta name="apple-mobile-web-app-title" content="fittrackee_client"><link rel="apple-touch-icon" href="/img/icons/apple-touch-icon-152x152.png"><link rel="mask-icon" href="/img/icons/safari-pinned-tab.svg" color="#4DBA87"><meta name="msapplication-TileImage" content="/img/icons/msapplication-icon-144x144.png"><meta name="msapplication-TileColor" content="#000000"></head><body><noscript><strong>We're sorry but FitTrackee doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/static/js/chunk-vendors.71654064.js"></script><script src="/static/js/app.4af713c5.js"></script></body></html>

View File

@ -64,7 +64,7 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
"url": "/img/workouts/mountains.svg"
},
{
"revision": "b25a1a86fb5897d7e1aa7c29ab6c767a",
"revision": "e1822eea53975be4c7802859ebb65de1",
"url": "/index.html"
},
{
@ -76,12 +76,12 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
"url": "/robots.txt"
},
{
"revision": "55e1f50bd31cac2908e3",
"url": "/static/css/admin.dc8b6d66.css"
"revision": "33002d1c4452ecd02e50",
"url": "/static/css/admin.babfd43e.css"
},
{
"revision": "e9224bbb1b4b15d1c11d",
"url": "/static/css/app.97115085.css"
"revision": "592aef69082002fccf26",
"url": "/static/css/app.f5a49827.css"
},
{
"revision": "82c1118c918377daaa71a320ab8eea42",
@ -92,24 +92,24 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
"url": "/static/css/leaflet.css"
},
{
"revision": "be5a37c7e9ea6bfcb8d7",
"url": "/static/css/main.411e7bd3.css"
"revision": "00c35b353719122c16cd",
"url": "/static/css/main.7229c1ab.css"
},
{
"revision": "ce60ed388b792b0e9a0e",
"url": "/static/css/main~workouts.c8c5694b.css"
"revision": "11b770a11a1cd8dae5f4",
"url": "/static/css/main~workouts.0edb3403.css"
},
{
"revision": "74137feddeb35e2de067",
"url": "/static/css/profile.314b1d45.css"
"revision": "058a877bc4b9cbf8929f",
"url": "/static/css/profile.05400f70.css"
},
{
"revision": "6066a5f13daad652feea",
"url": "/static/css/reset.a71577d5.css"
"revision": "8635e7636aa413afd289",
"url": "/static/css/reset.46776e72.css"
},
{
"revision": "152a2e4eea88a89fbd00",
"url": "/static/css/workouts.811b57d6.css"
"revision": "c78ff76a4bb0919c4b94",
"url": "/static/css/workouts.1b0a7916.css"
},
{
"revision": "e719f9244c69e28e7d00e725ca1e280e",
@ -192,12 +192,12 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
"url": "/static/img/pt-sans-v9-latin-regular.f1f73e45.svg"
},
{
"revision": "55e1f50bd31cac2908e3",
"revision": "33002d1c4452ecd02e50",
"url": "/static/js/admin.2f1d393d.js"
},
{
"revision": "e9224bbb1b4b15d1c11d",
"url": "/static/js/app.1cea050c.js"
"revision": "592aef69082002fccf26",
"url": "/static/js/app.4af713c5.js"
},
{
"revision": "bd7d183c9f68e5f4027d",
@ -224,23 +224,23 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
"url": "/static/js/chunk-vendors.71654064.js"
},
{
"revision": "be5a37c7e9ea6bfcb8d7",
"revision": "00c35b353719122c16cd",
"url": "/static/js/main.db9cee98.js"
},
{
"revision": "ce60ed388b792b0e9a0e",
"revision": "11b770a11a1cd8dae5f4",
"url": "/static/js/main~workouts.a74990d7.js"
},
{
"revision": "74137feddeb35e2de067",
"revision": "058a877bc4b9cbf8929f",
"url": "/static/js/profile.62578012.js"
},
{
"revision": "6066a5f13daad652feea",
"revision": "8635e7636aa413afd289",
"url": "/static/js/reset.518e646f.js"
},
{
"revision": "152a2e4eea88a89fbd00",
"url": "/static/js/workouts.f44fc0c9.js"
"revision": "c78ff76a4bb0919c4b94",
"url": "/static/js/workouts.d69cf48a.js"
}
]);

View File

@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
importScripts(
"/precache-manifest.c464572cf53279a4a77a0b894d8a1e6c.js"
"/precache-manifest.ddc2833e5b0364615f3352c5edfaec71.js"
);
workbox.core.setCacheNameDetails({prefix: "fittrackee_client"});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -24,7 +24,7 @@
</thead>
<tbody>
<tr v-for="sport in translatedSports" :key="sport.id">
<td class="center-text">
<td class="text-center">
<span class="cell-heading">id</span>
{{ sport.id }}
</td>
@ -44,12 +44,12 @@
</span>
{{ sport.translatedLabel }}
</td>
<td class="center-text">
<td class="text-center">
<span class="cell-heading">
{{ $t('admin.SPORTS.TABLE.ACTIVE') }}
</span>
<i
:class="`fa fa${sport.is_active ? '-check' : ''}-square-o`"
:class="`fa fa${sport.is_active ? '-check' : ''}`"
aria-hidden="true"
/>
</td>

View File

@ -63,13 +63,13 @@
)
}}
</td>
<td class="center-text">
<td class="text-center">
<span class="cell-heading">
{{ capitalize($t('workouts.WORKOUT', 0)) }}
</span>
{{ user.nb_workouts }}
</td>
<td class="center-text">
<td class="text-center">
<span class="cell-heading">
{{ $t('user.ADMIN') }}
</span>
@ -78,7 +78,7 @@
aria-hidden="true"
/>
</td>
<td class="center-text">
<td class="text-center">
<span class="cell-heading">
{{ $t('admin.ACTION') }}
</span>

View File

@ -22,6 +22,7 @@
<tr>
<th>{{ $t('user.PROFILE.SPORT.COLOR') }}</th>
<th class="text-left">{{ $t('workouts.SPORT', 0) }}</th>
<th>{{ $t('workouts.WORKOUT', 0) }}</th>
<th>{{ $t('user.PROFILE.SPORT.IS_ACTIVE') }}</th>
<th>{{ $t('user.PROFILE.SPORT.STOPPED_SPEED_THRESHOLD') }}</th>
<th v-if="isEdition">{{ $t('user.PROFILE.SPORT.ACTION') }}</th>
@ -47,11 +48,17 @@
:color="sport.color ? sport.color : sportColors[sport.label]"
/>
</td>
<td class="sport-label">
<td
class="sport-label"
:class="{ 'disabled-sport': !sport.is_active }"
>
<span class="cell-heading">
{{ $t('user.PROFILE.SPORT.LABEL') }}
</span>
{{ sport.translatedLabel }}
<span class="disabled-message" v-if="!sport.is_active">
({{ $t('user.PROFILE.SPORT.DISABLED_BY_ADMIN') }})
</span>
<i
v-if="loading && isSportInEdition(sport.id)"
class="fa fa-refresh fa-spin fa-fw"
@ -61,31 +68,49 @@
v-if="errorMessages && sportPayload.sport_id === sport.id"
/>
</td>
<td class="text-center">
<td
class="text-center"
:class="{ 'disabled-sport': !sport.is_active }"
>
<span class="cell-heading">
{{ $t('workouts.WORKOUT', 0) }}
</span>
<i
:class="`fa fa${
user.sports_list.includes(sport.id) ? '-check' : ''
}`"
aria-hidden="true"
/>
</td>
<td
class="text-center"
:class="{ 'disabled-sport': !sport.is_active }"
>
<span class="cell-heading">
{{ $t('user.PROFILE.SPORT.IS_ACTIVE') }}
</span>
<input
v-if="isSportInEdition(sport.id)"
v-if="isSportInEdition(sport.id) && sport.is_active"
type="checkbox"
:checked="sport.is_active_for_user"
@change="updateIsActive"
/>
<i
v-else
:class="`fa fa${
sport.is_active_for_user ? '-check' : ''
}-square-o`"
:class="`fa fa${sport.is_active_for_user ? '-check' : ''}`"
aria-hidden="true"
/>
</td>
<td class="text-center">
<td
class="text-center"
:class="{ 'disabled-sport': !sport.is_active }"
>
<span class="cell-heading">
{{ $t('user.PROFILE.SPORT.STOPPED_SPEED_THRESHOLD') }}
</span>
<input
class="threshold-input"
v-if="isSportInEdition(sport.id)"
v-if="isSportInEdition(sport.id) && sport.is_active"
type="number"
min="0"
step="0.1"
@ -139,11 +164,12 @@
import { AUTH_USER_STORE, ROOT_STORE, SPORTS_STORE } from '@/store/constants'
import { ISport, ITranslatedSport } from '@/types/sports'
import { IUserSportPreferencesPayload } from '@/types/user'
import { IUserProfile, IUserSportPreferencesPayload } from '@/types/user'
import { useStore } from '@/use/useStore'
import { translateSports } from '@/utils/sports'
interface Props {
user: IUserProfile
isEdition: boolean
}
const props = defineProps<Props>()
@ -151,13 +177,13 @@
const store = useStore()
const { t } = useI18n()
const { isEdition } = toRefs(props)
const { isEdition, user } = toRefs(props)
const sportColors = inject('sportColors')
const sports: ComputedRef<ISport[]> = computed(
() => store.getters[SPORTS_STORE.GETTERS.SPORTS]
)
const translatedSports: ComputedRef<ITranslatedSport[]> = computed(() =>
translateSports(sports.value, t)
translateSports(sports.value, t, true, user.value.sports_list)
)
const loading = computed(
() => store.getters[AUTH_USER_STORE.GETTERS.USER_LOADING]
@ -236,6 +262,17 @@
.sport-label {
width: 170px;
}
.disabled-sport {
font-style: italic;
color: var(--disabled-sport-color);
.disabled-message {
font-size: 0.9em;
}
.cell-heading {
font-style: normal;
}
}
.action-buttons {
width: 70px;
}

View File

@ -259,7 +259,12 @@
const { workout, isCreation, loading } = toRefs(props)
const translatedSports: ComputedRef<ISport[]> = computed(() =>
translateSports(props.sports, t, true)
translateSports(
props.sports,
t,
true,
workout.value.id ? [workout.value.sport_id] : null
)
)
const appConfig: ComputedRef<TAppConfig> = computed(
() => store.getters[ROOT_STORE.GETTERS.APP_CONFIG]

View File

@ -48,6 +48,7 @@
"SPORT": {
"ACTION": "action",
"COLOR": "color",
"DISABLED_BY_ADMIN": "disabled by admin",
"IS_ACTIVE": "active",
"LABEL": "label",
"STOPPED_SPEED_THRESHOLD": "stopped speed threshold"

View File

@ -48,6 +48,7 @@
"SPORT": {
"ACTION": "action",
"COLOR": "couleur",
"DISABLED_BY_ADMIN": "désactivé par l'administrateur",
"IS_ACTIVE": "actif",
"LABEL": "label",
"STOPPED_SPEED_THRESHOLD": "seuil de vitesse arrêtée"

View File

@ -53,6 +53,7 @@
--disabled-background-color: #e0e0e0;
--disabled-color: #a3a3a3;
--disabled-sport-color: #616161;
--scroll-button-bg-color: rgba(255, 255, 255, .7);

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`),

View File

@ -16,7 +16,7 @@ export const sports: ISport[] = [
},
{
color: '#000000',
has_workouts: false,
has_workouts: true,
id: 2,
img: '/img/sports/cycling-transport.png',
is_active: false,

View File

@ -7,7 +7,7 @@ import { translateSports } from '@/utils/sports'
const { t, locale } = createI18n.global
describe('sortSports', () => {
describe('translateSports', () => {
const testsParams = [
{
description: "returns sorted all translated sports (with 'en' locale)",
@ -15,6 +15,7 @@ describe('sortSports', () => {
sports,
locale: 'en',
onlyActive: false,
userSports: null,
},
expected: [
{
@ -30,7 +31,7 @@ describe('sortSports', () => {
},
{
color: '#000000',
has_workouts: false,
has_workouts: true,
id: 2,
img: '/img/sports/cycling-transport.png',
is_active: false,
@ -54,11 +55,12 @@ describe('sortSports', () => {
},
{
description:
"returns sorted only active translated sports (with 'en' locales)",
"returns sorted only translated sports, active for user (with 'en' locales)",
inputParams: {
sports,
locale: 'en',
onlyActive: true,
userSports: null,
},
expected: [
{
@ -80,6 +82,7 @@ describe('sortSports', () => {
sports: [],
locale: 'en',
onlyActive: false,
userSports: null,
},
expected: [],
},
@ -89,6 +92,7 @@ describe('sortSports', () => {
sports,
locale: 'fr',
onlyActive: false,
userSports: [],
},
expected: [
{
@ -115,7 +119,7 @@ describe('sortSports', () => {
},
{
color: '#000000',
has_workouts: false,
has_workouts: true,
id: 2,
img: '/img/sports/cycling-transport.png',
is_active: false,
@ -128,11 +132,12 @@ describe('sortSports', () => {
},
{
description:
"returns sorted only active translated sports (with 'fr' locales)",
"returns sorted only translated sports, active for user (with 'fr' locales)",
inputParams: {
sports,
locale: 'fr',
onlyActive: true,
userSports: null,
},
expected: [
{
@ -154,6 +159,209 @@ describe('sortSports', () => {
sports: [],
locale: 'fr',
onlyActive: false,
userSports: null,
},
expected: [],
},
{
description:
"returns sorted all translated sports, even with user sports list provided (with 'en' locale)",
inputParams: {
sports,
locale: 'en',
onlyActive: false,
userSports: [2],
},
expected: [
{
color: null,
has_workouts: false,
id: 1,
img: '/img/sports/cycling-sport.png',
is_active: true,
is_active_for_user: true,
label: 'Cycling (Sport)',
stopped_speed_threshold: 1,
translatedLabel: 'Cycling (Sport)',
},
{
color: '#000000',
has_workouts: true,
id: 2,
img: '/img/sports/cycling-transport.png',
is_active: false,
is_active_for_user: false,
label: 'Cycling (Transport)',
stopped_speed_threshold: 1,
translatedLabel: 'Cycling (Transport)',
},
{
color: null,
has_workouts: true,
id: 3,
img: '/img/sports/hiking.png',
is_active: true,
is_active_for_user: false,
label: 'Hiking',
stopped_speed_threshold: 0.1,
translatedLabel: 'Hiking',
},
],
},
{
description:
"returns sorted only translated sports active on application and sports with user workouts (with 'en' locales)",
inputParams: {
sports,
locale: 'en',
onlyActive: true,
userSports: [2],
},
expected: [
{
color: null,
has_workouts: false,
id: 1,
img: '/img/sports/cycling-sport.png',
is_active: true,
is_active_for_user: true,
label: 'Cycling (Sport)',
stopped_speed_threshold: 1,
translatedLabel: 'Cycling (Sport)',
},
{
color: '#000000',
has_workouts: true,
id: 2,
img: '/img/sports/cycling-transport.png',
is_active: false,
is_active_for_user: false,
label: 'Cycling (Transport)',
stopped_speed_threshold: 1,
translatedLabel: 'Cycling (Transport)',
},
{
color: null,
has_workouts: true,
id: 3,
img: '/img/sports/hiking.png',
is_active: true,
is_active_for_user: false,
label: 'Hiking',
stopped_speed_threshold: 0.1,
translatedLabel: 'Hiking',
},
],
},
{
description:
"returns empty array, with user sports list provided (with 'en' locale)",
inputParams: {
sports: [],
locale: 'en',
onlyActive: false,
userSports: null,
},
expected: [],
},
{
description:
"returns sorted all translated sports, even with user sports list provided (with 'fr' locale)",
inputParams: {
sports,
locale: 'fr',
onlyActive: false,
userSports: [2],
},
expected: [
{
color: null,
has_workouts: true,
id: 3,
img: '/img/sports/hiking.png',
is_active: true,
is_active_for_user: false,
label: 'Hiking',
stopped_speed_threshold: 0.1,
translatedLabel: 'Randonnée',
},
{
color: null,
has_workouts: false,
id: 1,
img: '/img/sports/cycling-sport.png',
is_active: true,
is_active_for_user: true,
label: 'Cycling (Sport)',
stopped_speed_threshold: 1,
translatedLabel: 'Vélo (Sport)',
},
{
color: '#000000',
has_workouts: true,
id: 2,
img: '/img/sports/cycling-transport.png',
is_active: false,
is_active_for_user: false,
label: 'Cycling (Transport)',
stopped_speed_threshold: 1,
translatedLabel: 'Vélo (Transport)',
},
],
},
{
description:
"returns sorted only translated sports active on application and sports with user workouts (with 'fr' locales)",
inputParams: {
sports,
locale: 'fr',
onlyActive: true,
userSports: [2],
},
expected: [
{
color: null,
has_workouts: true,
id: 3,
img: '/img/sports/hiking.png',
is_active: true,
is_active_for_user: false,
label: 'Hiking',
stopped_speed_threshold: 0.1,
translatedLabel: 'Randonnée',
},
{
color: null,
has_workouts: false,
id: 1,
img: '/img/sports/cycling-sport.png',
is_active: true,
is_active_for_user: true,
label: 'Cycling (Sport)',
stopped_speed_threshold: 1,
translatedLabel: 'Vélo (Sport)',
},
{
color: '#000000',
has_workouts: true,
id: 2,
img: '/img/sports/cycling-transport.png',
is_active: false,
is_active_for_user: false,
label: 'Cycling (Transport)',
stopped_speed_threshold: 1,
translatedLabel: 'Vélo (Transport)',
},
],
},
{
description:
"returns empty array, with user sports list provided (with 'fr' locale)",
inputParams: {
sports: [],
locale: 'fr',
onlyActive: false,
userSports: [2],
},
expected: [],
},
@ -165,7 +373,8 @@ describe('sortSports', () => {
translateSports(
testParams.inputParams.sports,
t,
testParams.inputParams.onlyActive
testParams.inputParams.onlyActive,
testParams.inputParams.userSports
),
testParams.expected
)