use empty placeholder cells for weekdays that are not part of the shown month
This commit is contained in:
@@ -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] = [];
|
||||
|
||||
Reference in New Issue
Block a user