@selfcommunity/react-templates 0.4.5-alpha.8 → 0.4.5-courses.99

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.
Files changed (72) hide show
  1. package/lib/cjs/components/CourseDashboard/CourseDashboard.d.ts +28 -0
  2. package/lib/cjs/components/CourseDashboard/CourseDashboard.js +39 -0
  3. package/lib/cjs/components/CourseDashboard/constants.d.ts +1 -0
  4. package/lib/cjs/components/CourseDashboard/constants.js +4 -0
  5. package/lib/cjs/components/CourseDashboard/index.d.ts +3 -0
  6. package/lib/cjs/components/CourseDashboard/index.js +5 -0
  7. package/lib/cjs/components/Courses/Courses.d.ts +25 -0
  8. package/lib/cjs/components/Courses/Courses.js +29 -0
  9. package/lib/cjs/components/Courses/constants.d.ts +1 -0
  10. package/lib/cjs/components/Courses/constants.js +4 -0
  11. package/lib/cjs/components/Courses/index.d.ts +3 -0
  12. package/lib/cjs/components/Courses/index.js +5 -0
  13. package/lib/cjs/components/EditCourse/EditCourse.d.ts +27 -0
  14. package/lib/cjs/components/EditCourse/EditCourse.js +29 -0
  15. package/lib/cjs/components/EditCourse/constants.d.ts +1 -0
  16. package/lib/cjs/components/EditCourse/constants.js +4 -0
  17. package/lib/cjs/components/EditCourse/index.d.ts +3 -0
  18. package/lib/cjs/components/EditCourse/index.js +5 -0
  19. package/lib/cjs/components/Event/Event.js +7 -1
  20. package/lib/cjs/components/EventFeed/EventFeed.js +9 -6
  21. package/lib/cjs/components/Lesson/Lesson.d.ts +40 -0
  22. package/lib/cjs/components/Lesson/Lesson.js +146 -0
  23. package/lib/cjs/components/Lesson/constants.d.ts +1 -0
  24. package/lib/cjs/components/Lesson/constants.js +4 -0
  25. package/lib/cjs/components/Lesson/index.d.ts +3 -0
  26. package/lib/cjs/components/Lesson/index.js +5 -0
  27. package/lib/cjs/components/UserFeed/UserFeed.js +10 -3
  28. package/lib/cjs/components/UserProfile/UserProfile.js +21 -7
  29. package/lib/cjs/index.d.ts +2 -1
  30. package/lib/cjs/index.js +3 -1
  31. package/lib/esm/components/CourseDashboard/CourseDashboard.d.ts +28 -0
  32. package/lib/esm/components/CourseDashboard/CourseDashboard.js +35 -0
  33. package/lib/esm/components/CourseDashboard/constants.d.ts +1 -0
  34. package/lib/esm/components/CourseDashboard/constants.js +1 -0
  35. package/lib/esm/components/CourseDashboard/index.d.ts +3 -0
  36. package/lib/esm/components/CourseDashboard/index.js +2 -0
  37. package/lib/esm/components/Courses/Courses.d.ts +25 -0
  38. package/lib/esm/components/Courses/Courses.js +25 -0
  39. package/lib/esm/components/Courses/constants.d.ts +1 -0
  40. package/lib/esm/components/Courses/constants.js +1 -0
  41. package/lib/esm/components/Courses/index.d.ts +3 -0
  42. package/lib/esm/components/Courses/index.js +2 -0
  43. package/lib/esm/components/EditCourse/EditCourse.d.ts +27 -0
  44. package/lib/esm/components/EditCourse/EditCourse.js +25 -0
  45. package/lib/esm/components/EditCourse/constants.d.ts +1 -0
  46. package/lib/esm/components/EditCourse/constants.js +1 -0
  47. package/lib/esm/components/EditCourse/index.d.ts +3 -0
  48. package/lib/esm/components/EditCourse/index.js +2 -0
  49. package/lib/esm/components/Event/Event.js +8 -2
  50. package/lib/esm/components/EventFeed/EventFeed.js +9 -6
  51. package/lib/esm/components/Lesson/Lesson.d.ts +40 -0
  52. package/lib/esm/components/Lesson/Lesson.js +143 -0
  53. package/lib/esm/components/Lesson/constants.d.ts +1 -0
  54. package/lib/esm/components/Lesson/constants.js +1 -0
  55. package/lib/esm/components/Lesson/index.d.ts +3 -0
  56. package/lib/esm/components/Lesson/index.js +2 -0
  57. package/lib/esm/components/UserFeed/UserFeed.js +11 -4
  58. package/lib/esm/components/UserProfile/UserProfile.js +22 -8
  59. package/lib/esm/index.d.ts +2 -1
  60. package/lib/esm/index.js +2 -1
  61. package/lib/umd/165.js +2 -0
  62. package/lib/umd/60a7fdeaadfe844bc015.woff2 +0 -0
  63. package/lib/umd/{e0b2b8a5f2f737384ae5.svg → 6158171e38cbff3c3340.svg} +9 -3
  64. package/lib/umd/{c3528e120c4e831db2ae.woff → b6dbec3d5816ff8baef1.woff} +0 -0
  65. package/lib/umd/{2aa155858f48b8f3911a.eot → ba74e493633796d551d1.ttf} +0 -0
  66. package/lib/umd/{a221d3aba0f6753cfbb7.ttf → c473ce30406a3dad83e1.eot} +0 -0
  67. package/lib/umd/react-templates.js +1 -19
  68. package/lib/umd/react-templates.js.LICENSE.txt +2 -0
  69. package/package.json +128 -123
  70. package/lib/umd/36f3af7f155d916c26ff.woff2 +0 -0
  71. package/lib/umd/555.js +0 -2
  72. /package/lib/umd/{555.js.LICENSE.txt → 165.js.LICENSE.txt} +0 -0
