@selfcommunity/react-ui 0.10.2-courses.176 → 0.10.2-courses.179
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/Composer/Content/ContentLesson/ContentLesson.js +1 -0
- package/lib/cjs/components/Course/Course.js +1 -1
- package/lib/cjs/components/CourseDashboard/Student.js +19 -6
- package/lib/cjs/components/CourseDashboard/Teacher/Students.js +1 -1
- package/lib/cjs/components/EditCourse/Lessons/LessonRow.js +2 -2
- package/lib/cjs/components/EditCourse/Lessons/SectionRow.js +2 -2
- package/lib/cjs/components/EditCourse/Lessons.js +1 -1
- package/lib/cjs/components/EditCourse/Requests.js +1 -1
- package/lib/cjs/components/EditCourse/Users.js +1 -1
- package/lib/cjs/components/EditCourse/hooks.d.ts +1 -1
- package/lib/cjs/components/EditCourse/hooks.js +3 -3
- package/lib/cjs/components/Editor/Editor.d.ts +1 -1
- package/lib/cjs/components/Editor/Editor.js +9 -9
- package/lib/cjs/components/Editor/plugins/HorizontalRulePlugin.d.ts +8 -0
- package/lib/cjs/components/Editor/plugins/HorizontalRulePlugin.js +34 -0
- package/lib/cjs/components/Editor/plugins/LexicalRichTextPlugin.d.ts +2 -2
- package/lib/cjs/components/Editor/plugins/LexicalRichTextPlugin.js +2 -3
- package/lib/cjs/components/LessonReleaseMenu/LessonReleaseMenu.js +26 -9
- package/lib/cjs/utils/buttonCounters.d.ts +1 -0
- package/lib/cjs/utils/buttonCounters.js +4 -3
- package/lib/esm/components/Composer/Content/ContentLesson/ContentLesson.js +1 -0
- package/lib/esm/components/Course/Course.js +1 -1
- package/lib/esm/components/CourseDashboard/Student.js +19 -6
- package/lib/esm/components/CourseDashboard/Teacher/Students.js +1 -1
- package/lib/esm/components/EditCourse/Lessons/LessonRow.js +2 -2
- package/lib/esm/components/EditCourse/Lessons/SectionRow.js +4 -4
- package/lib/esm/components/EditCourse/Lessons.js +2 -2
- package/lib/esm/components/EditCourse/Requests.js +1 -1
- package/lib/esm/components/EditCourse/Users.js +1 -1
- package/lib/esm/components/EditCourse/hooks.d.ts +1 -1
- package/lib/esm/components/EditCourse/hooks.js +1 -1
- package/lib/esm/components/Editor/Editor.d.ts +1 -1
- package/lib/esm/components/Editor/Editor.js +8 -8
- package/lib/esm/components/Editor/plugins/HorizontalRulePlugin.d.ts +8 -0
- package/lib/esm/components/Editor/plugins/HorizontalRulePlugin.js +30 -0
- package/lib/esm/components/Editor/plugins/LexicalRichTextPlugin.d.ts +2 -2
- package/lib/esm/components/Editor/plugins/LexicalRichTextPlugin.js +1 -1
- package/lib/esm/components/LessonReleaseMenu/LessonReleaseMenu.js +27 -10
- package/lib/esm/utils/buttonCounters.d.ts +1 -0
- package/lib/esm/utils/buttonCounters.js +3 -2
- package/lib/umd/{687.js → 233.js} +2 -2
- package/lib/umd/react-ui.js +1 -1
- package/package.json +11 -11
- /package/lib/umd/{687.js.LICENSE.txt → 233.js.LICENSE.txt} +0 -0
|
@@ -158,7 +158,7 @@ function Course(inProps) {
|
|
|
158
158
|
}), { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (_e = scCourse.created_by) === null || _e === void 0 ? void 0 : _e.username })) })), (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_ROUTE_NAME, scCourse), className: classes.previewNameWrapper }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6", className: classes.previewName }, { children: scCourse.name })) })), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.previewInfo }, { children: [(0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: scCourse.privacy ? `ui.course.privacy.${scCourse.privacy}` : 'ui.course.privacy.draft', defaultMessage: scCourse.privacy ? `ui.course.privacy.${scCourse.privacy}` : 'ui.course.privacy.draft' }), "-", (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.course.type.${scCourse.type}`, defaultMessage: `ui.course.type.${scCourse.type}` })] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.previewCategory }, { children: scCourse.categories.map((category) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", label: category.name }, category.id))) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.previewProgress }, { children: renderProgress() }))] })), actions !== null && actions !== void 0 ? actions : ((0, jsx_runtime_1.jsx)(material_1.CardActions, Object.assign({ className: classes.previewActions }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "outlined", size: "small", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_ROUTE_NAME, scCourse) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.course.see", id: "ui.course.see" }) })) })))] })));
|
|
159
159
|
}
|
|
160
160
|
else {
|
|
161
|
-
contentObj = ((0, jsx_runtime_1.jsx)(SnippetRoot, { elevation: 0, className: classes.snippetRoot, image: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.snippetImage }, { children: [(0, jsx_runtime_1.jsx)(material_1.Avatar, { variant: "square", alt: scCourse.name, src: scCourse.image_medium, className: userProfileSnippet ? classes.snippetAvatarUserProfile : classes.snippetAvatar }), !userProfileSnippet && (isCourseAdmin || (0, course_2.isCourseCompleted)(scCourse) || (0, course_2.isCourseNew)(scCourse)) && ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", component: "div", color: (0, course_2.isCourseCompleted)(scCourse) || (isCourseAdmin && scCourse.privacy)
|
|
161
|
+
contentObj = ((0, jsx_runtime_1.jsx)(SnippetRoot, { ButtonBaseProps: { component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_ROUTE_NAME, scCourse) }, elevation: 0, className: classes.snippetRoot, image: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.snippetImage }, { children: [(0, jsx_runtime_1.jsx)(material_1.Avatar, { variant: "square", alt: scCourse.name, src: scCourse.image_medium, className: userProfileSnippet ? classes.snippetAvatarUserProfile : classes.snippetAvatar }), !userProfileSnippet && (isCourseAdmin || (0, course_2.isCourseCompleted)(scCourse) || (0, course_2.isCourseNew)(scCourse)) && ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", component: "div", color: (0, course_2.isCourseCompleted)(scCourse) || (isCourseAdmin && scCourse.privacy)
|
|
162
162
|
? 'primary'
|
|
163
163
|
: isCourseAdmin && !scCourse.privacy
|
|
164
164
|
? 'default'
|
|
@@ -66,11 +66,12 @@ function getUrlNextLesson(course) {
|
|
|
66
66
|
return data;
|
|
67
67
|
}
|
|
68
68
|
(_a = course.sections) === null || _a === void 0 ? void 0 : _a.some((section) => {
|
|
69
|
+
var _a;
|
|
69
70
|
const isNextLessonInThisSection = section.num_lessons_completed < section.num_lessons;
|
|
70
71
|
if (isNextLessonInThisSection) {
|
|
71
72
|
Object.assign(data, {
|
|
72
73
|
section_id: section.id,
|
|
73
|
-
lesson_id: section.lessons.find((lesson) => lesson.completion_status === types_1.SCCourseLessonCompletionStatusType.UNCOMPLETED).id
|
|
74
|
+
lesson_id: (_a = section.lessons.find((lesson) => lesson.completion_status === types_1.SCCourseLessonCompletionStatusType.UNCOMPLETED)) === null || _a === void 0 ? void 0 : _a.id
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
77
|
return isNextLessonInThisSection;
|
|
@@ -118,21 +119,33 @@ function Student(inProps) {
|
|
|
118
119
|
const handleRequest = (0, react_1.useCallback)(() => {
|
|
119
120
|
setLoadingRequest(true);
|
|
120
121
|
let request;
|
|
121
|
-
let updatedCourse;
|
|
122
122
|
if (sentRequest) {
|
|
123
123
|
request = api_services_1.CourseService.leaveOrRemoveCourseRequest(scCourse.id);
|
|
124
|
-
updatedCourse = Object.assign(Object.assign({}, scCourse), { join_status: null });
|
|
125
124
|
}
|
|
126
125
|
else {
|
|
127
126
|
request = api_services_1.CourseService.joinOrAcceptInviteToCourse(scCourse.id);
|
|
128
|
-
updatedCourse = Object.assign(Object.assign({}, scCourse), { join_status: scCourse.privacy === types_1.SCCoursePrivacyType.PRIVATE ? types_1.SCCourseJoinStatusType.REQUESTED : types_1.SCCourseJoinStatusType.JOINED });
|
|
129
127
|
}
|
|
130
128
|
request
|
|
131
|
-
.then(() => {
|
|
129
|
+
.then((data) => {
|
|
130
|
+
let updatedCourse;
|
|
131
|
+
if (data) {
|
|
132
|
+
updatedCourse = data;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
updatedCourse = Object.assign(Object.assign({}, scCourse), { join_status: null });
|
|
136
|
+
}
|
|
132
137
|
setSCCourse(updatedCourse);
|
|
133
138
|
setSentRequest((prev) => !prev);
|
|
134
139
|
setLoadingRequest(false);
|
|
135
|
-
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id:
|
|
140
|
+
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: updatedCourse.join_status === types_1.SCCourseJoinStatusType.REQUESTED
|
|
141
|
+
? SNACKBAR_MESSAGES.request
|
|
142
|
+
: updatedCourse.join_status === types_1.SCCourseJoinStatusType.JOINED
|
|
143
|
+
? SNACKBAR_MESSAGES.enroll
|
|
144
|
+
: SNACKBAR_MESSAGES.cancel, defaultMessage: updatedCourse.join_status === types_1.SCCourseJoinStatusType.REQUESTED
|
|
145
|
+
? SNACKBAR_MESSAGES.request
|
|
146
|
+
: updatedCourse.join_status === types_1.SCCourseJoinStatusType.JOINED
|
|
147
|
+
? SNACKBAR_MESSAGES.enroll
|
|
148
|
+
: SNACKBAR_MESSAGES.cancel }), {
|
|
136
149
|
variant: 'success',
|
|
137
150
|
autoHideDuration: 3000
|
|
138
151
|
});
|
|
@@ -32,7 +32,7 @@ function Students(props) {
|
|
|
32
32
|
const [state, dispatch] = (0, react_1.useReducer)(widget_1.dataWidgetReducer, {
|
|
33
33
|
isLoadingNext: false,
|
|
34
34
|
next: null,
|
|
35
|
-
cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.
|
|
35
|
+
cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.STUDENTS_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY, course.id),
|
|
36
36
|
cacheStrategy: utils_1.CacheStrategies.CACHE_FIRST,
|
|
37
37
|
visibleItems: endpointQueryParams.limit
|
|
38
38
|
}, widget_1.stateWidgetInitializer);
|
|
@@ -16,8 +16,8 @@ const notistack_1 = require("notistack");
|
|
|
16
16
|
const react_core_1 = require("@selfcommunity/react-core");
|
|
17
17
|
const Errors_1 = require("../../../constants/Errors");
|
|
18
18
|
const types_1 = require("../types");
|
|
19
|
-
const hooks_1 = require("../hooks");
|
|
20
19
|
const ConfirmDialog_1 = tslib_1.__importDefault(require("../../../shared/ConfirmDialog/ConfirmDialog"));
|
|
20
|
+
const hooks_1 = require("../hooks");
|
|
21
21
|
const classes = {
|
|
22
22
|
cellWidth: `${constants_1.PREFIX}-cell-width`,
|
|
23
23
|
cellAlignRight: `${constants_1.PREFIX}-cell-align-right`,
|
|
@@ -42,7 +42,7 @@ function LessonRow(props) {
|
|
|
42
42
|
// CONTEXTS
|
|
43
43
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
44
44
|
// HOOKS
|
|
45
|
-
const { isDisabled } = (0, hooks_1.
|
|
45
|
+
const { isDisabled } = (0, hooks_1.useIsDisabled)();
|
|
46
46
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
47
47
|
// HANDLERS
|
|
48
48
|
const handleAbleEditMode = (0, react_1.useCallback)(() => setTimeout(() => setEditMode(true)), [setEditMode]);
|
|
@@ -40,7 +40,7 @@ function SectionRow(props) {
|
|
|
40
40
|
const [editMode, setEditMode] = (0, react_1.useState)(false);
|
|
41
41
|
const [lessons, setLessons] = (0, react_1.useState)([]);
|
|
42
42
|
// HOOKS
|
|
43
|
-
const { isDisabled } = (0, hooks_1.
|
|
43
|
+
const { isDisabled } = (0, hooks_1.useIsDisabled)();
|
|
44
44
|
const intl = (0, react_intl_1.useIntl)();
|
|
45
45
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
46
46
|
// EFFECTS
|
|
@@ -144,6 +144,6 @@ function SectionRow(props) {
|
|
|
144
144
|
? api_services_1.Endpoints.CreateCourseSection.url({ id: course.id })
|
|
145
145
|
: api_services_1.Endpoints.PatchCourseSection.url({ id: course.id, section_id: section.id }),
|
|
146
146
|
method: isNewRow ? api_services_1.Endpoints.CreateCourseSection.method : api_services_1.Endpoints.PatchCourseSection.method
|
|
147
|
-
}, row: section, isNewRow: isNewRow, handleManageRow: handleManageSection, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ className: classes.cellAlignCenter }, { children:
|
|
147
|
+
}, row: section, isNewRow: isNewRow, handleManageRow: handleManageSection, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ className: classes.cellAlignCenter }, { children: (0, jsx_runtime_1.jsx)(LessonReleaseMenu_1.default, { course: course, section: section }) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ className: classes.cellAlignRight }, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.actionsWrapper }, { children: [(0, jsx_runtime_1.jsx)(AddButton_1.default, { label: "ui.editCourse.tab.lessons.table.lesson", handleAddRow: handleAddTempLesson, color: "primary", variant: "outlined", disabled: isDisabled }), (0, jsx_runtime_1.jsxs)(MenuRow_1.default, Object.assign({ disabled: isDisabled }, { children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ onClick: handleAbleEditMode }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.rename", defaultMessage: "ui.editCourse.tab.lessons.table.menu.rename" }) })) })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ onClick: handleOpenDialog }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.delete", defaultMessage: "ui.editCourse.tab.lessons.table.menu.delete" }) })) }))] }))] })) }))] })), (0, jsx_runtime_1.jsx)(material_1.TableRow, { children: (0, jsx_runtime_1.jsxs)(material_1.TableCell, Object.assign({ className: classes.tableBodyCollapseWrapper, colSpan: 4 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ in: expand, timeout: "auto", unmountOnExit: true }, { children: (0, jsx_runtime_1.jsx)(dnd_1.DragDropContext, Object.assign({ onDragEnd: handleDragEnd }, { children: (0, jsx_runtime_1.jsx)(material_1.Table, { children: (0, jsx_runtime_1.jsx)(dnd_1.Droppable, Object.assign({ droppableId: "droppable-2" }, { children: (outerProvider) => ((0, jsx_runtime_1.jsxs)(material_1.TableBody, Object.assign({ ref: outerProvider.innerRef }, outerProvider.droppableProps, { children: [lessons.map((lesson, i, array) => ((0, jsx_runtime_1.jsx)(dnd_1.Draggable, Object.assign({ draggableId: i.toString(), index: i, isDragDisabled: isDisabled }, { children: (innerProvider) => ((0, jsx_runtime_1.jsx)(LessonRow_1.default, { provider: innerProvider, course: course, section: section, lesson: lesson, isNewRow: isNewLocalRow && i + 1 === array.length, handleManageLesson: handleManageLesson }, i)) }), i))), outerProvider.placeholder] }))) })) }) })) })), open && (0, jsx_runtime_1.jsx)(ConfirmDialog_1.default, { open: true, onClose: handleOpenDialog, onConfirm: handleDeleteSection })] })) })] }));
|
|
148
148
|
}
|
|
149
149
|
exports.default = (0, react_1.memo)(SectionRow);
|
|
@@ -58,7 +58,7 @@ function Lessons(props) {
|
|
|
58
58
|
// STATES
|
|
59
59
|
const [sections, setSections] = (0, react_1.useState)([]);
|
|
60
60
|
// HOOKS
|
|
61
|
-
const { isDisabled } = (0, hooks_1.
|
|
61
|
+
const { isDisabled } = (0, hooks_1.useIsDisabled)();
|
|
62
62
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
63
63
|
const intl = (0, react_intl_1.useIntl)();
|
|
64
64
|
// EFFECTS
|
|
@@ -42,7 +42,7 @@ function Requests(props) {
|
|
|
42
42
|
isLoadingPrevious: false,
|
|
43
43
|
isLoadingNext: false,
|
|
44
44
|
next: null,
|
|
45
|
-
cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.
|
|
45
|
+
cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.USERS_REQUESTS_COURSES_STATE_CACHE_PREFIX_KEY, course.id),
|
|
46
46
|
cacheStrategy: utils_1.CacheStrategies.CACHE_FIRST,
|
|
47
47
|
visibleItems: endpointQueryParams.limit
|
|
48
48
|
}, widget_1.stateWidgetInitializer);
|
|
@@ -48,7 +48,7 @@ function Users(props) {
|
|
|
48
48
|
const [state, dispatch] = (0, react_1.useReducer)(widget_1.dataWidgetReducer, {
|
|
49
49
|
isLoadingNext: false,
|
|
50
50
|
next: null,
|
|
51
|
-
cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.
|
|
51
|
+
cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.USERS_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY, course.id),
|
|
52
52
|
cacheStrategy: utils_1.CacheStrategies.CACHE_FIRST,
|
|
53
53
|
visibleItems: endpointQueryParams.limit
|
|
54
54
|
}, widget_1.stateWidgetInitializer);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.useIsDisabled = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
|
|
7
7
|
const PubSub_1 = require("../../constants/PubSub");
|
|
8
|
-
const
|
|
8
|
+
const useIsDisabled = () => {
|
|
9
9
|
// STATES
|
|
10
10
|
const [isDisabled, setIsDisabled] = (0, react_1.useState)(false);
|
|
11
11
|
// REFS
|
|
@@ -19,4 +19,4 @@ const useDisabled = () => {
|
|
|
19
19
|
}, [setIsDisabled]);
|
|
20
20
|
return { isDisabled };
|
|
21
21
|
};
|
|
22
|
-
exports.
|
|
22
|
+
exports.useIsDisabled = useIsDisabled;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { MediaPluginProps } from './plugins';
|
|
3
2
|
import { ToolbarPluginProps } from './plugins/ToolbarPlugin';
|
|
3
|
+
import { MediaPluginProps } from './plugins';
|
|
4
4
|
import { SCMediaType } from '@selfcommunity/types';
|
|
5
5
|
export declare type EditorRef = {
|
|
6
6
|
focus: () => void;
|
|
@@ -11,19 +11,19 @@ const system_1 = require("@mui/system");
|
|
|
11
11
|
const nodes_1 = tslib_1.__importDefault(require("./nodes"));
|
|
12
12
|
const LexicalComposer_1 = require("@lexical/react/LexicalComposer");
|
|
13
13
|
const LexicalContentEditable_1 = require("@lexical/react/LexicalContentEditable");
|
|
14
|
-
const
|
|
14
|
+
const ToolbarPlugin_1 = tslib_1.__importDefault(require("./plugins/ToolbarPlugin"));
|
|
15
|
+
const constants_1 = require("./constants");
|
|
16
|
+
const HorizontalRulePlugin_1 = require("./plugins/HorizontalRulePlugin");
|
|
15
17
|
const LexicalRichTextPlugin_1 = require("./plugins/LexicalRichTextPlugin");
|
|
16
|
-
const LexicalErrorBoundary_1 =
|
|
17
|
-
const LexicalHorizontalRulePlugin_1 = require("@lexical/react/LexicalHorizontalRulePlugin");
|
|
18
|
+
const LexicalErrorBoundary_1 = require("@lexical/react/LexicalErrorBoundary");
|
|
18
19
|
const plugins_1 = require("./plugins");
|
|
20
|
+
const OnBlurPlugin_1 = tslib_1.__importDefault(require("./plugins/OnBlurPlugin"));
|
|
21
|
+
const OnFocusPlugin_1 = tslib_1.__importDefault(require("./plugins/OnFocusPlugin"));
|
|
19
22
|
const LexicalLinkPlugin_1 = require("@lexical/react/LexicalLinkPlugin");
|
|
23
|
+
const FloatingLinkPlugin_1 = tslib_1.__importDefault(require("./plugins/FloatingLinkPlugin"));
|
|
20
24
|
const ApiPlugin_1 = tslib_1.__importDefault(require("./plugins/ApiPlugin"));
|
|
21
|
-
const
|
|
25
|
+
const LexicalHistoryPlugin_1 = require("@lexical/react/LexicalHistoryPlugin");
|
|
22
26
|
const LexicalListPlugin_1 = require("@lexical/react/LexicalListPlugin");
|
|
23
|
-
const FloatingLinkPlugin_1 = tslib_1.__importDefault(require("./plugins/FloatingLinkPlugin"));
|
|
24
|
-
const OnBlurPlugin_1 = tslib_1.__importDefault(require("./plugins/OnBlurPlugin"));
|
|
25
|
-
const OnFocusPlugin_1 = tslib_1.__importDefault(require("./plugins/OnFocusPlugin"));
|
|
26
|
-
const constants_1 = require("./constants");
|
|
27
27
|
const classes = {
|
|
28
28
|
root: `${constants_1.PREFIX}-root`,
|
|
29
29
|
focused: `${constants_1.PREFIX}-focused`,
|
|
@@ -148,6 +148,6 @@ const Editor = (inProps, ref) => {
|
|
|
148
148
|
nodes: [...nodes_1.default],
|
|
149
149
|
theme: editorTheme
|
|
150
150
|
}), [editable]);
|
|
151
|
-
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, { [classes.toolbar]: toolbar, [classes.focused]: focused }) }, { children: (0, jsx_runtime_1.jsxs)(LexicalComposer_1.LexicalComposer, Object.assign({ initialConfig: initialConfig }, { children: [toolbar ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ToolbarPlugin_1.default, Object.assign({ uploadImage: uploadImage, uploadFile: uploadFile, MediaPluginProps: { onMediaAdd: handleMediaChange } }, ToolBarProps)), (0, jsx_runtime_1.jsx)(LexicalListPlugin_1.ListPlugin, {}), (0, jsx_runtime_1.jsx)(
|
|
151
|
+
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, { [classes.toolbar]: toolbar, [classes.focused]: focused }) }, { children: (0, jsx_runtime_1.jsxs)(LexicalComposer_1.LexicalComposer, Object.assign({ initialConfig: initialConfig }, { children: [toolbar ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ToolbarPlugin_1.default, Object.assign({ uploadImage: uploadImage, uploadFile: uploadFile, MediaPluginProps: { onMediaAdd: handleMediaChange } }, ToolBarProps)), (0, jsx_runtime_1.jsx)(LexicalListPlugin_1.ListPlugin, {}), (0, jsx_runtime_1.jsx)(HorizontalRulePlugin_1.HorizontalRulePlugin, {})] })) : ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.actions, direction: "row" }, { children: [uploadImage && (0, jsx_runtime_1.jsx)(plugins_1.ImagePlugin, {}), uploadFile && (0, jsx_runtime_1.jsx)(plugins_1.MediaPlugin, Object.assign({}, MediaPluginProps)), (0, jsx_runtime_1.jsx)(plugins_1.EmojiPlugin, {}), action && action] }))), (0, jsx_runtime_1.jsx)(LexicalRichTextPlugin_1.RichTextPlugin, { contentEditable: (0, jsx_runtime_1.jsx)(LexicalContentEditable_1.ContentEditable, { className: classes.content }), placeholder: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.placeholder, onClick: handleFocus }, { children: placeholder })), ErrorBoundary: LexicalErrorBoundary_1.LexicalErrorBoundary }), (0, jsx_runtime_1.jsx)(plugins_1.DefaultHtmlValuePlugin, { defaultValue: defaultValue }), (0, jsx_runtime_1.jsx)(LexicalHistoryPlugin_1.HistoryPlugin, {}), (0, jsx_runtime_1.jsx)(plugins_1.OnChangePlugin, { onChange: handleChange }), (0, jsx_runtime_1.jsx)(OnBlurPlugin_1.default, { onBlur: handleHasBlur }), (0, jsx_runtime_1.jsx)(OnFocusPlugin_1.default, { onFocus: handleHasFocus }), (0, jsx_runtime_1.jsx)(plugins_1.AutoLinkPlugin, {}), (0, jsx_runtime_1.jsx)(plugins_1.MentionsPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalLinkPlugin_1.LinkPlugin, {}), (0, jsx_runtime_1.jsx)(FloatingLinkPlugin_1.default, {}), (0, jsx_runtime_1.jsx)(ApiPlugin_1.default, { ref: apiRef })] })) })));
|
|
152
152
|
};
|
|
153
153
|
exports.default = (0, react_1.forwardRef)(Editor);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.HorizontalRulePlugin = void 0;
|
|
11
|
+
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
|
|
12
|
+
const LexicalHorizontalRuleNode_1 = require("@lexical/react/LexicalHorizontalRuleNode");
|
|
13
|
+
const utils_1 = require("@lexical/utils");
|
|
14
|
+
const lexical_1 = require("lexical");
|
|
15
|
+
const react_1 = require("react");
|
|
16
|
+
function HorizontalRulePlugin() {
|
|
17
|
+
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
18
|
+
(0, react_1.useEffect)(() => {
|
|
19
|
+
return editor.registerCommand(LexicalHorizontalRuleNode_1.INSERT_HORIZONTAL_RULE_COMMAND, (type) => {
|
|
20
|
+
const selection = (0, lexical_1.$getSelection)();
|
|
21
|
+
if (!(0, lexical_1.$isRangeSelection)(selection)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const focusNode = selection.focus.getNode();
|
|
25
|
+
if (focusNode !== null) {
|
|
26
|
+
const horizontalRuleNode = (0, LexicalHorizontalRuleNode_1.$createHorizontalRuleNode)();
|
|
27
|
+
(0, utils_1.$insertNodeToNearestRoot)(horizontalRuleNode);
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}, lexical_1.COMMAND_PRIORITY_EDITOR);
|
|
31
|
+
}, [editor]);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
exports.HorizontalRulePlugin = HorizontalRulePlugin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ErrorBoundaryType } from '../shared/useDecorators';
|
|
2
2
|
export declare function RichTextPlugin({ contentEditable, placeholder, ErrorBoundary }: {
|
|
3
3
|
contentEditable: JSX.Element;
|
|
4
|
-
placeholder
|
|
5
|
-
ErrorBoundary
|
|
4
|
+
placeholder?: ((isEditable: boolean) => null | JSX.Element) | null | JSX.Element;
|
|
5
|
+
ErrorBoundary?: ErrorBoundaryType;
|
|
6
6
|
}): JSX.Element;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RichTextPlugin = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
5
|
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
|
|
7
|
-
const useLexicalEditable_1 =
|
|
6
|
+
const useLexicalEditable_1 = require("@lexical/react/useLexicalEditable");
|
|
8
7
|
const useDecorators_1 = require("../shared/useDecorators");
|
|
9
8
|
const useEditorFocus_1 = require("../shared/useEditorFocus");
|
|
10
9
|
const useCanShowPlaceholder_1 = require("../shared/useCanShowPlaceholder");
|
|
@@ -19,7 +18,7 @@ exports.RichTextPlugin = RichTextPlugin;
|
|
|
19
18
|
function Placeholder({ content }) {
|
|
20
19
|
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
21
20
|
const showPlaceholder = (0, useCanShowPlaceholder_1.useCanShowPlaceholder)(editor);
|
|
22
|
-
const editable = (0, useLexicalEditable_1.
|
|
21
|
+
const editable = (0, useLexicalEditable_1.useLexicalEditable)();
|
|
23
22
|
const hasFocus = (0, useEditorFocus_1.useEditorFocus)();
|
|
24
23
|
if (!showPlaceholder || hasFocus) {
|
|
25
24
|
return null;
|
|
@@ -19,6 +19,7 @@ const api_services_1 = require("@selfcommunity/api-services");
|
|
|
19
19
|
const Errors_1 = require("../../constants/Errors");
|
|
20
20
|
const utils_1 = require("@selfcommunity/utils");
|
|
21
21
|
const course_1 = require("../../utils/course");
|
|
22
|
+
const hooks_1 = require("../EditCourse/hooks");
|
|
22
23
|
const messages = (0, react_intl_1.defineMessages)({
|
|
23
24
|
pickerPlaceholder: {
|
|
24
25
|
id: 'ui.lessonReleaseMenu.scheduled.picker.placeholder',
|
|
@@ -49,13 +50,13 @@ const classes = {
|
|
|
49
50
|
const Root = (0, styles_1.styled)(material_1.FormControl, {
|
|
50
51
|
name: constants_1.PREFIX,
|
|
51
52
|
slot: 'Root',
|
|
52
|
-
overridesResolver: (
|
|
53
|
+
overridesResolver: (_props, styles) => [styles.root]
|
|
53
54
|
})(() => ({}));
|
|
54
55
|
const PopoverRoot = (0, styles_1.styled)(material_1.Popover, {
|
|
55
56
|
name: constants_1.PREFIX,
|
|
56
57
|
slot: 'PopoverRoot',
|
|
57
|
-
overridesResolver: (
|
|
58
|
-
})((
|
|
58
|
+
overridesResolver: (_props, styles) => styles.popoverRoot
|
|
59
|
+
})(() => ({}));
|
|
59
60
|
function LessonReleaseMenu(inProps) {
|
|
60
61
|
// PROPS
|
|
61
62
|
const props = (0, system_1.useThemeProps)({
|
|
@@ -66,17 +67,33 @@ function LessonReleaseMenu(inProps) {
|
|
|
66
67
|
// CONTEXT
|
|
67
68
|
const scContext = (0, react_core_1.useSCContext)();
|
|
68
69
|
// STATE
|
|
69
|
-
const [drippedAt, setDrippedAt] = (0, react_1.useState)(
|
|
70
|
+
const [drippedAt, setDrippedAt] = (0, react_1.useState)(null);
|
|
70
71
|
const { delay, _unit } = (0, course_1.getDripDelayAndUnit)((section === null || section === void 0 ? void 0 : section.drip_delay) || 0);
|
|
71
72
|
const [dripDelay, setDripDelay] = (0, react_1.useState)(delay);
|
|
72
73
|
const [unit, setUnit] = (0, react_1.useState)(_unit);
|
|
73
74
|
const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
|
|
74
75
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
76
|
+
// HOOKS
|
|
77
|
+
const { isDisabled } = (0, hooks_1.useIsDisabled)();
|
|
75
78
|
//INTL
|
|
76
79
|
const intl = (0, react_intl_1.useIntl)();
|
|
77
80
|
const handleUnitChange = (e) => {
|
|
78
81
|
setUnit(e.target.value);
|
|
79
82
|
};
|
|
83
|
+
// EFFECTS
|
|
84
|
+
(0, react_1.useEffect)(() => {
|
|
85
|
+
if (section && section.dripped_at) {
|
|
86
|
+
setDrippedAt(new Date(section.dripped_at));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
setDrippedAt(null);
|
|
90
|
+
}
|
|
91
|
+
}, [section, setDrippedAt]);
|
|
92
|
+
(0, react_1.useEffect)(() => {
|
|
93
|
+
if (section) {
|
|
94
|
+
setDripDelay(delay);
|
|
95
|
+
}
|
|
96
|
+
}, [section, setDripDelay]);
|
|
80
97
|
// HANDLERS
|
|
81
98
|
const handleClick = (event) => {
|
|
82
99
|
setAnchorEl(event.currentTarget);
|
|
@@ -122,10 +139,10 @@ function LessonReleaseMenu(inProps) {
|
|
|
122
139
|
okButtonLabel: `${intl.formatMessage(messages.pickerOkMessage)}`,
|
|
123
140
|
cancelButtonLabel: `${intl.formatMessage(messages.pickerCancelMessage)}`,
|
|
124
141
|
clearButtonLabel: `${intl.formatMessage(messages.pickerClearMessage)}`
|
|
125
|
-
} }, { children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDateTimePicker, { className: classes.picker, disablePast: true, label: drippedAt && ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.lessonReleaseMenu.scheduled.picker.placeholder", defaultMessage: "ui.lessonReleaseMenu.scheduled.picker.placeholder" })),
|
|
142
|
+
} }, { children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDateTimePicker, { className: classes.picker, disablePast: true, label: drippedAt && ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.lessonReleaseMenu.scheduled.picker.placeholder", defaultMessage: "ui.lessonReleaseMenu.scheduled.picker.placeholder" })), value: drippedAt, slots: {
|
|
126
143
|
//actionBar: PickerActionBar,
|
|
127
144
|
tabs: (props) => (0, jsx_runtime_1.jsx)(x_date_pickers_1.DateTimePickerTabs, Object.assign({}, props)),
|
|
128
|
-
textField: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { error: false, InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.pickerPlaceholder)}`, endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "expand_more" }) }) }))) }) })))
|
|
145
|
+
textField: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { error: false, InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.pickerPlaceholder)}`, endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ disabled: isDisabled }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "expand_more" }) })) }))) }) })))
|
|
129
146
|
}, slotProps: {
|
|
130
147
|
tabs: {
|
|
131
148
|
hidden: false
|
|
@@ -138,9 +155,9 @@ function LessonReleaseMenu(inProps) {
|
|
|
138
155
|
actionBar: {
|
|
139
156
|
actions: ['cancel', 'clear', 'accept']
|
|
140
157
|
}
|
|
141
|
-
}, onChange: (value) => setDrippedAt(value), onAccept: handleUpdate, onClear: () => setDrippedAt(null) }) }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { size: "small",
|
|
142
|
-
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: handleClick }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "expand_more" }) })) })))
|
|
143
|
-
} }), (0, jsx_runtime_1.jsxs)(PopoverRoot, Object.assign({ className: classes.popoverRoot, open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: {
|
|
158
|
+
}, onChange: (value) => setDrippedAt(value), onAccept: handleUpdate, onClear: () => setDrippedAt(null), disabled: isDisabled }) }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { size: "small", value: placeholderStructured, onClick: isDisabled ? undefined : handleClick, InputProps: {
|
|
159
|
+
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: handleClick, disabled: isDisabled }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "expand_more" }) })) })))
|
|
160
|
+
}, disabled: isDisabled }), (0, jsx_runtime_1.jsxs)(PopoverRoot, Object.assign({ className: classes.popoverRoot, open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: {
|
|
144
161
|
vertical: 'bottom',
|
|
145
162
|
horizontal: 'left'
|
|
146
163
|
}, transformOrigin: {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.numberFormatter = void 0;
|
|
3
|
+
exports.numberFormatter = exports.DEFAULT_COUNTERS_LIMIT = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
exports.DEFAULT_COUNTERS_LIMIT = 3;
|
|
5
6
|
function numberFormatter(num) {
|
|
6
|
-
const surplus = num -
|
|
7
|
+
const surplus = num === exports.DEFAULT_COUNTERS_LIMIT ? 1 : num < exports.DEFAULT_COUNTERS_LIMIT ? num : num - exports.DEFAULT_COUNTERS_LIMIT;
|
|
7
8
|
if (surplus > 999999) {
|
|
8
9
|
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["+", (Math.abs(surplus) / 1000000).toFixed(1), "M"] });
|
|
9
10
|
}
|
|
10
|
-
else if (
|
|
11
|
+
else if (surplus > 999) {
|
|
11
12
|
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["+", (Math.abs(surplus) / 1000).toFixed(1), "K"] });
|
|
12
13
|
}
|
|
13
14
|
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["+", surplus] });
|
|
@@ -156,7 +156,7 @@ export default function Course(inProps) {
|
|
|
156
156
|
}), { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: (_e = scCourse.created_by) === null || _e === void 0 ? void 0 : _e.username })) })), _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.COURSE_ROUTE_NAME, scCourse), className: classes.previewNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h6", className: classes.previewName }, { children: scCourse.name })) })), _jsxs(Typography, Object.assign({ className: classes.previewInfo }, { children: [_jsx(FormattedMessage, { id: scCourse.privacy ? `ui.course.privacy.${scCourse.privacy}` : 'ui.course.privacy.draft', defaultMessage: scCourse.privacy ? `ui.course.privacy.${scCourse.privacy}` : 'ui.course.privacy.draft' }), "-", _jsx(FormattedMessage, { id: `ui.course.type.${scCourse.type}`, defaultMessage: `ui.course.type.${scCourse.type}` })] })), _jsx(Box, Object.assign({ className: classes.previewCategory }, { children: scCourse.categories.map((category) => (_jsx(Chip, { size: "small", label: category.name }, category.id))) })), _jsx(Box, Object.assign({ className: classes.previewProgress }, { children: renderProgress() }))] })), actions !== null && actions !== void 0 ? actions : (_jsx(CardActions, Object.assign({ className: classes.previewActions }, { children: _jsx(Button, Object.assign({ variant: "outlined", size: "small", component: Link, to: scRoutingContext.url(SCRoutes.COURSE_ROUTE_NAME, scCourse) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.course.see", id: "ui.course.see" }) })) })))] })));
|
|
157
157
|
}
|
|
158
158
|
else {
|
|
159
|
-
contentObj = (_jsx(SnippetRoot, { elevation: 0, className: classes.snippetRoot, image: _jsxs(Box, Object.assign({ className: classes.snippetImage }, { children: [_jsx(Avatar, { variant: "square", alt: scCourse.name, src: scCourse.image_medium, className: userProfileSnippet ? classes.snippetAvatarUserProfile : classes.snippetAvatar }), !userProfileSnippet && (isCourseAdmin || isCourseCompleted(scCourse) || isCourseNew(scCourse)) && (_jsx(Chip, { size: "small", component: "div", color: isCourseCompleted(scCourse) || (isCourseAdmin && scCourse.privacy)
|
|
159
|
+
contentObj = (_jsx(SnippetRoot, { ButtonBaseProps: { component: Link, to: scRoutingContext.url(SCRoutes.COURSE_ROUTE_NAME, scCourse) }, elevation: 0, className: classes.snippetRoot, image: _jsxs(Box, Object.assign({ className: classes.snippetImage }, { children: [_jsx(Avatar, { variant: "square", alt: scCourse.name, src: scCourse.image_medium, className: userProfileSnippet ? classes.snippetAvatarUserProfile : classes.snippetAvatar }), !userProfileSnippet && (isCourseAdmin || isCourseCompleted(scCourse) || isCourseNew(scCourse)) && (_jsx(Chip, { size: "small", component: "div", color: isCourseCompleted(scCourse) || (isCourseAdmin && scCourse.privacy)
|
|
160
160
|
? 'primary'
|
|
161
161
|
: isCourseAdmin && !scCourse.privacy
|
|
162
162
|
? 'default'
|
|
@@ -64,11 +64,12 @@ function getUrlNextLesson(course) {
|
|
|
64
64
|
return data;
|
|
65
65
|
}
|
|
66
66
|
(_a = course.sections) === null || _a === void 0 ? void 0 : _a.some((section) => {
|
|
67
|
+
var _a;
|
|
67
68
|
const isNextLessonInThisSection = section.num_lessons_completed < section.num_lessons;
|
|
68
69
|
if (isNextLessonInThisSection) {
|
|
69
70
|
Object.assign(data, {
|
|
70
71
|
section_id: section.id,
|
|
71
|
-
lesson_id: section.lessons.find((lesson) => lesson.completion_status === SCCourseLessonCompletionStatusType.UNCOMPLETED).id
|
|
72
|
+
lesson_id: (_a = section.lessons.find((lesson) => lesson.completion_status === SCCourseLessonCompletionStatusType.UNCOMPLETED)) === null || _a === void 0 ? void 0 : _a.id
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
return isNextLessonInThisSection;
|
|
@@ -116,21 +117,33 @@ function Student(inProps) {
|
|
|
116
117
|
const handleRequest = useCallback(() => {
|
|
117
118
|
setLoadingRequest(true);
|
|
118
119
|
let request;
|
|
119
|
-
let updatedCourse;
|
|
120
120
|
if (sentRequest) {
|
|
121
121
|
request = CourseService.leaveOrRemoveCourseRequest(scCourse.id);
|
|
122
|
-
updatedCourse = Object.assign(Object.assign({}, scCourse), { join_status: null });
|
|
123
122
|
}
|
|
124
123
|
else {
|
|
125
124
|
request = CourseService.joinOrAcceptInviteToCourse(scCourse.id);
|
|
126
|
-
updatedCourse = Object.assign(Object.assign({}, scCourse), { join_status: scCourse.privacy === SCCoursePrivacyType.PRIVATE ? SCCourseJoinStatusType.REQUESTED : SCCourseJoinStatusType.JOINED });
|
|
127
125
|
}
|
|
128
126
|
request
|
|
129
|
-
.then(() => {
|
|
127
|
+
.then((data) => {
|
|
128
|
+
let updatedCourse;
|
|
129
|
+
if (data) {
|
|
130
|
+
updatedCourse = data;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
updatedCourse = Object.assign(Object.assign({}, scCourse), { join_status: null });
|
|
134
|
+
}
|
|
130
135
|
setSCCourse(updatedCourse);
|
|
131
136
|
setSentRequest((prev) => !prev);
|
|
132
137
|
setLoadingRequest(false);
|
|
133
|
-
enqueueSnackbar(_jsx(FormattedMessage, { id:
|
|
138
|
+
enqueueSnackbar(_jsx(FormattedMessage, { id: updatedCourse.join_status === SCCourseJoinStatusType.REQUESTED
|
|
139
|
+
? SNACKBAR_MESSAGES.request
|
|
140
|
+
: updatedCourse.join_status === SCCourseJoinStatusType.JOINED
|
|
141
|
+
? SNACKBAR_MESSAGES.enroll
|
|
142
|
+
: SNACKBAR_MESSAGES.cancel, defaultMessage: updatedCourse.join_status === SCCourseJoinStatusType.REQUESTED
|
|
143
|
+
? SNACKBAR_MESSAGES.request
|
|
144
|
+
: updatedCourse.join_status === SCCourseJoinStatusType.JOINED
|
|
145
|
+
? SNACKBAR_MESSAGES.enroll
|
|
146
|
+
: SNACKBAR_MESSAGES.cancel }), {
|
|
134
147
|
variant: 'success',
|
|
135
148
|
autoHideDuration: 3000
|
|
136
149
|
});
|
|
@@ -29,7 +29,7 @@ function Students(props) {
|
|
|
29
29
|
const [state, dispatch] = useReducer(dataWidgetReducer, {
|
|
30
30
|
isLoadingNext: false,
|
|
31
31
|
next: null,
|
|
32
|
-
cacheKey: SCCache.getWidgetStateCacheKey(SCCache.
|
|
32
|
+
cacheKey: SCCache.getWidgetStateCacheKey(SCCache.STUDENTS_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY, course.id),
|
|
33
33
|
cacheStrategy: CacheStrategies.CACHE_FIRST,
|
|
34
34
|
visibleItems: endpointQueryParams.limit
|
|
35
35
|
}, stateWidgetInitializer);
|
|
@@ -13,8 +13,8 @@ import { useSnackbar } from 'notistack';
|
|
|
13
13
|
import { Link, SCRoutes, useSCRouting } from '@selfcommunity/react-core';
|
|
14
14
|
import { SCOPE_SC_UI } from '../../../constants/Errors';
|
|
15
15
|
import { ActionLessonType } from '../types';
|
|
16
|
-
import { useDisabled } from '../hooks';
|
|
17
16
|
import ConfirmDialog from '../../../shared/ConfirmDialog/ConfirmDialog';
|
|
17
|
+
import { useIsDisabled } from '../hooks';
|
|
18
18
|
const classes = {
|
|
19
19
|
cellWidth: `${PREFIX}-cell-width`,
|
|
20
20
|
cellAlignRight: `${PREFIX}-cell-align-right`,
|
|
@@ -39,7 +39,7 @@ function LessonRow(props) {
|
|
|
39
39
|
// CONTEXTS
|
|
40
40
|
const scRoutingContext = useSCRouting();
|
|
41
41
|
// HOOKS
|
|
42
|
-
const { isDisabled } =
|
|
42
|
+
const { isDisabled } = useIsDisabled();
|
|
43
43
|
const { enqueueSnackbar } = useSnackbar();
|
|
44
44
|
// HANDLERS
|
|
45
45
|
const handleAbleEditMode = useCallback(() => setTimeout(() => setEditMode(true)), [setEditMode]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { DragDropContext, Draggable, Droppable } from '@hello-pangea/dnd';
|
|
3
3
|
import { Fragment, memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
|
-
import { Collapse, Icon, IconButton, MenuItem,
|
|
4
|
+
import { Collapse, Icon, IconButton, MenuItem, Stack, Table, TableBody, TableCell, TableRow, Typography } from '@mui/material';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import { PREFIX } from '../constants';
|
|
7
7
|
import LessonRow from './LessonRow';
|
|
@@ -16,7 +16,7 @@ import LessonReleaseMenu from '../../LessonReleaseMenu';
|
|
|
16
16
|
import { SCCourseLessonTypologyType } from '@selfcommunity/types';
|
|
17
17
|
import { CourseService, Endpoints } from '@selfcommunity/api-services';
|
|
18
18
|
import { ActionLessonType } from '../types';
|
|
19
|
-
import {
|
|
19
|
+
import { useIsDisabled } from '../hooks';
|
|
20
20
|
import ConfirmDialog from '../../../shared/ConfirmDialog/ConfirmDialog';
|
|
21
21
|
const classes = {
|
|
22
22
|
tableBodyIconWrapper: `${PREFIX}-table-body-icon-wrapper`,
|
|
@@ -37,7 +37,7 @@ function SectionRow(props) {
|
|
|
37
37
|
const [editMode, setEditMode] = useState(false);
|
|
38
38
|
const [lessons, setLessons] = useState([]);
|
|
39
39
|
// HOOKS
|
|
40
|
-
const { isDisabled } =
|
|
40
|
+
const { isDisabled } = useIsDisabled();
|
|
41
41
|
const intl = useIntl();
|
|
42
42
|
const { enqueueSnackbar } = useSnackbar();
|
|
43
43
|
// EFFECTS
|
|
@@ -141,6 +141,6 @@ function SectionRow(props) {
|
|
|
141
141
|
? Endpoints.CreateCourseSection.url({ id: course.id })
|
|
142
142
|
: Endpoints.PatchCourseSection.url({ id: course.id, section_id: section.id }),
|
|
143
143
|
method: isNewRow ? Endpoints.CreateCourseSection.method : Endpoints.PatchCourseSection.method
|
|
144
|
-
}, row: section, isNewRow: isNewRow, handleManageRow: handleManageSection, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), _jsx(TableCell, Object.assign({ className: classes.cellAlignCenter }, { children:
|
|
144
|
+
}, row: section, isNewRow: isNewRow, handleManageRow: handleManageSection, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), _jsx(TableCell, Object.assign({ className: classes.cellAlignCenter }, { children: _jsx(LessonReleaseMenu, { course: course, section: section }) })), _jsx(TableCell, Object.assign({ className: classes.cellAlignRight }, { children: _jsxs(Stack, Object.assign({ className: classes.actionsWrapper }, { children: [_jsx(AddButton, { label: "ui.editCourse.tab.lessons.table.lesson", handleAddRow: handleAddTempLesson, color: "primary", variant: "outlined", disabled: isDisabled }), _jsxs(MenuRow, Object.assign({ disabled: isDisabled }, { children: [_jsx(MenuItem, Object.assign({ onClick: handleAbleEditMode }, { children: _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.rename", defaultMessage: "ui.editCourse.tab.lessons.table.menu.rename" }) })) })), _jsx(MenuItem, Object.assign({ onClick: handleOpenDialog }, { children: _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.delete", defaultMessage: "ui.editCourse.tab.lessons.table.menu.delete" }) })) }))] }))] })) }))] })), _jsx(TableRow, { children: _jsxs(TableCell, Object.assign({ className: classes.tableBodyCollapseWrapper, colSpan: 4 }, { children: [_jsx(Collapse, Object.assign({ in: expand, timeout: "auto", unmountOnExit: true }, { children: _jsx(DragDropContext, Object.assign({ onDragEnd: handleDragEnd }, { children: _jsx(Table, { children: _jsx(Droppable, Object.assign({ droppableId: "droppable-2" }, { children: (outerProvider) => (_jsxs(TableBody, Object.assign({ ref: outerProvider.innerRef }, outerProvider.droppableProps, { children: [lessons.map((lesson, i, array) => (_jsx(Draggable, Object.assign({ draggableId: i.toString(), index: i, isDragDisabled: isDisabled }, { children: (innerProvider) => (_jsx(LessonRow, { provider: innerProvider, course: course, section: section, lesson: lesson, isNewRow: isNewLocalRow && i + 1 === array.length, handleManageLesson: handleManageLesson }, i)) }), i))), outerProvider.placeholder] }))) })) }) })) })), open && _jsx(ConfirmDialog, { open: true, onClose: handleOpenDialog, onConfirm: handleDeleteSection })] })) })] }));
|
|
145
145
|
}
|
|
146
146
|
export default memo(SectionRow);
|
|
@@ -13,7 +13,7 @@ import EmptyStatus from '../../shared/EmptyStatus';
|
|
|
13
13
|
import AddButton from './Lessons/AddButton';
|
|
14
14
|
import SectionRow from './Lessons/SectionRow';
|
|
15
15
|
import { ActionLessonType } from './types';
|
|
16
|
-
import {
|
|
16
|
+
import { useIsDisabled } from './hooks';
|
|
17
17
|
import classNames from 'classnames';
|
|
18
18
|
const classes = {
|
|
19
19
|
lessonTitle: `${PREFIX}-lesson-title`,
|
|
@@ -55,7 +55,7 @@ function Lessons(props) {
|
|
|
55
55
|
// STATES
|
|
56
56
|
const [sections, setSections] = useState([]);
|
|
57
57
|
// HOOKS
|
|
58
|
-
const { isDisabled } =
|
|
58
|
+
const { isDisabled } = useIsDisabled();
|
|
59
59
|
const { enqueueSnackbar } = useSnackbar();
|
|
60
60
|
const intl = useIntl();
|
|
61
61
|
// EFFECTS
|