@selfcommunity/react-ui 0.10.2-courses.176 → 0.10.2-courses.178
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/CourseDashboard/Student.js +17 -5
- 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/hooks.d.ts +1 -1
- package/lib/cjs/components/EditCourse/hooks.js +3 -3
- package/lib/cjs/components/LessonReleaseMenu/LessonReleaseMenu.js +10 -7
- package/lib/esm/components/CourseDashboard/Student.js +17 -5
- 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/hooks.d.ts +1 -1
- package/lib/esm/components/EditCourse/hooks.js +1 -1
- package/lib/esm/components/LessonReleaseMenu/LessonReleaseMenu.js +10 -7
- package/lib/umd/react-ui.js +1 -1
- package/package.json +8 -8
|
@@ -118,21 +118,33 @@ function Student(inProps) {
|
|
|
118
118
|
const handleRequest = (0, react_1.useCallback)(() => {
|
|
119
119
|
setLoadingRequest(true);
|
|
120
120
|
let request;
|
|
121
|
-
let updatedCourse;
|
|
122
121
|
if (sentRequest) {
|
|
123
122
|
request = api_services_1.CourseService.leaveOrRemoveCourseRequest(scCourse.id);
|
|
124
|
-
updatedCourse = Object.assign(Object.assign({}, scCourse), { join_status: null });
|
|
125
123
|
}
|
|
126
124
|
else {
|
|
127
125
|
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
126
|
}
|
|
130
127
|
request
|
|
131
|
-
.then(() => {
|
|
128
|
+
.then((data) => {
|
|
129
|
+
let updatedCourse;
|
|
130
|
+
if (data) {
|
|
131
|
+
updatedCourse = data;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
updatedCourse = Object.assign(Object.assign({}, scCourse), { join_status: null });
|
|
135
|
+
}
|
|
132
136
|
setSCCourse(updatedCourse);
|
|
133
137
|
setSentRequest((prev) => !prev);
|
|
134
138
|
setLoadingRequest(false);
|
|
135
|
-
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id:
|
|
139
|
+
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: updatedCourse.join_status === types_1.SCCourseJoinStatusType.REQUESTED
|
|
140
|
+
? SNACKBAR_MESSAGES.request
|
|
141
|
+
: updatedCourse.join_status === types_1.SCCourseJoinStatusType.JOINED
|
|
142
|
+
? SNACKBAR_MESSAGES.enroll
|
|
143
|
+
: SNACKBAR_MESSAGES.cancel, defaultMessage: updatedCourse.join_status === types_1.SCCourseJoinStatusType.REQUESTED
|
|
144
|
+
? SNACKBAR_MESSAGES.request
|
|
145
|
+
: updatedCourse.join_status === types_1.SCCourseJoinStatusType.JOINED
|
|
146
|
+
? SNACKBAR_MESSAGES.enroll
|
|
147
|
+
: SNACKBAR_MESSAGES.cancel }), {
|
|
136
148
|
variant: 'success',
|
|
137
149
|
autoHideDuration: 3000
|
|
138
150
|
});
|
|
@@ -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
|
|
@@ -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;
|
|
@@ -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)({
|
|
@@ -72,6 +73,8 @@ function LessonReleaseMenu(inProps) {
|
|
|
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) => {
|
|
@@ -125,7 +128,7 @@ function LessonReleaseMenu(inProps) {
|
|
|
125
128
|
} }, { 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" })), defaultValue: drippedAt, slots: {
|
|
126
129
|
//actionBar: PickerActionBar,
|
|
127
130
|
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" }) }) }))) }) })))
|
|
131
|
+
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
132
|
}, slotProps: {
|
|
130
133
|
tabs: {
|
|
131
134
|
hidden: false
|
|
@@ -138,9 +141,9 @@ function LessonReleaseMenu(inProps) {
|
|
|
138
141
|
actionBar: {
|
|
139
142
|
actions: ['cancel', 'clear', 'accept']
|
|
140
143
|
}
|
|
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", placeholder: placeholderStructured, defaultValue: null, onClick: handleClick, InputProps: {
|
|
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: {
|
|
144
|
+
}, 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", placeholder: placeholderStructured, defaultValue: null, onClick: isDisabled ? undefined : handleClick, InputProps: {
|
|
145
|
+
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" }) })) })))
|
|
146
|
+
}, disabled: isDisabled }), (0, jsx_runtime_1.jsxs)(PopoverRoot, Object.assign({ className: classes.popoverRoot, open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: {
|
|
144
147
|
vertical: 'bottom',
|
|
145
148
|
horizontal: 'left'
|
|
146
149
|
}, transformOrigin: {
|
|
@@ -116,21 +116,33 @@ function Student(inProps) {
|
|
|
116
116
|
const handleRequest = useCallback(() => {
|
|
117
117
|
setLoadingRequest(true);
|
|
118
118
|
let request;
|
|
119
|
-
let updatedCourse;
|
|
120
119
|
if (sentRequest) {
|
|
121
120
|
request = CourseService.leaveOrRemoveCourseRequest(scCourse.id);
|
|
122
|
-
updatedCourse = Object.assign(Object.assign({}, scCourse), { join_status: null });
|
|
123
121
|
}
|
|
124
122
|
else {
|
|
125
123
|
request = CourseService.joinOrAcceptInviteToCourse(scCourse.id);
|
|
126
|
-
updatedCourse = Object.assign(Object.assign({}, scCourse), { join_status: scCourse.privacy === SCCoursePrivacyType.PRIVATE ? SCCourseJoinStatusType.REQUESTED : SCCourseJoinStatusType.JOINED });
|
|
127
124
|
}
|
|
128
125
|
request
|
|
129
|
-
.then(() => {
|
|
126
|
+
.then((data) => {
|
|
127
|
+
let updatedCourse;
|
|
128
|
+
if (data) {
|
|
129
|
+
updatedCourse = data;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
updatedCourse = Object.assign(Object.assign({}, scCourse), { join_status: null });
|
|
133
|
+
}
|
|
130
134
|
setSCCourse(updatedCourse);
|
|
131
135
|
setSentRequest((prev) => !prev);
|
|
132
136
|
setLoadingRequest(false);
|
|
133
|
-
enqueueSnackbar(_jsx(FormattedMessage, { id:
|
|
137
|
+
enqueueSnackbar(_jsx(FormattedMessage, { id: updatedCourse.join_status === SCCourseJoinStatusType.REQUESTED
|
|
138
|
+
? SNACKBAR_MESSAGES.request
|
|
139
|
+
: updatedCourse.join_status === SCCourseJoinStatusType.JOINED
|
|
140
|
+
? SNACKBAR_MESSAGES.enroll
|
|
141
|
+
: SNACKBAR_MESSAGES.cancel, defaultMessage: updatedCourse.join_status === SCCourseJoinStatusType.REQUESTED
|
|
142
|
+
? SNACKBAR_MESSAGES.request
|
|
143
|
+
: updatedCourse.join_status === SCCourseJoinStatusType.JOINED
|
|
144
|
+
? SNACKBAR_MESSAGES.enroll
|
|
145
|
+
: SNACKBAR_MESSAGES.cancel }), {
|
|
134
146
|
variant: 'success',
|
|
135
147
|
autoHideDuration: 3000
|
|
136
148
|
});
|
|
@@ -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
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import PubSub from 'pubsub-js';
|
|
3
3
|
import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
|
|
4
|
-
export const
|
|
4
|
+
export const useIsDisabled = () => {
|
|
5
5
|
// STATES
|
|
6
6
|
const [isDisabled, setIsDisabled] = useState(false);
|
|
7
7
|
// REFS
|
|
@@ -17,6 +17,7 @@ import { CourseService } from '@selfcommunity/api-services';
|
|
|
17
17
|
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
18
18
|
import { Logger } from '@selfcommunity/utils';
|
|
19
19
|
import { getDripDelayAndUnit } from '../../utils/course';
|
|
20
|
+
import { useIsDisabled } from '../EditCourse/hooks';
|
|
20
21
|
const messages = defineMessages({
|
|
21
22
|
pickerPlaceholder: {
|
|
22
23
|
id: 'ui.lessonReleaseMenu.scheduled.picker.placeholder',
|
|
@@ -47,13 +48,13 @@ const classes = {
|
|
|
47
48
|
const Root = styled(FormControl, {
|
|
48
49
|
name: PREFIX,
|
|
49
50
|
slot: 'Root',
|
|
50
|
-
overridesResolver: (
|
|
51
|
+
overridesResolver: (_props, styles) => [styles.root]
|
|
51
52
|
})(() => ({}));
|
|
52
53
|
const PopoverRoot = styled(Popover, {
|
|
53
54
|
name: PREFIX,
|
|
54
55
|
slot: 'PopoverRoot',
|
|
55
|
-
overridesResolver: (
|
|
56
|
-
})((
|
|
56
|
+
overridesResolver: (_props, styles) => styles.popoverRoot
|
|
57
|
+
})(() => ({}));
|
|
57
58
|
export default function LessonReleaseMenu(inProps) {
|
|
58
59
|
// PROPS
|
|
59
60
|
const props = useThemeProps({
|
|
@@ -70,6 +71,8 @@ export default function LessonReleaseMenu(inProps) {
|
|
|
70
71
|
const [unit, setUnit] = useState(_unit);
|
|
71
72
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
72
73
|
const [open, setOpen] = useState(false);
|
|
74
|
+
// HOOKS
|
|
75
|
+
const { isDisabled } = useIsDisabled();
|
|
73
76
|
//INTL
|
|
74
77
|
const intl = useIntl();
|
|
75
78
|
const handleUnitChange = (e) => {
|
|
@@ -123,7 +126,7 @@ export default function LessonReleaseMenu(inProps) {
|
|
|
123
126
|
} }, { children: _jsx(MobileDateTimePicker, { className: classes.picker, disablePast: true, label: drippedAt && (_jsx(FormattedMessage, { id: "ui.lessonReleaseMenu.scheduled.picker.placeholder", defaultMessage: "ui.lessonReleaseMenu.scheduled.picker.placeholder" })), defaultValue: drippedAt, slots: {
|
|
124
127
|
//actionBar: PickerActionBar,
|
|
125
128
|
tabs: (props) => _jsx(DateTimePickerTabs, Object.assign({}, props)),
|
|
126
|
-
textField: (params) => (_jsx(TextField, Object.assign({}, params, { error: false, InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.pickerPlaceholder)}`, endAdornment: (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "expand_more" }) }) }))) }) })))
|
|
129
|
+
textField: (params) => (_jsx(TextField, Object.assign({}, params, { error: false, InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.pickerPlaceholder)}`, endAdornment: (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: _jsx(IconButton, Object.assign({ disabled: isDisabled }, { children: _jsx(Icon, { children: "expand_more" }) })) }))) }) })))
|
|
127
130
|
}, slotProps: {
|
|
128
131
|
tabs: {
|
|
129
132
|
hidden: false
|
|
@@ -136,9 +139,9 @@ export default function LessonReleaseMenu(inProps) {
|
|
|
136
139
|
actionBar: {
|
|
137
140
|
actions: ['cancel', 'clear', 'accept']
|
|
138
141
|
}
|
|
139
|
-
}, onChange: (value) => setDrippedAt(value), onAccept: handleUpdate, onClear: () => setDrippedAt(null) }) }))) : (_jsxs(_Fragment, { children: [_jsx(TextField, { size: "small", placeholder: placeholderStructured, defaultValue: null, onClick: handleClick, InputProps: {
|
|
140
|
-
endAdornment: (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: _jsx(IconButton, Object.assign({ onClick: handleClick }, { children: _jsx(Icon, { children: "expand_more" }) })) })))
|
|
141
|
-
} }), _jsxs(PopoverRoot, Object.assign({ className: classes.popoverRoot, open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: {
|
|
142
|
+
}, onChange: (value) => setDrippedAt(value), onAccept: handleUpdate, onClear: () => setDrippedAt(null), disabled: isDisabled }) }))) : (_jsxs(_Fragment, { children: [_jsx(TextField, { size: "small", placeholder: placeholderStructured, defaultValue: null, onClick: isDisabled ? undefined : handleClick, InputProps: {
|
|
143
|
+
endAdornment: (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: _jsx(IconButton, Object.assign({ onClick: handleClick, disabled: isDisabled }, { children: _jsx(Icon, { children: "expand_more" }) })) })))
|
|
144
|
+
}, disabled: isDisabled }), _jsxs(PopoverRoot, Object.assign({ className: classes.popoverRoot, open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: {
|
|
142
145
|
vertical: 'bottom',
|
|
143
146
|
horizontal: 'left'
|
|
144
147
|
}, transformOrigin: {
|