Client - update filters on sports

This commit is contained in:
Sam 2021-10-27 18:54:41 +02:00
parent e4434acc94
commit b695d665d2
3 changed files with 14 additions and 3 deletions

View File

@ -45,7 +45,7 @@
v-model="workoutDataObject.sport_id"
>
<option
v-for="sport in translatedSports"
v-for="sport in translatedSports.filter((s) => s.is_active)"
:value="sport.id"
:key="sport.id"
>

View File

@ -19,7 +19,9 @@
<select name="sport_id" @change="handleFilterChange">
<option value="" />
<option
v-for="sport in translatedSports"
v-for="sport in translatedSports.filter((s) =>
authUser.sports_list.includes(s.id)
)"
:value="sport.id"
:key="sport.id"
>
@ -137,11 +139,16 @@
import { useI18n } from 'vue-i18n'
import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
import { translateSports } from '@/utils/sports'
export default defineComponent({
name: 'WorkoutsFilters',
props: {
authUser: {
type: Object as PropType<IAuthUserProfile>,
required: true,
},
sports: {
type: Object as PropType<ISport[]>,
required: true,

View File

@ -2,7 +2,11 @@
<div id="workouts" v-if="authUser.username">
<div class="container workouts-container">
<div class="filters-container" :class="{ hidden: hiddenFilters }">
<WorkoutsFilters :sports="translatedSports" @filter="updateParams" />
<WorkoutsFilters
:sports="translatedSports"
:authUser="authUser"
@filter="updateParams"
/>
</div>
<div class="display-filters">
<div @click="toggleFilters">