@selfcommunity/react-ui 0.10.2-courses.196 → 0.10.2-courses.197
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 +5 -2
- package/lib/cjs/components/CourseDashboard/Teacher/Comments.js +1 -1
- package/lib/cjs/components/Notification/Course/Course.js +36 -16
- package/lib/esm/components/CourseDashboard/Student.js +5 -2
- package/lib/esm/components/CourseDashboard/Teacher/Comments.js +1 -1
- package/lib/esm/components/Notification/Course/Course.js +36 -16
- package/lib/umd/react-ui.js +1 -1
- package/package.json +8 -8
|
@@ -66,7 +66,7 @@ function getUrlNextLesson(course) {
|
|
|
66
66
|
}
|
|
67
67
|
(_a = course.sections) === null || _a === void 0 ? void 0 : _a.some((section) => {
|
|
68
68
|
var _a;
|
|
69
|
-
const isNextLessonInThisSection = section.num_lessons_completed < section.num_lessons;
|
|
69
|
+
const isNextLessonInThisSection = section.num_lessons_completed < section.num_lessons && !section.locked;
|
|
70
70
|
if (isNextLessonInThisSection) {
|
|
71
71
|
Object.assign(data, {
|
|
72
72
|
section_id: section.id,
|
|
@@ -79,6 +79,9 @@ function getUrlNextLesson(course) {
|
|
|
79
79
|
}
|
|
80
80
|
function getIsNextLessonLocked(course) {
|
|
81
81
|
var _a;
|
|
82
|
+
if (course.join_status === null) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
82
85
|
return (_a = course.sections) === null || _a === void 0 ? void 0 : _a.every((section) => {
|
|
83
86
|
var _a, _b;
|
|
84
87
|
return (section.num_lessons_completed < section.num_lessons &&
|
|
@@ -173,7 +176,7 @@ function Student(inProps) {
|
|
|
173
176
|
? BUTTON_MESSAGES.start
|
|
174
177
|
: scCourse.user_completion_rate === 100
|
|
175
178
|
? BUTTON_MESSAGES.review
|
|
176
|
-
: BUTTON_MESSAGES.continue, to: scCourse.join_status !== null ? scRoutingContext.url(react_core_1.SCRoutes.COURSE_LESSON_ROUTE_NAME, getUrlNextLesson(scCourse)) : undefined, disabled:
|
|
179
|
+
: BUTTON_MESSAGES.continue, to: scCourse.join_status !== null ? scRoutingContext.url(react_core_1.SCRoutes.COURSE_LESSON_ROUTE_NAME, getUrlNextLesson(scCourse)) : undefined, disabled: getIsNextLessonLocked(scCourse), color: scCourse.user_completion_rate === 100 ? 'inherit' : undefined, variant: scCourse.user_completion_rate === 100 ? 'outlined' : undefined, loading: scCourse.join_status === null ? loadingRequest : undefined, onClick: !scUserContext.user ? handleAnonymousAction : scCourse.join_status === null ? handleRequest : undefined })), scCourse.privacy === types_1.SCCoursePrivacyType.PRIVATE &&
|
|
177
180
|
(scCourse.join_status === null || scCourse.join_status === types_1.SCCourseJoinStatusType.REQUESTED) && ((0, jsx_runtime_1.jsx)(ActionButton_1.default, { labelId: sentRequest ? BUTTON_MESSAGES.cancel : BUTTON_MESSAGES.request, color: "inherit", variant: "outlined", loading: loadingRequest, onClick: handleRequest }))] })));
|
|
178
181
|
}, [scCourse, sentRequest, loadingRequest, handleRequest]);
|
|
179
182
|
if (!scCourse) {
|
|
@@ -98,7 +98,7 @@ function Comments(props) {
|
|
|
98
98
|
map.set(name, [...map.get(name), comment]);
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
|
-
return Array.from(map.entries()).map(([name, comments]) => ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.outerWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: name })), (0, jsx_runtime_1.jsx)(material_1.Divider, {}), (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.innerWrapper }, { children: [comments.map((comment) => ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.userWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Avatar, { src: comment.created_by.avatar, alt: comment.created_by.username, className: classes.avatar }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.userInfo }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: comment.created_by.username })), (0, jsx_runtime_1.jsx)(material_1.Box, { className: classes.circle }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedDate, { value: comment.created_at }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", component: "div", dangerouslySetInnerHTML: { __html: comment.html } })] })] }), comment.id))), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.
|
|
101
|
+
return Array.from(map.entries()).map(([name, comments]) => ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.outerWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: name })), (0, jsx_runtime_1.jsx)(material_1.Divider, {}), (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.innerWrapper }, { children: [comments.map((comment) => ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.userWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Avatar, { src: comment.created_by.avatar, alt: comment.created_by.username, className: classes.avatar }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.userInfo }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: comment.created_by.username })), (0, jsx_runtime_1.jsx)(material_1.Box, { className: classes.circle }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedDate, { value: comment.created_at }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", component: "div", dangerouslySetInnerHTML: { __html: comment.html } })] })] }), comment.id))), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_LESSON_PREVIEW_ROUTE_NAME, (0, course_1.getUrlLesson)(comments[0].extras.course, comments[0].extras.lesson, comments[0].extras.section)), size: "small", variant: "outlined", color: "inherit", className: classes.button }, { children: (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.dashboard.teacher.tab.comments.lessons.btn.label", defaultMessage: "ui.course.dashboard.teacher.tab.comments.lessons.btn.label" }) })) }))] }))] }), name)));
|
|
102
102
|
}, [state.results]);
|
|
103
103
|
if (!state.initialized) {
|
|
104
104
|
return (0, jsx_runtime_1.jsx)(CommentsSkeleton, {});
|
|
@@ -31,6 +31,14 @@ const Root = (0, styles_1.styled)(NotificationItem_1.default, {
|
|
|
31
31
|
name: constants_1.PREFIX,
|
|
32
32
|
slot: 'CourseRoot'
|
|
33
33
|
})(() => ({}));
|
|
34
|
+
function formatLessonUrl(notificationObject) {
|
|
35
|
+
return {
|
|
36
|
+
id: notificationObject.course.id,
|
|
37
|
+
slug: notificationObject.course.slug,
|
|
38
|
+
section_id: notificationObject.comment.section_id,
|
|
39
|
+
lesson_id: notificationObject.comment.lesson_id
|
|
40
|
+
};
|
|
41
|
+
}
|
|
34
42
|
/**
|
|
35
43
|
* This component render the content of the notification of type course
|
|
36
44
|
* @constructor
|
|
@@ -51,34 +59,46 @@ function CourseNotification(props) {
|
|
|
51
59
|
}
|
|
52
60
|
// RENDER
|
|
53
61
|
if (isSnippetTemplate || isToastTemplate) {
|
|
54
|
-
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, `${constants_1.PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!notificationObject.
|
|
55
|
-
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.
|
|
56
|
-
}), { onClick: notificationObject.
|
|
57
|
-
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.
|
|
58
|
-
}), { onClick: notificationObject.
|
|
62
|
+
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, `${constants_1.PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
63
|
+
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
64
|
+
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }, { children: (0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !notificationObject.user.community_badge, smaller: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar, classes: { root: classes.avatar } }) })) })), primary: (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
65
|
+
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
66
|
+
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.user.username })), ' ', (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.notification.course.${notificationObject.type}`, defaultMessage: `ui.notification.course.${notificationObject.type}`, values: {
|
|
59
67
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
60
68
|
// @ts-ignore
|
|
61
|
-
name: notificationObject.
|
|
69
|
+
name: notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
70
|
+
? notificationObject.comment.lesson_name
|
|
71
|
+
: notificationObject.course.name,
|
|
62
72
|
link: (...chunks) => ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
63
73
|
? react_core_1.SCRoutes.COURSE_LESSON_ROUTE_NAME
|
|
64
|
-
: react_core_1.SCRoutes.COURSE_ROUTE_NAME, notificationObject.
|
|
74
|
+
: react_core_1.SCRoutes.COURSE_ROUTE_NAME, notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
75
|
+
? formatLessonUrl(notificationObject)
|
|
76
|
+
: notificationObject.course) }, { children: chunks })))
|
|
65
77
|
} })] }), footer: isToastTemplate ? ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [(0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ color: "primary" }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
66
78
|
? react_core_1.SCRoutes.COURSE_LESSON_ROUTE_NAME
|
|
67
|
-
: react_core_1.SCRoutes.COURSE_ROUTE_NAME, notificationObject.
|
|
79
|
+
: react_core_1.SCRoutes.COURSE_ROUTE_NAME, notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
80
|
+
? formatLessonUrl(notificationObject)
|
|
81
|
+
: notificationObject.course) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.notification.course.button.see", defaultMessage: "ui.notification.course.button.see" }) })) }))] }))) : ((0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at, className: classes.snippetTime })) }, rest)));
|
|
68
82
|
}
|
|
69
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, `${constants_1.PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!notificationObject.
|
|
70
|
-
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.
|
|
71
|
-
}), { onClick: notificationObject.
|
|
72
|
-
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.
|
|
73
|
-
}), { onClick: notificationObject.
|
|
83
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, `${constants_1.PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
84
|
+
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
85
|
+
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }, { children: (0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !notificationObject.user.community_badge, smaller: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { className: classes.avatar, alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar }) })) })), primary: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
86
|
+
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
87
|
+
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.user.username })), ' ', (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.notification.course.${notificationObject.type}`, defaultMessage: `ui.notification.course.${notificationObject.type}`, values: {
|
|
74
88
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
75
89
|
// @ts-ignore
|
|
76
|
-
name: notificationObject.
|
|
90
|
+
name: notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
91
|
+
? notificationObject.comment.lesson_name
|
|
92
|
+
: notificationObject.course.name,
|
|
77
93
|
link: (...chunks) => ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
78
94
|
? react_core_1.SCRoutes.COURSE_LESSON_ROUTE_NAME
|
|
79
|
-
: react_core_1.SCRoutes.COURSE_ROUTE_NAME, notificationObject.
|
|
95
|
+
: react_core_1.SCRoutes.COURSE_ROUTE_NAME, notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
96
|
+
? formatLessonUrl(notificationObject)
|
|
97
|
+
: notificationObject.course) }, { children: chunks })))
|
|
80
98
|
} }), notificationObject.type !== types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON && ((0, jsx_runtime_1.jsx)(Course_1.default, { course: notificationObject.course, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), template: types_2.SCCourseTemplateType.SNIPPET, elevation: 0 }))] }), actions: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [(0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at, className: classes.activeAt }), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ color: 'primary', variant: "outlined", size: "small", classes: { root: classes.seeButton }, component: react_core_1.Link, to: scRoutingContext.url(notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
81
99
|
? react_core_1.SCRoutes.COURSE_LESSON_ROUTE_NAME
|
|
82
|
-
: react_core_1.SCRoutes.COURSE_ROUTE_NAME, notificationObject.
|
|
100
|
+
: react_core_1.SCRoutes.COURSE_ROUTE_NAME, notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
101
|
+
? formatLessonUrl(notificationObject)
|
|
102
|
+
: notificationObject.course) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.notification.course.button.see", defaultMessage: "ui.notification.course.button.see" }) }))] })) }, rest)), openAlert && (0, jsx_runtime_1.jsx)(UserDeletedSnackBar_1.default, { open: openAlert, handleClose: () => setOpenAlert(false) })] }));
|
|
83
103
|
}
|
|
84
104
|
exports.default = CourseNotification;
|
|
@@ -64,7 +64,7 @@ function getUrlNextLesson(course) {
|
|
|
64
64
|
}
|
|
65
65
|
(_a = course.sections) === null || _a === void 0 ? void 0 : _a.some((section) => {
|
|
66
66
|
var _a;
|
|
67
|
-
const isNextLessonInThisSection = section.num_lessons_completed < section.num_lessons;
|
|
67
|
+
const isNextLessonInThisSection = section.num_lessons_completed < section.num_lessons && !section.locked;
|
|
68
68
|
if (isNextLessonInThisSection) {
|
|
69
69
|
Object.assign(data, {
|
|
70
70
|
section_id: section.id,
|
|
@@ -77,6 +77,9 @@ function getUrlNextLesson(course) {
|
|
|
77
77
|
}
|
|
78
78
|
function getIsNextLessonLocked(course) {
|
|
79
79
|
var _a;
|
|
80
|
+
if (course.join_status === null) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
80
83
|
return (_a = course.sections) === null || _a === void 0 ? void 0 : _a.every((section) => {
|
|
81
84
|
var _a, _b;
|
|
82
85
|
return (section.num_lessons_completed < section.num_lessons &&
|
|
@@ -171,7 +174,7 @@ function Student(inProps) {
|
|
|
171
174
|
? BUTTON_MESSAGES.start
|
|
172
175
|
: scCourse.user_completion_rate === 100
|
|
173
176
|
? BUTTON_MESSAGES.review
|
|
174
|
-
: BUTTON_MESSAGES.continue, to: scCourse.join_status !== null ? scRoutingContext.url(SCRoutes.COURSE_LESSON_ROUTE_NAME, getUrlNextLesson(scCourse)) : undefined, disabled:
|
|
177
|
+
: BUTTON_MESSAGES.continue, to: scCourse.join_status !== null ? scRoutingContext.url(SCRoutes.COURSE_LESSON_ROUTE_NAME, getUrlNextLesson(scCourse)) : undefined, disabled: getIsNextLessonLocked(scCourse), color: scCourse.user_completion_rate === 100 ? 'inherit' : undefined, variant: scCourse.user_completion_rate === 100 ? 'outlined' : undefined, loading: scCourse.join_status === null ? loadingRequest : undefined, onClick: !scUserContext.user ? handleAnonymousAction : scCourse.join_status === null ? handleRequest : undefined })), scCourse.privacy === SCCoursePrivacyType.PRIVATE &&
|
|
175
178
|
(scCourse.join_status === null || scCourse.join_status === SCCourseJoinStatusType.REQUESTED) && (_jsx(ActionButton, { labelId: sentRequest ? BUTTON_MESSAGES.cancel : BUTTON_MESSAGES.request, color: "inherit", variant: "outlined", loading: loadingRequest, onClick: handleRequest }))] })));
|
|
176
179
|
}, [scCourse, sentRequest, loadingRequest, handleRequest]);
|
|
177
180
|
if (!scCourse) {
|
|
@@ -96,7 +96,7 @@ function Comments(props) {
|
|
|
96
96
|
map.set(name, [...map.get(name), comment]);
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
|
-
return Array.from(map.entries()).map(([name, comments]) => (_jsxs(Box, Object.assign({ className: classes.outerWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "h5" }, { children: name })), _jsx(Divider, {}), _jsxs(Stack, Object.assign({ className: classes.innerWrapper }, { children: [comments.map((comment) => (_jsxs(Stack, Object.assign({ className: classes.userWrapper }, { children: [_jsx(Avatar, { src: comment.created_by.avatar, alt: comment.created_by.username, className: classes.avatar }), _jsxs(Box, { children: [_jsxs(Stack, Object.assign({ className: classes.userInfo }, { children: [_jsx(Typography, Object.assign({ variant: "body1" }, { children: comment.created_by.username })), _jsx(Box, { className: classes.circle }), _jsx(Typography, Object.assign({ variant: "body2" }, { children: _jsx(FormattedDate, { value: comment.created_at }) }))] })), _jsx(Typography, { variant: "body1", component: "div", dangerouslySetInnerHTML: { __html: comment.html } })] })] }), comment.id))), _jsx(Button, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.
|
|
99
|
+
return Array.from(map.entries()).map(([name, comments]) => (_jsxs(Box, Object.assign({ className: classes.outerWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "h5" }, { children: name })), _jsx(Divider, {}), _jsxs(Stack, Object.assign({ className: classes.innerWrapper }, { children: [comments.map((comment) => (_jsxs(Stack, Object.assign({ className: classes.userWrapper }, { children: [_jsx(Avatar, { src: comment.created_by.avatar, alt: comment.created_by.username, className: classes.avatar }), _jsxs(Box, { children: [_jsxs(Stack, Object.assign({ className: classes.userInfo }, { children: [_jsx(Typography, Object.assign({ variant: "body1" }, { children: comment.created_by.username })), _jsx(Box, { className: classes.circle }), _jsx(Typography, Object.assign({ variant: "body2" }, { children: _jsx(FormattedDate, { value: comment.created_at }) }))] })), _jsx(Typography, { variant: "body1", component: "div", dangerouslySetInnerHTML: { __html: comment.html } })] })] }), comment.id))), _jsx(Button, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.COURSE_LESSON_PREVIEW_ROUTE_NAME, getUrlLesson(comments[0].extras.course, comments[0].extras.lesson, comments[0].extras.section)), size: "small", variant: "outlined", color: "inherit", className: classes.button }, { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.teacher.tab.comments.lessons.btn.label", defaultMessage: "ui.course.dashboard.teacher.tab.comments.lessons.btn.label" }) })) }))] }))] }), name)));
|
|
100
100
|
}, [state.results]);
|
|
101
101
|
if (!state.initialized) {
|
|
102
102
|
return _jsx(CommentsSkeleton, {});
|
|
@@ -29,6 +29,14 @@ const Root = styled(NotificationItem, {
|
|
|
29
29
|
name: PREFIX,
|
|
30
30
|
slot: 'CourseRoot'
|
|
31
31
|
})(() => ({}));
|
|
32
|
+
function formatLessonUrl(notificationObject) {
|
|
33
|
+
return {
|
|
34
|
+
id: notificationObject.course.id,
|
|
35
|
+
slug: notificationObject.course.slug,
|
|
36
|
+
section_id: notificationObject.comment.section_id,
|
|
37
|
+
lesson_id: notificationObject.comment.lesson_id
|
|
38
|
+
};
|
|
39
|
+
}
|
|
32
40
|
/**
|
|
33
41
|
* This component render the content of the notification of type course
|
|
34
42
|
* @constructor
|
|
@@ -49,33 +57,45 @@ export default function CourseNotification(props) {
|
|
|
49
57
|
}
|
|
50
58
|
// RENDER
|
|
51
59
|
if (isSnippetTemplate || isToastTemplate) {
|
|
52
|
-
return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: _jsx(Link, Object.assign({}, (!notificationObject.
|
|
53
|
-
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.
|
|
54
|
-
}), { onClick: notificationObject.
|
|
55
|
-
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.
|
|
56
|
-
}), { onClick: notificationObject.
|
|
60
|
+
return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: _jsx(Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
61
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
62
|
+
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !notificationObject.user.community_badge, smaller: true }, { children: _jsx(Avatar, { alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar, classes: { root: classes.avatar } }) })) })), primary: _jsxs(Box, { children: [_jsx(Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
63
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
64
|
+
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.user.username })), ' ', _jsx(FormattedMessage, { id: `ui.notification.course.${notificationObject.type}`, defaultMessage: `ui.notification.course.${notificationObject.type}`, values: {
|
|
57
65
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
58
66
|
// @ts-ignore
|
|
59
|
-
name: notificationObject.
|
|
67
|
+
name: notificationObject.type === SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
68
|
+
? notificationObject.comment.lesson_name
|
|
69
|
+
: notificationObject.course.name,
|
|
60
70
|
link: (...chunks) => (_jsx(Link, Object.assign({ to: scRoutingContext.url(notificationObject.type === SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
61
71
|
? SCRoutes.COURSE_LESSON_ROUTE_NAME
|
|
62
|
-
: SCRoutes.COURSE_ROUTE_NAME, notificationObject.
|
|
72
|
+
: SCRoutes.COURSE_ROUTE_NAME, notificationObject.type === SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
73
|
+
? formatLessonUrl(notificationObject)
|
|
74
|
+
: notificationObject.course) }, { children: chunks })))
|
|
63
75
|
} })] }), footer: isToastTemplate ? (_jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [_jsx(DateTimeAgo, { date: notificationObject.active_at }), _jsx(Typography, Object.assign({ color: "primary" }, { children: _jsx(Link, Object.assign({ to: scRoutingContext.url(notificationObject.type === SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
64
76
|
? SCRoutes.COURSE_LESSON_ROUTE_NAME
|
|
65
|
-
: SCRoutes.COURSE_ROUTE_NAME, notificationObject.
|
|
77
|
+
: SCRoutes.COURSE_ROUTE_NAME, notificationObject.type === SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
78
|
+
? formatLessonUrl(notificationObject)
|
|
79
|
+
: notificationObject.course) }, { children: _jsx(FormattedMessage, { id: "ui.notification.course.button.see", defaultMessage: "ui.notification.course.button.see" }) })) }))] }))) : (_jsx(DateTimeAgo, { date: notificationObject.active_at, className: classes.snippetTime })) }, rest)));
|
|
66
80
|
}
|
|
67
|
-
return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: _jsx(Link, Object.assign({}, (!notificationObject.
|
|
68
|
-
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.
|
|
69
|
-
}), { onClick: notificationObject.
|
|
70
|
-
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.
|
|
71
|
-
}), { onClick: notificationObject.
|
|
81
|
+
return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: _jsx(Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
82
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
83
|
+
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !notificationObject.user.community_badge, smaller: true }, { children: _jsx(Avatar, { className: classes.avatar, alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar }) })) })), primary: _jsxs(_Fragment, { children: [_jsx(Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
84
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
85
|
+
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.user.username })), ' ', _jsx(FormattedMessage, { id: `ui.notification.course.${notificationObject.type}`, defaultMessage: `ui.notification.course.${notificationObject.type}`, values: {
|
|
72
86
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
73
87
|
// @ts-ignore
|
|
74
|
-
name: notificationObject.
|
|
88
|
+
name: notificationObject.type === SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
89
|
+
? notificationObject.comment.lesson_name
|
|
90
|
+
: notificationObject.course.name,
|
|
75
91
|
link: (...chunks) => (_jsx(Link, Object.assign({ to: scRoutingContext.url(notificationObject.type === SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
76
92
|
? SCRoutes.COURSE_LESSON_ROUTE_NAME
|
|
77
|
-
: SCRoutes.COURSE_ROUTE_NAME, notificationObject.
|
|
93
|
+
: SCRoutes.COURSE_ROUTE_NAME, notificationObject.type === SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
94
|
+
? formatLessonUrl(notificationObject)
|
|
95
|
+
: notificationObject.course) }, { children: chunks })))
|
|
78
96
|
} }), notificationObject.type !== SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON && (_jsx(CourseItem, { course: notificationObject.course, actions: _jsx(_Fragment, {}), template: SCCourseTemplateType.SNIPPET, elevation: 0 }))] }), actions: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [_jsx(DateTimeAgo, { date: notificationObject.active_at, className: classes.activeAt }), _jsx(LoadingButton, Object.assign({ color: 'primary', variant: "outlined", size: "small", classes: { root: classes.seeButton }, component: Link, to: scRoutingContext.url(notificationObject.type === SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
79
97
|
? SCRoutes.COURSE_LESSON_ROUTE_NAME
|
|
80
|
-
: SCRoutes.COURSE_ROUTE_NAME, notificationObject.
|
|
98
|
+
: SCRoutes.COURSE_ROUTE_NAME, notificationObject.type === SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
|
|
99
|
+
? formatLessonUrl(notificationObject)
|
|
100
|
+
: notificationObject.course) }, { children: _jsx(FormattedMessage, { id: "ui.notification.course.button.see", defaultMessage: "ui.notification.course.button.see" }) }))] })) }, rest)), openAlert && _jsx(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })] }));
|
|
81
101
|
}
|