diff --git a/src/components/shared/Calendar.vue b/src/components/shared/Calendar.vue index 4179e3a3..edffe2dd 100644 --- a/src/components/shared/Calendar.vue +++ b/src/components/shared/Calendar.vue @@ -56,6 +56,7 @@ @click:event="showEvent" @click:more="viewDay" @click:date="viewDay" + @input="onMonthChange" /> event?.admins.includes(this.$store.direct.state.me?.userId ?? '') ?? false } + onMonthChange(value) { + value = new Date(value) + this.$emit('monthChanged', value) + } } diff --git a/src/pages/Calendar.vue b/src/pages/Calendar.vue index 8faf0fda..80f56f49 100644 --- a/src/pages/Calendar.vue +++ b/src/pages/Calendar.vue @@ -1,6 +1,10 @@ @@ -19,7 +23,16 @@ export default class CalendarPage extends Vue { events: ResponseEvent[] = [] async created() { - this.events = await api.events.getEvents({}) + await this.fetchMonthlyEvents(new Date()) + } + + async fetchMonthlyEvents(newDate) { + const startDate = new Date(newDate.getFullYear(), newDate.getMonth(), 1) + const endDate = new Date(newDate.getFullYear(), newDate.getMonth() + 1, 0) + this.events = await api.events.getEvents({ + dateBegin: startDate.toISOString(), + dateEnd: endDate.toISOString(), + }) } }