FitTrackee/fittrackee_client/src/components/Dashboard/UserMonthStats.vue

64 lines
1.4 KiB
Vue
Raw Normal View History

<template>
<div class="user-month-stats">
<Card>
2021-09-04 19:40:27 +02:00
<template #title>{{ $t('dashboard.THIS_MONTH') }}</template>
<template #content>
2021-10-03 19:23:17 +02:00
<StatChart
:sports="sports"
:user="user"
:chart-params="chartParams"
:displayed-sport-ids="selectedSportIds"
:hide-chart-if-no-data="true"
2021-10-03 19:23:17 +02:00
/>
</template>
2021-09-04 19:40:27 +02:00
</Card>
</div>
</template>
2021-09-04 19:40:27 +02:00
<script lang="ts">
2021-10-03 19:23:17 +02:00
import { endOfMonth, startOfMonth } from 'date-fns'
import { PropType, defineComponent } from 'vue'
2021-09-04 19:40:27 +02:00
2021-10-03 19:23:17 +02:00
import StatChart from '@/components/Common/StatsChart/index.vue'
2021-09-04 19:40:27 +02:00
import { ISport } from '@/types/sports'
import { IAuthUserProfile } from '@/types/user'
export default defineComponent({
name: 'UserMonthStats',
components: {
2021-10-03 19:23:17 +02:00
StatChart,
2021-09-04 19:40:27 +02:00
},
props: {
2021-09-27 13:06:17 +02:00
sports: {
type: Object as PropType<ISport[]>,
required: true,
},
2021-09-04 19:40:27 +02:00
user: {
type: Object as PropType<IAuthUserProfile>,
required: true,
},
},
setup(props) {
2021-09-27 13:06:17 +02:00
const date = new Date()
2021-09-04 19:40:27 +02:00
return {
2021-10-03 19:23:17 +02:00
chartParams: {
duration: 'week',
start: startOfMonth(date),
end: endOfMonth(date),
},
selectedSportIds: props.sports.map((sport) => sport.id),
2021-09-04 19:40:27 +02:00
}
},
})
</script>
2021-09-20 18:23:05 +02:00
<style lang="scss" scoped>
2021-09-04 19:40:27 +02:00
@import '~@/scss/base';
2021-09-20 18:23:05 +02:00
.user-month-stats {
::v-deep(.card-content) {
padding: $default-padding;
2021-09-04 19:40:27 +02:00
}
}
</style>