2021-09-20 12:18:40 +02:00
|
|
|
<template>
|
|
|
|
<div class="timeline">
|
|
|
|
<WorkoutCard
|
|
|
|
v-for="workout in workouts"
|
|
|
|
:workout="workout"
|
|
|
|
:sport="sports.filter((s) => s.id === workout.sport_id)[0]"
|
|
|
|
:user="user"
|
|
|
|
:key="workout.id"
|
|
|
|
></WorkoutCard>
|
2021-09-21 08:51:07 +02:00
|
|
|
<Card v-if="workouts.length === 0" class="no-workouts">
|
|
|
|
<template #content>{{ t('workouts.NO_WORKOUTS') }}</template>
|
|
|
|
</Card>
|
2021-09-20 12:18:40 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import {
|
|
|
|
computed,
|
|
|
|
ComputedRef,
|
|
|
|
defineComponent,
|
|
|
|
onBeforeMount,
|
|
|
|
PropType,
|
|
|
|
} from 'vue'
|
2021-09-21 08:51:07 +02:00
|
|
|
import { useI18n } from 'vue-i18n'
|
2021-09-20 12:18:40 +02:00
|
|
|
|
2021-09-21 08:51:07 +02:00
|
|
|
import Card from '@/components/Common/Card.vue'
|
2021-09-20 12:18:40 +02:00
|
|
|
import WorkoutCard from '@/components/Dashboard/Timeline/WorkoutCard.vue'
|
|
|
|
import { SPORTS_STORE, WORKOUTS_STORE } from '@/store/constants'
|
|
|
|
import { ISport } from '@/types/sports'
|
|
|
|
import { IAuthUserProfile } from '@/types/user'
|
|
|
|
import { IWorkout } from '@/types/workouts'
|
|
|
|
import { useStore } from '@/use/useStore'
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
name: 'Timeline',
|
|
|
|
components: {
|
2021-09-21 08:51:07 +02:00
|
|
|
Card,
|
2021-09-20 12:18:40 +02:00
|
|
|
WorkoutCard,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
user: {
|
|
|
|
type: Object as PropType<IAuthUserProfile>,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
setup() {
|
|
|
|
const store = useStore()
|
2021-09-21 08:51:07 +02:00
|
|
|
const { t } = useI18n()
|
2021-09-20 12:18:40 +02:00
|
|
|
onBeforeMount(() =>
|
|
|
|
store.dispatch(WORKOUTS_STORE.ACTIONS.GET_USER_WORKOUTS, { page: 1 })
|
|
|
|
)
|
|
|
|
|
|
|
|
const workouts: ComputedRef<IWorkout[]> = computed(
|
|
|
|
() => store.getters[WORKOUTS_STORE.GETTERS.USER_WORKOUTS]
|
|
|
|
)
|
|
|
|
|
|
|
|
const sports: ComputedRef<ISport[]> = computed(
|
|
|
|
() => store.getters[SPORTS_STORE.GETTERS.SPORTS]
|
|
|
|
)
|
|
|
|
|
2021-09-21 08:51:07 +02:00
|
|
|
return { workouts, sports, t }
|
2021-09-20 12:18:40 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
</script>
|
2021-09-21 08:51:07 +02:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import '~@/scss/base';
|
|
|
|
|
|
|
|
.no-workouts {
|
|
|
|
margin-bottom: $default-margin * 2;
|
|
|
|
}
|
|
|
|
</style>
|