@selfcommunity/react-ui 0.10.2-courses.141 → 0.10.2-courses.142
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 +4 -1
- package/lib/cjs/shared/AccordionLessons/AccordionLessons.js +1 -1
- package/lib/esm/components/CourseDashboard/Student.js +4 -1
- package/lib/esm/shared/AccordionLessons/AccordionLessons.js +1 -1
- package/lib/umd/react-ui.js +1 -1
- package/package.json +8 -8
|
@@ -58,6 +58,9 @@ function getUrlNextLesson(course) {
|
|
|
58
58
|
});
|
|
59
59
|
return data;
|
|
60
60
|
}
|
|
61
|
+
function getIsNextLessonAvailable(course) {
|
|
62
|
+
return course.sections.some((section) => section.num_lessons_completed < section.num_lessons && section.lessons[section.num_lessons_completed].locked);
|
|
63
|
+
}
|
|
61
64
|
const Root = (0, material_1.styled)(material_1.Box, {
|
|
62
65
|
name: constants_1.PREFIX,
|
|
63
66
|
slot: 'Root',
|
|
@@ -116,7 +119,7 @@ function Student(inProps) {
|
|
|
116
119
|
const actionButton = (0, react_1.useMemo)(() => {
|
|
117
120
|
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.actionsWrapper }, { children: [((scCourse === null || scCourse === void 0 ? void 0 : scCourse.join_status) === types_1.SCCourseJoinStatusType.CREATOR || (scCourse === null || scCourse === void 0 ? void 0 : 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 === null || scCourse === void 0 ? void 0 : scCourse.join_status) === types_1.SCCourseJoinStatusType.MANAGER || (scCourse === null || scCourse === void 0 ? void 0 : scCourse.join_status) === types_1.SCCourseJoinStatusType.JOINED) &&
|
|
118
121
|
((scCourse === null || scCourse === void 0 ? void 0 : scCourse.join_status) !== null || (scCourse === null || scCourse === void 0 ? void 0 : scCourse.privacy) !== types_1.SCCoursePrivacyType.PRIVATE) &&
|
|
119
|
-
(scCourse === null || scCourse === void 0 ? void 0 : scCourse.user_completion_rate) < 100 && ((0, jsx_runtime_1.jsx)(ActionButton_1.default, { labelId: scCourse.num_lessons_completed === 0 ? messages.start : messages.continue, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_LESSON_ROUTE_NAME, getUrlNextLesson(scCourse)) })), (scCourse === null || scCourse === void 0 ? void 0 : scCourse.privacy) === types_1.SCCoursePrivacyType.PRIVATE &&
|
|
122
|
+
(scCourse === null || scCourse === void 0 ? void 0 : scCourse.user_completion_rate) < 100 && ((0, jsx_runtime_1.jsx)(ActionButton_1.default, { labelId: scCourse.num_lessons_completed === 0 ? messages.start : messages.continue, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_LESSON_ROUTE_NAME, getUrlNextLesson(scCourse)), disabled: getIsNextLessonAvailable(scCourse) })), (scCourse === null || scCourse === void 0 ? void 0 : scCourse.privacy) === types_1.SCCoursePrivacyType.PRIVATE &&
|
|
120
123
|
((scCourse === null || scCourse === void 0 ? void 0 : scCourse.join_status) === null || (scCourse === null || scCourse === void 0 ? void 0 : 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 }))] })));
|
|
121
124
|
}, [scCourse, sentRequest, loadingRequest, handleRequest]);
|
|
122
125
|
if (!scCourse) {
|
|
@@ -43,6 +43,6 @@ function AccordionLessons(inProps) {
|
|
|
43
43
|
}
|
|
44
44
|
return ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: ((_a = course.sections) === null || _a === void 0 ? void 0 : _a.length) > 0 ? ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, { children: course.sections.map((section) => ((0, jsx_runtime_1.jsxs)(material_1.Accordion, Object.assign({ className: classes.accordion, expanded: expanded === section.id, onChange: handleChange(section.id), disableGutters: true, elevation: 0, square: true }, { children: [(0, jsx_runtime_1.jsxs)(material_1.AccordionSummary, Object.assign({ className: classes.summary, expandIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "expand_less" }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ component: "span", variant: "body1" }, { children: section.name })), !isMobile && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ component: "span", variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.table.lessons.title", defaultMessage: "ui.course.table.lessons.title", values: {
|
|
45
45
|
lessonsNumber: section.lessons.length
|
|
46
|
-
} }) })))] })), section.lessons.map((lesson) => ((0, jsx_runtime_1.jsxs)(material_1.AccordionDetails, Object.assign({ className: classes.details }, { children: [lesson.completion_status === types_1.SCCourseLessonCompletionStatusType.COMPLETED ? ((0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small", color: "primary" }, { children: "circle_checked" }))) : ((0, jsx_runtime_1.jsx)(material_1.Box, { className: classes.circle })), (0, jsx_runtime_1.jsx)(material_1.Typography, { children: lesson.name })] }), lesson.id)))] }), section.id))) }))) : ((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.accordionLessons.empty", defaultMessage: "ui.course.accordionLessons.empty" }) }))) }));
|
|
46
|
+
} }) })))] })), section.lessons.map((lesson) => ((0, jsx_runtime_1.jsxs)(material_1.AccordionDetails, Object.assign({ className: classes.details }, { children: [lesson.completion_status === types_1.SCCourseLessonCompletionStatusType.COMPLETED ? ((0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small", color: "primary" }, { children: "circle_checked" }))) : lesson.locked ? ((0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" })) : ((0, jsx_runtime_1.jsx)(material_1.Box, { className: classes.circle })), (0, jsx_runtime_1.jsx)(material_1.Typography, { children: lesson.name })] }), lesson.id)))] }), section.id))) }))) : ((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.accordionLessons.empty", defaultMessage: "ui.course.accordionLessons.empty" }) }))) }));
|
|
47
47
|
}
|
|
48
48
|
exports.default = AccordionLessons;
|
|
@@ -56,6 +56,9 @@ function getUrlNextLesson(course) {
|
|
|
56
56
|
});
|
|
57
57
|
return data;
|
|
58
58
|
}
|
|
59
|
+
function getIsNextLessonAvailable(course) {
|
|
60
|
+
return course.sections.some((section) => section.num_lessons_completed < section.num_lessons && section.lessons[section.num_lessons_completed].locked);
|
|
61
|
+
}
|
|
59
62
|
const Root = styled(Box, {
|
|
60
63
|
name: PREFIX,
|
|
61
64
|
slot: 'Root',
|
|
@@ -114,7 +117,7 @@ function Student(inProps) {
|
|
|
114
117
|
const actionButton = useMemo(() => {
|
|
115
118
|
return (_jsxs(Stack, Object.assign({ className: classes.actionsWrapper }, { children: [((scCourse === null || scCourse === void 0 ? void 0 : scCourse.join_status) === SCCourseJoinStatusType.CREATOR || (scCourse === null || scCourse === void 0 ? void 0 : scCourse.join_status) === SCCourseJoinStatusType.MANAGER) && (_jsx(ActionButton, { labelId: messages.dashboard, to: scRoutingContext.url(SCRoutes.COURSE_DASHBOARD_ROUTE_NAME, scCourse), color: "inherit", variant: "outlined" })), ((scCourse === null || scCourse === void 0 ? void 0 : scCourse.join_status) === SCCourseJoinStatusType.MANAGER || (scCourse === null || scCourse === void 0 ? void 0 : scCourse.join_status) === SCCourseJoinStatusType.JOINED) &&
|
|
116
119
|
((scCourse === null || scCourse === void 0 ? void 0 : scCourse.join_status) !== null || (scCourse === null || scCourse === void 0 ? void 0 : scCourse.privacy) !== SCCoursePrivacyType.PRIVATE) &&
|
|
117
|
-
(scCourse === null || scCourse === void 0 ? void 0 : scCourse.user_completion_rate) < 100 && (_jsx(ActionButton, { labelId: scCourse.num_lessons_completed === 0 ? messages.start : messages.continue, to: scRoutingContext.url(SCRoutes.COURSE_LESSON_ROUTE_NAME, getUrlNextLesson(scCourse)) })), (scCourse === null || scCourse === void 0 ? void 0 : scCourse.privacy) === SCCoursePrivacyType.PRIVATE &&
|
|
120
|
+
(scCourse === null || scCourse === void 0 ? void 0 : scCourse.user_completion_rate) < 100 && (_jsx(ActionButton, { labelId: scCourse.num_lessons_completed === 0 ? messages.start : messages.continue, to: scRoutingContext.url(SCRoutes.COURSE_LESSON_ROUTE_NAME, getUrlNextLesson(scCourse)), disabled: getIsNextLessonAvailable(scCourse) })), (scCourse === null || scCourse === void 0 ? void 0 : scCourse.privacy) === SCCoursePrivacyType.PRIVATE &&
|
|
118
121
|
((scCourse === null || scCourse === void 0 ? void 0 : scCourse.join_status) === null || (scCourse === null || scCourse === void 0 ? void 0 : scCourse.join_status) === SCCourseJoinStatusType.REQUESTED) && (_jsx(ActionButton, { labelId: sentRequest ? messages.cancel : messages.request, color: "inherit", variant: "outlined", loading: loadingRequest, onClick: handleRequest }))] })));
|
|
119
122
|
}, [scCourse, sentRequest, loadingRequest, handleRequest]);
|
|
120
123
|
if (!scCourse) {
|
|
@@ -40,5 +40,5 @@ export default function AccordionLessons(inProps) {
|
|
|
40
40
|
}
|
|
41
41
|
return (_jsx(Fragment, { children: ((_a = course.sections) === null || _a === void 0 ? void 0 : _a.length) > 0 ? (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, { children: course.sections.map((section) => (_jsxs(Accordion, Object.assign({ className: classes.accordion, expanded: expanded === section.id, onChange: handleChange(section.id), disableGutters: true, elevation: 0, square: true }, { children: [_jsxs(AccordionSummary, Object.assign({ className: classes.summary, expandIcon: _jsx(Icon, { children: "expand_less" }) }, { children: [_jsx(Typography, Object.assign({ component: "span", variant: "body1" }, { children: section.name })), !isMobile && (_jsx(Typography, Object.assign({ component: "span", variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.course.table.lessons.title", defaultMessage: "ui.course.table.lessons.title", values: {
|
|
42
42
|
lessonsNumber: section.lessons.length
|
|
43
|
-
} }) })))] })), section.lessons.map((lesson) => (_jsxs(AccordionDetails, Object.assign({ className: classes.details }, { children: [lesson.completion_status === SCCourseLessonCompletionStatusType.COMPLETED ? (_jsx(Icon, Object.assign({ fontSize: "small", color: "primary" }, { children: "circle_checked" }))) : (_jsx(Box, { className: classes.circle })), _jsx(Typography, { children: lesson.name })] }), lesson.id)))] }), section.id))) }))) : (_jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.course.accordionLessons.empty", defaultMessage: "ui.course.accordionLessons.empty" }) }))) }));
|
|
43
|
+
} }) })))] })), section.lessons.map((lesson) => (_jsxs(AccordionDetails, Object.assign({ className: classes.details }, { children: [lesson.completion_status === SCCourseLessonCompletionStatusType.COMPLETED ? (_jsx(Icon, Object.assign({ fontSize: "small", color: "primary" }, { children: "circle_checked" }))) : lesson.locked ? (_jsx(Icon, { children: "private" })) : (_jsx(Box, { className: classes.circle })), _jsx(Typography, { children: lesson.name })] }), lesson.id)))] }), section.id))) }))) : (_jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.course.accordionLessons.empty", defaultMessage: "ui.course.accordionLessons.empty" }) }))) }));
|
|
44
44
|
}
|