♻️ Refactor frontend
This commit is contained in:
20
src/util.js
20
src/util.js
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user