2021-08-21 18:47:35 +02:00
|
|
|
<template>
|
2021-09-05 09:41:39 +02:00
|
|
|
<div class="user-month-stats">
|
2021-10-02 16:16:58 +02:00
|
|
|
<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"
|
2021-10-05 17:52:36 +02:00
|
|
|
:hide-chart-if-no-data="true"
|
2021-10-03 19:23:17 +02:00
|
|
|
/>
|
2021-09-21 08:51:07 +02:00
|
|
|
</template>
|
2021-09-04 19:40:27 +02:00
|
|
|
</Card>
|
|
|
|
</div>
|
2021-08-21 18:47:35 +02:00
|
|
|
</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
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
|
|
|
|
import Card from '@/components/Common/Card.vue'
|
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: {
|
|
|
|
Card,
|
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) {
|
|
|
|
const { t } = useI18n()
|
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
|
|
|
t,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|
|
|
|
</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 {
|
2021-09-22 11:49:56 +02:00
|
|
|
::v-deep(.card-content) {
|
|
|
|
padding: $default-padding;
|
2021-09-04 19:40:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|