FitTrackee/fittrackee_client/src/views/StatisticsView.vue

62 lines
1.7 KiB
Vue
Raw Normal View History

2021-10-03 19:23:17 +02:00
<template>
2021-11-03 09:10:23 +01:00
<div id="statistics" class="view">
2021-10-03 19:23:17 +02:00
<div class="container" v-if="authUser.username">
<Card>
<template #title>{{ $t('statistics.STATISTICS') }}</template>
<template #content>
<Statistics
:class="{ 'stats-disabled': authUser.nb_workouts === 0 }"
:user="authUser"
:sports="sports"
/>
</template>
</Card>
<NoWorkouts v-if="authUser.nb_workouts === 0"></NoWorkouts>
2021-10-03 19:23:17 +02:00
</div>
</div>
</template>
<script lang="ts">
import { ComputedRef, computed, defineComponent } from 'vue'
import Statistics from '@/components/Statistics/index.vue'
2021-10-13 09:57:48 +02:00
import NoWorkouts from '@/components/Workouts/NoWorkouts.vue'
import { AUTH_USER_STORE, SPORTS_STORE } from '@/store/constants'
2021-10-03 19:23:17 +02:00
import { ISport } from '@/types/sports'
2021-10-30 12:01:55 +02:00
import { IUserProfile } from '@/types/user'
2021-10-03 19:23:17 +02:00
import { useStore } from '@/use/useStore'
export default defineComponent({
name: 'StatisticsView',
components: {
NoWorkouts,
2021-10-03 19:23:17 +02:00
Statistics,
},
setup() {
const store = useStore()
2021-10-30 12:01:55 +02:00
const authUser: ComputedRef<IUserProfile> = computed(
() => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE]
2021-10-03 19:23:17 +02:00
)
const sports: ComputedRef<ISport[]> = computed(() =>
store.getters[SPORTS_STORE.GETTERS.SPORTS].filter((sport) =>
authUser.value.sports_list.includes(sport.id)
)
2021-10-03 19:23:17 +02:00
)
return { authUser, sports }
},
})
</script>
<style lang="scss" scoped>
@import '~@/scss/base';
#statistics {
display: flex;
width: 100%;
.container {
display: flex;
flex-direction: column;
width: 100%;
}
2021-10-03 19:23:17 +02:00
}
</style>