@selfcommunity/react-templates 0.4.5-alpha.9 → 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
@@ -11,4 +11,5 @@ 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
- export { Category, CategoryProps, CategorySkeleton, CategoryFeed, CategoryFeedProps, CategoryFeedSkeleton, 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 };
14
+ import Lesson, { LessonProps } from './components/Lesson';
15
+ export { Category, CategoryProps, CategorySkeleton, CategoryFeed, CategoryFeedProps, CategoryFeedSkeleton, 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.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,5 @@ 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;
@@ -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,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 CourseDashboardTemplate(inProps) {
16
+ // PROPS
17
+ const props = useThemeProps({
18
+ props: inProps,
19
+ name: PREFIX
20
+ });
21
+ const { id = 'course_dashboard', className = null, course = null, courseId = null, page, onTabChange, 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, page: page, onTabChange: onTabChange }) })));
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 = "SCCourseDashboardTemplate";
@@ -0,0 +1 @@
1
+ export const PREFIX = 'SCCourseDashboardTemplate';
@@ -0,0 +1,3 @@
1
+ import CourseDashboardTemplate, { CourseDashboardTemplateProps } from './CourseDashboard';
2
+ export default CourseDashboardTemplate;
3
+ export { CourseDashboardTemplateProps };
@@ -0,0 +1,2 @@
1
+ import CourseDashboardTemplate from './CourseDashboard';
2
+ export default CourseDashboardTemplate;
@@ -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,25 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box, styled, useThemeProps } from '@mui/material';
3
+ import { useSCFetchCourse, useSCUser } from '@selfcommunity/react-core';
4
+ import { PREFIX } from './constants';
5
+ import classNames from 'classnames';
6
+ import { Courses } from '@selfcommunity/react-ui';
7
+ const classes = {
8
+ root: `${PREFIX}-root`
9
+ };
10
+ const Root = styled(Box, {
11
+ name: PREFIX,
12
+ slot: 'Root'
13
+ })(() => ({}));
14
+ export default function CoursesTemplate(inProps) {
15
+ // PROPS
16
+ const props = useThemeProps({
17
+ props: inProps,
18
+ name: PREFIX
19
+ });
20
+ const { id = 'courses', className = null, course = null, courseId = null } = props;
21
+ // HOOKS
22
+ const { scCourse } = useSCFetchCourse({ id: courseId, course });
23
+ const scUserContext = useSCUser();
24
+ return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: _jsx(Courses, { endpoint: { url: () => '', method: 'GET' } }) })));
25
+ }
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCCoursesTemplate";
@@ -0,0 +1 @@
1
+ export const PREFIX = 'SCCoursesTemplate';
@@ -0,0 +1,3 @@
1
+ import CoursesTemplate, { CoursesTemplateProps } from './Courses';
2
+ export default CoursesTemplate;
3
+ export { CoursesTemplateProps };
@@ -0,0 +1,2 @@
1
+ import CoursesTemplate from './Courses';
2
+ export default CoursesTemplate;
@@ -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,25 @@
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 { EditCourse } 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 EditCourseTemplate(inProps) {
16
+ // PROPS
17
+ const props = useThemeProps({
18
+ props: inProps,
19
+ name: PREFIX
20
+ });
21
+ const { id = 'course_edit', className = null, course = null, courseId = null, page, onTabChange } = props;
22
+ // HOOKS
23
+ const { scCourse } = useSCFetchCourse({ id: courseId, course, params: { view: CourseInfoViewType.EDIT } });
24
+ return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: _jsx(EditCourse, { course: scCourse, page: page, onTabChange: onTabChange }) })));
25
+ }
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCEditCourseTemplate";
@@ -0,0 +1 @@
1
+ export const PREFIX = 'SCEditCourseTemplate';
@@ -0,0 +1,3 @@
1
+ import EditCourseTemplate, { EditCourseTemplateProps } from './EditCourse';
2
+ export default EditCourseTemplate;
3
+ export { EditCourseTemplateProps };
@@ -0,0 +1,2 @@
1
+ import EditCourseTemplate from './EditCourse';
2
+ export default EditCourseTemplate;
@@ -2,7 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { styled } from '@mui/material/styles';
3
3
  import { Box } from '@mui/material';
4
4
  import { EventHeader } from '@selfcommunity/react-ui';
5
- import { useSCFetchEvent } from '@selfcommunity/react-core';
5
+ import { useSCFetchEvent, useSCUser } from '@selfcommunity/react-core';
6
+ import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
6
7
  import EventSkeletonTemplate from './Skeleton';
