@selfcommunity/react-templates 0.4.5-courses.206 → 0.4.5-courses.207
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.
|
@@ -49,7 +49,7 @@ function Lesson(inProps) {
|
|
|
49
49
|
const [_lessonId, setLessonId] = (0, react_1.useState)(lessonId);
|
|
50
50
|
const [_sectionId, setSectionId] = (0, react_1.useState)(sectionId);
|
|
51
51
|
const { scLesson, setSCLesson } = (0, react_core_1.useSCFetchLesson)({ id: _lessonId, courseId, sectionId: _sectionId });
|
|
52
|
-
const { scCourse,
|
|
52
|
+
const { scCourse, refreshCourse } = (0, react_core_1.useSCFetchCourse)({
|
|
53
53
|
id: courseId,
|
|
54
54
|
params: { view: editMode || previewMode ? api_services_1.CourseInfoViewType.EDIT : api_services_1.CourseInfoViewType.USER }
|
|
55
55
|
});
|
|
@@ -170,10 +170,8 @@ function Lesson(inProps) {
|
|
|
170
170
|
.then(() => {
|
|
171
171
|
setCompleted(!completed);
|
|
172
172
|
setLoading(false);
|
|
173
|
-
const updatedCourse = Object.assign(Object.assign({}, scCourse), { num_lessons_completed: completed ? scCourse.num_lessons_completed - 1 : scCourse.num_lessons_completed + 1 });
|
|
174
173
|
refreshCourse();
|
|
175
|
-
|
|
176
|
-
if (updatedCourse.num_lessons === updatedCourse.num_lessons_completed) {
|
|
174
|
+
if (!completed && scCourse.num_lessons === scCourse.num_lessons_completed + 1) {
|
|
177
175
|
setOpenDialog(true);
|
|
178
176
|
}
|
|
179
177
|
onLessonStatusChange === null || onLessonStatusChange === void 0 ? void 0 : onLessonStatusChange();
|
|
@@ -47,7 +47,7 @@ export default function Lesson(inProps) {
|
|
|
47
47
|
const [_lessonId, setLessonId] = useState(lessonId);
|
|
48
48
|
const [_sectionId, setSectionId] = useState(sectionId);
|
|
49
49
|
const { scLesson, setSCLesson } = useSCFetchLesson({ id: _lessonId, courseId, sectionId: _sectionId });
|
|
50
|
-
const { scCourse,
|
|
50
|
+
const { scCourse, refreshCourse } = useSCFetchCourse({
|
|
51
51
|
id: courseId,
|
|
52
52
|
params: { view: editMode || previewMode ? CourseInfoViewType.EDIT : CourseInfoViewType.USER }
|
|
53
53
|
});
|
|
@@ -168,10 +168,8 @@ export default function Lesson(inProps) {
|
|
|
168
168
|
.then(() => {
|
|
169
169
|
setCompleted(!completed);
|
|
170
170
|
setLoading(false);
|
|
171
|
-
const updatedCourse = Object.assign(Object.assign({}, scCourse), { num_lessons_completed: completed ? scCourse.num_lessons_completed - 1 : scCourse.num_lessons_completed + 1 });
|
|
172
171
|
refreshCourse();
|
|
173
|
-
|
|
174
|
-
if (updatedCourse.num_lessons === updatedCourse.num_lessons_completed) {
|
|
172
|
+
if (!completed && scCourse.num_lessons === scCourse.num_lessons_completed + 1) {
|
|
175
173
|
setOpenDialog(true);
|
|
176
174
|
}
|
|
177
175
|
onLessonStatusChange === null || onLessonStatusChange === void 0 ? void 0 : onLessonStatusChange();
|