1
0

feat: Show always annoucements for this week
Remote Deploy / deploy (push) Successful in 1m35s

This commit is contained in:
2026-06-02 12:29:00 +02:00
parent 1f9543909a
commit 32b31814e2
3 changed files with 31 additions and 6 deletions
+30 -3
View File
@@ -124,13 +124,21 @@ export default async function parseV3(workbook: Workbook, downloadedFilePath: st
const upcoming = getUpcomingSheets(workbook);
const resolvedDays = groupSheetsByDate(upcoming);
const getDates = resolvedDays.map((d) => d.dateKey);
const annoucements = await getAnnouncements(getDates);
const sheetDates = resolvedDays.map((d) => d.dateKey);
const announcementDates = getWeekDates().concat(sheetDates);
if (new Date().getDay() === 0) {
announcementDates.push(...getWeekDates(7));
}
const annoucements = await getAnnouncements([...new Set(announcementDates)]);
const schedule: any = {};
for (const { dateKey, sheet } of resolvedDays) {
const { changes, absence, inWork, takesPlace, reservedRooms } = extractDaySchedule(sheet, teacherMap, themeColors, annoucements[dateKey]?.map(a => a.flags)?.flat() || []);
const ann = annoucements[dateKey];
const allFlags = ann.map(a => a.flags).flat();
const { changes, absence, inWork, takesPlace, reservedRooms } = extractDaySchedule(sheet, teacherMap, themeColors, allFlags);
schedule[dateKey] = {
info: { inWork },
@@ -420,6 +428,25 @@ function letterToNumber(letter: string) {
return letter.toLowerCase().charCodeAt(0) - 97;
}
function getWeekDates(offset: number = 0): string[] {
const today = new Date();
const day = today.getDay();
const monday = new Date(today);
monday.setDate(today.getDate() + (day === 0 ? -6 : 1 - day) + offset);
const dates: string[] = [];
for (let i = 0; i < 5; i++) {
const d = new Date(monday);
d.setDate(monday.getDate() + i);
dates.push(formatDateKey(d));
}
return dates;
}
function formatDateKey(date: Date): string {
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
}
function formatNowTime() {
const now = new Date();
return (