7
8
  import { useThemeProps } from '@mui/system';
8
9
  import classNames from 'classnames';
@@ -51,7 +52,12 @@ export default function Event(inProps) {
51
52
  const { id = 'event', className, event, eventId, widgets, FeedObjectProps, FeedSidebarProps, EventFeedProps = {}, EventHeaderProps = {} } = props;
52
53
  // HOOKS
53
54
  const { scEvent } = useSCFetchEvent({ id: eventId, event });
54
- if (!scEvent) {
55
+ const scUserContext = useSCUser();
56
+ if (scUserContext.user === undefined ||
57
+ !scEvent ||
58
+ (scUserContext.user &&
59
+ ((scEvent.privacy === SCEventPrivacyType.PUBLIC && !scEvent.subscription_status) ||
60
+ scEvent.subscription_status === SCEventSubscriptionStatusType.INVITED))) {
55
61
  return _jsx(EventSkeletonTemplate, {});
56
62
  }
57
63
  return (_jsxs(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: [_jsx(EventHeader, Object.assign({ event: scEvent }, EventHeaderProps)), _jsx(EventFeed, Object.assign({ className: classes.feed, event: scEvent, widgets: widgets, FeedObjectProps: FeedObjectProps, FeedSidebarProps: FeedSidebarProps }, EventFeedProps))] })));
@@ -88,12 +88,12 @@ export default function EventFeed(inProps) {
88
88
  // REF
89
89
  const feedRef = useRef();
90
90
  // Hooks
91
- const { scEvent, setSCEvent } = useSCFetchEvent({ id: eventId, event });
91
+ const { scEvent } = useSCFetchEvent({ id: eventId, event });
92
92
  // HANDLERS
93
93
  const handleComposerSuccess = (feedObject) => {
94
94
  var _a;
95
95
  enqueueSnackbar(_jsx(FormattedMessage, { id: "ui.composerIconButton.composer.success", defaultMessage: "ui.composerIconButton.composer.success" }), {
96
- action: (snackbarId) => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes[`${feedObject.type.toUpperCase()}_ROUTE_NAME`], ContributionUtils.getRouteData(feedObject)) }, { children: _jsx(FormattedMessage, { id: "ui.composerIconButton.composer.viewContribute", defaultMessage: "ui.composerIconButton.composer.viewContribute" }) }))),
96
+ action: () => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes[`${feedObject.type.toUpperCase()}_ROUTE_NAME`], ContributionUtils.getRouteData(feedObject)) }, { children: _jsx(FormattedMessage, { id: "ui.composerIconButton.composer.viewContribute", defaultMessage: "ui.composerIconButton.composer.viewContribute" }) }))),
97
97
  variant: 'success',
98
98
  autoHideDuration: 7000
99
99
  });
@@ -111,16 +111,20 @@ export default function EventFeed(inProps) {
111
111
  // WIDGETS
112
112
  const _widgets = useMemo(() => widgets.map((w) => {
113
113
  if (scEvent) {
114
- return Object.assign(Object.assign({}, w), { componentProps: Object.assign(Object.assign({}, w.componentProps), { eventId: scEvent.id }) });
114
+ return Object.assign(Object.assign({}, w), { componentProps: Object.assign(Object.assign({}, w.componentProps), { event: scEvent }) });
115
115
  }
116
116
  return w;
117
117
  }), [widgets, scEvent]);
118
- if (!scEvent || (scEvent && ((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id)))) {
118
+ if (scUserContext.user === undefined ||
119
+ !scEvent ||
120
+ (scUserContext.user &&
121
+ ((scEvent.privacy === SCEventPrivacyType.PUBLIC && !scEvent.subscription_status) ||
122
+ scEvent.subscription_status === SCEventSubscriptionStatusType.INVITED)) ||
123
+ (scEvent && ((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id)))) {
119
124
  return _jsx(EventFeedSkeleton, {});
120
125
  }
121
126
  else if (scEvent.privacy === SCEventPrivacyType.PRIVATE &&
122
127
  scEvent.subscription_status !== SCEventSubscriptionStatusType.SUBSCRIBED &&
123
- scEvent.subscription_status !== SCEventSubscriptionStatusType.INVITED &&
124
128
  scEvent.subscription_status !== SCEventSubscriptionStatusType.GOING &&
125
129
  scEvent.subscription_status !== SCEventSubscriptionStatusType.NOT_GOING) {
126
130
  return (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(EventInfoWidget, { className: classes.root, event: scEvent }) })));
