import { computed } from "@vue/reactivity"; import { ref } from "vue"; export const timetable = ref([]); export const substitutions = ref([]); export const substitutionsForDate = computed(() => { const dates = {}; for (const substitution of substitutions.value) { const date = substitution.date; if (!dates[date]) dates[date] = []; dates[substitution.date].push(substitution); } return dates; }); export const parsedTimetable = computed(() => { return timetable.value.map((day) => { const newDay = []; for (const lesson of day) { const lessonLength = lesson.length || 1; delete lesson.length; for (var i = 0; i < lessonLength; i++) newDay.push(lesson); } return newDay; }); });