♻️ Refactor frontend

This commit is contained in:
2022-12-10 16:10:10 +01:00
parent 568bfb9782
commit f243137145
12 changed files with 64 additions and 46 deletions

View File

@ -1,11 +1,4 @@
import {
classFilter,
fetchSubstitutions,
fetchHistory,
loading,
selectedDate,
} from "./store";
import dayjs from "dayjs";
import { classFilter } from "./store";
export function getSubstitutionText(substitution) {
const includeClass = !classFilter.value || classFilter.value == "none";
@ -29,3 +22,14 @@ export function getSubstitutionColor(substitution) {
return "background-color: var(--substitution-background-cancellation);";
}
}
export function getDateSkippingWeekend(date, onlyNext) {
// Go from saturday to next monday
if (date.getDay() == 6) return new Date(date.getTime() + 86400000 * 2);
// Go from sunday to last friday or next monday
if (date.getDay() == 0)
return new Date(
onlyNext ? date.getTime() + 86400000 * 1 : date.getTime() - 86400000 * 2
);
return date;
}