@@ -139,7 +143,6 @@ export default function EventFeed(inProps) {
139
143
  ((!scUserContext.user && scEvent.privacy === SCEventPrivacyType.PUBLIC) ||
140
144
  (scUserContext.user &&
141
145
  (scEvent.subscription_status === SCEventSubscriptionStatusType.SUBSCRIBED ||
142
- scEvent.subscription_status === SCEventSubscriptionStatusType.INVITED ||
143
146
  scEvent.subscription_status === SCEventSubscriptionStatusType.GOING ||
144
147
  scEvent.subscription_status === SCEventSubscriptionStatusType.NOT_GOING)))) && (_jsx(InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { event: scEvent }, label: _jsx(FormattedMessage, { id: "templates.eventFeed.composer.label", defaultMessage: "templates.eventFeed.composer.label" }), feedType: SCFeedTypologyType.EVENT }))] }), CustomAdvProps: { position: SCCustomAdvPosition.POSITION_FEED, groupsId: [scEvent.id] }, enabledCustomAdvPositions: [
145
148
  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,143 @@
1
+ import { __rest } from "tslib";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useMemo, useState } from 'react';
4
+ import { styled } from '@mui/material/styles';
5
+ import { useThemeProps } from '@mui/system';
6
+ import { Box, Icon, IconButton, Typography, useMediaQuery, useTheme } from '@mui/material';
7
+ import { PREFIX } from './constants';
8
+ import { SCCourseJoinStatusType } from '@selfcommunity/types';
9
+ import { useSCFetchCourse, useSCFetchLesson } from '@selfcommunity/react-core';
10
+ import classNames from 'classnames';
11
+ import { getCurrentSectionAndLessonIndex, HiddenPlaceholder, LessonAppbar, LessonDrawer, LessonObject, SCLessonActionsType } from '@selfcommunity/react-ui';
12
+ import { CourseInfoViewType, CourseService } from '@selfcommunity/api-services';
13
+ import { FormattedMessage } from 'react-intl';
14
+ const classes = {
15
+ root: `${PREFIX}-root`,
16
+ containerRoot: `${PREFIX}-container-root`,
17
+ navigation: `${PREFIX}-navigation`,
18
+ navigationTitle: `${PREFIX}-navigation-title`
19
+ };
20
+ const Root = styled(Box, {
21
+ name: PREFIX,
22
+ slot: 'Root',
23
+ overridesResolver: (props, styles) => [styles.root]
24
+ })(() => ({}));
25
+ const Container = styled(Box, {
26
+ name: PREFIX,
27
+ slot: 'ContainerRoot',
28
+ overridesResolver: (props, styles) => styles.containerRoot,
29
+ shouldForwardProp: (prop) => prop !== 'open'
30
+ })(() => ({}));
31
+ export default function Lesson(inProps) {
32
+ var _a, _b, _c, _d;
33
+ // PROPS
34
+ const props = useThemeProps({
35
+ props: inProps,
36
+ name: PREFIX
37
+ });
38
+ const { className = null, course, courseId, sectionId, lessonId, LessonAppbarProps = {}, LessonDrawerProps = {} } = props, rest = __rest(props, ["className", "course", "courseId", "sectionId", "lessonId", "LessonAppbarProps", "LessonDrawerProps"]);
39
+ // HOOKS
40
+ const theme = useTheme();
41
+ const isMobile = useMediaQuery(theme.breakpoints.down('md'));
42
+ const [_lessonId, setLessonId] = useState(lessonId);
43
+ const [_sectionId, setSectionId] = useState(sectionId);
44
+ const isCourseAdmin = useMemo(() => course && (course.join_status === SCCourseJoinStatusType.CREATOR || course.join_status === SCCourseJoinStatusType.MANAGER), [course]);
45
+ const { scCourse } = useSCFetchCourse({ id: courseId, params: { view: isCourseAdmin ? CourseInfoViewType.EDIT : CourseInfoViewType.USER } });
46
+ const { scLesson, setSCLesson } = useSCFetchLesson({ id: _lessonId, courseId, sectionId: _sectionId });
47
+ // STATE
48
+ const [activePanel, setActivePanel] = useState(null);
49
+ const [settings, setSettings] = useState(null);
50
+ const [updating, setUpdating] = useState(false);
51
+ const [lessonContent, setLessonContent] = useState('');
52
+ const [lessonMedias, setLessonMedias] = useState((_a = scLesson === null || scLesson === void 0 ? void 0 : scLesson.medias) !== null && _a !== void 0 ? _a : []);
53
+ const [editMode, setEditMode] = useState(isCourseAdmin);
54
+ const isEditMode = editMode;
55
+ // const isEditMode = useMemo(() => {
56
+ // return value.startsWith(scRoutingContext.url(SCRoutes.COURSE_EDIT_ROUTE_NAME, {}));
57
+ // }, [value, scRoutingContext]);
58
+ // HANDLERS
59
+ /**
60
+ * Handles lesson settings change
61
+ * @param newSettings
62
+ */
63
+ const handleSettingsChange = (newSettings) => {
64
+ setSettings(newSettings);
65
+ };
66
+ const handleOpenDrawer = (panel) => {
67
+ setActivePanel((prevPanel) => (prevPanel === panel ? null : panel));
68
+ };
69
+ const handleCloseDrawer = () => {
70
+ setActivePanel(null);
71
+ setEditMode(false);
72
+ };
73
+ const handleLessonContentEdit = (html) => {
74
+ setLessonContent(html);
75
+ };
76
+ const handleLessonMediaEdit = (medias) => {
77
+ setLessonMedias(medias);
78
+ };
79
+ const handleChangeLesson = (l, s) => {
80
+ setLessonId(l.id);
81
+ setSectionId(s.id);
82
+ setCurrentSection(s);
83
+ };
84
+ /**
85
+ * Handles Lesson Edit
86
+ */
87
+ const handleLessonUpdate = () => {
88
+ setUpdating(true);
89
+ const mediaIds = lessonMedias.map((media) => media.id);
90
+ const data = Object.assign(Object.assign({}, settings), { type: scLesson.type, name: scLesson.name, text: lessonContent, medias: mediaIds });
91
+ CourseService.updateCourseLesson(scCourse.id, sectionId, scLesson.id, data)
92
+ .then((data) => {
93
+ setUpdating(false);
94
+ setSCLesson(data);
95
+ })
96
+ .catch((error) => {
97
+ setUpdating(false);
98
+ console.log(error);
99
+ });
100
+ };
101
+ const currentData = useMemo(() => {
102
+ if (!scCourse || !scLesson)
103
+ return null;
104
+ return getCurrentSectionAndLessonIndex(scCourse, scLesson.section_id, scLesson.id);
105
+ }, [scCourse, scLesson]);
106
+ const [currentSectionIndex, setCurrentSectionIndex] = useState((currentData === null || currentData === void 0 ? void 0 : currentData.currentSectionIndex) || 0);
107
+ const [currentLessonIndex, setCurrentLessonIndex] = useState((currentData === null || currentData === void 0 ? void 0 : currentData.currentLessonIndex) || 0);
108
+ const [currentSection, setCurrentSection] = useState(((_b = scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections) === null || _b === void 0 ? void 0 : _b[currentSectionIndex]) || null);
109
+ const handlePrev = () => {
110
+ if (currentLessonIndex > 0) {
111
+ const newLessonIndex = currentLessonIndex - 1;
112
+ setCurrentLessonIndex(newLessonIndex);
113
+ handleChangeLesson(currentSection.lessons[newLessonIndex], currentSection);
114
+ }
115
+ else if (currentSectionIndex > 0) {
116
+ const prevSectionIndex = currentSectionIndex - 1;
117
+ const prevSection = scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections[prevSectionIndex];
118
+ const newLessonIndex = prevSection.lessons.length - 1;
119
+ setCurrentSectionIndex(prevSectionIndex);
120
+ setCurrentLessonIndex(newLessonIndex);
121
+ handleChangeLesson(prevSection.lessons[newLessonIndex], prevSection);
122
+ }
123
+ };
124
+ const handleNext = () => {
125
+ if (currentLessonIndex < currentSection.lessons.length - 1) {
126
+ const newLessonIndex = currentLessonIndex + 1;
127
+ setCurrentLessonIndex(newLessonIndex);
128
+ handleChangeLesson(currentSection.lessons[newLessonIndex], currentSection);
129
+ }
130
+ else if (currentSectionIndex < (scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections.length) - 1) {
131
+ const newSectionIndex = currentSectionIndex + 1;
132
+ setCurrentSectionIndex(newSectionIndex);
133
+ setCurrentLessonIndex(0);
134
+ handleChangeLesson(scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections[newSectionIndex].lessons[0], scCourse.sections[newSectionIndex]);
135
+ }
136
+ };
137
+ const isPrevDisabled = !(scCourse === null || scCourse === void 0 ? void 0 : scCourse.sections) || (currentSectionIndex === 0 && currentLessonIndex === 0);
138
+ 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);
139
+ if (!scLesson || !scCourse) {
140
+ return _jsx(HiddenPlaceholder, {});
141
+ }
142
+ return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: [_jsx(LessonAppbar, Object.assign({ showComments: scLesson.comments_enabled, editMode: isEditMode, activePanel: activePanel, title: scCourse.name, handleOpen: handleOpenDrawer, onSave: handleLessonUpdate, updating: updating }, LessonAppbarProps)), _jsxs(Container, Object.assign({ open: Boolean(activePanel) || isEditMode, className: classes.containerRoot }, { children: [_jsx(Box, Object.assign({ className: classes.navigation }, { children: _jsx(Typography, Object.assign({ variant: "body2", color: "text.secondary" }, { children: _jsx(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 } }) })) })), _jsxs(Box, Object.assign({ className: classes.navigationTitle }, { children: [_jsx(Typography, Object.assign({ variant: "h5" }, { children: scLesson.name })), _jsxs(Box, { children: [_jsx(IconButton, Object.assign({ onClick: handlePrev, disabled: isPrevDisabled }, { children: _jsx(Icon, { children: "arrow_back" }) })), _jsx(IconButton, Object.assign({ onClick: handleNext, disabled: isNextDisabled }, { children: _jsx(Icon, { children: "arrow_next" }) }))] })] })), _jsx(LessonObject, { course: scCourse, lesson: scLesson, editMode: isEditMode, onContentChange: handleLessonContentEdit, onMediaChange: handleLessonMediaEdit })] })), _jsx(LessonDrawer, Object.assign({ course: scCourse, lesson: scLesson, editMode: isMobile ? activePanel === SCLessonActionsType.SETTINGS : isEditMode, activePanel: activePanel, handleClose: handleCloseDrawer, handleChangeLesson: handleChangeLesson, LessonEditFormProps: { lesson: scLesson, onSave: handleLessonUpdate, updating: updating, onSettingsChange: handleSettingsChange } }, LessonDrawerProps))] })));
143
+ }
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCLessonTemplate";
@@ -0,0 +1 @@
1
+ export const PREFIX = 'SCLessonTemplate';
@@ -0,0 +1,3 @@
1
+ import Lesson, { LessonProps } from './Lesson';
2
+ export default Lesson;
3
+ export { LessonProps };
@@ -0,0 +1,2 @@
1
+ import Lesson from './Lesson';
2
+ export default Lesson;
@@ -3,7 +3,7 @@ import { useMemo, useRef } from 'react';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import { Endpoints } from '@selfcommunity/api-services';
5
5
  import { useSCFetchUser, useSCUser } from '@selfcommunity/react-core';
