diff --git a/assets/calendar.js b/assets/calendar.js index 8629e61aa15b2cf5e4a324ff1a9691e00b6d5dd3..d13c171df4bcc241acde285c6467e313692055a1 100644 --- a/assets/calendar.js +++ b/assets/calendar.js @@ -10,8 +10,6 @@ // start the Stimulus application //import './bootstrap'; -import 'tui-calendar'; - var Calendar = require('tui-calendar'); /* CommonJS */ @@ -89,19 +87,21 @@ $(function () { url: "/calendar/receive", success: function (data) { var cleanedData = [] - data.forEach(function(schedule){ - if (schedule) { - schedule.start = schedule.start._date - schedule.end = schedule.end._date - scheduleIds[scheduleIds.length] = parseInt(schedule.id) - currentSchedule++ - cleanedData[cleanedData.length] = schedule - } - }) - - // console.log(currentSchedule) - - calendar.createSchedules(cleanedData) + console.log(data) + if (Array.isArray(data)) + { + data.forEach(function(schedule){ + if (schedule) { + schedule.start = schedule.start._date + schedule.end = schedule.end._date + scheduleIds[scheduleIds.length] = parseInt(schedule.id) + currentSchedule++ + cleanedData[cleanedData.length] = schedule + } + }) + + calendar.createSchedules(cleanedData) + } }, });