use empty placeholder cells for weekdays that are not part of the shown month

This commit is contained in:
2024-08-06 01:24:27 +02:00
parent 5ac05114ce
commit 8f30c9e983
2 changed files with 44 additions and 17 deletions
+7 -7
View File
@@ -168,20 +168,20 @@ export function organizeEventsInCalendar(
let currentDate = startOfWeek(minDate, { weekStartsOn: 1 });
while (currentDate <= maxDate) {
const yearMonth = formatDate(currentDate, "yyyy-MM");
const week = formatDate(currentDate, "w");
const daysOfWeek = eachDayOfInterval({
start: currentDate,
end: endOfWeek(currentDate, { weekStartsOn: 1 }),
});
if (!calendar[yearMonth]) {
calendar[yearMonth] = {};
}
if (!calendar[yearMonth][week]) {
calendar[yearMonth][week] = {};
}
daysOfWeek.forEach((day) => {
const yearMonth = formatDate(day, "yyyy-MM");
if (!calendar[yearMonth]) {
calendar[yearMonth] = {};
}
if (!calendar[yearMonth][week]) {
calendar[yearMonth][week] = {};
}
const formattedDay = formatDate(day, "yyyy-MM-dd");
if (!calendar[yearMonth][week][formattedDay]) {
calendar[yearMonth][week][formattedDay] = [];