@selfcommunity/react-ui 0.10.2-courses.189 → 0.10.2-courses.191
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/Course/Course.js +2 -2
- package/lib/cjs/components/CourseForm/CourseForm.d.ts +5 -0
- package/lib/cjs/components/CourseForm/CourseForm.js +10 -5
- package/lib/cjs/components/CourseFormDialog/CourseFormDialog.js +12 -2
- package/lib/cjs/components/Courses/Courses.js +3 -9
- package/lib/cjs/components/EditCourse/Lessons/SectionRow.js +1 -1
- package/lib/cjs/components/EditCourse/Lessons.js +32 -26
- package/lib/esm/components/Course/Course.js +2 -2
- package/lib/esm/components/CourseForm/CourseForm.d.ts +5 -0
- package/lib/esm/components/CourseForm/CourseForm.js +12 -7
- package/lib/esm/components/CourseFormDialog/CourseFormDialog.js +13 -3
- package/lib/esm/components/Courses/Courses.js +3 -9
- package/lib/esm/components/EditCourse/Lessons/SectionRow.js +2 -2
- package/lib/esm/components/EditCourse/Lessons.js +23 -17
- package/lib/umd/578.js +2 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +11 -11
- package/lib/umd/689.js +0 -2
- /package/lib/umd/{689.js.LICENSE.txt → 578.js.LICENSE.txt} +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
3
3
|
import { PREFIX } from './constants';
|
|
4
|
-
import {
|
|
4
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
5
|
import { DragDropContext, Draggable, Droppable } from '@hello-pangea/dnd';
|
|
6
|
+
import { SCCourseTypologyType } from '@selfcommunity/types';
|
|
6
7
|
import { CourseService } from '@selfcommunity/api-services';
|
|
7
8
|
import { Logger } from '@selfcommunity/utils';
|
|
8
9
|
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
@@ -20,6 +21,7 @@ import classNames from 'classnames';
|
|
|
20
21
|
const classes = {
|
|
21
22
|
lessonTitle: `${PREFIX}-lesson-title`,
|
|
22
23
|
lessonInfoWrapper: `${PREFIX}-lesson-info-wrapper`,
|
|
24
|
+
lessonsInnerWrapper: `${PREFIX}-lessons-inner-wrapper`,
|
|
23
25
|
lessonsSectionsWrapper: `${PREFIX}-lessons-sections-wrapper`,
|
|
24
26
|
lessonsSections: `${PREFIX}-lessons-sections`,
|
|
25
27
|
circle: `${PREFIX}-circle`,
|
|
@@ -35,20 +37,6 @@ const classes = {
|
|
|
35
37
|
emptyStatusButton: `${PREFIX}-empty-status-button`,
|
|
36
38
|
contrastColor: `${PREFIX}-contrast-color`
|
|
37
39
|
};
|
|
38
|
-
const headerCells = [
|
|
39
|
-
{
|
|
40
|
-
className: undefined,
|
|
41
|
-
id: 'ui.editCourse.tab.lessons.table.header.lessonName'
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
className: classes.cellAlignCenter,
|
|
45
|
-
id: 'ui.editCourse.tab.lessons.table.header.calendar'
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
className: classes.cellAlignRight,
|
|
49
|
-
id: 'ui.editCourse.tab.lessons.table.header.actions'
|
|
50
|
-
}
|
|
51
|
-
];
|
|
52
40
|
function Lessons(props) {
|
|
53
41
|
// PROPS
|
|
54
42
|
const { course, setCourse, handleTabChange } = props;
|
|
@@ -69,6 +57,24 @@ function Lessons(props) {
|
|
|
69
57
|
}, [course]);
|
|
70
58
|
// MEMOS
|
|
71
59
|
const isNewRow = useMemo(() => { var _a; return sections.length > ((_a = course.sections) === null || _a === void 0 ? void 0 : _a.length); }, [course, sections]);
|
|
60
|
+
const headerCells = useMemo(() => [
|
|
61
|
+
{
|
|
62
|
+
className: undefined,
|
|
63
|
+
id: 'ui.editCourse.tab.lessons.table.header.lessonName'
|
|
64
|
+
},
|
|
65
|
+
...(course.type !== SCCourseTypologyType.SELF
|
|
66
|
+
? [
|
|
67
|
+
{
|
|
68
|
+
className: classes.cellAlignCenter,
|
|
69
|
+
id: 'ui.editCourse.tab.lessons.table.header.calendar'
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
: []),
|
|
73
|
+
{
|
|
74
|
+
className: classes.cellAlignRight,
|
|
75
|
+
id: 'ui.editCourse.tab.lessons.table.header.actions'
|
|
76
|
+
}
|
|
77
|
+
], [course]);
|
|
72
78
|
// FUNCTIONS
|
|
73
79
|
const getSection = useCallback((id) => {
|
|
74
80
|
return {
|
|
@@ -178,10 +184,10 @@ function Lessons(props) {
|
|
|
178
184
|
}
|
|
179
185
|
handleOpenDialog(null);
|
|
180
186
|
}, [dialog, handleOpenDialog]);
|
|
181
|
-
return (_jsxs(Box, { children: [_jsx(Typography, Object.assign({ className: classNames(classes.lessonTitle, classes.contrastColor), variant: "h4" }, { children: _jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons", defaultMessage: "ui.editCourse.tab.lessons" }) })), _jsxs(Stack, Object.assign({ className: classes.lessonInfoWrapper }, { children: [_jsx(CourseTypePopover, { course: course }), _jsx(Status, { course: course, handleTabChange: handleTabChange })] })), sections.length === 0 && (_jsx(EmptyStatus, { icon: "courses", title: "ui.editCourse.tab.lessons.table.empty.title", description: "ui.editCourse.tab.lessons.table.empty.description", actions: _jsx(AddButton, { className: classes.emptyStatusButton, label: "ui.editCourse.tab.lessons.table.section", handleAddRow: handleAddTempSection, color: "inherit", variant: "outlined" }), className: classes.lessonEmptyStatus })), sections.length > 0 && (_jsxs(
|
|
187
|
+
return (_jsxs(Box, { children: [_jsx(Typography, Object.assign({ className: classNames(classes.lessonTitle, classes.contrastColor), variant: "h4" }, { children: _jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons", defaultMessage: "ui.editCourse.tab.lessons" }) })), _jsxs(Stack, Object.assign({ className: classes.lessonInfoWrapper }, { children: [_jsx(CourseTypePopover, { course: course }), _jsx(Status, { course: course, handleTabChange: handleTabChange })] })), sections.length === 0 && (_jsx(EmptyStatus, { icon: "courses", title: "ui.editCourse.tab.lessons.table.empty.title", description: "ui.editCourse.tab.lessons.table.empty.description", actions: _jsx(AddButton, { className: classes.emptyStatusButton, label: "ui.editCourse.tab.lessons.table.section", handleAddRow: handleAddTempSection, color: "inherit", variant: "outlined" }), className: classes.lessonEmptyStatus })), sections.length > 0 && (_jsxs(Box, Object.assign({ className: classes.lessonsInnerWrapper }, { children: [_jsxs(Stack, Object.assign({ className: classes.lessonsSectionsWrapper }, { children: [_jsxs(Stack, Object.assign({ className: classes.lessonsSections }, { children: [_jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.course.table.sections.title", defaultMessage: "ui.course.table.sections.title", values: {
|
|
182
188
|
sectionsNumber: course.num_sections
|
|
183
189
|
} }) })), _jsx(Box, { className: classes.circle }), _jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.course.table.lessons.title", defaultMessage: "ui.course.table.lessons.title", values: {
|
|
184
190
|
lessonsNumber: course.num_lessons
|
|
185
|
-
} }) }))] })), _jsx(AddButton, { label: "ui.editCourse.tab.lessons.table.section", handleAddRow: handleAddTempSection, color: "primary", variant: "contained", disabled: isDisabled })] })), _jsx(DragDropContext, Object.assign({ onDragEnd: handleDragEnd }, { children: _jsx(TableContainer, Object.assign({ className: classes.tableContainer }, { children: _jsxs(Table, Object.assign({ className: classes.table }, { children: [_jsx(TableHead, Object.assign({ className: classes.tableHeader }, { children: _jsxs(TableRow, { children: [_jsx(TableCell, { className: classes.cellWidth }), headerCells.map((cell, i) => (_jsx(TableCell, Object.assign({ className: cell.className }, { children: _jsx(Typography, Object.assign({ className: classes.tableHeaderTypography, variant: "overline" }, { children: _jsx(FormattedMessage, { id: cell.id, defaultMessage: cell.id }) })) }), i)))] }) })), _jsx(Droppable, Object.assign({ droppableId: "droppable-1" }, { children: (outerProvider) => (_jsxs(TableBody, Object.assign({ ref: outerProvider.innerRef }, outerProvider.droppableProps, { className: classes.tableBody }, { children: [sections.map((section, i, array) => (_jsx(Draggable, Object.assign({ draggableId: i.toString(), index: i, isDragDisabled: isDisabled }, { children: (innerProvider) => (_jsx(SectionRow, { course: course, provider: innerProvider, section: section, isNewRow: isNewRow && i + 1 === array.length, handleManageSection: handleManageSection, handleOpenDialog: handleOpenDialog, ref: ref }, i)) }), i))), outerProvider.placeholder] }))) }))] })) })) })), dialog && _jsx(ConfirmDialog, { open: true, onClose: () => handleOpenDialog(null), onConfirm: handleDeleteRow })] }))] }));
|
|
191
|
+
} }) }))] })), _jsx(AddButton, { label: "ui.editCourse.tab.lessons.table.section", handleAddRow: handleAddTempSection, color: "primary", variant: "contained", disabled: isDisabled })] })), _jsx(DragDropContext, Object.assign({ onDragEnd: handleDragEnd }, { children: _jsx(TableContainer, Object.assign({ className: classes.tableContainer }, { children: _jsxs(Table, Object.assign({ className: classes.table }, { children: [_jsx(TableHead, Object.assign({ className: classes.tableHeader }, { children: _jsxs(TableRow, { children: [_jsx(TableCell, { className: classes.cellWidth }), headerCells.map((cell, i) => (_jsx(TableCell, Object.assign({ className: cell.className }, { children: _jsx(Typography, Object.assign({ className: classes.tableHeaderTypography, variant: "overline" }, { children: _jsx(FormattedMessage, { id: cell.id, defaultMessage: cell.id }) })) }), i)))] }) })), _jsx(Droppable, Object.assign({ droppableId: "droppable-1" }, { children: (outerProvider) => (_jsxs(TableBody, Object.assign({ ref: outerProvider.innerRef }, outerProvider.droppableProps, { className: classes.tableBody }, { children: [sections.map((section, i, array) => (_jsx(Draggable, Object.assign({ draggableId: i.toString(), index: i, isDragDisabled: isDisabled }, { children: (innerProvider) => (_jsx(SectionRow, { course: course, provider: innerProvider, section: section, isNewRow: isNewRow && i + 1 === array.length, handleManageSection: handleManageSection, handleOpenDialog: handleOpenDialog, ref: ref }, i)) }), i))), outerProvider.placeholder] }))) }))] })) })) })), dialog && _jsx(ConfirmDialog, { open: true, onClose: () => handleOpenDialog(null), onConfirm: handleDeleteRow })] })))] }));
|
|
186
192
|
}
|
|
187
193
|
export default memo(Lessons);
|