@selfcommunity/react-templates 0.4.5-courses.144 → 0.4.5-courses.146

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,7 +62,7 @@ function Lesson(inProps) {
62
62
  const currentData = (0, react_1.useMemo)(() => {
63
63
  if (!scCourse || !scLesson)
64
64
  return null;
65
- return (0, react_ui_1.getCurrentSectionAndLessonIndex)(scCourse, _sectionId, _lessonId);
65
+ return (0, react_ui_1.getCurrentSectionAndLessonIndex)(scCourse, scLesson.section_id, scLesson.id);
66
66
  }, [scCourse, scLesson]);
67
67
  const [currentSectionIndex, setCurrentSectionIndex] = (0, react_1.useState)((currentData === null || currentData === void 0 ? void 0 : currentData.currentSectionIndex) || 0);
68
68
  const [currentLessonIndex, setCurrentLessonIndex] = (0, react_1.useState)((currentData === null || currentData === void 0 ? void 0 : currentData.currentLessonIndex) || 0);
@@ -169,8 +169,7 @@ function Lesson(inProps) {
169
169
  const updatedCourse = Object.assign(Object.assign({}, scCourse), { sections: scCourse.sections.map((section) => (Object.assign(Object.assign({}, section), { lessons: section.lessons.map((lesson) => lesson.id === scLesson.id
170
170
  ? Object.assign(Object.assign({}, lesson), { completion_status: c ? types_1.SCCourseLessonCompletionStatusType.UNCOMPLETED : types_1.SCCourseLessonCompletionStatusType.COMPLETED }) : lesson) }))), num_lessons_completed: c ? scCourse.num_lessons_completed - 1 : scCourse.num_lessons_completed + 1 });
171
171
  setSCCourse(updatedCourse);
172
- //TODO: fix it
173
- if (scCourse.num_lessons - scCourse.num_lessons_completed === 1) {
172
+ if (updatedCourse.num_lessons === updatedCourse.num_lessons_completed) {
174
173
  setOpenDialog(true);
175
174
  }
176
175
  })
@@ -60,7 +60,7 @@ export default function Lesson(inProps) {
60
60
  const currentData = useMemo(() => {
61
61
  if (!scCourse || !scLesson)
62
62
  return null;
63
- return getCurrentSectionAndLessonIndex(scCourse, _sectionId, _lessonId);
63
+ return getCurrentSectionAndLessonIndex(scCourse, scLesson.section_id, scLesson.id);
64
64
  }, [scCourse, scLesson]);
65
65
  const [currentSectionIndex, setCurrentSectionIndex] = useState((currentData === null || currentData === void 0 ? void 0 : currentData.currentSectionIndex) || 0);
66
66
  const [currentLessonIndex, setCurrentLessonIndex] = useState((currentData === null || currentData === void 0 ? void 0 : currentData.currentLessonIndex) || 0);
@@ -167,8 +167,7 @@ export default function Lesson(inProps) {
167
167
  const updatedCourse = Object.assign(Object.assign({}, scCourse), { sections: scCourse.sections.map((section) => (Object.assign(Object.assign({}, section), { lessons: section.lessons.map((lesson) => lesson.id === scLesson.id
168
168
  ? Object.assign(Object.assign({}, lesson), { completion_status: c ? SCCourseLessonCompletionStatusType.UNCOMPLETED : SCCourseLessonCompletionStatusType.COMPLETED }) : lesson) }))), num_lessons_completed: c ? scCourse.num_lessons_completed - 1 : scCourse.num_lessons_completed + 1 });
169
169
  setSCCourse(updatedCourse);
170
- //TODO: fix it
171
- if (scCourse.num_lessons - scCourse.num_lessons_completed === 1) {
170
+ if (updatedCourse.num_lessons === updatedCourse.num_lessons_completed) {
172
171
  setOpenDialog(true);
173
172
  }
174
173
  })