feat: course section reordering & migration to course v2 (#437)

* feat: reorder sections and lessons gracefully

* convert course into version 2

* feat: get next and prev working
This commit is contained in:
Rotimi Best
2024-08-17 17:10:15 +01:00
committed by GitHub
parent e18b4ca1b1
commit 1c9dc004a0
17 changed files with 425 additions and 143 deletions
@@ -287,7 +287,7 @@ export function updateLessonSection(section: any, sectionId: LessonSection['id']
.match({ id: sectionId });
}
export function updateLesson(lesson: any, lessonId: Lesson['id']) {
export async function updateLesson(lesson: any, lessonId: Lesson['id']) {
return supabase
.from('lesson')
.update({ ...lesson, id: undefined })
@@ -307,6 +307,14 @@ export function updateLessonCompletion(completion: LessonCompletion, shouldUpdat
}
}
export const upsertLessons = (data: { id: string; order: number }[]) => {
return supabase.from('lesson').upsert(data);
};
export const upsertLessonSections = (data: { id: string; order: number }[]) => {
return supabase.from('lesson_section').upsert(data);
};
export function deleteLesson(lessonId: Lesson['id']) {
// Need to implement soft delete
return supabase.from('lesson').delete().match({ id: lessonId });