Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-03-31 14:39:04 -03:00
parent 8b792e1d44
commit 0bea4173f5
18 changed files with 517 additions and 192 deletions
@@ -197,7 +197,7 @@ export default function LessonEditor({ params }: { params: { id: string; lessonI
}
const updated = await cmsApi.updateLesson(lesson.id, {
metadata: { ...lesson.metadata },
metadata: lesson.metadata ?? { blocks: [] },
content_blocks: blocks,
content_url,
content_type, // Sync type to ensure backend triggers transcription
@@ -348,11 +348,16 @@ export default function LessonEditor({ params }: { params: { id: string; lessonI
};
setBlocks([...blocks, newBlock]);
} else {
const newBlocks = await cmsApi.generateQuiz(lesson.id, {
const generatedQuiz = await cmsApi.generateQuiz(lesson.id, {
prompt_hint: aiQuizContext,
quiz_type: aiQuizType
});
setBlocks([...blocks, ...newBlocks]);
const newBlock: Block = {
id: Math.random().toString(36).substr(2, 9),
type: 'quiz',
quiz_data: { questions: generatedQuiz.questions }
};
setBlocks([...blocks, newBlock]);
}
setAiQuizContext("");
} catch (err) {