6
- import { Feed, FeedObject, FeedObjectSkeleton, InlineComposerWidget, SCFeedObjectTemplateType, UserFollowedCategoriesWidget, UserFollowedUsersWidget, UserFollowersWidget } from '@selfcommunity/react-ui';
6
+ import { Feed, FeedObject, FeedObjectSkeleton, InlineComposerWidget, SCFeedObjectTemplateType, UserFollowedCategoriesWidget, UserFollowedUsersWidget, UserFollowersWidget, UserLiveStreamWidget } from '@selfcommunity/react-ui';
7
7
  import { UserFeedSkeleton } from './index';
8
8
  import { useThemeProps } from '@mui/system';
9
9
  import classNames from 'classnames';
@@ -21,24 +21,31 @@ const Root = styled(Feed, {
21
21
  const WIDGETS = [
22
22
  {
23
23
  type: 'widget',
24
- component: UserFollowedCategoriesWidget,
24
+ component: UserLiveStreamWidget,
25
25
  componentProps: {},
26
26
  column: 'right',
27
27
  position: 0
28
28
  },
29
29
  {
30
30
  type: 'widget',
31
- component: UserFollowedUsersWidget,
31
+ component: UserFollowedCategoriesWidget,
32
32
  componentProps: {},
33
33
  column: 'right',
34
34
  position: 1
35
35
  },
36
36
  {
37
37
  type: 'widget',
38
- component: UserFollowersWidget,
38
+ component: UserFollowedUsersWidget,
39
39
  componentProps: {},
40
40
  column: 'right',
41
41
  position: 2
42
+ },
43
+ {
44
+ type: 'widget',
45
+ component: UserFollowersWidget,
46
+ componentProps: {},
47
+ column: 'right',
48
+ position: 3
42
49
  }
43
50
  ];
44
51
  /**