✨ Add swipe gestures for changing days
This commit is contained in:
@ -1,13 +1,8 @@
|
||||
<script setup>
|
||||
import {
|
||||
selectedDate,
|
||||
selectedDay,
|
||||
fetchSubstitutions,
|
||||
fetchHistory,
|
||||
loading,
|
||||
} from "../store";
|
||||
import dayjs from "dayjs";
|
||||
import { selectedDate, selectedDay } from "../store";
|
||||
import ArrowIcon from "./icons/arrow-icon.vue";
|
||||
import dayjs from "dayjs";
|
||||
import { changeDate, previousDay, nextDay } from "../util";
|
||||
|
||||
const dayNames = [
|
||||
"days.sunday",
|
||||
@ -18,26 +13,6 @@ const dayNames = [
|
||||
"days.friday",
|
||||
"days.saturday",
|
||||
];
|
||||
|
||||
function nextDay() {
|
||||
var newDate = dayjs(selectedDate.value).add(1, "day");
|
||||
// Skip weekend
|
||||
if (newDate.day() == 6) newDate = newDate.add(2, "day");
|
||||
changeDate(newDate);
|
||||
}
|
||||
function previousDay() {
|
||||
var newDate = dayjs(selectedDate.value).subtract(1, "day");
|
||||
// Skip weekend
|
||||
if (newDate.day() == 0) newDate = newDate.subtract(2, "day");
|
||||
changeDate(newDate);
|
||||
}
|
||||
async function changeDate(newDate) {
|
||||
selectedDate.value = new Date(newDate.toDate().setUTCHours(0, 0, 0, 0));
|
||||
loading.value = true;
|
||||
await fetchSubstitutions();
|
||||
await fetchHistory();
|
||||
loading.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
Reference in New Issue
Block a user