@selfcommunity/react-templates 0.4.8-alpha.9 → 0.4.8-payments.144
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/CategoryFeed/CategoryFeed.js +2 -1
- package/lib/cjs/components/Course/Course.d.ts +26 -0
- package/lib/cjs/components/Course/Course.js +39 -0
- package/lib/cjs/components/Course/constants.d.ts +1 -0
- package/lib/cjs/components/Course/constants.js +4 -0
- package/lib/cjs/components/Course/index.d.ts +4 -0
- package/lib/cjs/components/Course/index.js +9 -0
- package/lib/cjs/components/Lesson/Lesson.d.ts +65 -0
- package/lib/cjs/components/Lesson/Lesson.js +144 -0
- package/lib/cjs/components/Lesson/constants.d.ts +1 -0
- package/lib/cjs/components/Lesson/constants.js +4 -0
- package/lib/cjs/components/Lesson/index.d.ts +3 -0
- package/lib/cjs/components/Lesson/index.js +5 -0
- package/lib/cjs/index.d.ts +3 -1
- package/lib/cjs/index.js +7 -1
- package/lib/esm/components/CategoryFeed/CategoryFeed.js +4 -3
- package/lib/esm/components/Course/Course.d.ts +26 -0
- package/lib/esm/components/Course/Course.js +35 -0
- package/lib/esm/components/Course/constants.d.ts +1 -0
- package/lib/esm/components/Course/constants.js +1 -0
- package/lib/esm/components/Course/index.d.ts +4 -0
- package/lib/esm/components/Course/index.js +4 -0
- package/lib/esm/components/Lesson/Lesson.d.ts +65 -0
- package/lib/esm/components/Lesson/Lesson.js +141 -0
- package/lib/esm/components/Lesson/constants.d.ts +1 -0
- package/lib/esm/components/Lesson/constants.js +1 -0
- package/lib/esm/components/Lesson/index.d.ts +3 -0
- package/lib/esm/components/Lesson/index.js +2 -0
- package/lib/esm/index.d.ts +3 -1
- package/lib/esm/index.js +3 -1
- package/lib/umd/595.js +2 -0
- package/lib/umd/60a7fdeaadfe844bc015.woff2 +0 -0
- package/lib/umd/{e0b2b8a5f2f737384ae5.svg → 6158171e38cbff3c3340.svg} +9 -3
- package/lib/umd/{c3528e120c4e831db2ae.woff → b6dbec3d5816ff8baef1.woff} +0 -0
- package/lib/umd/{2aa155858f48b8f3911a.eot → ba74e493633796d551d1.ttf} +0 -0
- package/lib/umd/{a221d3aba0f6753cfbb7.ttf → c473ce30406a3dad83e1.eot} +0 -0
- package/lib/umd/react-templates.js +1 -1
- package/package.json +6 -6
- package/lib/umd/36f3af7f155d916c26ff.woff2 +0 -0
- package/lib/umd/920.js +0 -2
- /package/lib/umd/{920.js.LICENSE.txt → 595.js.LICENSE.txt} +0 -0
|
@@ -72,6 +72,7 @@ function CategoryFeed(inProps) {
|
|
|
72
72
|
const { id = 'category_feed', className, category, categoryId, widgets = WIDGETS, FeedObjectProps = {}, FeedSidebarProps = null, FeedProps = {} } = props;
|
|
73
73
|
// CONTEXT
|
|
74
74
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
75
|
+
const scUserContext = (0, react_core_1.useSCUser)();
|
|
75
76
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
76
77
|
// REF
|
|
77
78
|
const feedRef = (0, react_1.useRef)();
|
|
@@ -114,7 +115,7 @@ function CategoryFeed(inProps) {
|
|
|
114
115
|
markRead: scUser ? !item.seen_by_id.includes(scUser.id) : null
|
|
115
116
|
}), itemIdGenerator: (item) => item[item.type].id, ItemProps: FeedObjectProps, ItemSkeleton: react_ui_1.FeedObjectSkeleton, ItemSkeletonProps: {
|
|
116
117
|
template: react_ui_1.SCFeedObjectTemplateType.PREVIEW
|
|
117
|
-
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: (0, jsx_runtime_1.jsx)(react_ui_1.InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { categories: [scCategory] }, feedType: types_1.SCFeedTypologyType.CATEGORY }), CustomAdvProps: { categoriesId: [scCategory.id] }, enabledCustomAdvPositions: [
|
|
118
|
+
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: ((scCategory.content_only_staff && react_core_1.UserUtils.isStaff(scUserContext.user)) || !scCategory.content_only_staff) && ((0, jsx_runtime_1.jsx)(react_ui_1.InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { categories: [scCategory] }, feedType: types_1.SCFeedTypologyType.CATEGORY })) }), CustomAdvProps: { categoriesId: [scCategory.id] }, enabledCustomAdvPositions: [
|
|
118
119
|
types_1.SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|
|
119
120
|
types_1.SCCustomAdvPosition.POSITION_FEED,
|
|
120
121
|
types_1.SCCustomAdvPosition.POSITION_BELOW_TOPBAR
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
import { SCCourseType } from '@selfcommunity/types';
|
|
3
|
+
export interface CourseProps {
|
|
4
|
+
/**
|
|
5
|
+
* Id of the feed object
|
|
6
|
+
* @default 'course'
|
|
7
|
+
*/
|
|
8
|
+
id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Overrides or extends the styles applied to the component.
|
|
11
|
+
* @default null
|
|
12
|
+
*/
|
|
13
|
+
className?: HTMLAttributes<HTMLDivElement>['className'];
|
|
14
|
+
/**
|
|
15
|
+
* Course Object
|
|
16
|
+
* @default null
|
|
17
|
+
*/
|
|
18
|
+
course?: SCCourseType;
|
|
19
|
+
/**
|
|
20
|
+
* Id of the course for filter the feed
|
|
21
|
+
* @default null
|
|
22
|
+
*/
|
|
23
|
+
courseId?: number;
|
|
24
|
+
viewDashboard?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export default function Course(inProps: CourseProps): JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
8
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
9
|
+
const react_ui_1 = require("@selfcommunity/react-ui");
|
|
10
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
11
|
+
const classes = {
|
|
12
|
+
root: `${constants_1.PREFIX}-root`
|
|
13
|
+
};
|
|
14
|
+
const Root = (0, material_1.styled)(material_1.Box, {
|
|
15
|
+
name: constants_1.PREFIX,
|
|
16
|
+
slot: 'Root'
|
|
17
|
+
})(() => ({}));
|
|
18
|
+
function Course(inProps) {
|
|
19
|
+
// PROPS
|
|
20
|
+
const props = (0, material_1.useThemeProps)({
|
|
21
|
+
props: inProps,
|
|
22
|
+
name: constants_1.PREFIX
|
|
23
|
+
});
|
|
24
|
+
const { id = 'course', className = null, course = null, courseId = null, viewDashboard } = props;
|
|
25
|
+
// HOOKS
|
|
26
|
+
const { scCourse, error } = (0, react_core_1.useSCFetchCourse)({
|
|
27
|
+
id: courseId,
|
|
28
|
+
course,
|
|
29
|
+
params: { view: viewDashboard ? api_services_1.CourseInfoViewType.DASHBOARD : api_services_1.CourseInfoViewType.USER }
|
|
30
|
+
});
|
|
31
|
+
if (error) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
if (viewDashboard) {
|
|
35
|
+
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: (0, jsx_runtime_1.jsx)(react_ui_1.CourseDashboard.Teacher, { course: scCourse }) })));
|
|
36
|
+
}
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: (0, jsx_runtime_1.jsx)(react_ui_1.CourseDashboard.Student, { course: scCourse }) })));
|
|
38
|
+
}
|
|
39
|
+
exports.default = Course;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCCourse";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StudentSkeleton = exports.TeacherSkeleton = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Course_1 = tslib_1.__importDefault(require("./Course"));
|
|
6
|
+
const react_ui_1 = require("@selfcommunity/react-ui");
|
|
7
|
+
Object.defineProperty(exports, "TeacherSkeleton", { enumerable: true, get: function () { return react_ui_1.TeacherSkeleton; } });
|
|
8
|
+
Object.defineProperty(exports, "StudentSkeleton", { enumerable: true, get: function () { return react_ui_1.StudentSkeleton; } });
|
|
9
|
+
exports.default = Course_1.default;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { SCCourseLessonType, SCCourseType } from '@selfcommunity/types';
|
|
2
|
+
import { LessonAppbarProps, LessonDrawerProps } from '@selfcommunity/react-ui';
|
|
3
|
+
export interface LessonProps {
|
|
4
|
+
/**
|
|
5
|
+
* Overrides or extends the styles applied to the component.
|
|
6
|
+
* @default null
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The course object
|
|
11
|
+
*/
|
|
12
|
+
course?: SCCourseType;
|
|
13
|
+
/**
|
|
14
|
+
* The course id
|
|
15
|
+
*/
|
|
16
|
+
courseId?: string | number;
|
|
17
|
+
/**
|
|
18
|
+
* The section id
|
|
19
|
+
*/
|
|
20
|
+
sectionId: string | number;
|
|
21
|
+
/**
|
|
22
|
+
* The lesson object
|
|
23
|
+
* @default null
|
|
24
|
+
*/
|
|
25
|
+
lesson?: SCCourseLessonType;
|
|
26
|
+
/**
|
|
27
|
+
* The lesson id
|
|
28
|
+
*/
|
|
29
|
+
lessonId?: string | number;
|
|
30
|
+
/**
|
|
31
|
+
* Props to spread to LessonAppbar Component
|
|
32
|
+
* @default {}
|
|
33
|
+
*/
|
|
34
|
+
LessonAppbarProps?: LessonAppbarProps;
|
|
35
|
+
/**
|
|
36
|
+
* Props to spread to LessonDrawer Component
|
|
37
|
+
* @default {}
|
|
38
|
+
*/
|
|
39
|
+
LessonDrawerProps?: LessonDrawerProps;
|
|
40
|
+
/**
|
|
41
|
+
* Opens edit mode
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
editMode?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Callback fired on edit mode close
|
|
47
|
+
* @default null
|
|
48
|
+
*/
|
|
49
|
+
onEditModeClose?: () => void;
|
|
50
|
+
/**
|
|
51
|
+
* Handler on lesson change
|
|
52
|
+
* @default null
|
|
53
|
+
*/
|
|
54
|
+
onLessonChange?: (lessonId: any, sectionId: any) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Handler on panel change
|
|
57
|
+
* @default null
|
|
58
|
+
*/
|
|
59
|
+
onActivePanelChange?: (panel: any) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Any other properties
|
|
62
|
+
*/
|
|
63
|
+
[p: string]: any;
|
|
64
|
+
}
|
|
65
|
+
export default function Lesson(inProps: LessonProps): JSX.Element;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const styles_1 = require("@mui/material/styles");
|
|
7
|
+
const system_1 = require("@mui/system");
|
|
8
|
+
const material_1 = require("@mui/material");
|
|
9
|
+
const constants_1 = require("./constants");
|
|
10
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
11
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
12
|
+
const react_ui_1 = require("@selfcommunity/react-ui");
|
|
13
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
14
|
+
const react_intl_1 = require("react-intl");
|
|
15
|
+
const classes = {
|
|
16
|
+
root: `${constants_1.PREFIX}-root`,
|
|
17
|
+
containerRoot: `${constants_1.PREFIX}-container-root`,
|
|
18
|
+
navigation: `${constants_1.PREFIX}-navigation`,
|
|
19
|
+
navigationTitle: `${constants_1.PREFIX}-navigation-title`
|
|
20
|
+
};
|
|
21
|
+
const Root = (0, styles_1.styled)(material_1.Box, {
|
|
22
|
+
name: constants_1.PREFIX,
|
|
23
|
+
slot: 'Root',
|
|
24
|
+
overridesResolver: (props, styles) => [styles.root]
|
|
25
|
+
})(() => ({}));
|
|
26
|
+
const Container = (0, styles_1.styled)(material_1.Box, {
|
|
27
|
+
name: constants_1.PREFIX,
|
|
28
|
+
slot: 'ContainerRoot',
|
|
29
|
+
overridesResolver: (props, styles) => styles.containerRoot,
|
|
30
|
+
shouldForwardProp: (prop) => prop !== 'open'
|
|
31
|
+
})(() => ({}));
|
|
32
|
+
function Lesson(inProps) {
|
|
33
|
+
var _a, _b, _c, _d, _e, _f;
|
|
34
|
+
// PROPS
|
|
35
|
+
const props = (0, system_1.useThemeProps)({
|
|
36
|
+
props: inProps,
|
|
37
|
+
name: constants_1.PREFIX
|
|
38
|
+
});
|
|
39
|
+
const { className = null, course, courseId, sectionId, lesson = null, lessonId, LessonAppbarProps = {}, LessonDrawerProps = {}, editMode = false, onEditModeClose = null, onLessonChange = null, onActivePanelChange = null } = props, rest = tslib_1.__rest(props, ["className", "course", "courseId", "sectionId", "lesson", "lessonId", "LessonAppbarProps", "LessonDrawerProps", "editMode", "onEditModeClose", "onLessonChange", "onActivePanelChange"]);
|
|
40
|
+
// HOOKS
|
|
41
|
+
const theme = (0, material_1.useTheme)();
|
|
42
|
+
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
43
|
+
const [_lessonId, setLessonId] = (0, react_1.useState)(lessonId);
|
|
44
|
+
const [_sectionId, setSectionId] = (0, react_1.useState)(sectionId);
|
|
45
|
+
const { scCourse } = (0, react_core_1.useSCFetchCourse)({ id: courseId, course, params: { view: editMode ? api_services_1.CourseInfoViewType.EDIT : api_services_1.CourseInfoViewType.USER } });
|
|
46
|
+
const { scLesson, setSCLesson } = (0, react_core_1.useSCFetchLesson)({ id: _lessonId, lesson, courseId, sectionId: _sectionId });
|
|
47
|
+
// STATE
|
|
48
|
+
const [activePanel, setActivePanel] = (0, react_1.useState)(null);
|
|
49
|
+
const [settings, setSettings] = (0, react_1.useState)(null);
|
|
50
|
+
const [updating, setUpdating] = (0, react_1.useState)(false);
|
|
51
|
+
const [lessonContent, setLessonContent] = (0, react_1.useState)('');
|
|
52
|
+
const [lessonMedias, setLessonMedias] = (0, react_1.useState)((_a = scLesson === null || scLesson === void 0 ? void 0 : scLesson.medias) !== null && _a !== void 0 ? _a : []);
|
|
53
|
+
// HANDLERS
|
|
54
|
+
/**
|
|
55
|
+
* Handles lesson settings change
|
|
56
|
+
* @param newSettings
|
|
57
|
+
*/
|
|
58
|
+
const handleSettingsChange = (newSettings) => {
|
|
59
|
+
setSettings(newSettings);
|
|
60
|
+
};
|
|
61
|
+
const handleOpenDrawer = (panel) => {
|
|
62
|
+
setActivePanel((prevPanel) => (prevPanel === panel ? null : panel));
|
|
63
|
+
onActivePanelChange && onActivePanelChange(panel);
|
|
64
|
+
};
|
|
65
|
+
const handleCloseDrawer = () => {
|
|
66
|
+
setActivePanel(null);
|
|
67
|
+
onEditModeClose && onEditModeClose();
|
|
68
|
+
onActivePanelChange && onActivePanelChange(null);
|
|
69
|
+
};
|
|
70
|
+
const handleLessonContentEdit = (html) => {
|
|
71
|
+
setLessonContent(html);
|
|
72
|
+
};
|
|
73
|
+
const handleLessonMediaEdit = (medias) => {
|
|
74
|
+
setLessonMedias(medias);
|
|
75
|
+
};
|
|
76
|
+
const handleChangeLesson = (l, s) => {
|
|
77
|
+
setLessonId(l.id);
|
|
78
|
+
setSectionId(s.id);
|
|
79
|
+
setCurrentSection(s);
|
|
80
|
+
onLessonChange && onLessonChange(l.id, s.id);
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Handles Lesson Edit
|
|
84
|
+
*/
|
|
85
|
+
const handleLessonUpdate = () => {
|
|
86
|
+
setUpdating(true);
|
|
87
|
+
const mediaIds = lessonMedias.map((media) => media.id);
|
|
88
|
+
const data = Object.assign(Object.assign({}, settings), { type: scLesson.type, name: scLesson.name, text: lessonContent, medias: mediaIds });
|
|
89
|
+
api_services_1.CourseService.updateCourseLesson(scCourse.id, sectionId, scLesson.id, data)
|
|
90
|
+
.then((data) => {
|
|
91
|
+
setUpdating(false);
|
|
92
|
+
setSCLesson(data);
|
|
93
|
+
})
|
|
94
|
+
.catch((error) => {
|
|
95
|
+
setUpdating(false);
|
|
96
|
+
console.log(error);
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
const currentData = (0, react_1.useMemo)(() => {
|
|
100
|
+
if (!scCourse || !scLesson)
|
|
101
|
+
return null;
|
|
102
|
+
return (0, react_ui_1.getCurrentSectionAndLessonIndex)(scCourse, scLesson.section_id, scLesson.id);
|
|
103
|
+
}, [scCourse, scLesson]);
|
|
104
|
+
const [currentSectionIndex, setCurrentSectionIndex] = (0, react_1.useState)((currentData === null || currentData === void 0 ? void 0 : currentData.currentSectionIndex) || 0);
|
|
105
|
+
const [currentLessonIndex, setCurrentLessonIndex] = (0, react_1.useState)((currentData === null || currentData === void 0 ? void 0 : currentData.currentLessonIndex) || 0);
|
|
106
|
+
const [currentSection, setCurrentSection] = (0, react_1.useState)(((_b = scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections) === null || _b === void 0 ? void 0 : _b[currentSectionIndex]) || null);
|
|
107
|
+
const handlePrev = () => {
|
|
108
|
+
if (currentLessonIndex > 0) {
|
|
109
|
+
const newLessonIndex = currentLessonIndex - 1;
|
|
110
|
+
setCurrentLessonIndex(newLessonIndex);
|
|
111
|
+
handleChangeLesson(currentSection.lessons[newLessonIndex], currentSection);
|
|
112
|
+
}
|
|
113
|
+
else if (currentSectionIndex > 0) {
|
|
114
|
+
const prevSectionIndex = currentSectionIndex - 1;
|
|
115
|
+
const prevSection = scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections[prevSectionIndex];
|
|
116
|
+
const newLessonIndex = prevSection.lessons.length - 1;
|
|
117
|
+
setCurrentSectionIndex(prevSectionIndex);
|
|
118
|
+
setCurrentLessonIndex(newLessonIndex);
|
|
119
|
+
handleChangeLesson(prevSection.lessons[newLessonIndex], prevSection);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const handleNext = () => {
|
|
123
|
+
if (currentLessonIndex < currentSection.lessons.length - 1) {
|
|
124
|
+
const newLessonIndex = currentLessonIndex + 1;
|
|
125
|
+
setCurrentLessonIndex(newLessonIndex);
|
|
126
|
+
handleChangeLesson(currentSection.lessons[newLessonIndex], currentSection);
|
|
127
|
+
}
|
|
128
|
+
else if (currentSectionIndex < (scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections.length) - 1) {
|
|
129
|
+
const newSectionIndex = currentSectionIndex + 1;
|
|
130
|
+
setCurrentSectionIndex(newSectionIndex);
|
|
131
|
+
setCurrentLessonIndex(0);
|
|
132
|
+
handleChangeLesson(scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections[newSectionIndex].lessons[0], scCourse.sections[newSectionIndex]);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const isPrevDisabled = !(scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections) || (currentSectionIndex === 0 && currentLessonIndex === 0);
|
|
136
|
+
const isNextDisabled = !(scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections) ||
|
|
137
|
+
(currentSectionIndex === (scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections.length) - 1 && currentLessonIndex === ((_c = currentSection === null || currentSection === void 0 ? void 0 : currentSection.lessons) === null || _c === void 0 ? void 0 : _c.length) - 1) ||
|
|
138
|
+
((_e = (_d = scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections[currentSectionIndex + 1]) === null || _d === void 0 ? void 0 : _d.lessons[0]) === null || _e === void 0 ? void 0 : _e.locked);
|
|
139
|
+
if (!scLesson || !scCourse) {
|
|
140
|
+
return (0, jsx_runtime_1.jsx)(react_ui_1.HiddenPlaceholder, {});
|
|
141
|
+
}
|
|
142
|
+
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [(0, jsx_runtime_1.jsx)(react_ui_1.LessonAppbar, Object.assign({ showComments: scLesson.comments_enabled, editMode: editMode, activePanel: activePanel, title: scCourse.name, handleOpen: handleOpenDrawer, onSave: handleLessonUpdate, updating: updating }, LessonAppbarProps)), (0, jsx_runtime_1.jsxs)(Container, Object.assign({ open: Boolean(activePanel) || editMode, className: classes.containerRoot }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.navigation }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", color: "text.secondary" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "templates.lesson.number", defaultMessage: "templates.lesson.number", values: { from: currentLessonIndex + 1, to: (_f = currentSection === null || currentSection === void 0 ? void 0 : currentSection.lessons) === null || _f === void 0 ? void 0 : _f.length } }) })) })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.navigationTitle }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: scLesson.name })), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: handlePrev, disabled: isPrevDisabled }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "arrow_back" }) })), (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: handleNext, disabled: isNextDisabled }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "arrow_next" }) }))] })] })), (0, jsx_runtime_1.jsx)(react_ui_1.LessonObject, { course: scCourse, lesson: scLesson, editMode: editMode, onContentChange: handleLessonContentEdit, onMediaChange: handleLessonMediaEdit })] })), (0, jsx_runtime_1.jsx)(react_ui_1.LessonDrawer, Object.assign({ course: scCourse, lesson: scLesson, editMode: isMobile ? activePanel === react_ui_1.SCLessonActionsType.SETTINGS : editMode, activePanel: activePanel, handleClose: handleCloseDrawer, handleChangeLesson: handleChangeLesson, LessonEditFormProps: { lesson: scLesson, onSave: handleLessonUpdate, updating: updating, onSettingsChange: handleSettingsChange } }, LessonDrawerProps))] })));
|
|
143
|
+
}
|
|
144
|
+
exports.default = Lesson;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCLessonTemplate";
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -11,4 +11,6 @@ import Group, { GroupProps, GroupSkeleton } from './components/Group';
|
|
|
11
11
|
import GroupFeed, { GroupFeedProps, GroupFeedSkeleton } from './components/GroupFeed';
|
|
12
12
|
import Event, { EventProps, EventSkeleton } from './components/Event';
|
|
13
13
|
import EventFeed, { EventFeedProps, EventFeedSkeleton } from './components/EventFeed';
|
|
14
|
-
|
|
14
|
+
import Lesson, { LessonProps } from './components/Lesson';
|
|
15
|
+
import Course, { CourseProps, TeacherSkeleton, StudentSkeleton } from './components/Course';
|
|
16
|
+
export { Category, CategoryProps, CategorySkeleton, CategoryFeed, CategoryFeedProps, CategoryFeedSkeleton, Course, CourseProps, TeacherSkeleton, StudentSkeleton, ExploreFeed, ExploreFeedProps, ExploreFeedSkeleton, FeedObjectDetail, FeedObjectDetailProps, FeedObjectDetailSkeleton, MainFeed, MainFeedProps, MainFeedSkeleton, NotificationFeed, NotificationFeedProps, NotificationFeedSkeleton, UserFeed, UserFeedProps, UserFeedSkeleton, UserProfile, UserProfileProps, UserProfileSkeleton, LoyaltyProgramDetail, LoyaltyProgramDetailProps, LoyaltyProgramDetailSkeleton, GroupFeed, GroupFeedProps, GroupFeedSkeleton, Group, GroupProps, GroupSkeleton, Event, EventProps, EventSkeleton, EventFeed, EventFeedProps, EventFeedSkeleton, Lesson, LessonProps };
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventFeedSkeleton = exports.EventFeed = exports.EventSkeleton = exports.Event = exports.GroupSkeleton = exports.Group = exports.GroupFeedSkeleton = exports.GroupFeed = exports.LoyaltyProgramDetailSkeleton = exports.LoyaltyProgramDetail = exports.UserProfileSkeleton = exports.UserProfile = exports.UserFeedSkeleton = exports.UserFeed = exports.NotificationFeedSkeleton = exports.NotificationFeed = exports.MainFeedSkeleton = exports.MainFeed = exports.FeedObjectDetailSkeleton = exports.FeedObjectDetail = exports.ExploreFeedSkeleton = exports.ExploreFeed = exports.CategoryFeedSkeleton = exports.CategoryFeed = exports.CategorySkeleton = exports.Category = void 0;
|
|
3
|
+
exports.Lesson = exports.EventFeedSkeleton = exports.EventFeed = exports.EventSkeleton = exports.Event = exports.GroupSkeleton = exports.Group = exports.GroupFeedSkeleton = exports.GroupFeed = exports.LoyaltyProgramDetailSkeleton = exports.LoyaltyProgramDetail = exports.UserProfileSkeleton = exports.UserProfile = exports.UserFeedSkeleton = exports.UserFeed = exports.NotificationFeedSkeleton = exports.NotificationFeed = exports.MainFeedSkeleton = exports.MainFeed = exports.FeedObjectDetailSkeleton = exports.FeedObjectDetail = exports.ExploreFeedSkeleton = exports.ExploreFeed = exports.StudentSkeleton = exports.TeacherSkeleton = exports.Course = exports.CategoryFeedSkeleton = exports.CategoryFeed = exports.CategorySkeleton = exports.Category = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const Category_1 = tslib_1.__importStar(require("./components/Category"));
|
|
6
6
|
exports.Category = Category_1.default;
|
|
@@ -41,3 +41,9 @@ Object.defineProperty(exports, "EventSkeleton", { enumerable: true, get: functio
|
|
|
41
41
|
const EventFeed_1 = tslib_1.__importStar(require("./components/EventFeed"));
|
|
42
42
|
exports.EventFeed = EventFeed_1.default;
|
|
43
43
|
Object.defineProperty(exports, "EventFeedSkeleton", { enumerable: true, get: function () { return EventFeed_1.EventFeedSkeleton; } });
|
|
44
|
+
const Lesson_1 = tslib_1.__importDefault(require("./components/Lesson"));
|
|
45
|
+
exports.Lesson = Lesson_1.default;
|
|
46
|
+
const Course_1 = tslib_1.__importStar(require("./components/Course"));
|
|
47
|
+
exports.Course = Course_1.default;
|
|
48
|
+
Object.defineProperty(exports, "TeacherSkeleton", { enumerable: true, get: function () { return Course_1.TeacherSkeleton; } });
|
|
49
|
+
Object.defineProperty(exports, "StudentSkeleton", { enumerable: true, get: function () { return Course_1.StudentSkeleton; } });
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useRef } from 'react';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
4
|
import { CategoryTrendingFeedWidget, CategoryTrendingUsersWidget, ContributionUtils, Feed, FeedObject, FeedObjectSkeleton, InlineComposerWidget, SCFeedObjectTemplateType } from '@selfcommunity/react-ui';
|
|
5
5
|
import { Endpoints } from '@selfcommunity/api-services';
|
|
6
|
-
import { Link, SCRoutes, useSCFetchCategory, useSCRouting } from '@selfcommunity/react-core';
|
|
6
|
+
import { Link, SCRoutes, UserUtils, useSCFetchCategory, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
7
7
|
import { SCCustomAdvPosition, SCFeedTypologyType } from '@selfcommunity/types';
|
|
8
8
|
import { CategoryFeedSkeleton } from './index';
|
|
9
9
|
import { useThemeProps } from '@mui/system';
|
|
@@ -69,6 +69,7 @@ export default function CategoryFeed(inProps) {
|
|
|
69
69
|
const { id = 'category_feed', className, category, categoryId, widgets = WIDGETS, FeedObjectProps = {}, FeedSidebarProps = null, FeedProps = {} } = props;
|
|
70
70
|
// CONTEXT
|
|
71
71
|
const scRoutingContext = useSCRouting();
|
|
72
|
+
const scUserContext = useSCUser();
|
|
72
73
|
const { enqueueSnackbar } = useSnackbar();
|
|
73
74
|
// REF
|
|
74
75
|
const feedRef = useRef();
|
|
@@ -111,7 +112,7 @@ export default function CategoryFeed(inProps) {
|
|
|
111
112
|
markRead: scUser ? !item.seen_by_id.includes(scUser.id) : null
|
|
112
113
|
}), itemIdGenerator: (item) => item[item.type].id, ItemProps: FeedObjectProps, ItemSkeleton: FeedObjectSkeleton, ItemSkeletonProps: {
|
|
113
114
|
template: SCFeedObjectTemplateType.PREVIEW
|
|
114
|
-
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: _jsx(InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { categories: [scCategory] }, feedType: SCFeedTypologyType.CATEGORY }), CustomAdvProps: { categoriesId: [scCategory.id] }, enabledCustomAdvPositions: [
|
|
115
|
+
}, FeedSidebarProps: FeedSidebarProps, HeaderComponent: _jsx(_Fragment, { children: ((scCategory.content_only_staff && UserUtils.isStaff(scUserContext.user)) || !scCategory.content_only_staff) && (_jsx(InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { categories: [scCategory] }, feedType: SCFeedTypologyType.CATEGORY })) }), CustomAdvProps: { categoriesId: [scCategory.id] }, enabledCustomAdvPositions: [
|
|
115
116
|
SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|
|
116
117
|
SCCustomAdvPosition.POSITION_FEED,
|
|
117
118
|
SCCustomAdvPosition.POSITION_BELOW_TOPBAR
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
import { SCCourseType } from '@selfcommunity/types';
|
|
3
|
+
export interface CourseProps {
|
|
4
|
+
/**
|
|
5
|
+
* Id of the feed object
|
|
6
|
+
* @default 'course'
|
|
7
|
+
*/
|
|
8
|
+
id?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Overrides or extends the styles applied to the component.
|
|
11
|
+
* @default null
|
|
12
|
+
*/
|
|
13
|
+
className?: HTMLAttributes<HTMLDivElement>['className'];
|
|
14
|
+
/**
|
|
15
|
+
* Course Object
|
|
16
|
+
* @default null
|
|
17
|
+
*/
|
|
18
|
+
course?: SCCourseType;
|
|
19
|
+
/**
|
|
20
|
+
* Id of the course for filter the feed
|
|
21
|
+
* @default null
|
|
22
|
+
*/
|
|
23
|
+
courseId?: number;
|
|
24
|
+
viewDashboard?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export default function Course(inProps: CourseProps): JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { PREFIX } from './constants';
|
|
3
|
+
import { Box, styled, useThemeProps } from '@mui/material';
|
|
4
|
+
import { useSCFetchCourse } from '@selfcommunity/react-core';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import { CourseDashboard } from '@selfcommunity/react-ui';
|
|
7
|
+
import { CourseInfoViewType } from '@selfcommunity/api-services';
|
|
8
|
+
const classes = {
|
|
9
|
+
root: `${PREFIX}-root`
|
|
10
|
+
};
|
|
11
|
+
const Root = styled(Box, {
|
|
12
|
+
name: PREFIX,
|
|
13
|
+
slot: 'Root'
|
|
14
|
+
})(() => ({}));
|
|
15
|
+
export default function Course(inProps) {
|
|
16
|
+
// PROPS
|
|
17
|
+
const props = useThemeProps({
|
|
18
|
+
props: inProps,
|
|
19
|
+
name: PREFIX
|
|
20
|
+
});
|
|
21
|
+
const { id = 'course', className = null, course = null, courseId = null, viewDashboard } = props;
|
|
22
|
+
// HOOKS
|
|
23
|
+
const { scCourse, error } = useSCFetchCourse({
|
|
24
|
+
id: courseId,
|
|
25
|
+
course,
|
|
26
|
+
params: { view: viewDashboard ? CourseInfoViewType.DASHBOARD : CourseInfoViewType.USER }
|
|
27
|
+
});
|
|
28
|
+
if (error) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
if (viewDashboard) {
|
|
32
|
+
return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: _jsx(CourseDashboard.Teacher, { course: scCourse }) })));
|
|
33
|
+
}
|
|
34
|
+
return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: _jsx(CourseDashboard.Student, { course: scCourse }) })));
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCCourse";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PREFIX = 'SCCourse';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { SCCourseLessonType, SCCourseType } from '@selfcommunity/types';
|
|
2
|
+
import { LessonAppbarProps, LessonDrawerProps } from '@selfcommunity/react-ui';
|
|
3
|
+
export interface LessonProps {
|
|
4
|
+
/**
|
|
5
|
+
* Overrides or extends the styles applied to the component.
|
|
6
|
+
* @default null
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The course object
|
|
11
|
+
*/
|
|
12
|
+
course?: SCCourseType;
|
|
13
|
+
/**
|
|
14
|
+
* The course id
|
|
15
|
+
*/
|
|
16
|
+
courseId?: string | number;
|
|
17
|
+
/**
|
|
18
|
+
* The section id
|
|
19
|
+
*/
|
|
20
|
+
sectionId: string | number;
|
|
21
|
+
/**
|
|
22
|
+
* The lesson object
|
|
23
|
+
* @default null
|
|
24
|
+
*/
|
|
25
|
+
lesson?: SCCourseLessonType;
|
|
26
|
+
/**
|
|
27
|
+
* The lesson id
|
|
28
|
+
*/
|
|
29
|
+
lessonId?: string | number;
|
|
30
|
+
/**
|
|
31
|
+
* Props to spread to LessonAppbar Component
|
|
32
|
+
* @default {}
|
|
33
|
+
*/
|
|
34
|
+
LessonAppbarProps?: LessonAppbarProps;
|
|
35
|
+
/**
|
|
36
|
+
* Props to spread to LessonDrawer Component
|
|
37
|
+
* @default {}
|
|
38
|
+
*/
|
|
39
|
+
LessonDrawerProps?: LessonDrawerProps;
|
|
40
|
+
/**
|
|
41
|
+
* Opens edit mode
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
editMode?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Callback fired on edit mode close
|
|
47
|
+
* @default null
|
|
48
|
+
*/
|
|
49
|
+
onEditModeClose?: () => void;
|
|
50
|
+
/**
|
|
51
|
+
* Handler on lesson change
|
|
52
|
+
* @default null
|
|
53
|
+
*/
|
|
54
|
+
onLessonChange?: (lessonId: any, sectionId: any) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Handler on panel change
|
|
57
|
+
* @default null
|
|
58
|
+
*/
|
|
59
|
+
onActivePanelChange?: (panel: any) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Any other properties
|
|
62
|
+
*/
|
|
63
|
+
[p: string]: any;
|
|
64
|
+
}
|
|
65
|
+
export default function Lesson(inProps: LessonProps): JSX.Element;
|