✨ Implement day navigation gestures with Swiper.js
This commit is contained in:
14
src/store.js
14
src/store.js
@ -24,6 +24,12 @@ watch(language, (newValue) => {
|
||||
location.reload();
|
||||
});
|
||||
|
||||
// Set this to a positive or negative integer
|
||||
// to change selectedDate by this number
|
||||
export const changeDay = ref(0);
|
||||
// Set this to jump to a specific date
|
||||
export const changeDate = ref(new Date());
|
||||
|
||||
export const selectedDate = ref(new Date(new Date().setUTCHours(0, 0, 0, 0)));
|
||||
export const selectedDay = computed(() => selectedDate.value.getDay() - 1);
|
||||
// Jump to next Monday if it is weekend
|
||||
@ -32,6 +38,14 @@ if (selectedDay.value == 5)
|
||||
if (selectedDay.value == -1)
|
||||
selectedDate.value = new Date(selectedDate.value.getTime() + 86400000);
|
||||
|
||||
// Load new data if date changes
|
||||
watch(selectedDate, async () => {
|
||||
loading.value = true;
|
||||
await fetchSubstitutions();
|
||||
await fetchHistory();
|
||||
loading.value = false;
|
||||
});
|
||||
|
||||
export const timetable = ref({ trusted: true });
|
||||
export const substitutions = ref([]);
|
||||
export const history = ref([]);
|
||||
|
Reference in New Issue
Block a user