diff --git a/src/constants/weekDays.ts b/src/constants/weekDays.ts index 875d86b..53c4297 100644 --- a/src/constants/weekDays.ts +++ b/src/constants/weekDays.ts @@ -7,7 +7,7 @@ export const emptyTimeTable = { fr: [], sa: [], su: [] -} satisfies TimeTable; +} as TimeTable; export type WeekDay = (typeof weekdays)[number]; diff --git a/src/lib/dates/dataWeekday.ts b/src/lib/dates/dataWeekday.ts index fc32059..99187c3 100644 --- a/src/lib/dates/dataWeekday.ts +++ b/src/lib/dates/dataWeekday.ts @@ -49,4 +49,27 @@ export function getWeekdayByAbbreviation(abbreviation: WeekDay) { } as const); } +export const getCurrentWeekdayAbbreviation = () => { + const weekdayIndex = new Date().getDay(); + + switch (weekdayIndex) { + case 0: + return 'su'; + case 1: + return 'mo'; + case 2: + return 'tu'; + case 3: + return 'we'; + case 4: + return 'th'; + case 5: + return 'fr'; + case 6: + return 'sa'; + default: + return 'mo'; + } +}; + export const getWeekdays = () => token.map((key) => i(key)) as WeekdayTranslation[]; diff --git a/src/lib/helpers/mapValues.ts b/src/lib/helpers/mapValues.ts new file mode 100644 index 0000000..f29de1c --- /dev/null +++ b/src/lib/helpers/mapValues.ts @@ -0,0 +1,15 @@ +type ObjectOf = Record; + +/** + * Map over the values of an object, returning a new object with the same keys + * and mapped values. + */ +export const mapValues = (object: ObjectOf, fn: (value: T) => U) => { + // iterate over the keys of the object + const newObject: ObjectOf = {}; + for (const key of Object.keys(object)) { + const mappedValue = fn(object[key]); + newObject[key] = mappedValue; + } + return newObject; +}; diff --git a/src/lib/homework/CreateHomeworkAssignment.svelte b/src/lib/homework/CreateHomeworkAssignment.svelte new file mode 100644 index 0000000..24761b6 --- /dev/null +++ b/src/lib/homework/CreateHomeworkAssignment.svelte @@ -0,0 +1,87 @@ + + +
+ { + const index = allAssignments.indexOf(assignment); + const newIndex = index - 1; + + allAssignments = swapArrayElements(allAssignments, index, newIndex); + }} + disabled={allAssignments.indexOf(assignment) === 0} + /> + { + const index = allAssignments.indexOf(assignment); + const newIndex = index + 1; + + allAssignments = swapArrayElements(allAssignments, index, newIndex); + }} + disabled={allAssignments.indexOf(assignment) === allAssignments.length - 1} + /> +
+
+ +
+ + + + + {#each subjectsSortetCapitalized as subj} + + + + +
+
+ +