-
# worst code ever ```js for (const lesson of processedLessons) { let savedLesson; if (lesson.unpublished) { const validationResult = validateEvent(lesson.unpublished); if (validationResult !== true) { console.error('Invalid event:', validationResult); showToast('error', 'Error', `Invalid event: ${validationResult}`); return; } const published = await lesson.unpublished.publish(); savedLesson = await handlePostResource(lesson.unpublished); if (published && savedLesson) { const deleted = await axios.delete(`/api/drafts/${lesson.d}`); if (deleted && deleted.status === 204) { const savedLesson = await handlePostLesson(lesson); if (savedLesson) { createdLessons.push(savedLesson); } } } } else { const savedLesson = await handlePostLesson(lesson); if (savedLesson) { createdLessons.push(savedLesson); } } } ```