@selfcommunity/react-ui 0.10.2-courses.152 → 0.10.2-courses.154
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.
- package/lib/cjs/components/CourseDashboard/Student.js +22 -8
- package/lib/cjs/components/EditCourse/Customize.d.ts +1 -1
- package/lib/cjs/components/EditCourse/Customize.js +3 -3
- package/lib/cjs/components/EditCourse/EditCourse.js +4 -4
- package/lib/cjs/components/EditCourse/Lessons/FieldName.d.ts +1 -1
- package/lib/cjs/components/EditCourse/Lessons/FieldName.js +1 -1
- package/lib/cjs/components/EditCourse/Lessons/LessonRow.d.ts +1 -1
- package/lib/cjs/components/EditCourse/Lessons/SectionRow.d.ts +1 -1
- package/lib/cjs/components/EditCourse/Lessons/SectionRow.js +4 -3
- package/lib/cjs/components/EditCourse/Lessons.d.ts +1 -1
- package/lib/cjs/components/EditCourse/Lessons.js +36 -20
- package/lib/cjs/components/EditCourse/Options.d.ts +1 -1
- package/lib/cjs/components/EditCourse/Options.js +2 -2
- package/lib/esm/components/CourseDashboard/Student.js +23 -9
- package/lib/esm/components/EditCourse/Customize.d.ts +1 -1
- package/lib/esm/components/EditCourse/Customize.js +3 -3
- package/lib/esm/components/EditCourse/EditCourse.js +4 -4
- package/lib/esm/components/EditCourse/Lessons/FieldName.d.ts +1 -1
- package/lib/esm/components/EditCourse/Lessons/FieldName.js +1 -1
- package/lib/esm/components/EditCourse/Lessons/LessonRow.d.ts +1 -1
- package/lib/esm/components/EditCourse/Lessons/SectionRow.d.ts +1 -1
- package/lib/esm/components/EditCourse/Lessons/SectionRow.js +4 -3
- package/lib/esm/components/EditCourse/Lessons.d.ts +1 -1
- package/lib/esm/components/EditCourse/Lessons.js +36 -20
- package/lib/esm/components/EditCourse/Options.d.ts +1 -1
- package/lib/esm/components/EditCourse/Options.js +2 -2
- package/lib/umd/react-ui.js +1 -1
- package/package.json +8 -8
|
@@ -22,6 +22,7 @@ const UserAvatar_1 = tslib_1.__importDefault(require("../../shared/UserAvatar"))
|
|
|
22
22
|
const messages = {
|
|
23
23
|
dashboard: 'ui.course.dashboard.student.button.dashboard',
|
|
24
24
|
request: 'ui.course.dashboard.student.button.request',
|
|
25
|
+
review: 'ui.course.dashboard.student.button.review',
|
|
25
26
|
cancel: 'ui.course.dashboard.student.button.cancel',
|
|
26
27
|
start: 'ui.course.dashboard.student.button.start',
|
|
27
28
|
continue: 'ui.course.dashboard.student.button.continue'
|
|
@@ -47,6 +48,13 @@ function getUrlNextLesson(course) {
|
|
|
47
48
|
id: course.id,
|
|
48
49
|
slug: course.slug
|
|
49
50
|
};
|
|
51
|
+
if (course.user_completion_rate === 100) {
|
|
52
|
+
Object.assign(data, {
|
|
53
|
+
section_id: course.sections[0].id,
|
|
54
|
+
lesson_id: course.sections[0].lessons[0].id
|
|
55
|
+
});
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
50
58
|
course.sections.some((section) => {
|
|
51
59
|
const isNextLessonInThisSection = section.num_lessons_completed < section.num_lessons;
|
|
52
60
|
if (isNextLessonInThisSection) {
|
|
@@ -122,10 +130,13 @@ function Student(inProps) {
|
|
|
122
130
|
}, [scCourse, sentRequest, setLoadingRequest]);
|
|
123
131
|
// MEMOS
|
|
124
132
|
const actionButton = (0, react_1.useMemo)(() => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
if (!scCourse) {
|
|
134
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
135
|
+
}
|
|
136
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.actionsWrapper }, { children: [(scCourse.join_status === types_1.SCCourseJoinStatusType.CREATOR || scCourse.join_status === types_1.SCCourseJoinStatusType.MANAGER) && ((0, jsx_runtime_1.jsx)(ActionButton_1.default, { labelId: messages.dashboard, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_DASHBOARD_ROUTE_NAME, scCourse), color: "inherit", variant: "outlined" })), ((scCourse.privacy === types_1.SCCoursePrivacyType.PRIVATE &&
|
|
137
|
+
(scCourse.join_status === types_1.SCCourseJoinStatusType.MANAGER || (scCourse === null || scCourse === void 0 ? void 0 : scCourse.join_status) === types_1.SCCourseJoinStatusType.JOINED)) ||
|
|
138
|
+
(scCourse.privacy === types_1.SCCoursePrivacyType.OPEN && scCourse.join_status !== types_1.SCCourseJoinStatusType.CREATOR)) && ((0, jsx_runtime_1.jsx)(ActionButton_1.default, { labelId: scCourse.user_completion_rate === 0 ? messages.start : scCourse.user_completion_rate === 100 ? messages.review : messages.continue, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_LESSON_ROUTE_NAME, getUrlNextLesson(scCourse)), disabled: getIsNextLessonLocked(scCourse), color: scCourse.user_completion_rate === 100 ? 'inherit' : undefined, variant: scCourse.user_completion_rate === 100 ? 'outlined' : undefined })), scCourse.privacy === types_1.SCCoursePrivacyType.PRIVATE &&
|
|
139
|
+
(scCourse.join_status === null || scCourse.join_status === types_1.SCCourseJoinStatusType.REQUESTED) && ((0, jsx_runtime_1.jsx)(ActionButton_1.default, { labelId: sentRequest ? messages.cancel : messages.request, color: "inherit", variant: "outlined", loading: loadingRequest, onClick: handleRequest }))] })));
|
|
129
140
|
}, [scCourse, sentRequest, loadingRequest, handleRequest]);
|
|
130
141
|
if (!scCourse) {
|
|
131
142
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
@@ -134,10 +145,13 @@ function Student(inProps) {
|
|
|
134
145
|
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, scCourse.created_by)
|
|
135
146
|
}), { children: (0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !scCourse.created_by.community_badge, smaller: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { className: classes.avatar, src: scCourse.created_by.avatar, alt: scCourse.created_by.username }) })) })), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!scCourse.created_by.deleted && {
|
|
136
147
|
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, scCourse.created_by)
|
|
137
|
-
}), { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: scCourse.created_by.username })) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.header.user.creator", defaultMessage: "ui.course.dashboard.header.user.creator" }) }))] })] })), actionButton] })), (0, jsx_runtime_1.jsx)(material_1.Divider, {}), (scCourse.
|
|
138
|
-
scCourse.join_status === types_1.SCCourseJoinStatusType.
|
|
139
|
-
|
|
140
|
-
|
|
148
|
+
}), { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: scCourse.created_by.username })) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.header.user.creator", defaultMessage: "ui.course.dashboard.header.user.creator" }) }))] })] })), actionButton] })), (0, jsx_runtime_1.jsx)(material_1.Divider, {}), ((scCourse.privacy === types_1.SCCoursePrivacyType.PRIVATE &&
|
|
149
|
+
(scCourse.join_status === types_1.SCCourseJoinStatusType.CREATOR ||
|
|
150
|
+
scCourse.join_status === types_1.SCCourseJoinStatusType.MANAGER ||
|
|
151
|
+
scCourse.join_status === types_1.SCCourseJoinStatusType.JOINED)) ||
|
|
152
|
+
scCourse.privacy === types_1.SCCoursePrivacyType.OPEN) && ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6", className: classes.margin }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.student.description", defaultMessage: "ui.course.dashboard.student.description" }) })), (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ className: classes.box }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: scCourse.description })) }))] })), ((scCourse.privacy === types_1.SCCoursePrivacyType.PRIVATE &&
|
|
153
|
+
(scCourse.join_status === types_1.SCCourseJoinStatusType.MANAGER || scCourse.join_status === types_1.SCCourseJoinStatusType.JOINED)) ||
|
|
154
|
+
(scCourse.privacy === types_1.SCCoursePrivacyType.OPEN && scCourse.join_status !== types_1.SCCourseJoinStatusType.CREATOR)) && ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6", className: classes.margin }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.student.progress", defaultMessage: "ui.course.dashboard.student.description" }) })), (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.box }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.percentageWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.student.progress.described", defaultMessage: "ui.course.dashboard.student.progress.described", values: { progress: scCourse.num_lessons_completed, end: scCourse.num_lessons } }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.student.progress.percentage", defaultMessage: "ui.course.dashboard.student.progress.percentage", values: { percentage: scCourse.user_completion_rate } }) }))] })), (0, jsx_runtime_1.jsx)(material_1.LinearProgress, { className: classes.progress, variant: "determinate", value: scCourse === null || scCourse === void 0 ? void 0 : scCourse.user_completion_rate })] })), scCourse.user_completion_rate === 100 && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: (0, classnames_1.default)(classes.completedWrapper, classes.margin) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.student.completed", defaultMessage: "ui.course.dashboard.student.completed" }) })), (0, jsx_runtime_1.jsx)("img", { src: clapping_1.CLAPPING, alt: intl.formatMessage({ id: 'ui.course.dashboard.student.completed', defaultMessage: 'ui.course.dashboard.student.completed' }), width: 32, height: 32 })] }))), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6", className: classes.margin }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.student.contents", defaultMessage: "ui.course.dashboard.student.contents" }) })), (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.lessonsSections }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.table.sections.title", defaultMessage: "ui.course.table.sections.title", values: {
|
|
141
155
|
sectionsNumber: scCourse.num_sections
|
|
142
156
|
} }) })), (0, jsx_runtime_1.jsx)(material_1.Box, { className: classes.circle }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.table.lessons.title", defaultMessage: "ui.course.table.lessons.title", values: {
|
|
143
157
|
lessonsNumber: scCourse.num_lessons
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { SCCourseType } from '@selfcommunity/types';
|
|
3
3
|
interface CustomizeProps {
|
|
4
4
|
course: SCCourseType;
|
|
5
|
-
|
|
5
|
+
setCourse: (course: SCCourseType) => void;
|
|
6
6
|
}
|
|
7
7
|
declare function Customize(props: CustomizeProps): JSX.Element;
|
|
8
8
|
declare const _default: import("react").MemoExoticComponent<typeof Customize>;
|
|
@@ -9,17 +9,17 @@ const react_intl_1 = require("react-intl");
|
|
|
9
9
|
const Course_1 = require("../../constants/Course");
|
|
10
10
|
function Customize(props) {
|
|
11
11
|
// PROPS
|
|
12
|
-
const { course,
|
|
12
|
+
const { course, setCourse } = props;
|
|
13
13
|
// HOOKS
|
|
14
14
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
15
15
|
// HANDLERS
|
|
16
16
|
const handleSuccess = (0, react_1.useCallback)((data) => {
|
|
17
|
-
|
|
17
|
+
setCourse(data);
|
|
18
18
|
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.editCourse.tab.customize.snackbar.save", defaultMessage: "ui.editCourse.tab.customize.snackbar.save" }), {
|
|
19
19
|
variant: 'success',
|
|
20
20
|
autoHideDuration: 3000
|
|
21
21
|
});
|
|
22
|
-
}, [
|
|
22
|
+
}, [setCourse]);
|
|
23
23
|
const handleError = (0, react_1.useCallback)(() => {
|
|
24
24
|
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.common.error.action", defaultMessage: "ui.common.error.action" }), {
|
|
25
25
|
variant: 'error',
|
|
@@ -46,15 +46,15 @@ const TAB_DATA = [
|
|
|
46
46
|
value: course_1.SCCourseEditTabType.OPTIONS
|
|
47
47
|
}
|
|
48
48
|
];
|
|
49
|
-
function getPanelData(course,
|
|
49
|
+
function getPanelData(course, setCourse) {
|
|
50
50
|
return [
|
|
51
51
|
{
|
|
52
52
|
value: course_1.SCCourseEditTabType.LESSONS,
|
|
53
|
-
children: (0, jsx_runtime_1.jsx)(Lessons_1.default, { course: course,
|
|
53
|
+
children: (0, jsx_runtime_1.jsx)(Lessons_1.default, { course: course, setCourse: setCourse })
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
value: course_1.SCCourseEditTabType.CUSTOMIZE,
|
|
57
|
-
children: (0, jsx_runtime_1.jsx)(Customize_1.default, { course: course,
|
|
57
|
+
children: (0, jsx_runtime_1.jsx)(Customize_1.default, { course: course, setCourse: setCourse })
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
value: course_1.SCCourseEditTabType.USERS,
|
|
@@ -66,7 +66,7 @@ function getPanelData(course, setSCCourse) {
|
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
value: course_1.SCCourseEditTabType.OPTIONS,
|
|
69
|
-
children: (0, jsx_runtime_1.jsx)(Options_1.default, { course: course,
|
|
69
|
+
children: (0, jsx_runtime_1.jsx)(Options_1.default, { course: course, setCourse: setCourse })
|
|
70
70
|
}
|
|
71
71
|
];
|
|
72
72
|
}
|
|
@@ -6,7 +6,7 @@ interface FieldNameProps<T> {
|
|
|
6
6
|
endpoint: EndpointType;
|
|
7
7
|
row: T;
|
|
8
8
|
isNewRow: boolean;
|
|
9
|
-
handleManageRow: (section: SCCourseSectionType, type: ActionLessonType) => void;
|
|
9
|
+
handleManageRow: (section: SCCourseSectionType, type: ActionLessonType, newRow?: boolean) => void;
|
|
10
10
|
editMode: boolean;
|
|
11
11
|
handleDisableEditMode: () => void;
|
|
12
12
|
}
|
|
@@ -70,7 +70,7 @@ function FieldName(props) {
|
|
|
70
70
|
}, [isNewRow, name, endpoint, setLoading, handleDisableEditMode, handleManageRow]);
|
|
71
71
|
const handleClose = (0, react_1.useCallback)(() => {
|
|
72
72
|
if (isNewRow) {
|
|
73
|
-
handleManageRow(row, types_2.ActionLessonType.DELETE);
|
|
73
|
+
handleManageRow(row, types_2.ActionLessonType.DELETE, true);
|
|
74
74
|
pubsub_js_1.default.publish(`${PubSub_1.SCTopicType.COURSE}.${PubSub_1.SCGroupEventType.UPDATE}`, false);
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
@@ -8,7 +8,7 @@ interface LessonRowProps {
|
|
|
8
8
|
section: SCCourseSectionType;
|
|
9
9
|
lesson: SCCourseLessonType;
|
|
10
10
|
isNewRow: boolean;
|
|
11
|
-
handleManageLesson: (lesson: SCCourseLessonType, type: ActionLessonType) => void;
|
|
11
|
+
handleManageLesson: (lesson: SCCourseLessonType, type: ActionLessonType, newRow?: boolean) => void;
|
|
12
12
|
}
|
|
13
13
|
declare function LessonRow(props: LessonRowProps): JSX.Element;
|
|
14
14
|
declare const _default: import("react").MemoExoticComponent<typeof LessonRow>;
|
|
@@ -7,7 +7,7 @@ interface SectionRowProps {
|
|
|
7
7
|
provider: DraggableProvided;
|
|
8
8
|
section: SCCourseSectionType;
|
|
9
9
|
isNewRow: boolean;
|
|
10
|
-
handleManageSection: (section: SCCourseSectionType, type: ActionLessonType) => void;
|
|
10
|
+
handleManageSection: (section: SCCourseSectionType, type: ActionLessonType, newRow?: boolean) => void;
|
|
11
11
|
}
|
|
12
12
|
declare function SectionRow(props: SectionRowProps): JSX.Element;
|
|
13
13
|
declare const _default: import("react").MemoExoticComponent<typeof SectionRow>;
|
|
@@ -88,7 +88,8 @@ function SectionRow(props) {
|
|
|
88
88
|
const handleDeleteSection = (0, react_1.useCallback)(() => {
|
|
89
89
|
api_services_1.CourseService.deleteCourseSection(course.id, section.id)
|
|
90
90
|
.then(() => {
|
|
91
|
-
|
|
91
|
+
var _a;
|
|
92
|
+
const tempSection = Object.assign(Object.assign({}, section), { num_lessons: ((_a = section.lessons) === null || _a === void 0 ? void 0 : _a.length) || 0 });
|
|
92
93
|
handleManageSection(tempSection, types_2.ActionLessonType.DELETE);
|
|
93
94
|
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.editCourse.tab.lessons.table.snackbar.delete", defaultMessage: "ui.editCourse.tab.lessons.table.snackbar.delete" }), {
|
|
94
95
|
variant: 'success',
|
|
@@ -103,7 +104,7 @@ function SectionRow(props) {
|
|
|
103
104
|
});
|
|
104
105
|
});
|
|
105
106
|
}, [course, section, handleManageSection]);
|
|
106
|
-
const handleManageLesson = (0, react_1.useCallback)((lesson, type) => {
|
|
107
|
+
const handleManageLesson = (0, react_1.useCallback)((lesson, type, newRow) => {
|
|
107
108
|
switch (type) {
|
|
108
109
|
case types_2.ActionLessonType.ADD: {
|
|
109
110
|
const tempSection = Object.assign(Object.assign({}, section), { lessons: section.lessons ? [...section.lessons, lesson] : [lesson] });
|
|
@@ -122,7 +123,7 @@ function SectionRow(props) {
|
|
|
122
123
|
}
|
|
123
124
|
case types_2.ActionLessonType.DELETE: {
|
|
124
125
|
const tempSection = Object.assign(Object.assign({}, section), { lessons: section.lessons.filter((prevLesson) => prevLesson.id !== lesson.id) });
|
|
125
|
-
handleManageSection(tempSection, types_2.ActionLessonType.DELETE_UPDATE);
|
|
126
|
+
handleManageSection(tempSection, types_2.ActionLessonType.DELETE_UPDATE, newRow);
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
}, [section, handleManageSection]);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { SCCourseType } from '@selfcommunity/types';
|
|
3
3
|
interface LessonsProps {
|
|
4
4
|
course: SCCourseType;
|
|
5
|
-
|
|
5
|
+
setCourse: (course: SCCourseType) => void;
|
|
6
6
|
}
|
|
7
7
|
declare function Lessons(props: LessonsProps): JSX.Element;
|
|
8
8
|
declare const _default: import("react").MemoExoticComponent<typeof Lessons>;
|
|
@@ -51,7 +51,7 @@ const headerCells = [
|
|
|
51
51
|
];
|
|
52
52
|
function Lessons(props) {
|
|
53
53
|
// PROPS
|
|
54
|
-
const { course,
|
|
54
|
+
const { course, setCourse } = props;
|
|
55
55
|
// STATES
|
|
56
56
|
const [sections, setSections] = (0, react_1.useState)([]);
|
|
57
57
|
// HOOKS
|
|
@@ -85,7 +85,7 @@ function Lessons(props) {
|
|
|
85
85
|
sections_order: tempSections.map((tempSection) => tempSection.id)
|
|
86
86
|
};
|
|
87
87
|
api_services_1.CourseService.patchCourse(course.id, data)
|
|
88
|
-
.then(() =>
|
|
88
|
+
.then(() => setCourse(Object.assign(Object.assign({}, course), { sections: tempSections })))
|
|
89
89
|
.catch((error) => {
|
|
90
90
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
91
91
|
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.common.error.action", defaultMessage: "ui.common.error.action" }), {
|
|
@@ -97,24 +97,30 @@ function Lessons(props) {
|
|
|
97
97
|
const handleAddTempSection = (0, react_1.useCallback)(() => {
|
|
98
98
|
setSections((prevSections) => (prevSections.length > 0 ? [...prevSections, getSection(prevSections.length + 1)] : [getSection(1)]));
|
|
99
99
|
}, [setSections]);
|
|
100
|
-
const handleManageSection = (0, react_1.useCallback)((section, type) => {
|
|
100
|
+
const handleManageSection = (0, react_1.useCallback)((section, type, newRow = false) => {
|
|
101
101
|
switch (type) {
|
|
102
102
|
case types_1.ActionLessonType.ADD:
|
|
103
|
-
|
|
103
|
+
setCourse(Object.assign(Object.assign({}, course), { num_sections: course.num_sections + 1, sections: [...course.sections, section] }));
|
|
104
104
|
break;
|
|
105
105
|
case types_1.ActionLessonType.RENAME:
|
|
106
|
-
|
|
106
|
+
setCourse(Object.assign(Object.assign({}, course), { sections: course.sections.map((prevSection) => {
|
|
107
107
|
if (prevSection.id === section.id) {
|
|
108
108
|
return Object.assign(Object.assign({}, prevSection), { name: section.name });
|
|
109
109
|
}
|
|
110
110
|
return prevSection;
|
|
111
111
|
}) }));
|
|
112
112
|
break;
|
|
113
|
-
case types_1.ActionLessonType.DELETE:
|
|
114
|
-
|
|
113
|
+
case types_1.ActionLessonType.DELETE: {
|
|
114
|
+
if (newRow) {
|
|
115
|
+
setCourse(Object.assign(Object.assign({}, course), { sections: course.sections.filter((prevSection) => prevSection.id !== section.id) }));
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
setCourse(Object.assign(Object.assign({}, course), { num_sections: course.num_sections - 1, num_lessons: course.num_lessons - section.num_lessons, sections: course.sections.filter((prevSection) => prevSection.id !== section.id) }));
|
|
119
|
+
}
|
|
115
120
|
break;
|
|
121
|
+
}
|
|
116
122
|
case types_1.ActionLessonType.UPDATE:
|
|
117
|
-
|
|
123
|
+
setCourse(Object.assign(Object.assign({}, course), { sections: course.sections.map((prevSection) => {
|
|
118
124
|
if (prevSection.id === section.id) {
|
|
119
125
|
return Object.assign(Object.assign({}, prevSection), { lessons: section.lessons });
|
|
120
126
|
}
|
|
@@ -122,22 +128,32 @@ function Lessons(props) {
|
|
|
122
128
|
}) }));
|
|
123
129
|
break;
|
|
124
130
|
case type.endsWith(types_1.ActionLessonType.UPDATE) && type: {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
if (newRow) {
|
|
132
|
+
setCourse(Object.assign(Object.assign({}, course), { sections: course.sections.map((prevSection) => {
|
|
133
|
+
if (prevSection.id === section.id) {
|
|
134
|
+
return section;
|
|
135
|
+
}
|
|
136
|
+
return prevSection;
|
|
137
|
+
}) }));
|
|
128
138
|
}
|
|
129
|
-
else
|
|
130
|
-
numLessons = course.num_lessons
|
|
139
|
+
else {
|
|
140
|
+
let numLessons = course.num_lessons;
|
|
141
|
+
if (type === types_1.ActionLessonType.ADD_UPDATE) {
|
|
142
|
+
numLessons = course.num_lessons + 1;
|
|
143
|
+
}
|
|
144
|
+
else if (type === types_1.ActionLessonType.DELETE_UPDATE) {
|
|
145
|
+
numLessons = course.num_lessons - 1;
|
|
146
|
+
}
|
|
147
|
+
setCourse(Object.assign(Object.assign({}, course), { num_lessons: numLessons, sections: course.sections.map((prevSection) => {
|
|
148
|
+
if (prevSection.id === section.id) {
|
|
149
|
+
return section;
|
|
150
|
+
}
|
|
151
|
+
return prevSection;
|
|
152
|
+
}) }));
|
|
131
153
|
}
|
|
132
|
-
setSCCourse(Object.assign(Object.assign({}, course), { num_lessons: numLessons, sections: course.sections.map((prevSection) => {
|
|
133
|
-
if (prevSection.id === section.id) {
|
|
134
|
-
return section;
|
|
135
|
-
}
|
|
136
|
-
return prevSection;
|
|
137
|
-
}) }));
|
|
138
154
|
}
|
|
139
155
|
}
|
|
140
|
-
}, [course
|
|
156
|
+
}, [course]);
|
|
141
157
|
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.lessonTitle, variant: "h4" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.editCourse.tab.lessons", defaultMessage: "ui.editCourse.tab.lessons" }) })), (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.lessonInfoWrapper }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.lessonInfo }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "courses" }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.type", defaultMessage: "ui.course.type", values: {
|
|
142
158
|
typeOfCourse: intl.formatMessage({
|
|
143
159
|
id: `ui.course.type.${course.type}`,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { SCCourseType } from '@selfcommunity/types';
|
|
3
3
|
interface OptionsProps {
|
|
4
4
|
course: SCCourseType;
|
|
5
|
-
|
|
5
|
+
setCourse: (course: SCCourseType) => void;
|
|
6
6
|
}
|
|
7
7
|
declare function Options(props: OptionsProps): JSX.Element;
|
|
8
8
|
declare const _default: import("react").MemoExoticComponent<typeof Options>;
|
|
@@ -34,7 +34,7 @@ const OPTIONS = {
|
|
|
34
34
|
};
|
|
35
35
|
function Options(props) {
|
|
36
36
|
// PROPS
|
|
37
|
-
const { course,
|
|
37
|
+
const { course, setCourse } = props;
|
|
38
38
|
// STATES
|
|
39
39
|
const [tempOptions, setTempOptions] = (0, react_1.useState)(null);
|
|
40
40
|
const [canSave, setCanSave] = (0, react_1.useState)(false);
|
|
@@ -73,7 +73,7 @@ function Options(props) {
|
|
|
73
73
|
setLoading(true);
|
|
74
74
|
api_services_1.CourseService.patchCourse(course.id, Object.assign({ id: course.id }, tempOptions))
|
|
75
75
|
.then((data) => {
|
|
76
|
-
|
|
76
|
+
setCourse(data);
|
|
77
77
|
setTempOptions(null);
|
|
78
78
|
setCanSave(false);
|
|
79
79
|
setLoading(false);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Fragment, memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
4
|
import { PREFIX } from './constants';
|
|
5
5
|
import { Avatar, Box, Divider, LinearProgress, Stack, styled, Typography, useThemeProps } from '@mui/material';
|
|
@@ -20,6 +20,7 @@ import UserAvatar from '../../shared/UserAvatar';
|
|
|
20
20
|
const messages = {
|
|
21
21
|
dashboard: 'ui.course.dashboard.student.button.dashboard',
|
|
22
22
|
request: 'ui.course.dashboard.student.button.request',
|
|
23
|
+
review: 'ui.course.dashboard.student.button.review',
|
|
23
24
|
cancel: 'ui.course.dashboard.student.button.cancel',
|
|
24
25
|
start: 'ui.course.dashboard.student.button.start',
|
|
25
26
|
continue: 'ui.course.dashboard.student.button.continue'
|
|
@@ -45,6 +46,13 @@ function getUrlNextLesson(course) {
|
|
|
45
46
|
id: course.id,
|
|
46
47
|
slug: course.slug
|
|
47
48
|
};
|
|
49
|
+
if (course.user_completion_rate === 100) {
|
|
50
|
+
Object.assign(data, {
|
|
51
|
+
section_id: course.sections[0].id,
|
|
52
|
+
lesson_id: course.sections[0].lessons[0].id
|
|
53
|
+
});
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
48
56
|
course.sections.some((section) => {
|
|
49
57
|
const isNextLessonInThisSection = section.num_lessons_completed < section.num_lessons;
|
|
50
58
|
if (isNextLessonInThisSection) {
|
|
@@ -120,10 +128,13 @@ function Student(inProps) {
|
|
|
120
128
|
}, [scCourse, sentRequest, setLoadingRequest]);
|
|
121
129
|
// MEMOS
|
|
122
130
|
const actionButton = useMemo(() => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
if (!scCourse) {
|
|
132
|
+
return _jsx(_Fragment, {});
|
|
133
|
+
}
|
|
134
|
+
return (_jsxs(Stack, Object.assign({ className: classes.actionsWrapper }, { children: [(scCourse.join_status === SCCourseJoinStatusType.CREATOR || scCourse.join_status === SCCourseJoinStatusType.MANAGER) && (_jsx(ActionButton, { labelId: messages.dashboard, to: scRoutingContext.url(SCRoutes.COURSE_DASHBOARD_ROUTE_NAME, scCourse), color: "inherit", variant: "outlined" })), ((scCourse.privacy === SCCoursePrivacyType.PRIVATE &&
|
|
135
|
+
(scCourse.join_status === SCCourseJoinStatusType.MANAGER || (scCourse === null || scCourse === void 0 ? void 0 : scCourse.join_status) === SCCourseJoinStatusType.JOINED)) ||
|
|
136
|
+
(scCourse.privacy === SCCoursePrivacyType.OPEN && scCourse.join_status !== SCCourseJoinStatusType.CREATOR)) && (_jsx(ActionButton, { labelId: scCourse.user_completion_rate === 0 ? messages.start : scCourse.user_completion_rate === 100 ? messages.review : messages.continue, to: scRoutingContext.url(SCRoutes.COURSE_LESSON_ROUTE_NAME, getUrlNextLesson(scCourse)), disabled: getIsNextLessonLocked(scCourse), color: scCourse.user_completion_rate === 100 ? 'inherit' : undefined, variant: scCourse.user_completion_rate === 100 ? 'outlined' : undefined })), scCourse.privacy === SCCoursePrivacyType.PRIVATE &&
|
|
137
|
+
(scCourse.join_status === null || scCourse.join_status === SCCourseJoinStatusType.REQUESTED) && (_jsx(ActionButton, { labelId: sentRequest ? messages.cancel : messages.request, color: "inherit", variant: "outlined", loading: loadingRequest, onClick: handleRequest }))] })));
|
|
127
138
|
}, [scCourse, sentRequest, loadingRequest, handleRequest]);
|
|
128
139
|
if (!scCourse) {
|
|
129
140
|
return _jsx(StudentSkeleton, {});
|
|
@@ -132,10 +143,13 @@ function Student(inProps) {
|
|
|
132
143
|
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, scCourse.created_by)
|
|
133
144
|
}), { children: _jsx(UserAvatar, Object.assign({ hide: !scCourse.created_by.community_badge, smaller: true }, { children: _jsx(Avatar, { className: classes.avatar, src: scCourse.created_by.avatar, alt: scCourse.created_by.username }) })) })), _jsxs(Box, { children: [_jsx(Link, Object.assign({}, (!scCourse.created_by.deleted && {
|
|
134
145
|
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, scCourse.created_by)
|
|
135
|
-
}), { children: _jsx(Typography, Object.assign({ variant: "body1" }, { children: scCourse.created_by.username })) })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.header.user.creator", defaultMessage: "ui.course.dashboard.header.user.creator" }) }))] })] })), actionButton] })), _jsx(Divider, {}), (scCourse.
|
|
136
|
-
scCourse.join_status === SCCourseJoinStatusType.
|
|
137
|
-
|
|
138
|
-
|
|
146
|
+
}), { children: _jsx(Typography, Object.assign({ variant: "body1" }, { children: scCourse.created_by.username })) })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.header.user.creator", defaultMessage: "ui.course.dashboard.header.user.creator" }) }))] })] })), actionButton] })), _jsx(Divider, {}), ((scCourse.privacy === SCCoursePrivacyType.PRIVATE &&
|
|
147
|
+
(scCourse.join_status === SCCourseJoinStatusType.CREATOR ||
|
|
148
|
+
scCourse.join_status === SCCourseJoinStatusType.MANAGER ||
|
|
149
|
+
scCourse.join_status === SCCourseJoinStatusType.JOINED)) ||
|
|
150
|
+
scCourse.privacy === SCCoursePrivacyType.OPEN) && (_jsxs(Fragment, { children: [_jsx(Typography, Object.assign({ variant: "h6", className: classes.margin }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.student.description", defaultMessage: "ui.course.dashboard.student.description" }) })), _jsx(Stack, Object.assign({ className: classes.box }, { children: _jsx(Typography, Object.assign({ variant: "body1" }, { children: scCourse.description })) }))] })), ((scCourse.privacy === SCCoursePrivacyType.PRIVATE &&
|
|
151
|
+
(scCourse.join_status === SCCourseJoinStatusType.MANAGER || scCourse.join_status === SCCourseJoinStatusType.JOINED)) ||
|
|
152
|
+
(scCourse.privacy === SCCoursePrivacyType.OPEN && scCourse.join_status !== SCCourseJoinStatusType.CREATOR)) && (_jsxs(Fragment, { children: [_jsx(Typography, Object.assign({ variant: "h6", className: classes.margin }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.student.progress", defaultMessage: "ui.course.dashboard.student.description" }) })), _jsxs(Stack, Object.assign({ className: classes.box }, { children: [_jsxs(Stack, Object.assign({ className: classes.percentageWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.student.progress.described", defaultMessage: "ui.course.dashboard.student.progress.described", values: { progress: scCourse.num_lessons_completed, end: scCourse.num_lessons } }) })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.student.progress.percentage", defaultMessage: "ui.course.dashboard.student.progress.percentage", values: { percentage: scCourse.user_completion_rate } }) }))] })), _jsx(LinearProgress, { className: classes.progress, variant: "determinate", value: scCourse === null || scCourse === void 0 ? void 0 : scCourse.user_completion_rate })] })), scCourse.user_completion_rate === 100 && (_jsxs(Stack, Object.assign({ className: classNames(classes.completedWrapper, classes.margin) }, { children: [_jsx(Typography, Object.assign({ variant: "h3" }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.student.completed", defaultMessage: "ui.course.dashboard.student.completed" }) })), _jsx("img", { src: CLAPPING, alt: intl.formatMessage({ id: 'ui.course.dashboard.student.completed', defaultMessage: 'ui.course.dashboard.student.completed' }), width: 32, height: 32 })] }))), _jsx(Typography, Object.assign({ variant: "h6", className: classes.margin }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.student.contents", defaultMessage: "ui.course.dashboard.student.contents" }) })), _jsxs(Stack, Object.assign({ className: classes.lessonsSections }, { children: [_jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.course.table.sections.title", defaultMessage: "ui.course.table.sections.title", values: {
|
|
139
153
|
sectionsNumber: scCourse.num_sections
|
|
140
154
|
} }) })), _jsx(Box, { className: classes.circle }), _jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.course.table.lessons.title", defaultMessage: "ui.course.table.lessons.title", values: {
|
|
141
155
|
lessonsNumber: scCourse.num_lessons
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { SCCourseType } from '@selfcommunity/types';
|
|
3
3
|
interface CustomizeProps {
|
|
4
4
|
course: SCCourseType;
|
|
5
|
-
|
|
5
|
+
setCourse: (course: SCCourseType) => void;
|
|
6
6
|
}
|
|
7
7
|
declare function Customize(props: CustomizeProps): JSX.Element;
|
|
8
8
|
declare const _default: import("react").MemoExoticComponent<typeof Customize>;
|
|
@@ -6,17 +6,17 @@ import { FormattedMessage } from 'react-intl';
|
|
|
6
6
|
import { SCCourseFormStepType } from '../../constants/Course';
|
|
7
7
|
function Customize(props) {
|
|
8
8
|
// PROPS
|
|
9
|
-
const { course,
|
|
9
|
+
const { course, setCourse } = props;
|
|
10
10
|
// HOOKS
|
|
11
11
|
const { enqueueSnackbar } = useSnackbar();
|
|
12
12
|
// HANDLERS
|
|
13
13
|
const handleSuccess = useCallback((data) => {
|
|
14
|
-
|
|
14
|
+
setCourse(data);
|
|
15
15
|
enqueueSnackbar(_jsx(FormattedMessage, { id: "ui.editCourse.tab.customize.snackbar.save", defaultMessage: "ui.editCourse.tab.customize.snackbar.save" }), {
|
|
16
16
|
variant: 'success',
|
|
17
17
|
autoHideDuration: 3000
|
|
18
18
|
});
|
|
19
|
-
}, [
|
|
19
|
+
}, [setCourse]);
|
|
20
20
|
const handleError = useCallback(() => {
|
|
21
21
|
enqueueSnackbar(_jsx(FormattedMessage, { id: "ui.common.error.action", defaultMessage: "ui.common.error.action" }), {
|
|
22
22
|
variant: 'error',
|
|
@@ -44,15 +44,15 @@ const TAB_DATA = [
|
|
|
44
44
|
value: SCCourseEditTabType.OPTIONS
|
|
45
45
|
}
|
|
46
46
|
];
|
|
47
|
-
function getPanelData(course,
|
|
47
|
+
function getPanelData(course, setCourse) {
|
|
48
48
|
return [
|
|
49
49
|
{
|
|
50
50
|
value: SCCourseEditTabType.LESSONS,
|
|
51
|
-
children: _jsx(Lessons, { course: course,
|
|
51
|
+
children: _jsx(Lessons, { course: course, setCourse: setCourse })
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
value: SCCourseEditTabType.CUSTOMIZE,
|
|
55
|
-
children: _jsx(Customize, { course: course,
|
|
55
|
+
children: _jsx(Customize, { course: course, setCourse: setCourse })
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
value: SCCourseEditTabType.USERS,
|
|
@@ -64,7 +64,7 @@ function getPanelData(course, setSCCourse) {
|
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
value: SCCourseEditTabType.OPTIONS,
|
|
67
|
-
children: _jsx(Options, { course: course,
|
|
67
|
+
children: _jsx(Options, { course: course, setCourse: setCourse })
|
|
68
68
|
}
|
|
69
69
|
];
|
|
70
70
|
}
|
|
@@ -6,7 +6,7 @@ interface FieldNameProps<T> {
|
|
|
6
6
|
endpoint: EndpointType;
|
|
7
7
|
row: T;
|
|
8
8
|
isNewRow: boolean;
|
|
9
|
-
handleManageRow: (section: SCCourseSectionType, type: ActionLessonType) => void;
|
|
9
|
+
handleManageRow: (section: SCCourseSectionType, type: ActionLessonType, newRow?: boolean) => void;
|
|
10
10
|
editMode: boolean;
|
|
11
11
|
handleDisableEditMode: () => void;
|
|
12
12
|
}
|
|
@@ -67,7 +67,7 @@ function FieldName(props) {
|
|
|
67
67
|
}, [isNewRow, name, endpoint, setLoading, handleDisableEditMode, handleManageRow]);
|
|
68
68
|
const handleClose = useCallback(() => {
|
|
69
69
|
if (isNewRow) {
|
|
70
|
-
handleManageRow(row, ActionLessonType.DELETE);
|
|
70
|
+
handleManageRow(row, ActionLessonType.DELETE, true);
|
|
71
71
|
PubSub.publish(`${SCTopicType.COURSE}.${SCGroupEventType.UPDATE}`, false);
|
|
72
72
|
}
|
|
73
73
|
else {
|
|
@@ -8,7 +8,7 @@ interface LessonRowProps {
|
|
|
8
8
|
section: SCCourseSectionType;
|
|
9
9
|
lesson: SCCourseLessonType;
|
|
10
10
|
isNewRow: boolean;
|
|
11
|
-
handleManageLesson: (lesson: SCCourseLessonType, type: ActionLessonType) => void;
|
|
11
|
+
handleManageLesson: (lesson: SCCourseLessonType, type: ActionLessonType, newRow?: boolean) => void;
|
|
12
12
|
}
|
|
13
13
|
declare function LessonRow(props: LessonRowProps): JSX.Element;
|
|
14
14
|
declare const _default: import("react").MemoExoticComponent<typeof LessonRow>;
|
|
@@ -7,7 +7,7 @@ interface SectionRowProps {
|
|
|
7
7
|
provider: DraggableProvided;
|
|
8
8
|
section: SCCourseSectionType;
|
|
9
9
|
isNewRow: boolean;
|
|
10
|
-
handleManageSection: (section: SCCourseSectionType, type: ActionLessonType) => void;
|
|
10
|
+
handleManageSection: (section: SCCourseSectionType, type: ActionLessonType, newRow?: boolean) => void;
|
|
11
11
|
}
|
|
12
12
|
declare function SectionRow(props: SectionRowProps): JSX.Element;
|
|
13
13
|
declare const _default: import("react").MemoExoticComponent<typeof SectionRow>;
|
|
@@ -85,7 +85,8 @@ function SectionRow(props) {
|
|
|
85
85
|
const handleDeleteSection = useCallback(() => {
|
|
86
86
|
CourseService.deleteCourseSection(course.id, section.id)
|
|
87
87
|
.then(() => {
|
|
88
|
-
|
|
88
|
+
var _a;
|
|
89
|
+
const tempSection = Object.assign(Object.assign({}, section), { num_lessons: ((_a = section.lessons) === null || _a === void 0 ? void 0 : _a.length) || 0 });
|
|
89
90
|
handleManageSection(tempSection, ActionLessonType.DELETE);
|
|
90
91
|
enqueueSnackbar(_jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons.table.snackbar.delete", defaultMessage: "ui.editCourse.tab.lessons.table.snackbar.delete" }), {
|
|
91
92
|
variant: 'success',
|
|
@@ -100,7 +101,7 @@ function SectionRow(props) {
|
|
|
100
101
|
});
|
|
101
102
|
});
|
|
102
103
|
}, [course, section, handleManageSection]);
|
|
103
|
-
const handleManageLesson = useCallback((lesson, type) => {
|
|
104
|
+
const handleManageLesson = useCallback((lesson, type, newRow) => {
|
|
104
105
|
switch (type) {
|
|
105
106
|
case ActionLessonType.ADD: {
|
|
106
107
|
const tempSection = Object.assign(Object.assign({}, section), { lessons: section.lessons ? [...section.lessons, lesson] : [lesson] });
|
|
@@ -119,7 +120,7 @@ function SectionRow(props) {
|
|
|
119
120
|
}
|
|
120
121
|
case ActionLessonType.DELETE: {
|
|
121
122
|
const tempSection = Object.assign(Object.assign({}, section), { lessons: section.lessons.filter((prevLesson) => prevLesson.id !== lesson.id) });
|
|
122
|
-
handleManageSection(tempSection, ActionLessonType.DELETE_UPDATE);
|
|
123
|
+
handleManageSection(tempSection, ActionLessonType.DELETE_UPDATE, newRow);
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
}, [section, handleManageSection]);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { SCCourseType } from '@selfcommunity/types';
|
|
3
3
|
interface LessonsProps {
|
|
4
4
|
course: SCCourseType;
|
|
5
|
-
|
|
5
|
+
setCourse: (course: SCCourseType) => void;
|
|
6
6
|
}
|
|
7
7
|
declare function Lessons(props: LessonsProps): JSX.Element;
|
|
8
8
|
declare const _default: import("react").MemoExoticComponent<typeof Lessons>;
|