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:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user