2021-10-05 15:23:41 +02:00
|
|
|
<template>
|
|
|
|
<div id="workouts" v-if="authUser.username">
|
|
|
|
<div class="container workouts-container">
|
2021-10-05 19:41:16 +02:00
|
|
|
<div class="filters-container" :class="{ hidden: hiddenFilters }">
|
2021-10-27 18:54:41 +02:00
|
|
|
<WorkoutsFilters
|
|
|
|
:sports="translatedSports"
|
|
|
|
:authUser="authUser"
|
|
|
|
@filter="updateParams"
|
|
|
|
/>
|
2021-10-05 15:23:41 +02:00
|
|
|
</div>
|
2021-10-05 19:41:16 +02:00
|
|
|
<div class="display-filters">
|
|
|
|
<div @click="toggleFilters">
|
|
|
|
<i
|
|
|
|
:class="`fa fa-caret-${hiddenFilters ? 'down' : 'up'}`"
|
|
|
|
aria-hidden="true"
|
|
|
|
/>
|
|
|
|
<span>
|
2021-10-20 17:38:25 +02:00
|
|
|
{{ $t(`workouts.${hiddenFilters ? 'DISPLAY' : 'HIDE'}_FILTERS`) }}
|
2021-10-05 19:41:16 +02:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-10-05 15:23:41 +02:00
|
|
|
<div class="list-container">
|
|
|
|
<WorkoutsList
|
|
|
|
:user="authUser"
|
|
|
|
:params="params"
|
|
|
|
:sports="translatedSports"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { ComputedRef, Ref, computed, defineComponent, ref } from 'vue'
|
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
|
|
|
|
import WorkoutsFilters from '@/components/Workouts/WorkoutsFilters.vue'
|
|
|
|
import WorkoutsList from '@/components/Workouts/WorkoutsList.vue'
|
|
|
|
import { USER_STORE, SPORTS_STORE } from '@/store/constants'
|
|
|
|
import { ISport, ITranslatedSport } from '@/types/sports'
|
|
|
|
import { IAuthUserProfile } from '@/types/user'
|
|
|
|
import { useStore } from '@/use/useStore'
|
|
|
|
import { translateSports } from '@/utils/sports'
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
name: 'WorkoutsView',
|
|
|
|
components: {
|
|
|
|
WorkoutsFilters,
|
|
|
|
WorkoutsList,
|
|
|
|
},
|
|
|
|
setup() {
|
|
|
|
const { t } = useI18n()
|
|
|
|
const store = useStore()
|
|
|
|
const authUser: ComputedRef<IAuthUserProfile> = computed(
|
|
|
|
() => store.getters[USER_STORE.GETTERS.AUTH_USER_PROFILE]
|
|
|
|
)
|
|
|
|
const sports: ComputedRef<ISport[]> = computed(
|
|
|
|
() => store.getters[SPORTS_STORE.GETTERS.SPORTS]
|
|
|
|
)
|
|
|
|
const translatedSports: ComputedRef<ITranslatedSport[]> = computed(() =>
|
|
|
|
translateSports(sports.value, t)
|
|
|
|
)
|
|
|
|
const params: Ref<Record<string, string>> = ref({})
|
2021-10-05 19:41:16 +02:00
|
|
|
const hiddenFilters = ref(true)
|
2021-10-05 15:23:41 +02:00
|
|
|
|
|
|
|
function updateParams(filters: Record<string, string>) {
|
|
|
|
params.value = filters
|
2021-10-05 19:41:16 +02:00
|
|
|
hiddenFilters.value = true
|
|
|
|
}
|
|
|
|
function toggleFilters() {
|
|
|
|
hiddenFilters.value = !hiddenFilters.value
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
authUser,
|
|
|
|
hiddenFilters,
|
|
|
|
params,
|
|
|
|
translatedSports,
|
|
|
|
toggleFilters,
|
|
|
|
updateParams,
|
2021-10-05 15:23:41 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import '~@/scss/base';
|
|
|
|
#workouts {
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
.workouts-container {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
@media screen and (max-width: $medium-limit) {
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
|
|
|
|
.filters-container,
|
|
|
|
.list-container {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
|
|
|
|
.filters-container {
|
|
|
|
width: 25%;
|
|
|
|
@media screen and (max-width: $medium-limit) {
|
|
|
|
width: 100%;
|
2021-10-05 19:41:16 +02:00
|
|
|
|
|
|
|
@media screen and (max-width: $small-limit) {
|
|
|
|
&.hidden {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.display-filters {
|
|
|
|
display: none;
|
|
|
|
font-size: 0.8em;
|
|
|
|
padding: 0 $default-padding * 2;
|
|
|
|
|
|
|
|
span {
|
|
|
|
cursor: pointer;
|
|
|
|
font-weight: bold;
|
|
|
|
padding-left: $default-padding * 0.5;
|
|
|
|
}
|
|
|
|
.fa {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media screen and (max-width: $small-limit) {
|
|
|
|
display: flex;
|
|
|
|
justify-content: flex-end;
|
|
|
|
align-items: center;
|
2021-10-05 15:23:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.list-container {
|
|
|
|
width: 75%;
|
|
|
|
@media screen and (max-width: $medium-limit) {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|