@selfcommunity/react-templates 0.4.5-courses.183 → 0.4.5-courses.184

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.
@@ -56,7 +56,7 @@ function Lesson(inProps) {
56
56
  const [_lessonId, setLessonId] = (0, react_1.useState)(lessonId);
57
57
  const [_sectionId, setSectionId] = (0, react_1.useState)(sectionId);
58
58
  const { scLesson, setSCLesson } = (0, react_core_1.useSCFetchLesson)({ id: _lessonId, courseId, sectionId: _sectionId });
59
- const { scCourse, setSCCourse } = (0, react_core_1.useSCFetchCourse)({
59
+ const { scCourse, setSCCourse, refreshCourse } = (0, react_core_1.useSCFetchCourse)({
60
60
  id: courseId,
61
61
  params: { view: editMode || previewMode ? api_services_1.CourseInfoViewType.EDIT : api_services_1.CourseInfoViewType.USER }
62
62
  });
@@ -177,8 +177,8 @@ function Lesson(inProps) {
177
177
  .then(() => {
178
178
  setCompleted(!completed);
179
179
  setLoading(false);
180
- 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
181
- ? Object.assign(Object.assign({}, lesson), { completion_status: completed ? types_1.SCCourseLessonCompletionStatusType.UNCOMPLETED : types_1.SCCourseLessonCompletionStatusType.COMPLETED }) : lesson) }))), num_lessons_completed: completed ? scCourse.num_lessons_completed - 1 : scCourse.num_lessons_completed + 1 });
180
+ const updatedCourse = Object.assign(Object.assign({}, scCourse), { num_lessons_completed: completed ? scCourse.num_lessons_completed - 1 : scCourse.num_lessons_completed + 1 });
181
+ refreshCourse();
182
182
  setSCCourse(updatedCourse);
183
183
  if (updatedCourse.num_lessons === updatedCourse.num_lessons_completed) {
184
184
  setOpenDialog(true);
@@ -54,7 +54,7 @@ export default function Lesson(inProps) {
54
54
  const [_lessonId, setLessonId] = useState(lessonId);
55
55
  const [_sectionId, setSectionId] = useState(sectionId);
56
56
  const { scLesson, setSCLesson } = useSCFetchLesson({ id: _lessonId, courseId, sectionId: _sectionId });
57
- const { scCourse, setSCCourse } = useSCFetchCourse({
57
+ const { scCourse, setSCCourse, refreshCourse } = useSCFetchCourse({
58
58
  id: courseId,
59
59
  params: { view: editMode || previewMode ? CourseInfoViewType.EDIT : CourseInfoViewType.USER }
60
60
  });
@@ -175,8 +175,8 @@ export default function Lesson(inProps) {
175
175
  .then(() => {
176
176
  setCompleted(!completed);
177
177
  setLoading(false);
178
- 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
179
- ? Object.assign(Object.assign({}, lesson), { completion_status: completed ? SCCourseLessonCompletionStatusType.UNCOMPLETED : SCCourseLessonCompletionStatusType.COMPLETED }) : lesson) }))), num_lessons_completed: completed ? scCourse.num_lessons_completed - 1 : scCourse.num_lessons_completed + 1 });
178
+ const updatedCourse = Object.assign(Object.assign({}, scCourse), { num_lessons_completed: completed ? scCourse.num_lessons_completed - 1 : scCourse.num_lessons_completed + 1 });
179
+ refreshCourse();
180
180
  setSCCourse(updatedCourse);
181
181
  if (updatedCourse.num_lessons === updatedCourse.num_lessons_completed) {
182
182
  setOpenDialog(true);