const removeLesson = (thisId: string, index: number) => {
const lessons = fieldArray.state.value;
const isCurrent = currentLessonId === thisId;
const nextId = lessons[index + 1]?.id ?? lessons[index - 1]?.id;
if (isCurrent) {
router.navigate(
nextId
? ludoNavigation.build.toBuilderModule(courseId, nextId) //changes the search param of moduleId
: ludoNavigation.build.toSelectCourse() // Should not happen, so as fallback navigate back
);
}
fieldArray.removeValue(index);
};
const removeLesson = (thisId: string, index: number) => {
const lessons = fieldArray.state.value;
const isCurrent = currentLessonId === thisId;
const nextId = lessons[index + 1]?.id ?? lessons[index - 1]?.id;
if (isCurrent) {
router.navigate(
nextId
? ludoNavigation.build.toBuilderModule(courseId, nextId) //changes the search param of moduleId
: ludoNavigation.build.toSelectCourse() // Should not happen, so as fallback navigate back
);
}
fieldArray.removeValue(index);
};