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" v-model="workoutDataObject.sport_id"
> >
<option <option
v-for="sport in translatedSports" v-for="sport in translatedSports.filter((s) => s.is_active)"
:value="sport.id" :value="sport.id"
:key="sport.id" :key="sport.id"
> >

View File

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

View File

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