Added loading logic to calendar page

This commit is contained in:
Alexis
2024-05-17 20:50:45 +02:00
parent 5dd06ea3f8
commit 059edd6fc1
3 changed files with 32 additions and 20 deletions

View File

@@ -29,6 +29,14 @@ export const useCalendar = defineStore('calendar', () => {
* Month list
*/
const months: Ref<CalendarMonth[]> = ref<CalendarMonth[]>([])
function setMonths(data: CalendarMonth[]) {
months.value = data
}
/**
* Sorted month data
*/
const sortedMonths = computed<CalendarMonth[]>(() => months.value.sort((a, b) => a.position - b.position))
const monthsPerYear = computed(() => months.value.length)
const daysPerYear = computed(() => months.value.reduce((acc, o) => acc + o.days, 0))
@@ -332,6 +340,7 @@ export const useCalendar = defineStore('calendar', () => {
return {
months,
setMonths,
sortedMonths,
daysPerYear,
monthsPerYear,