@@ -0,0 +1,28 @@
1
+ import { HTMLAttributes } from 'react';
2
+ import { SCCourseType } from '@selfcommunity/types';
3
+ export interface CourseDashboardTemplateProps {
4
+ /**
5
+ * Id of the feed object
6
+ * @default 'course_dashboard'
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
+ page?: 'students' | 'comments';
25
+ onTabChange?: (page: 'students' | 'comments') => void;
26
+ viewDashboard?: boolean;
27
+ }
28
+ export default function CourseDashboardTemplate(inProps: CourseDashboardTemplateProps): 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 CourseDashboardTemplate(inProps) {
19
+ // PROPS
20
+ const props = (0, material_1.useThemeProps)({
21
+ props: inProps,
22
+ name: constants_1.PREFIX
23
+ });
24
+ const { id = 'course_dashboard', className = null, course = null, courseId = null, page, onTabChange, 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, page: page, onTabChange: onTabChange }) })));
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 = CourseDashboardTemplate;
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCCourseDashboardTemplate";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PREFIX = void 0;
4
+ exports.PREFIX = 'SCCourseDashboardTemplate';
@@ -0,0 +1,3 @@
1
+ import CourseDashboardTemplate, { CourseDashboardTemplateProps } from './CourseDashboard';
2
+ export default CourseDashboardTemplate;
3
+ export { CourseDashboardTemplateProps };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const CourseDashboard_1 = tslib_1.__importDefault(require("./CourseDashboard"));
5
+ exports.default = CourseDashboard_1.default;
@@ -0,0 +1,25 @@
1
+ import { SCCourseType } from '@selfcommunity/types';
2
+ import { HTMLAttributes } from 'react';
3
+ export interface CoursesTemplateProps {
4
+ /**
5
+ * Id of the feed object
6
+ * @default 'course_dashboard'
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
+ }
25
+ export default function CoursesTemplate(inProps: CoursesTemplateProps): JSX.Element;
@@ -0,0 +1,29 @@
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 material_1 = require("@mui/material");
6
+ const react_core_1 = require("@selfcommunity/react-core");
7
+ const constants_1 = require("./constants");
8
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
9
+ const react_ui_1 = require("@selfcommunity/react-ui");
10
+ const classes = {
11
+ root: `${constants_1.PREFIX}-root`
12
+ };
13
+ const Root = (0, material_1.styled)(material_1.Box, {
14
+ name: constants_1.PREFIX,
15
+ slot: 'Root'
16
+ })(() => ({}));
17
+ function CoursesTemplate(inProps) {
18
+ // PROPS
19
+ const props = (0, material_1.useThemeProps)({
20
+ props: inProps,
21
+ name: constants_1.PREFIX
22
+ });
23
+ const { id = 'courses', className = null, course = null, courseId = null } = props;
24
+ // HOOKS
25
+ const { scCourse } = (0, react_core_1.useSCFetchCourse)({ id: courseId, course });
26
+ const scUserContext = (0, react_core_1.useSCUser)();
27
+ 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.Courses, { endpoint: { url: () => '', method: 'GET' } }) })));
28
+ }
29
+ exports.default = CoursesTemplate;
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCCoursesTemplate";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PREFIX = void 0;
4
+ exports.PREFIX = 'SCCoursesTemplate';
@@ -0,0 +1,3 @@
1
+ import CoursesTemplate, { CoursesTemplateProps } from './Courses';
2
+ export default CoursesTemplate;
3
+ export { CoursesTemplateProps };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const Courses_1 = tslib_1.__importDefault(require("./Courses"));
5
+ exports.default = Courses_1.default;
@@ -0,0 +1,27 @@
1
+ import { HTMLAttributes } from 'react';
2
+ import { SCCourseType } from '@selfcommunity/types';
3
+ export interface EditCourseTemplateProps {
4
+ /**
5
+ * Id of the feed object
6
+ * @default 'course_edit'
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
+ page: 'lessons' | 'customize' | 'users' | 'options';
25
+ onTabChange: (page: 'lessons' | 'customize' | 'users' | 'options') => void;
26
+ }
27
+ export default function EditCourseTemplate(inProps: EditCourseTemplateProps): JSX.Element;
@@ -0,0 +1,29 @@
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 EditCourseTemplate(inProps) {
19
+ // PROPS
20
+ const props = (0, material_1.useThemeProps)({
21
+ props: inProps,
22
+ name: constants_1.PREFIX
23
+ });
24
+ const { id = 'course_edit', className = null, course = null, courseId = null, page, onTabChange } = props;
25
+ // HOOKS
26
+ const { scCourse } = (0, react_core_1.useSCFetchCourse)({ id: courseId, course, params: { view: api_services_1.CourseInfoViewType.EDIT } });
27
+ 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.EditCourse, { course: scCourse, page: page, onTabChange: onTabChange }) })));
28
+ }
29
+ exports.default = EditCourseTemplate;
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCEditCourseTemplate";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PREFIX = void 0;
4
+ exports.PREFIX = 'SCEditCourseTemplate';
@@ -0,0 +1,3 @@
1
+ import EditCourseTemplate, { EditCourseTemplateProps } from './EditCourse';
2
+ export default EditCourseTemplate;
3
+ export { EditCourseTemplateProps };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const EditCourse_1 = tslib_1.__importDefault(require("./EditCourse"));
5
+ exports.default = EditCourse_1.default;
@@ -6,6 +6,7 @@ const styles_1 = require("@mui/material/styles");
6
6
  const material_1 = require("@mui/material");
7
7
  const react_ui_1 = require("@selfcommunity/react-ui");
8
8
  const react_core_1 = require("@selfcommunity/react-core");
9
+ const types_1 = require("@selfcommunity/types");
9
10
  const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
10
11
  const system_1 = require("@mui/system");
11
12
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
@@ -54,7 +55,12 @@ function Event(inProps) {
54
55
  const { id = 'event', className, event, eventId, widgets, FeedObjectProps, FeedSidebarProps, EventFeedProps = {}, EventHeaderProps = {} } = props;
55
56
  // HOOKS
56
57
  const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
57
- if (!scEvent) {
58
+ const scUserContext = (0, react_core_1.useSCUser)();
59
+ if (scUserContext.user === undefined ||
60
+ !scEvent ||
61
+ (scUserContext.user &&
62
+ ((scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC && !scEvent.subscription_status) ||
63
+ scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED))) {
58
64
  return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
59
65
  }
60
66
  return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: [(0, jsx_runtime_1.jsx)(react_ui_1.EventHeader, Object.assign({ event: scEvent }, EventHeaderProps)), (0, jsx_runtime_1.jsx)(EventFeed_1.default, Object.assign({ className: classes.feed, event: scEvent, widgets: widgets, FeedObjectProps: FeedObjectProps, FeedSidebarProps: FeedSidebarProps }, EventFeedProps))] })));
@@ -91,12 +91,12 @@ function EventFeed(inProps) {
91
91
  // REF
92
92
  const feedRef = (0, react_1.useRef)();
93
93
  // Hooks
94
- const { scEvent, setSCEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
94
+ const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
95
95
  // HANDLERS
96
96
  const handleComposerSuccess = (feedObject) => {
97
97
  var _a;
98
98
  enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composerIconButton.composer.success", defaultMessage: "ui.composerIconButton.composer.success" }), {
99
- action: (snackbarId) => ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes[`${feedObject.type.toUpperCase()}_ROUTE_NAME`], react_ui_1.ContributionUtils.getRouteData(feedObject)) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composerIconButton.composer.viewContribute", defaultMessage: "ui.composerIconButton.composer.viewContribute" }) }))),
99
+ action: () => ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes[`${feedObject.type.toUpperCase()}_ROUTE_NAME`], react_ui_1.ContributionUtils.getRouteData(feedObject)) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composerIconButton.composer.viewContribute", defaultMessage: "ui.composerIconButton.composer.viewContribute" }) }))),
100
100
  variant: 'success',
101
101
  autoHideDuration: 7000
102
102
  });
@@ -114,16 +114,20 @@ function EventFeed(inProps) {
114
114
  // WIDGETS
115
115
  const _widgets = (0, react_1.useMemo)(() => widgets.map((w) => {
116
116
  if (scEvent) {
117
- return Object.assign(Object.assign({}, w), { componentProps: Object.assign(Object.assign({}, w.componentProps), { eventId: scEvent.id }) });
117
+ return Object.assign(Object.assign({}, w), { componentProps: Object.assign(Object.assign({}, w.componentProps), { event: scEvent }) });
118
118
  }
119
119
  return w;
120
120
  }), [widgets, scEvent]);
121
- if (!scEvent || (scEvent && ((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id)))) {
121
+ if (scUserContext.user === undefined ||
122
+ !scEvent ||
123
+ (scUserContext.user &&
124
+ ((scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC && !scEvent.subscription_status) ||
125
+ scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED)) ||
126
+ (scEvent && ((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id)))) {
122
127
  return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
123
128
  }
124
129
  else if (scEvent.privacy === types_1.SCEventPrivacyType.PRIVATE &&
125
130
  scEvent.subscription_status !== types_1.SCEventSubscriptionStatusType.SUBSCRIBED &&
126
- scEvent.subscription_status !== types_1.SCEventSubscriptionStatusType.INVITED &&
127
131
  scEvent.subscription_status !== types_1.SCEventSubscriptionStatusType.GOING &&
128
132
  scEvent.subscription_status !== types_1.SCEventSubscriptionStatusType.NOT_GOING) {
129
133
  return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(react_ui_1.EventInfoWidget, { className: classes.root, event: scEvent }) })));
@@ -142,7 +146,6 @@ function EventFeed(inProps) {
142
146
  ((!scUserContext.user && scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC) ||
143
147
  (scUserContext.user &&
144
148
  (scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.SUBSCRIBED ||
145
- scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED ||
146
149
  scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.GOING ||
147
150
  scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.NOT_GOING)))) && ((0, jsx_runtime_1.jsx)(react_ui_1.InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { event: scEvent }, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "templates.eventFeed.composer.label", defaultMessage: "templates.eventFeed.composer.label" }), feedType: types_1.SCFeedTypologyType.EVENT }))] }), CustomAdvProps: { position: types_1.SCCustomAdvPosition.POSITION_FEED, groupsId: [scEvent.id] }, enabledCustomAdvPositions: [
148
151
  types_1.SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
@@ -0,0 +1,40 @@
1
+ import { 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?: number;
17
+ /**
18
+ * The section id
19
+ */
20
+ sectionId: number;
21
+ /**
22
+ * The lesson id
23
+ */
24
+ lessonId?: number;
25
+ /**
26
+ * Props to spread to LessonAppbar Component
27
+ * @default {}
28
+ */
29
+ LessonAppbarProps?: LessonAppbarProps;
30
+ /**
31
+ * Props to spread to LessonDrawer Component
32
+ * @default {}
33
+ */
34
+ LessonDrawerProps?: LessonDrawerProps;
35
+ /**
36
+ * Any other properties
37
+ */
38
+ [p: string]: any;
39
+ }
40
+ export default function Lesson(inProps: LessonProps): JSX.Element;
@@ -0,0 +1,146 @@
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 types_1 = require("@selfcommunity/types");
11
+ const react_core_1 = require("@selfcommunity/react-core");
12
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
13
+ const react_ui_1 = require("@selfcommunity/react-ui");
14
+ const api_services_1 = require("@selfcommunity/api-services");
15
+ const react_intl_1 = require("react-intl");
16
+ const classes = {
17
+ root: `${constants_1.PREFIX}-root`,
18
+ containerRoot: `${constants_1.PREFIX}-container-root`,
19
+ navigation: `${constants_1.PREFIX}-navigation`,
20
+ navigationTitle: `${constants_1.PREFIX}-navigation-title`
21
+ };
22
+ const Root = (0, styles_1.styled)(material_1.Box, {
23
+ name: constants_1.PREFIX,
24
+ slot: 'Root',
25
+ overridesResolver: (props, styles) => [styles.root]
26
+ })(() => ({}));
27
+ const Container = (0, styles_1.styled)(material_1.Box, {
28
+ name: constants_1.PREFIX,
29
+ slot: 'ContainerRoot',
30
+ overridesResolver: (props, styles) => styles.containerRoot,
31
+ shouldForwardProp: (prop) => prop !== 'open'
32
+ })(() => ({}));
33
+ function Lesson(inProps) {
34
+ var _a, _b, _c, _d;
35
+ // PROPS
36
+ const props = (0, system_1.useThemeProps)({
37
+ props: inProps,
38
+ name: constants_1.PREFIX
39
+ });
40
+ const { className = null, course, courseId, sectionId, lessonId, LessonAppbarProps = {}, LessonDrawerProps = {} } = props, rest = tslib_1.__rest(props, ["className", "course", "courseId", "sectionId", "lessonId", "LessonAppbarProps", "LessonDrawerProps"]);
41
+ // HOOKS
42
+ const theme = (0, material_1.useTheme)();
43
+ const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
44
+ const [_lessonId, setLessonId] = (0, react_1.useState)(lessonId);
45
+ const [_sectionId, setSectionId] = (0, react_1.useState)(sectionId);
46
+ const isCourseAdmin = (0, react_1.useMemo)(() => course && (course.join_status === types_1.SCCourseJoinStatusType.CREATOR || course.join_status === types_1.SCCourseJoinStatusType.MANAGER), [course]);
47
+ const { scCourse } = (0, react_core_1.useSCFetchCourse)({ id: courseId, params: { view: isCourseAdmin ? api_services_1.CourseInfoViewType.EDIT : api_services_1.CourseInfoViewType.USER } });
48
+ const { scLesson, setSCLesson } = (0, react_core_1.useSCFetchLesson)({ id: _lessonId, courseId, sectionId: _sectionId });
49
+ // STATE
50
+ const [activePanel, setActivePanel] = (0, react_1.useState)(null);
51
+ const [settings, setSettings] = (0, react_1.useState)(null);
52
+ const [updating, setUpdating] = (0, react_1.useState)(false);
53
+ const [lessonContent, setLessonContent] = (0, react_1.useState)('');
54
+ const [lessonMedias, setLessonMedias] = (0, react_1.useState)((_a = scLesson === null || scLesson === void 0 ? void 0 : scLesson.medias) !== null && _a !== void 0 ? _a : []);
55
+ const [editMode, setEditMode] = (0, react_1.useState)(isCourseAdmin);
56
+ const isEditMode = editMode;
57
+ // const isEditMode = useMemo(() => {
58
+ // return value.startsWith(scRoutingContext.url(SCRoutes.COURSE_EDIT_ROUTE_NAME, {}));
59
+ // }, [value, scRoutingContext]);
60
+ // HANDLERS
61
+ /**
62
+ * Handles lesson settings change
63
+ * @param newSettings
64
+ */
65
+ const handleSettingsChange = (newSettings) => {
66
+ setSettings(newSettings);
67
+ };
68
+ const handleOpenDrawer = (panel) => {
69
+ setActivePanel((prevPanel) => (prevPanel === panel ? null : panel));
70
+ };
71
+ const handleCloseDrawer = () => {
72
+ setActivePanel(null);
73
+ setEditMode(false);
74
+ };
75
+ const handleLessonContentEdit = (html) => {
76
+ setLessonContent(html);
77
+ };
78
+ const handleLessonMediaEdit = (medias) => {
79
+ setLessonMedias(medias);
80
+ };
81
+ const handleChangeLesson = (l, s) => {
82
+ setLessonId(l.id);
83
+ setSectionId(s.id);
84
+ setCurrentSection(s);
85
+ };
86
+ /**
87
+ * Handles Lesson Edit
88
+ */
89
+ const handleLessonUpdate = () => {
90
+ setUpdating(true);
91
+ const mediaIds = lessonMedias.map((media) => media.id);
92
+ const data = Object.assign(Object.assign({}, settings), { type: scLesson.type, name: scLesson.name, text: lessonContent, medias: mediaIds });
93
+ api_services_1.CourseService.updateCourseLesson(scCourse.id, sectionId, scLesson.id, data)
94
+ .then((data) => {
95
+ setUpdating(false);
96
+ setSCLesson(data);
97
+ })
98
+ .catch((error) => {
99
+ setUpdating(false);
100
+ console.log(error);
101
+ });
102
+ };
103
+ const currentData = (0, react_1.useMemo)(() => {
104
+ if (!scCourse || !scLesson)
105
+ return null;
106
+ return (0, react_ui_1.getCurrentSectionAndLessonIndex)(scCourse, scLesson.section_id, scLesson.id);
107
+ }, [scCourse, scLesson]);
108
+ const [currentSectionIndex, setCurrentSectionIndex] = (0, react_1.useState)((currentData === null || currentData === void 0 ? void 0 : currentData.currentSectionIndex) || 0);
109
+ const [currentLessonIndex, setCurrentLessonIndex] = (0, react_1.useState)((currentData === null || currentData === void 0 ? void 0 : currentData.currentLessonIndex) || 0);
110
+ 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);
111
+ const handlePrev = () => {
112
+ if (currentLessonIndex > 0) {
113
+ const newLessonIndex = currentLessonIndex - 1;
114
+ setCurrentLessonIndex(newLessonIndex);
115
+ handleChangeLesson(currentSection.lessons[newLessonIndex], currentSection);
116
+ }
117
+ else if (currentSectionIndex > 0) {
118
+ const prevSectionIndex = currentSectionIndex - 1;
119
+ const prevSection = scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections[prevSectionIndex];
120
+ const newLessonIndex = prevSection.lessons.length - 1;
121
+ setCurrentSectionIndex(prevSectionIndex);
122
+ setCurrentLessonIndex(newLessonIndex);
123
+ handleChangeLesson(prevSection.lessons[newLessonIndex], prevSection);
124
+ }
125
+ };
126
+ const handleNext = () => {
127
+ if (currentLessonIndex < currentSection.lessons.length - 1) {
128
+ const newLessonIndex = currentLessonIndex + 1;
129
+ setCurrentLessonIndex(newLessonIndex);
130
+ handleChangeLesson(currentSection.lessons[newLessonIndex], currentSection);
131
+ }
132
+ else if (currentSectionIndex < (scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections.length) - 1) {
133
+ const newSectionIndex = currentSectionIndex + 1;
134
+ setCurrentSectionIndex(newSectionIndex);
135
+ setCurrentLessonIndex(0);
136
+ handleChangeLesson(scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections[newSectionIndex].lessons[0], scCourse.sections[newSectionIndex]);
137
+ }
138
+ };
139
+ const isPrevDisabled = !(scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections) || (currentSectionIndex === 0 && currentLessonIndex === 0);
140
+ const isNextDisabled = !(scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections) || (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);
141
+ if (!scLesson || !scCourse) {
142
+ return (0, jsx_runtime_1.jsx)(react_ui_1.HiddenPlaceholder, {});
143
+ }
144
+ 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: isEditMode, activePanel: activePanel, title: scCourse.name, handleOpen: handleOpenDrawer, onSave: handleLessonUpdate, updating: updating }, LessonAppbarProps)), (0, jsx_runtime_1.jsxs)(Container, Object.assign({ open: Boolean(activePanel) || isEditMode, 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: (_d = currentSection === null || currentSection === void 0 ? void 0 : currentSection.lessons) === null || _d === void 0 ? void 0 : _d.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: isEditMode, 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 : isEditMode, activePanel: activePanel, handleClose: handleCloseDrawer, handleChangeLesson: handleChangeLesson, LessonEditFormProps: { lesson: scLesson, onSave: handleLessonUpdate, updating: updating, onSettingsChange: handleSettingsChange } }, LessonDrawerProps))] })));
145
+ }
146
+ exports.default = Lesson;
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCLessonTemplate";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PREFIX = void 0;
4
+ exports.PREFIX = 'SCLessonTemplate';
@@ -0,0 +1,3 @@
1
+ import Lesson, { LessonProps } from './Lesson';
2
+ export default Lesson;
3
+ export { LessonProps };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const Lesson_1 = tslib_1.__importDefault(require("./Lesson"));
5
+ exports.default = Lesson_1.default;
@@ -24,24 +24,31 @@ const Root = (0, styles_1.styled)(react_ui_1.Feed, {
24
24
  const WIDGETS = [
25
25
  {
26
26
  type: 'widget',
27
- component: react_ui_1.UserFollowedCategoriesWidget,
27
+ component: react_ui_1.UserLiveStreamWidget,
28
28
  componentProps: {},
29
29
  column: 'right',
30
30
  position: 0
31
31
  },
32
32
  {
33
33
  type: 'widget',
34
- component: react_ui_1.UserFollowedUsersWidget,
34
+ component: react_ui_1.UserFollowedCategoriesWidget,
35
35
  componentProps: {},
36
36
  column: 'right',
37
37
  position: 1
38
38
  },
39
39
  {
40
40
  type: 'widget',
41
- component: react_ui_1.UserFollowersWidget,
41
+ component: react_ui_1.UserFollowedUsersWidget,
42
42
  componentProps: {},
43
43
  column: 'right',
44
44
  position: 2
45
+ },
46
+ {
47
+ type: 'widget',
48
+ component: react_ui_1.UserFollowersWidget,
49
+ componentProps: {},
50
+ column: 'right',
51
+ position: 3
45
52
  }
46
53
  ];
47
54
  /**
@@ -30,31 +30,38 @@ const Root = (0, styles_1.styled)(material_1.Box, {
30
30
  const WIDGETS_FOLLOWERS = [
31
31
  {
32
32
  type: 'widget',
33
- component: react_ui_1.UserFollowedCategoriesWidget,
33
+ component: react_ui_1.UserLiveStreamWidget,
34
34
  componentProps: {},
35
35
  column: 'right',
36
36
  position: 0
37
37
  },
38
38
  {
39
39
  type: 'widget',
40
- component: react_ui_1.UserFollowedUsersWidget,
40
+ component: react_ui_1.UserFollowedCategoriesWidget,
41
41
  componentProps: {},
42
42
  column: 'right',
43
43
  position: 1
44
44
  },
45
45
  {
46
46
  type: 'widget',
47
- component: react_ui_1.UserFollowersWidget,
47
+ component: react_ui_1.UserFollowedUsersWidget,
48
48
  componentProps: {},
49
49
  column: 'right',
50
50
  position: 2
51
51
  },
52
52
  {
53
53
  type: 'widget',
54
- component: react_ui_1.UserSubscribedGroupsWidget,
54
+ component: react_ui_1.UserFollowersWidget,
55
55
  componentProps: {},
56
56
  column: 'right',
57
57
  position: 3
58
+ },
59
+ {
60
+ type: 'widget',
61
+ component: react_ui_1.UserSubscribedGroupsWidget,
62
+ componentProps: {},
63
+ column: 'right',
64
+ position: 4
58
65
  }
59
66
  ];
60
67
  const WIDGETS_FOLLOWERS_MY_PROFILE = [
@@ -69,24 +76,31 @@ const WIDGETS_FOLLOWERS_MY_PROFILE = [
69
76
  const WIDGETS_CONNECTIONS = [
70
77
  {
71
78
  type: 'widget',
72
- component: react_ui_1.UserFollowedCategoriesWidget,
79
+ component: react_ui_1.UserLiveStreamWidget,
73
80
  componentProps: {},
74
81
  column: 'right',
75
82
  position: 0
76
83
  },
77
84
  {
78
85
  type: 'widget',
79
- component: react_ui_1.UserConnectionsWidget,
86
+ component: react_ui_1.UserFollowedCategoriesWidget,
80
87
  componentProps: {},
81
88
  column: 'right',
82
89
  position: 1
83
90
  },
84
91
  {
85
92
  type: 'widget',
86
- component: react_ui_1.UserSubscribedGroupsWidget,
93
+ component: react_ui_1.UserConnectionsWidget,
87
94
  componentProps: {},
88
95
  column: 'right',
89
96
  position: 2
97
+ },
98
+ {
99
+ type: 'widget',
100
+ component: react_ui_1.UserSubscribedGroupsWidget,
101
+ componentProps: {},
102
+ column: 'right',
103
+ position: 3
90
104
  }
91
105
  ];
92
106
  const WIDGETS_CONNECTIONS_MY_PROFILE = [