Skip to content

Commit

Permalink
Fix TypeError: undefined is not an object in getMonthsMap function
Browse files Browse the repository at this point in the history
fixes #110
  • Loading branch information
SjoenH committed Apr 18, 2024
1 parent 972086b commit b70779d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions kabinizer-front-end/src/utils/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@ export const getMonthsMap = (data: Option[]): MonthMapType => {
const weeksMap = getWeeksMap(data);

for (const week in weeksMap) {
const month = weeksMap[week][0].month;
if (!monthsMap[month]) {
monthsMap[month] = {};
if (weeksMap[week] && weeksMap[week].length > 0) {
const month = weeksMap[week][0].month;
if (!monthsMap[month]) {
monthsMap[month] = {};
}
monthsMap[month][Number(week)] = weeksMap[week];
}
monthsMap[month][Number(week)] = weeksMap[week];
}

return monthsMap;
Expand Down

0 comments on commit b70779d

Please sign in to comment.