@selfcommunity/react-ui 1.2.0-alpha.3 → 1.2.0-alpha.5
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/CategoryAutocomplete/CategoryAutocomplete.js +6 -5
- package/lib/cjs/components/CourseDashboard/Header.d.ts +2 -2
- package/lib/cjs/components/CourseDashboard/Header.js +4 -10
- package/lib/cjs/components/CourseDashboard/Student/ActionButton.js +6 -2
- package/lib/cjs/components/CourseDashboard/Student.js +6 -5
- package/lib/cjs/components/CourseDashboard/Teacher/Comments.js +3 -3
- package/lib/cjs/components/CourseDashboard/Teacher/Info.js +2 -2
- package/lib/cjs/components/CourseDashboard/Teacher.js +2 -2
- package/lib/cjs/components/CourseForm/CourseForm.js +11 -6
- package/lib/cjs/components/CourseForm/Edit.js +4 -4
- package/lib/cjs/components/CourseParticipantsButton/CourseParticipantsButton.js +3 -2
- package/lib/cjs/components/EditCourse/EditCourse.js +2 -2
- package/lib/cjs/components/EditCourse/Lessons/ChangeLessonStatus.js +10 -5
- package/lib/cjs/components/EditCourse/Lessons/FieldName.js +2 -2
- package/lib/cjs/components/EditCourse/Lessons/LessonRow.js +3 -3
- package/lib/cjs/components/EditCourse/Lessons/SectionRow.js +3 -3
- package/lib/cjs/components/EditCourse/Lessons.js +5 -4
- package/lib/cjs/components/EditCourse/Options/Skeleton.js +2 -2
- package/lib/cjs/components/EditCourse/Options/SwitchForm.js +2 -2
- package/lib/cjs/components/EditCourse/Options.js +2 -2
- package/lib/cjs/components/EditCourse/Status.js +3 -5
- package/lib/cjs/components/EditCourse/Users.js +2 -2
- package/lib/cjs/components/FeedObject/Contributors/Contributors.js +1 -1
- package/lib/cjs/components/PaywallsConfigurator/PaywallsConfigurator.js +1 -1
- package/lib/cjs/components/PrivateMessageThreadItem/PrivateMessageThreadItem.js +2 -1
- package/lib/cjs/components/User/User.js +2 -2
- package/lib/cjs/shared/AccordionLessons/AccordionLessons.js +4 -4
- package/lib/cjs/shared/AddUsersButton/AddUsersButton.js +14 -6
- package/lib/cjs/shared/ConfirmDialog/ConfirmDialog.js +11 -7
- package/lib/cjs/shared/CourseUsersTable/ChangeUsersStatus.js +3 -5
- package/lib/cjs/shared/CourseUsersTable/CourseUsersTable.js +6 -4
- package/lib/cjs/shared/CourseUsersTable/SeeProgressButton.js +4 -3
- package/lib/cjs/types/course.d.ts +5 -0
- package/lib/cjs/utils/course.d.ts +2 -1
- package/lib/cjs/utils/course.js +9 -1
- package/lib/esm/components/CategoryAutocomplete/CategoryAutocomplete.js +7 -6
- package/lib/esm/components/CourseDashboard/Header.d.ts +2 -2
- package/lib/esm/components/CourseDashboard/Header.js +4 -10
- package/lib/esm/components/CourseDashboard/Student/ActionButton.js +6 -2
- package/lib/esm/components/CourseDashboard/Student.js +6 -5
- package/lib/esm/components/CourseDashboard/Teacher/Comments.js +3 -3
- package/lib/esm/components/CourseDashboard/Teacher/Info.js +2 -2
- package/lib/esm/components/CourseDashboard/Teacher.js +2 -2
- package/lib/esm/components/CourseForm/CourseForm.js +12 -7
- package/lib/esm/components/CourseForm/Edit.js +4 -4
- package/lib/esm/components/CourseParticipantsButton/CourseParticipantsButton.js +3 -2
- package/lib/esm/components/EditCourse/EditCourse.js +2 -2
- package/lib/esm/components/EditCourse/Lessons/ChangeLessonStatus.js +10 -5
- package/lib/esm/components/EditCourse/Lessons/FieldName.js +2 -2
- package/lib/esm/components/EditCourse/Lessons/LessonRow.js +4 -4
- package/lib/esm/components/EditCourse/Lessons/SectionRow.js +4 -4
- package/lib/esm/components/EditCourse/Lessons.js +5 -4
- package/lib/esm/components/EditCourse/Options/Skeleton.js +3 -3
- package/lib/esm/components/EditCourse/Options/SwitchForm.js +2 -2
- package/lib/esm/components/EditCourse/Options.js +2 -2
- package/lib/esm/components/EditCourse/Status.js +3 -4
- package/lib/esm/components/EditCourse/Users.js +2 -2
- package/lib/esm/components/FeedObject/Contributors/Contributors.js +1 -1
- package/lib/esm/components/PaywallsConfigurator/PaywallsConfigurator.js +1 -1
- package/lib/esm/components/PrivateMessageThreadItem/PrivateMessageThreadItem.js +2 -1
- package/lib/esm/components/User/User.js +3 -3
- package/lib/esm/shared/AccordionLessons/AccordionLessons.js +4 -4
- package/lib/esm/shared/AddUsersButton/AddUsersButton.js +15 -7
- package/lib/esm/shared/ConfirmDialog/ConfirmDialog.js +12 -8
- package/lib/esm/shared/CourseUsersTable/ChangeUsersStatus.js +4 -6
- package/lib/esm/shared/CourseUsersTable/CourseUsersTable.js +7 -5
- package/lib/esm/shared/CourseUsersTable/SeeProgressButton.js +4 -3
- package/lib/esm/types/course.d.ts +5 -0
- package/lib/esm/utils/course.d.ts +2 -1
- package/lib/esm/utils/course.js +7 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +5 -5
|
@@ -4,13 +4,13 @@ import { useEffect, useState } from 'react';
|
|
|
4
4
|
import { FormattedMessage } from 'react-intl';
|
|
5
5
|
import parse from 'autosuggest-highlight/parse';
|
|
6
6
|
import match from 'autosuggest-highlight/match';
|
|
7
|
-
import { Autocomplete, Chip, TextField, Checkbox, CircularProgress, styled, Typography } from '@mui/material';
|
|
7
|
+
import { Autocomplete, Chip, TextField, Checkbox, CircularProgress, styled, Typography, useTheme } from '@mui/material';
|
|
8
8
|
import { useSCFetchCategories } from '@selfcommunity/react-core';
|
|
9
9
|
import { useThemeProps } from '@mui/system';
|
|
10
10
|
import { PREFIX } from './constants';
|
|
11
11
|
const classes = {
|
|
12
12
|
root: `${PREFIX}-root`,
|
|
13
|
-
|
|
13
|
+
paperContrastColor: `${PREFIX}-paper-contrast-color`
|
|
14
14
|
};
|
|
15
15
|
const Root = styled(Autocomplete, {
|
|
16
16
|
name: PREFIX,
|
|
@@ -54,6 +54,7 @@ const CategoryAutocomplete = (inProps) => {
|
|
|
54
54
|
const [value, setValue] = useState(typeof defaultValue === 'string' ? null : defaultValue);
|
|
55
55
|
// HOOKS
|
|
56
56
|
const { categories, isLoading } = useSCFetchCategories({ endpointQueryParams });
|
|
57
|
+
const theme = useTheme();
|
|
57
58
|
useEffect(() => {
|
|
58
59
|
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
59
60
|
}, [value]);
|
|
@@ -82,19 +83,19 @@ const CategoryAutocomplete = (inProps) => {
|
|
|
82
83
|
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
83
84
|
};
|
|
84
85
|
// Render
|
|
85
|
-
return (_jsx(Root, Object.assign({ className: classes.root, multiple: multiple, open: open, onOpen: handleOpen, onClose: handleClose, filterSelectedOptions: !checkboxSelect, disableCloseOnSelect: checkboxSelect, options: categories || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, blurOnSelect: true, handleHomeEndKeys: true, clearIcon: null, disabled: disabled || isLoading, noOptionsText: _jsx(FormattedMessage, { id: "ui.categoryAutocomplete.empty", defaultMessage: "ui.categoryAutocomplete.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id, renderValue: (value, getItemProps) => {
|
|
86
|
+
return (_jsx(Root, Object.assign({ className: classes.root, multiple: multiple, open: open, onOpen: handleOpen, onClose: handleClose, filterSelectedOptions: !checkboxSelect, disableCloseOnSelect: checkboxSelect, options: categories || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, blurOnSelect: true, handleHomeEndKeys: true, clearIcon: null, disabled: disabled || isLoading, noOptionsText: _jsx(Typography, Object.assign({ component: "span", sx: { color: theme.palette.getContrastText(theme.palette.background.paper) } }, { children: _jsx(FormattedMessage, { id: "ui.categoryAutocomplete.empty", defaultMessage: "ui.categoryAutocomplete.empty" }) })), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id, renderValue: (value, getItemProps) => {
|
|
86
87
|
if (multiple) {
|
|
87
88
|
return value.map((option, index) => {
|
|
88
89
|
const _a = getItemProps({ index }), { key } = _a, rest = __rest(_a, ["key"]);
|
|
89
|
-
return (_jsx(Chip, Object.assign({ id: option.id, label: _jsx(Typography, Object.assign({ component: "span", className: classes.
|
|
90
|
+
return (_jsx(Chip, Object.assign({ id: option.id, label: _jsx(Typography, Object.assign({ component: "span", className: classes.paperContrastColor }, { children: option.name })), color: option.color }, rest), key));
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
|
-
return (_jsx(Chip, Object.assign({ id: value.id, label: _jsx(Typography, Object.assign({ component: "span", className: classes.
|
|
93
|
+
return (_jsx(Chip, Object.assign({ id: value.id, label: _jsx(Typography, Object.assign({ component: "span", className: classes.paperContrastColor }, { children: value.name })), color: value.color }, getItemProps)));
|
|
93
94
|
}, renderOption: (props, option, { selected, inputValue }) => {
|
|
94
95
|
const { key } = props, rest = __rest(props, ["key"]);
|
|
95
96
|
const matches = match(option.name, inputValue);
|
|
96
97
|
const parts = parse(option.name, matches);
|
|
97
|
-
return (_jsxs("li", Object.assign({}, rest, { children: [checkboxSelect && _jsx(Checkbox, { style: { marginRight: 8 }, checked: selected }), _jsx(Chip, { label: parts.map((part, index) => (_jsx(Typography, Object.assign({ component: "span",
|
|
98
|
+
return (_jsxs("li", Object.assign({}, rest, { children: [checkboxSelect && _jsx(Checkbox, { style: { marginRight: 8 }, checked: selected }), _jsx(Chip, { label: parts.map((part, index) => (_jsx(Typography, Object.assign({ component: "span", sx: { fontWeight: part.highlight ? 700 : 400, color: theme.palette.getContrastText(theme.palette.background.paper) } }, { children: part.text }), index))) })] }), key));
|
|
98
99
|
}, renderInput: (params) => {
|
|
99
100
|
return (_jsx(TextField, Object.assign({}, params, TextFieldProps, { margin: "dense", slotProps: {
|
|
100
101
|
input: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'categories', endAdornment: (_jsxs(_Fragment, { children: [isLoading ? _jsx(CircularProgress, { color: "inherit", size: 20 }) : null, params.InputProps.endAdornment] })) })
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { SCCourseType } from '@selfcommunity/types';
|
|
2
|
-
import React from 'react';
|
|
3
3
|
interface HeaderCourseDashboardProps {
|
|
4
4
|
course: SCCourseType;
|
|
5
5
|
hasAction?: boolean;
|
|
6
6
|
}
|
|
7
7
|
declare function HeaderCourseDashboard(props: HeaderCourseDashboardProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
declare const _default:
|
|
8
|
+
declare const _default: import("react").MemoExoticComponent<typeof HeaderCourseDashboard>;
|
|
9
9
|
export default _default;
|
|
@@ -9,6 +9,7 @@ import { SCCourseEditTabType } from '../../types';
|
|
|
9
9
|
import classNames from 'classnames';
|
|
10
10
|
import CourseTypePopover from '../../shared/CourseTypePopover';
|
|
11
11
|
import BuyButton from '../BuyButton';
|
|
12
|
+
import { getUrlEditDashboard } from '../../utils/course';
|
|
12
13
|
const classes = {
|
|
13
14
|
header: `${PREFIX}-header`,
|
|
14
15
|
img: `${PREFIX}-header-img`,
|
|
@@ -16,15 +17,8 @@ const classes = {
|
|
|
16
17
|
innerWrapper: `${PREFIX}-header-inner-wrapper`,
|
|
17
18
|
iconWrapper: `${PREFIX}-header-icon-wrapper`,
|
|
18
19
|
buttonPopover: `${PREFIX}-header-button-popover`,
|
|
19
|
-
|
|
20
|
+
defaultContrastColor: `${PREFIX}-default-contrast-color`
|
|
20
21
|
};
|
|
21
|
-
function getUrlEditDashboard(course) {
|
|
22
|
-
return {
|
|
23
|
-
id: course.id,
|
|
24
|
-
slug: course.slug,
|
|
25
|
-
tab: SCCourseEditTabType.LESSONS
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
22
|
function HeaderCourseDashboard(props) {
|
|
29
23
|
var _a;
|
|
30
24
|
// PROPS
|
|
@@ -35,7 +29,7 @@ function HeaderCourseDashboard(props) {
|
|
|
35
29
|
const intl = useIntl();
|
|
36
30
|
// PAYMENTS
|
|
37
31
|
const { isPaymentsEnabled } = useSCPaymentsEnabled();
|
|
38
|
-
return (_jsxs(Box, Object.assign({ className: classes.header }, { children: [_jsx("img", { src: course.image_bigger, alt: course.image_bigger, className: classes.img }), _jsx(Typography, Object.assign({ variant: "h3", className: classes.
|
|
32
|
+
return (_jsxs(Box, Object.assign({ className: classes.header }, { children: [_jsx("img", { src: course.image_bigger, alt: course.image_bigger, className: classes.img }), _jsx(Typography, Object.assign({ variant: "h3", className: classes.defaultContrastColor }, { children: course.name })), _jsxs(Stack, Object.assign({ className: classes.outerWrapper }, { children: [_jsxs(Stack, Object.assign({ className: classes.innerWrapper }, { children: [_jsxs(Stack, Object.assign({ className: classNames(classes.iconWrapper, classes.defaultContrastColor) }, { children: [_jsx(Icon, Object.assign({ fontSize: "small" }, { children: "public" })), _jsx(Typography, Object.assign({ variant: "body2" }, { children: _jsx(FormattedMessage, { id: "ui.course.label", defaultMessage: "ui.course.label", values: {
|
|
39
33
|
privacy: intl.formatMessage({
|
|
40
34
|
id: `ui.course.privacy.${course.privacy === SCCoursePrivacyType.DRAFT ? 'draft' : course.privacy}`,
|
|
41
35
|
defaultMessage: `ui.course.privacy.${course.privacy === SCCoursePrivacyType.DRAFT ? 'draft' : course.privacy}`
|
|
@@ -43,6 +37,6 @@ function HeaderCourseDashboard(props) {
|
|
|
43
37
|
} }) }))] })), _jsx(CourseTypePopover, { course: course }), isPaymentsEnabled &&
|
|
44
38
|
((_a = course.paywalls) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
45
39
|
(course.privacy === SCCoursePrivacyType.OPEN ||
|
|
46
|
-
(course.privacy === SCCoursePrivacyType.PRIVATE && course.join_status && course.join_status !== SCCourseJoinStatusType.REQUESTED)) && (_jsx(BuyButton, { size: "md", variant: "text", startIcon: _jsx(Icon, { children: "dredit-card" }), contentType: SCContentType.COURSE, content: course, label: _jsx(FormattedMessage, { id: "ui.course.paid", defaultMessage: "ui.course.paid" }) }))] })), hasAction && (_jsx(Button, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.COURSE_EDIT_ROUTE_NAME, getUrlEditDashboard(course)), size: "small", color: "primary", variant: "contained" }, { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.teacher.btn.label", defaultMessage: "ui.course.dashboard.teacher.btn.label" }) })) })))] }))] })));
|
|
40
|
+
(course.privacy === SCCoursePrivacyType.PRIVATE && course.join_status && course.join_status !== SCCourseJoinStatusType.REQUESTED)) && (_jsx(BuyButton, { size: "md", variant: "text", startIcon: _jsx(Icon, { children: "dredit-card" }), contentType: SCContentType.COURSE, content: course, label: _jsx(FormattedMessage, { id: "ui.course.paid", defaultMessage: "ui.course.paid" }) }))] })), hasAction && (_jsx(Button, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.COURSE_EDIT_ROUTE_NAME, getUrlEditDashboard(course, SCCourseEditTabType.LESSONS)), size: "small", color: "primary", variant: "contained" }, { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.teacher.btn.label", defaultMessage: "ui.course.dashboard.teacher.btn.label" }) })) })))] }))] })));
|
|
47
41
|
}
|
|
48
42
|
export default memo(HeaderCourseDashboard);
|
|
@@ -3,10 +3,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { Button, Typography } from '@mui/material';
|
|
4
4
|
import { FormattedMessage } from 'react-intl';
|
|
5
5
|
import { Link } from '@selfcommunity/react-core';
|
|
6
|
+
import { PREFIX } from './../constants';
|
|
7
|
+
const classes = {
|
|
8
|
+
paperContrastColor: `${PREFIX}-paper-contrast-color`
|
|
9
|
+
};
|
|
6
10
|
export default function ActionButton(props) {
|
|
7
11
|
const { labelId, to, size = 'small', color = 'primary', variant = 'contained' } = props, rest = __rest(props, ["labelId", "to", "size", "color", "variant"]);
|
|
8
12
|
if (to) {
|
|
9
|
-
return (_jsx(Button, Object.assign({ component: Link, to: to, size: size, color: color, variant: variant }, rest, { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: _jsx(FormattedMessage, { id: labelId, defaultMessage: labelId }) })) })));
|
|
13
|
+
return (_jsx(Button, Object.assign({ component: Link, to: to, size: size, color: color, variant: variant }, rest, { children: _jsx(Typography, Object.assign({ variant: "body2", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: labelId, defaultMessage: labelId }) })) })));
|
|
10
14
|
}
|
|
11
|
-
return (_jsx(Button, Object.assign({ size: size, color: color, variant: variant }, rest, { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: _jsx(FormattedMessage, { id: labelId, defaultMessage: labelId }) })) })));
|
|
15
|
+
return (_jsx(Button, Object.assign({ size: size, color: color, variant: variant }, rest, { children: _jsx(Typography, Object.assign({ variant: "body2", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: labelId, defaultMessage: labelId }) })) })));
|
|
12
16
|
}
|
|
@@ -48,7 +48,8 @@ const classes = {
|
|
|
48
48
|
box: `${PREFIX}-box`,
|
|
49
49
|
percentageWrapper: `${PREFIX}-percentage-wrapper`,
|
|
50
50
|
completedWrapper: `${PREFIX}-completed-wrapper`,
|
|
51
|
-
|
|
51
|
+
defaultContrastColor: `${PREFIX}-default-contrast-color`,
|
|
52
|
+
paperContrastColor: `${PREFIX}-paper-contrast-color`
|
|
52
53
|
};
|
|
53
54
|
function getUrlNextLesson(course) {
|
|
54
55
|
var _a, _b, _c;
|
|
@@ -195,17 +196,17 @@ function Student(inProps) {
|
|
|
195
196
|
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, scCourse.created_by)
|
|
196
197
|
}), { children: _jsx(UserAvatar, Object.assign({ hide: !scCourse.created_by.community_badge, smaller: true }, { children: _jsx(Avatar, { className: classes.avatar, src: scCourse.created_by.avatar, alt: scCourse.created_by.username }) })) })), _jsxs(Box, { children: [_jsx(Link, Object.assign({}, (!scCourse.created_by.deleted && {
|
|
197
198
|
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, scCourse.created_by)
|
|
198
|
-
}), { children: _jsx(Typography, Object.assign({ variant: "body1" }, { children: scCourse.created_by.username })) })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.header.user.creator", defaultMessage: "ui.course.dashboard.header.user.creator" }) }))] })] })), actionButton] })), _jsx(Divider, {}), (((scCourse.privacy === SCCoursePrivacyType.PRIVATE || scCourse.privacy === SCCoursePrivacyType.SECRET) &&
|
|
199
|
+
}), { children: _jsx(Typography, Object.assign({ variant: "body1", className: classes.paperContrastColor }, { children: scCourse.created_by.username })) })), _jsx(Typography, Object.assign({ variant: "body1", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.header.user.creator", defaultMessage: "ui.course.dashboard.header.user.creator" }) }))] })] })), actionButton] })), _jsx(Divider, {}), (((scCourse.privacy === SCCoursePrivacyType.PRIVATE || scCourse.privacy === SCCoursePrivacyType.SECRET) &&
|
|
199
200
|
(scCourse.join_status === SCCourseJoinStatusType.CREATOR ||
|
|
200
201
|
scCourse.join_status === SCCourseJoinStatusType.MANAGER ||
|
|
201
202
|
scCourse.join_status === SCCourseJoinStatusType.JOINED)) ||
|
|
202
203
|
scCourse.privacy === SCCoursePrivacyType.OPEN ||
|
|
203
204
|
scCourse.privacy === SCCoursePrivacyType.DRAFT) &&
|
|
204
|
-
scCourse.description && (_jsxs(Fragment, { children: [_jsx(Typography, Object.assign({ variant: "h6", className: classNames(classes.margin, classes.
|
|
205
|
+
scCourse.description && (_jsxs(Fragment, { children: [_jsx(Typography, Object.assign({ variant: "h6", className: classNames(classes.margin, classes.defaultContrastColor) }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.student.description", defaultMessage: "ui.course.dashboard.student.description" }) })), _jsx(Stack, Object.assign({ className: classes.box }, { children: _jsx(Typography, Object.assign({ variant: "body1", className: classNames(classes.description, classes.paperContrastColor) }, { children: scCourse.description })) }))] })), (((scCourse.privacy === SCCoursePrivacyType.PRIVATE || scCourse.privacy === SCCoursePrivacyType.SECRET) &&
|
|
205
206
|
(scCourse.join_status === SCCourseJoinStatusType.MANAGER || scCourse.join_status === SCCourseJoinStatusType.JOINED)) ||
|
|
206
|
-
(scCourse.privacy === SCCoursePrivacyType.OPEN && scCourse.join_status !== SCCourseJoinStatusType.CREATOR)) && (_jsxs(Fragment, { children: [scCourse.join_status !== null && (_jsxs(Fragment, { children: [_jsx(Typography, Object.assign({ variant: "h6", className: classNames(classes.margin, classes.
|
|
207
|
+
(scCourse.privacy === SCCoursePrivacyType.OPEN && scCourse.join_status !== SCCourseJoinStatusType.CREATOR)) && (_jsxs(Fragment, { children: [scCourse.join_status !== null && (_jsxs(Fragment, { children: [_jsx(Typography, Object.assign({ variant: "h6", className: classNames(classes.margin, classes.defaultContrastColor) }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.student.progress", defaultMessage: "ui.course.dashboard.student.progress" }) })), _jsxs(Stack, Object.assign({ className: classes.box }, { children: [_jsxs(Stack, Object.assign({ className: classes.percentageWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "body1", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.student.progress.described", defaultMessage: "ui.course.dashboard.student.progress.described", values: { progress: scCourse.num_lessons_completed, end: scCourse.num_lessons } }) })), _jsx(Typography, Object.assign({ variant: "body1", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.student.progress.percentage", defaultMessage: "ui.course.dashboard.student.progress.percentage", values: { percentage: scCourse.user_completion_rate } }) }))] })), _jsx(LinearProgress, { className: classes.progress, variant: "determinate", value: scCourse.user_completion_rate })] }))] })), scCourse.user_completion_rate === 100 && (_jsxs(Stack, Object.assign({ className: classNames(classes.completedWrapper, classes.margin) }, { children: [_jsx(Typography, Object.assign({ variant: "h3", className: classes.defaultContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.student.completed", defaultMessage: "ui.course.dashboard.student.completed" }) })), _jsx("img", { src: clapping, alt: intl.formatMessage({ id: 'ui.course.dashboard.student.completed', defaultMessage: 'ui.course.dashboard.student.completed' }), width: 32, height: 32 })] }))), _jsx(Typography, Object.assign({ variant: "h6", className: classNames(classes.margin, classes.defaultContrastColor) }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.student.contents", defaultMessage: "ui.course.dashboard.student.contents" }) })), _jsxs(Stack, Object.assign({ className: classes.lessonsSections }, { children: [_jsx(Typography, Object.assign({ variant: "h5", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.course.table.sections.title", defaultMessage: "ui.course.table.sections.title", values: {
|
|
207
208
|
sectionsNumber: scCourse.num_sections
|
|
208
|
-
} }) })), _jsx(Box, { className: classes.circle }), _jsx(Typography, Object.assign({ variant: "h5", className: classes.
|
|
209
|
+
} }) })), _jsx(Box, { className: classes.circle }), _jsx(Typography, Object.assign({ variant: "h5", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.course.table.lessons.title", defaultMessage: "ui.course.table.lessons.title", values: {
|
|
209
210
|
lessonsNumber: scCourse.num_lessons
|
|
210
211
|
} }) }))] })), _jsx(AccordionLessons, { course: scCourse, className: classes.accordion })] }))] })));
|
|
211
212
|
}
|
|
@@ -19,7 +19,7 @@ const classes = {
|
|
|
19
19
|
userInfo: `${PREFIX}-user-info`,
|
|
20
20
|
circle: `${PREFIX}-circle`,
|
|
21
21
|
button: `${PREFIX}-button`,
|
|
22
|
-
|
|
22
|
+
paperContrastColor: `${PREFIX}-paper-contrast-color`
|
|
23
23
|
};
|
|
24
24
|
function CommentSkeleton({ id }) {
|
|
25
25
|
return (_jsxs(Box, Object.assign({ className: classes.outerWrapper }, { children: [_jsx(Skeleton, { animation: "wave", variant: "text", width: "90px", height: "21px" }), _jsx(Divider, {}), _jsxs(Stack, Object.assign({ className: classes.innerWrapper }, { children: [Array.from(new Array(id)).map((_, i) => (_jsxs(Stack, Object.assign({ className: classes.userWrapper }, { children: [_jsx(Skeleton, { animation: "wave", variant: "circular", className: classes.avatar }), _jsxs(Box, { children: [_jsxs(Stack, Object.assign({ className: classes.userInfo }, { children: [_jsx(Skeleton, { animation: "wave", variant: "text", width: "90px", height: "21px" }), _jsx(Box, { className: classes.circle }), _jsx(Skeleton, { animation: "wave", variant: "text", width: "90px", height: "21px" })] })), _jsx(Skeleton, { animation: "wave", variant: "text", width: "180px", height: "21px" })] })] }), i))), _jsx(Skeleton, { animation: "wave", variant: "rounded", width: "112px", height: "36px", className: classes.button })] }))] })));
|
|
@@ -95,11 +95,11 @@ function Comments(props) {
|
|
|
95
95
|
map.set(name, [...map.get(name), comment]);
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
|
-
return Array.from(map.entries()).map(([name, comments]) => (_jsxs(Box, Object.assign({ className: classes.outerWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "h5", className: classes.
|
|
98
|
+
return Array.from(map.entries()).map(([name, comments]) => (_jsxs(Box, Object.assign({ className: classes.outerWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "h5", className: classes.paperContrastColor }, { children: name })), _jsx(Divider, {}), _jsxs(Stack, Object.assign({ className: classes.innerWrapper }, { children: [comments.map((comment) => (_jsxs(Stack, Object.assign({ className: classes.userWrapper }, { children: [_jsx(Avatar, { src: comment.created_by.avatar, alt: comment.created_by.username, className: classes.avatar }), _jsxs(Box, { children: [_jsxs(Stack, Object.assign({ className: classes.userInfo }, { children: [_jsx(Typography, Object.assign({ variant: "body1", className: classes.paperContrastColor }, { children: comment.created_by.username })), _jsx(Box, { className: classes.circle }), _jsx(Typography, Object.assign({ variant: "body2", className: classes.paperContrastColor }, { children: _jsx(FormattedDate, { value: comment.created_at }) }))] })), _jsx(Typography, { variant: "body1", component: "div", dangerouslySetInnerHTML: { __html: comment.html }, className: classes.paperContrastColor })] })] }), comment.id))), _jsx(Button, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.COURSE_LESSON_COMMENTS_ROUTE_NAME, getUrlLesson(comments[0].extras.course, comments[0].extras.lesson, comments[0].extras.section)), size: "small", variant: "contained", color: "inherit", className: classes.button }, { children: _jsx(Typography, Object.assign({ variant: "body2", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.teacher.tab.comments.lessons.btn.label", defaultMessage: "ui.course.dashboard.teacher.tab.comments.lessons.btn.label" }) })) }))] }))] }), name)));
|
|
99
99
|
}, [state.results]);
|
|
100
100
|
if (!state.initialized) {
|
|
101
101
|
return _jsx(CommentsSkeleton, {});
|
|
102
102
|
}
|
|
103
|
-
return (_jsx(Box, Object.assign({ className: classes.container }, { children: state.count > 0 ? (_jsxs(Fragment, { children: [_jsx(Typography, Object.assign({ variant: "body1", className: classes.
|
|
103
|
+
return (_jsx(Box, Object.assign({ className: classes.container }, { children: state.count > 0 ? (_jsxs(Fragment, { children: [_jsx(Typography, Object.assign({ variant: "body1", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.teacher.tab.comments.number", defaultMessage: "ui.course.dashboard.teacher.tab.comments.number", values: { commentsNumber: state.count } }) })), renderComments, isLoading && _jsx(CommentSkeleton, { id: 1 }), _jsx(Button, Object.assign({ size: "small", variant: "contained", color: "inherit", loading: isLoading, disabled: !state.next, onClick: handleNext }, { children: _jsx(Typography, Object.assign({ variant: "body2", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.teacher.tab.comments.btn.label", defaultMessage: "ui.course.dashboard.teacher.tab.comments.btn.label" }) })) }))] })) : (_jsx(Typography, Object.assign({ variant: "body2", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.course.dashboard.teacher.tab.comments.empty", defaultMessage: "ui.course.dashboard.teacher.tab.comments.empty" }) }))) })));
|
|
104
104
|
}
|
|
105
105
|
export default memo(Comments);
|
|
@@ -7,11 +7,11 @@ import { memo } from 'react';
|
|
|
7
7
|
import { InfoPositionType } from '../types';
|
|
8
8
|
const classes = {
|
|
9
9
|
info: `${PREFIX}-info`,
|
|
10
|
-
|
|
10
|
+
paperContrastColor: `${PREFIX}-paper-contrast-color`
|
|
11
11
|
};
|
|
12
12
|
function InfoCourseDashboard(props) {
|
|
13
13
|
// PROPS
|
|
14
14
|
const { title, course, position } = props;
|
|
15
|
-
return (_jsxs(Stack, Object.assign({ className: classes.info }, { children: [_jsx(Typography, Object.assign({ variant: "h4", className: classes.
|
|
15
|
+
return (_jsxs(Stack, Object.assign({ className: classes.info }, { children: [_jsx(Typography, Object.assign({ variant: "h4", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: title, defaultMessage: title }) })), position === InfoPositionType.FIRST && _jsx(CourseParticipantsButton, { course: course }), position === InfoPositionType.SECOND && (_jsxs(Typography, Object.assign({ variant: "h5", className: classes.paperContrastColor }, { children: [course.avg_completion_rate, "%"] })))] })));
|
|
16
16
|
}
|
|
17
17
|
export default memo(InfoCourseDashboard);
|
|
@@ -20,7 +20,7 @@ const classes = {
|
|
|
20
20
|
tabList: `${PREFIX}-tab-list`,
|
|
21
21
|
tab: `${PREFIX}-tab`,
|
|
22
22
|
tabPanel: `${PREFIX}-tab-panel`,
|
|
23
|
-
|
|
23
|
+
defaultContrastColor: `${PREFIX}-default-contrast-color`
|
|
24
24
|
};
|
|
25
25
|
const TAB_DATA = [
|
|
26
26
|
{
|
|
@@ -55,6 +55,6 @@ function Teacher(inProps) {
|
|
|
55
55
|
if (!scCourse) {
|
|
56
56
|
return _jsx(TeacherSkeleton, {});
|
|
57
57
|
}
|
|
58
|
-
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: [_jsx(HeaderCourseDashboard, { course: scCourse, hasAction: true }), _jsxs(Stack, Object.assign({ className: classes.infoWrapper }, { children: [_jsx(InfoCourseDashboard, { title: "ui.course.dashboard.teacher.info.students", course: scCourse, position: InfoPositionType.FIRST }), _jsx(InfoCourseDashboard, { title: "ui.course.dashboard.teacher.info.completion", course: scCourse, position: InfoPositionType.SECOND })] })), _jsxs(TabContext, Object.assign({ value: tabValue }, { children: [_jsx(TabList, Object.assign({ className: classes.tabList, onChange: handleTabChange, textColor: "primary", indicatorColor: "primary", variant: "standard", centered: true }, { children: TAB_DATA.map((data, i) => (_jsx(Tab, { label: _jsx(Typography, Object.assign({ variant: "h6" }, { children: _jsx(FormattedMessage, { id: data.label, defaultMessage: data.label }) })), value: data.value, className: classNames(classes.tab, classes.
|
|
58
|
+
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: [_jsx(HeaderCourseDashboard, { course: scCourse, hasAction: true }), _jsxs(Stack, Object.assign({ className: classes.infoWrapper }, { children: [_jsx(InfoCourseDashboard, { title: "ui.course.dashboard.teacher.info.students", course: scCourse, position: InfoPositionType.FIRST }), _jsx(InfoCourseDashboard, { title: "ui.course.dashboard.teacher.info.completion", course: scCourse, position: InfoPositionType.SECOND })] })), _jsxs(TabContext, Object.assign({ value: tabValue }, { children: [_jsx(TabList, Object.assign({ className: classes.tabList, onChange: handleTabChange, textColor: "primary", indicatorColor: "primary", variant: "standard", centered: true }, { children: TAB_DATA.map((data, i) => (_jsx(Tab, { label: _jsx(Typography, Object.assign({ variant: "h6" }, { children: _jsx(FormattedMessage, { id: data.label, defaultMessage: data.label }) })), value: data.value, className: classNames(classes.tab, classes.defaultContrastColor) }, i))) })), _jsx(TabPanel, Object.assign({ className: classes.tabPanel, value: TabContentType.STUDENTS }, { children: _jsx(Students, { course: scCourse }) })), _jsx(TabPanel, Object.assign({ className: classes.tabPanel, value: TabContentType.COMMENTS }, { children: _jsx(Comments, { course: scCourse }) }))] }))] })));
|
|
59
59
|
}
|
|
60
60
|
export default memo(Teacher);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Box, CardActionArea, Card, CardContent, FormGroup, Paper, TextField, Typography, Chip, styled, Button } from '@mui/material';
|
|
3
|
+
import { Box, CardActionArea, Card, CardContent, FormGroup, Paper, TextField, Typography, Chip, styled, Button, useTheme } from '@mui/material';
|
|
4
4
|
import { useThemeProps } from '@mui/system';
|
|
5
5
|
import { CourseService, formatHttpErrorCode } from '@selfcommunity/api-services';
|
|
6
6
|
import { SCPreferences, UserUtils, useSCPaymentsEnabled, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
|
|
@@ -58,7 +58,8 @@ const classes = {
|
|
|
58
58
|
stepCustomization: `${PREFIX}-step-customization`,
|
|
59
59
|
cardTitle: `${PREFIX}-card-title`,
|
|
60
60
|
title: `${PREFIX}-title`,
|
|
61
|
-
|
|
61
|
+
defaultContrastColor: `${PREFIX}-default-contrast-color`,
|
|
62
|
+
paperContrastColor: `${PREFIX}-paper-contrast-color`,
|
|
62
63
|
paywallsConfiguratorWrap: `${PREFIX}-paywalls-configurator-wrap`
|
|
63
64
|
};
|
|
64
65
|
const Root = styled(Box, {
|
|
@@ -132,6 +133,8 @@ export default function CourseForm(inProps) {
|
|
|
132
133
|
const { preferences } = useSCPreferences();
|
|
133
134
|
// PAYMENTS
|
|
134
135
|
const { isPaymentsEnabled } = useSCPaymentsEnabled();
|
|
136
|
+
// HOOKS
|
|
137
|
+
const theme = useTheme();
|
|
135
138
|
const isStaff = useMemo(() => scUserContext.user && UserUtils.isStaff(scUserContext.user), [scUserContext.user]);
|
|
136
139
|
const courseAdvancedEnabled = useMemo(() => preferences[SCPreferences.CONFIGURATIONS_COURSES_ADVANCED_ENABLED].value, [preferences]);
|
|
137
140
|
const _backgroundCover = Object.assign({}, (field.imageOriginal
|
|
@@ -281,15 +284,17 @@ export default function CourseForm(inProps) {
|
|
|
281
284
|
* Renders root object
|
|
282
285
|
*/
|
|
283
286
|
return (_jsxs(Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: _jsxs(Box, Object.assign({ className: _step === SCCourseFormStepType.GENERAL ? classes.stepOne : classes.stepTwo }, { children: [_step === SCCourseFormStepType.GENERAL &&
|
|
284
|
-
Object.values(SCCourseTypologyType).map((option, index) => (_jsx(Card, Object.assign({ className: classNames(classes.card, { [classes.selected]: option === field.type }, { [classes.disabled]: !courseAdvancedEnabled && option !== SCCourseTypologyType.SELF }) }, { children: _jsx(CardActionArea, Object.assign({ onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['type']: option }))) }, { children: _jsxs(CardContent, { children: [_jsxs(Typography, Object.assign({ variant: "subtitle2", className: classNames(classes.cardTitle, classes.
|
|
287
|
+
Object.values(SCCourseTypologyType).map((option, index) => (_jsx(Card, Object.assign({ className: classNames(classes.card, { [classes.selected]: option === field.type }, { [classes.disabled]: !courseAdvancedEnabled && option !== SCCourseTypologyType.SELF }) }, { children: _jsx(CardActionArea, Object.assign({ onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['type']: option }))) }, { children: _jsxs(CardContent, { children: [_jsxs(Typography, Object.assign({ variant: "subtitle2", className: classNames(classes.cardTitle, classes.paperContrastColor) }, { children: [_jsx(FormattedMessage, { id: `ui.courseForm.${option}.title`, defaultMessage: `ui.courseForm.${option}.title` }), !courseAdvancedEnabled && option !== SCCourseTypologyType.SELF && (_jsx(Chip, { variant: "outlined", color: "warning", size: "small", label: _jsx(FormattedMessage, { id: "ui.courseForm.comingSoon.chip", defaultMessage: "ui.courseForm.comingSoon.chip" }) }))] })), _jsx(Typography, Object.assign({ variant: "body2", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: `ui.courseForm.${option}.info`, defaultMessage: `ui.courseForm.${option}.info` }) }))] }) })) }), index))), _step === SCCourseFormStepType.CUSTOMIZATION && (_jsxs(Fragment, { children: [course && (_jsx(Typography, Object.assign({ variant: "h5", className: classes.defaultContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.courseForm.edit.title.general", defaultMessage: "ui.courseForm.edit.title.general" }) }))), _jsxs(FormGroup, Object.assign({ className: classNames(classes.form, _step === SCCourseFormStepType.CUSTOMIZATION && course ? classes.stepCustomization : undefined) }, { children: [_jsx(Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: _jsx(UploadCourseCover, { isUploading: field.isSubmitting, onChange: handleChangeCover }) })), _jsx(TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, slotProps: {
|
|
285
288
|
input: {
|
|
286
|
-
endAdornment: (_jsx(Typography, Object.assign({ variant: "body2", className: classes.
|
|
289
|
+
endAdornment: (_jsx(Typography, Object.assign({ variant: "body2", className: classes.paperContrastColor }, { children: COURSE_TITLE_MAX_LENGTH - field.name.length })))
|
|
287
290
|
}
|
|
288
291
|
}, error: Boolean((!!course && !field.name) || field.name.length > COURSE_TITLE_MAX_LENGTH) || Boolean(error['nameError']), helperText: !!course && !field.name ? (_jsx(FormattedMessage, { id: "ui.courseForm.required", defaultMessage: "ui.courseForm.required" })) : field.name.length > COURSE_TITLE_MAX_LENGTH ? (_jsx(FormattedMessage, { id: "ui.courseForm.name.error.maxLength", defaultMessage: "ui.courseForm.name.error.maxLength" })) : error['nameError'] ? (error['nameError']) : null }), _jsx(TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, slotProps: {
|
|
289
292
|
input: {
|
|
290
|
-
endAdornment: (_jsx(Typography, Object.assign({ variant: "body2", className: classes.
|
|
293
|
+
endAdornment: (_jsx(Typography, Object.assign({ variant: "body2", className: classes.paperContrastColor }, { children: ((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) ? COURSE_DESCRIPTION_MAX_LENGTH - field.description.length : COURSE_DESCRIPTION_MAX_LENGTH })))
|
|
291
294
|
}
|
|
292
|
-
}, error: Boolean((!!field.privacy && !field.description) || ((_d = field.description) === null || _d === void 0 ? void 0 : _d.length) > COURSE_DESCRIPTION_MAX_LENGTH), helperText: !!field.privacy && !field.description ? (_jsx(FormattedMessage, { id: "ui.courseForm.required", defaultMessage: "ui.courseForm.required" })) : (((_e = field.description) === null || _e === void 0 ? void 0 : _e.length) > COURSE_DESCRIPTION_MAX_LENGTH && (_jsx(FormattedMessage, { id: "ui.courseForm.description.error.maxLength", defaultMessage: "ui.courseForm.description.error.maxLength" }))) }), _jsx(CategoryAutocomplete, { defaultValue: field.categories, TextFieldProps: {
|
|
295
|
+
}, error: Boolean((!!field.privacy && !field.description) || ((_d = field.description) === null || _d === void 0 ? void 0 : _d.length) > COURSE_DESCRIPTION_MAX_LENGTH), helperText: !!field.privacy && !field.description ? (_jsx(FormattedMessage, { id: "ui.courseForm.required", defaultMessage: "ui.courseForm.required" })) : (((_e = field.description) === null || _e === void 0 ? void 0 : _e.length) > COURSE_DESCRIPTION_MAX_LENGTH && (_jsx(FormattedMessage, { id: "ui.courseForm.description.error.maxLength", defaultMessage: "ui.courseForm.description.error.maxLength" }))) }), _jsx(CategoryAutocomplete, { defaultValue: field.categories, TextFieldProps: {
|
|
296
|
+
label: (_jsx(Typography, Object.assign({ component: "span", sx: { color: theme.palette.getContrastText(theme.palette.background.paper) } }, { children: intl.formatMessage(Object.keys(field.categories).length ? messages.category : messages.categoryEmpty) })))
|
|
297
|
+
}, multiple: true, onChange: handleOnChangeCategory }), course && _jsx(CourseEdit, { course: course, onPrivacyChange: (privacy) => setField((prev) => (Object.assign(Object.assign({}, prev), { ['privacy']: privacy }))) }), isPaymentsEnabled && isStaff && !hidePaywalls && (_jsx(Box, Object.assign({ className: classes.paywallsConfiguratorWrap }, { children: _jsx(PaywallsConfigurator, Object.assign({}, (course && { contentId: course.id }), { contentType: SCContentType.COURSE, onChangeContentAccessType: handleChangeContentAccessType, onChangePaymentProducts: handleChangePaymentsProducts })) })))] }))] })), _jsx(Box, Object.assign({ className: classNames(classes.actions, _step === SCCourseFormStepType.CUSTOMIZATION && course ? classes.stepCustomization : undefined) }, { children: _jsx(Button, Object.assign({ size: "small", loading: field.isSubmitting, disabled: _step === SCCourseFormStepType.GENERAL
|
|
293
298
|
? !field.type || Object.keys(error).length !== 0
|
|
294
299
|
: _step === SCCourseFormStepType.CUSTOMIZATION &&
|
|
295
300
|
(!field.name ||
|
|
@@ -300,5 +305,5 @@ export default function CourseForm(inProps) {
|
|
|
300
305
|
? () => handleChangeStep(SCCourseFormStepType.CUSTOMIZATION)
|
|
301
306
|
: field.privacy !== SCCoursePrivacyType.DRAFT && course.privacy === SCCoursePrivacyType.DRAFT
|
|
302
307
|
? () => setOpenDialog(true)
|
|
303
|
-
: handleSubmit, color: "primary" }, { children: course ? (_jsx(
|
|
308
|
+
: handleSubmit, color: "primary" }, { children: course ? (_jsx(FormattedMessage, { id: "ui.courseForm.edit.action.save", defaultMessage: "ui.courseForm.edit.action.save" })) : _step === SCCourseFormStepType.GENERAL ? (_jsx(FormattedMessage, { id: "ui.courseForm.button.next", defaultMessage: "ui.courseForm.button.next" })) : (_jsx(FormattedMessage, { id: "ui.courseForm.button.create", defaultMessage: "ui.courseForm.button.create" })) })) }))] })) })), openDialog && _jsx(CoursePublicationDialog, { onSubmit: handleSubmit, onClose: handleClose })] }));
|
|
304
309
|
}
|
|
@@ -18,7 +18,7 @@ const classes = {
|
|
|
18
18
|
privacyItem: `${PREFIX}-edit-privacy-item`,
|
|
19
19
|
privacyItemInfo: `${PREFIX}-edit-privacy-item-info`,
|
|
20
20
|
disabled: `${PREFIX}-disabled`,
|
|
21
|
-
|
|
21
|
+
paperContrastColor: `${PREFIX}-paper-contrast-color`
|
|
22
22
|
};
|
|
23
23
|
const Root = styled(Box, {
|
|
24
24
|
name: PREFIX,
|
|
@@ -44,11 +44,11 @@ export default function CourseEdit(inProps) {
|
|
|
44
44
|
/**
|
|
45
45
|
* Renders root object
|
|
46
46
|
*/
|
|
47
|
-
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: [course.privacy === SCCoursePrivacyType.DRAFT && (_jsxs(Box, Object.assign({ className: classes.access }, { children: [_jsx(Typography, Object.assign({ variant: "h5", className: classes.
|
|
47
|
+
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: [course.privacy === SCCoursePrivacyType.DRAFT && (_jsxs(Box, Object.assign({ className: classes.access }, { children: [_jsx(Typography, Object.assign({ variant: "h5", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.courseForm.edit.access.section.title", defaultMessage: "ui.courseForm.edit.access.section.title" }) })), _jsxs(Widget, Object.assign({ className: classes.card }, { children: [_jsx(Icon, Object.assign({ fontSize: "medium", color: "warning" }, { children: "error" })), _jsxs(Box, { children: [_jsx(Typography, Object.assign({ variant: "h5", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.courseForm.edit.access.info.title", defaultMessage: "ui.courseForm.edit.access.info.title" }) })), _jsx(Typography, Object.assign({ variant: "body1", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.courseForm.edit.access.info.subtitle", defaultMessage: "ui.courseForm.edit.access.info.subtitle" }) })), _jsxs(Box, Object.assign({ className: classes.accessInfo }, { children: [_jsx(Typography, Object.assign({ variant: "body1", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.courseForm.edit.access.info.access", defaultMessage: "ui.courseForm.edit.access.info.access", values: { icon: (chunks) => _jsx(Icon, { children: chunks }, "ui.courseForm.edit.access.info.access.icon") } }) })), _jsx(Typography, Object.assign({ variant: "body1", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.courseForm.edit.access.info.visibility", defaultMessage: "ui.courseForm.edit.access.info.visibility", values: { icon: (chunks) => _jsx(Icon, { children: chunks }, "ui.courseForm.edit.access.info.visibility.icon") } }) }))] }))] })] }))] }))), _jsxs(Box, Object.assign({ className: classes.publish }, { children: [_jsx(Typography, Object.assign({ variant: "h5", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.courseForm.edit.publication.title", defaultMessage: "ui.courseForm.edit.publication.title" }) })), notPublishable ? (_jsxs(Widget, Object.assign({ className: classes.card }, { children: [_jsx(Icon, Object.assign({ fontSize: "medium", color: "warning" }, { children: "error" })), _jsx(Typography, Object.assign({ className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: "ui.courseForm.edit.publication.subtitle.info", defaultMessage: "ui.courseForm.edit.publication.subtitle.info" }) }))] }))) : (_jsx(Typography, Object.assign({ variant: "body1", className: classNames(classes.publishInfo, classes.paperContrastColor) }, { children: _jsx(FormattedMessage, { id: "ui.courseForm.edit.publication.subtitle", defaultMessage: "ui.courseForm.edit.publication.subtitle" }) }))), _jsx(RadioGroup, { children: Object.values(SCCoursePrivacyType)
|
|
48
48
|
.filter((option) => option !== SCCoursePrivacyType.DRAFT)
|
|
49
|
-
.map((option, index) => (_jsxs(FormControl, Object.assign({ className: classes.privacyItem, disabled: notPublishable }, { children: [_jsx(FormControlLabel, { control: _jsx(Radio, { size: "small", value: option, checked: option === privacy, onChange: handleChange, disabled: notPublishable }), label: _jsx(Typography, Object.assign({ component: "span", className: classes.
|
|
49
|
+
.map((option, index) => (_jsxs(FormControl, Object.assign({ className: classes.privacyItem, disabled: notPublishable }, { children: [_jsx(FormControlLabel, { control: _jsx(Radio, { size: "small", value: option, checked: option === privacy, onChange: handleChange, disabled: notPublishable }), label: _jsx(Typography, Object.assign({ component: "span", className: classes.paperContrastColor }, { children: _jsx(FormattedMessage, { id: `ui.courseForm.edit.publication.option.${option}.title`, defaultMessage: `ui.courseForm.edit.publication.option.${option}.title` }) })) }), _jsxs(_Fragment, { children: [_jsx(Typography, Object.assign({ variant: "body1", className: classNames(classes.paperContrastColor, classes.privacyItemInfo, { [classes.disabled]: notPublishable }) }, { children: _jsx(FormattedMessage, { id: `ui.courseForm.edit.publication.option.${option}.access`, defaultMessage: `ui.courseForm.edit.publication.option.${option}.access`, values: {
|
|
50
50
|
icon: (chunks) => (_jsx(Icon, { children: chunks }, `ui.courseForm.edit.publication.option.${option}.access.icon`))
|
|
51
|
-
} }) })), _jsx(Typography, Object.assign({ variant: "body1", className: (classes.
|
|
51
|
+
} }) })), _jsx(Typography, Object.assign({ variant: "body1", className: (classes.paperContrastColor, classNames(classes.privacyItemInfo, { [classes.disabled]: notPublishable })) }, { children: _jsx(FormattedMessage, { id: `ui.courseForm.edit.publication.option.${option}.visibility`, defaultMessage: `ui.courseForm.edit.publication.option.${option}.visibility`, values: {
|
|
52
52
|
icon: (chunks) => (_jsx(Icon, { children: chunks }, `ui.courseForm.edit.publication.option.${option}.visibility.icon`))
|
|
53
53
|
} }) }))] })] }), index))) })] }))] })));
|
|
54
54
|
}
|
|
@@ -23,7 +23,8 @@ const classes = {
|
|
|
23
23
|
endMessage: `${PREFIX}-end-message`,
|
|
24
24
|
infiniteScroll: `${PREFIX}-infinite-scroll`,
|
|
25
25
|
participants: `${PREFIX}-participants`,
|
|
26
|
-
|
|
26
|
+
paperContrastColor: `${PREFIX}-paper-contrast-color`,
|
|
27
|
+
dialogPaperContrastColor: `${PREFIX}-dialog-paper-contrast-color`
|
|
27
28
|
};
|
|
28
29
|
const Root = styled(Button, {
|
|
29
30
|
name: PREFIX,
|
|
@@ -142,5 +143,5 @@ export default function CourseParticipantsButton(inProps) {
|
|
|
142
143
|
}
|
|
143
144
|
return (_jsxs(_Fragment, { children: [_jsxs(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scCourse || count === 0,
|
|
144
145
|
// @ts-expect-error this is needed to use enrolled into SCCourseParticipantsButton
|
|
145
|
-
enrolled: enrolled }, rest, { children: [!hideCaption && (_jsxs(Typography, Object.assign({ className: classNames(classes.participants, classes.
|
|
146
|
+
enrolled: enrolled }, rest, { children: [!hideCaption && (_jsxs(Typography, Object.assign({ className: classNames(classes.participants, classes.paperContrastColor) }, { children: [_jsx(Icon, { children: "people_alt" }), _jsx(FormattedMessage, { defaultMessage: "ui.courseParticipantsButton.participants", id: "ui.courseParticipantsButton.participants", values: { total: count } })] }))), !count && (loading || !scCourse) ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest, (!participantsAvailable && { skeletonsAnimation: false }), { count: 4 }))) : (_jsx(AvatarGroup, Object.assign({ total: count, renderSurplus: renderSurplus, className: classes.paperContrastColor }, { children: enrolled.map((c) => (_jsx(Avatar, { alt: c.username, src: c.avatar }, c.id))) })))] })), open && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: _jsx(Typography, Object.assign({ component: "span", className: classes.dialogPaperContrastColor }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.courseParticipantsButton.dialogTitle", id: "ui.courseParticipantsButton.dialogTitle", values: { total: count } }) })), onClose: handleToggleDialogOpen, open: true }, DialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: count, next: fetchEnrolledUsers, hasMoreNext: next !== null || loading, loaderNext: _jsx(UserSkeleton, { elevation: 0 }), className: classes.infiniteScroll, endMessage: _jsx(Typography, Object.assign({ className: classNames(classes.endMessage, classes.dialogPaperContrastColor) }, { children: _jsx(FormattedMessage, { id: "ui.courseParticipantsButton.noOtherParticipants", defaultMessage: "ui.courseParticipantsButton.noOtherParticipants" }) })) }, { children: _jsx(List, { children: enrolled.map((e) => (_jsx(ListItem, { children: _jsx(User, { elevation: 0, user: e }) }, e.id))) }) })) })))] }));
|
|
146
147
|
}
|
|
@@ -21,7 +21,7 @@ const classes = {
|
|
|
21
21
|
tabList: `${PREFIX}-tab-list`,
|
|
22
22
|
tab: `${PREFIX}-tab`,
|
|
23
23
|
tabPanel: `${PREFIX}-tab-panel`,
|
|
24
|
-
|
|
24
|
+
defaultContrastColor: `${PREFIX}-default-contrast-color`
|
|
25
25
|
};
|
|
26
26
|
const TAB_DATA = [
|
|
27
27
|
{
|
|
@@ -103,5 +103,5 @@ export default function EditCourse(inProps) {
|
|
|
103
103
|
if (!scCourse) {
|
|
104
104
|
return _jsx(EditCourseSkeleton, { tab: tab });
|
|
105
105
|
}
|
|
106
|
-
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: [_jsxs(Stack, Object.assign({ className: classes.header }, { children: [_jsx(IconButton, Object.assign({ href: scRoutingContext.url(SCRoutes.COURSE_DASHBOARD_ROUTE_NAME, scCourse), size: "small" }, { children: _jsx(Icon, Object.assign({ className: classes.
|
|
106
|
+
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: [_jsxs(Stack, Object.assign({ className: classes.header }, { children: [_jsx(IconButton, Object.assign({ href: scRoutingContext.url(SCRoutes.COURSE_DASHBOARD_ROUTE_NAME, scCourse), size: "small" }, { children: _jsx(Icon, Object.assign({ className: classes.defaultContrastColor }, { children: "arrow_back" })) })), _jsx(Typography, Object.assign({ variant: "h5", className: classes.defaultContrastColor }, { children: scCourse.name }))] })), _jsxs(TabContext, Object.assign({ value: tabValue }, { children: [_jsx(TabList, Object.assign({ className: classes.tabList, onChange: handleTabChange, textColor: "primary", indicatorColor: "primary", variant: isMobile ? 'scrollable' : 'standard', scrollButtons: isMobile, centered: !isMobile }, { children: TAB_DATA.map((data, i) => (_jsx(Tab, { label: _jsx(Typography, Object.assign({ variant: "h6" }, { children: _jsx(FormattedMessage, { id: data.label, defaultMessage: data.label }) })), value: data.value, className: classNames(classes.tab, classes.defaultContrastColor) }, i))) })), panelData.map((data, i) => (_jsx(TabPanel, Object.assign({ className: classes.tabPanel, value: data.value }, { children: data.children }), i)))] }))] })));
|
|
107
107
|
}
|
|
@@ -24,15 +24,16 @@ const OPTIONS = [
|
|
|
24
24
|
const classes = {
|
|
25
25
|
changeLessonStatusPublishedWrapper: `${PREFIX}-change-lesson-status-published-wrapper`,
|
|
26
26
|
changeLessonStatusIconDraft: `${PREFIX}-change-lesson-status-icon-draft`,
|
|
27
|
-
|
|
27
|
+
paperContrastColor: `${PREFIX}-paper-constrast-color`
|
|
28
28
|
};
|
|
29
29
|
function ChangeLessonStatus(props) {
|
|
30
30
|
// PROPS
|
|
31
31
|
const { course, section, lesson, onChange, disabled } = props;
|
|
32
|
+
// CONTEXTS
|
|
33
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
32
34
|
// HOOKS
|
|
33
35
|
const theme = useTheme();
|
|
34
36
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
35
|
-
const { enqueueSnackbar } = useSnackbar();
|
|
36
37
|
// STATES
|
|
37
38
|
const [value, setValue] = useState('');
|
|
38
39
|
const [loading, setLoading] = useState(false);
|
|
@@ -75,16 +76,20 @@ function ChangeLessonStatus(props) {
|
|
|
75
76
|
handleAction(newValue);
|
|
76
77
|
}
|
|
77
78
|
}, [handleAction, value]);
|
|
78
|
-
return (_jsx(Fragment, { children: isMobile ? (_jsx(MenuRow, Object.assign({ buttonClassName: classNames(
|
|
79
|
+
return (_jsx(Fragment, { children: isMobile ? (_jsx(MenuRow, Object.assign({ buttonClassName: classNames(hasPublished ? classes.changeLessonStatusPublishedWrapper : undefined), icon: icon }, { children: OPTIONS.map((option, i) => (_jsx(MenuItem, { children: _jsx(Button, Object.assign({ size: "small", color: "inherit", onClick: handleClick, loading: loading, disabled: loading, "data-value": option.value, sx: {
|
|
79
80
|
padding: 0,
|
|
80
81
|
':hover': {
|
|
81
82
|
backgroundColor: 'unset'
|
|
82
83
|
}
|
|
83
|
-
} }, { children: _jsx(Typography, Object.assign({ variant: "body1",
|
|
84
|
+
} }, { children: _jsx(Typography, Object.assign({ variant: "body1", sx: {
|
|
85
|
+
color: theme.palette.getContrastText(theme.palette.background.paper)
|
|
86
|
+
} }, { children: _jsx(FormattedMessage, { id: option.id, defaultMessage: option.id }) })) })) }, i))) }))) : (_jsx(Select, Object.assign({ className: classNames(hasPublished ? classes.changeLessonStatusPublishedWrapper : undefined), size: "small", value: value, onChange: handleChange, disabled: disabled }, { children: OPTIONS.map((option, i) => (_jsx(MenuItem, Object.assign({ value: option.value }, { children: _jsx(Button, Object.assign({ size: "small", color: "inherit", loading: loading, disabled: loading, sx: {
|
|
84
87
|
padding: 0,
|
|
85
88
|
':hover': {
|
|
86
89
|
backgroundColor: 'unset'
|
|
87
90
|
}
|
|
88
|
-
} }, { children: _jsx(Typography, Object.assign({ variant: "body1",
|
|
91
|
+
} }, { children: _jsx(Typography, Object.assign({ variant: "body1", sx: {
|
|
92
|
+
color: theme.palette.getContrastText(theme.palette.background.paper)
|
|
93
|
+
} }, { children: _jsx(FormattedMessage, { id: option.id, defaultMessage: option.id }) })) })) }), i))) }))) }));
|
|
89
94
|
}
|
|
90
95
|
export default memo(ChangeLessonStatus);
|
|
@@ -15,7 +15,7 @@ const classes = {
|
|
|
15
15
|
editModeWrapper: `${PREFIX}-edit-mode-wrapper`,
|
|
16
16
|
editModeSaveButton: `${PREFIX}-edit-mode-save-button`,
|
|
17
17
|
editModeCloseButton: `${PREFIX}-edit-mode-close-button`,
|
|
18
|
-
|
|
18
|
+
paperContrastColor: `${PREFIX}-paper-contrast-color`
|
|
19
19
|
};
|
|
20
20
|
function FieldName(props) {
|
|
21
21
|
// PROPS
|
|
@@ -75,6 +75,6 @@ function FieldName(props) {
|
|
|
75
75
|
handleDisableEditMode();
|
|
76
76
|
}
|
|
77
77
|
}, [row, isNewRow, handleManageRow, setName, handleDisableEditMode]);
|
|
78
|
-
return (_jsx(Fragment, { children: isNewRow || editMode ? (_jsxs(Stack, Object.assign({ className: classes.editModeWrapper }, { children: [_jsx(TextField, { type: "text", variant: "outlined", size: "small", focused: true, autoFocus: true, defaultValue: row.name, onChange: handleChange }), _jsx(Button, Object.assign({ size: "small", color: "primary", variant: "contained", onClick: handleSubmit, loading: loading, disabled: loading, className: classes.editModeSaveButton }, { children: _jsx(Icon, { children: "check" }) })), _jsx(IconButton, Object.assign({ color: "default", size: "small", onClick: handleClose, className: classes.editModeCloseButton }, { children: _jsx(Icon, { children: "close" }) }))] }))) : (_jsx(Typography, Object.assign({ variant: "body1", className: classes.
|
|
78
|
+
return (_jsx(Fragment, { children: isNewRow || editMode ? (_jsxs(Stack, Object.assign({ className: classes.editModeWrapper }, { children: [_jsx(TextField, { type: "text", variant: "outlined", size: "small", focused: true, autoFocus: true, defaultValue: row.name, onChange: handleChange }), _jsx(Button, Object.assign({ size: "small", color: "primary", variant: "contained", onClick: handleSubmit, loading: loading, disabled: loading, className: classes.editModeSaveButton }, { children: _jsx(Icon, { children: "check" }) })), _jsx(IconButton, Object.assign({ color: "default", size: "small", onClick: handleClose, className: classes.editModeCloseButton }, { children: _jsx(Icon, { children: "close" }) }))] }))) : (_jsx(Typography, Object.assign({ variant: "body1", className: classes.paperContrastColor }, { children: row.name }))) }));
|
|
79
79
|
}
|
|
80
80
|
export default memo(FieldName);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Icon, MenuItem, Stack, TableCell, TableRow, Typography } from '@mui/material';
|
|
2
|
+
import { Icon, MenuItem, Stack, TableCell, TableRow, Typography, useTheme } from '@mui/material';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { PREFIX } from '../constants';
|
|
5
5
|
import { forwardRef, memo, useCallback, useImperativeHandle, useState } from 'react';
|
|
@@ -20,8 +20,7 @@ const classes = {
|
|
|
20
20
|
cellAlignRight: `${PREFIX}-cell-align-right`,
|
|
21
21
|
cellPadding: `${PREFIX}-cell-padding`,
|
|
22
22
|
tableBodyIconWrapper: `${PREFIX}-table-body-icon-wrapper`,
|
|
23
|
-
actionsWrapper: `${PREFIX}-actions-wrapper
|
|
24
|
-
contrastColor: `${PREFIX}-contrast-color`
|
|
23
|
+
actionsWrapper: `${PREFIX}-actions-wrapper`
|
|
25
24
|
};
|
|
26
25
|
function LessonRow(props, ref) {
|
|
27
26
|
// PROPS
|
|
@@ -33,6 +32,7 @@ function LessonRow(props, ref) {
|
|
|
33
32
|
// HOOKS
|
|
34
33
|
const { isDisabled } = useIsDisabled();
|
|
35
34
|
const { enqueueSnackbar } = useSnackbar();
|
|
35
|
+
const theme = useTheme();
|
|
36
36
|
// HANDLERS
|
|
37
37
|
const handleAbleEditMode = useCallback(() => setTimeout(() => setEditMode(true)), [setEditMode]);
|
|
38
38
|
const handleDisableEditMode = useCallback(() => setEditMode(false), [setEditMode]);
|
|
@@ -61,6 +61,6 @@ function LessonRow(props, ref) {
|
|
|
61
61
|
? Endpoints.CreateCourseLesson.url({ id: course.id, section_id: section.id })
|
|
62
62
|
: Endpoints.PatchCourseLesson.url({ id: course.id, section_id: section.id, lesson_id: lesson.id }),
|
|
63
63
|
method: isNewRow ? Endpoints.CreateCourseLesson.method : Endpoints.PatchCourseLesson.method
|
|
64
|
-
}, row: lesson, isNewRow: isNewRow, handleManageRow: handleManageLesson, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), _jsx(TableCell, {}), _jsx(TableCell, Object.assign({ className: classes.cellAlignRight }, { children: _jsxs(Stack, Object.assign({ className: classes.actionsWrapper }, { children: [_jsx(ChangeLessonStatus, { course: course, section: section, lesson: lesson, onChange: handleManageLesson, disabled: isDisabled }), _jsxs(MenuRow, Object.assign({ disabled: isDisabled }, { children: [_jsx(MenuItem, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.COURSE_LESSON_EDIT_ROUTE_NAME, getUrlLesson(course, lesson, section)) }, { children: _jsx(Typography, Object.assign({ variant: "body1",
|
|
64
|
+
}, row: lesson, isNewRow: isNewRow, handleManageRow: handleManageLesson, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), _jsx(TableCell, {}), _jsx(TableCell, Object.assign({ className: classes.cellAlignRight }, { children: _jsxs(Stack, Object.assign({ className: classes.actionsWrapper }, { children: [_jsx(ChangeLessonStatus, { course: course, section: section, lesson: lesson, onChange: handleManageLesson, disabled: isDisabled }), _jsxs(MenuRow, Object.assign({ disabled: isDisabled }, { children: [_jsx(MenuItem, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.COURSE_LESSON_EDIT_ROUTE_NAME, getUrlLesson(course, lesson, section)) }, { children: _jsx(Typography, Object.assign({ variant: "body1", sx: { color: theme.palette.getContrastText(theme.palette.background.paper) } }, { children: _jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.edit", defaultMessage: "ui.editCourse.tab.lessons.table.menu.edit" }) })) })), _jsx(MenuItem, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.COURSE_LESSON_PREVIEW_ROUTE_NAME, getUrlLesson(course, lesson, section)) }, { children: _jsx(Typography, Object.assign({ variant: "body1", sx: { color: theme.palette.getContrastText(theme.palette.background.paper) } }, { children: _jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.preview", defaultMessage: "ui.editCourse.tab.lessons.table.menu.preview" }) })) })), _jsx(MenuItem, Object.assign({ onClick: handleAbleEditMode }, { children: _jsx(Typography, Object.assign({ variant: "body1", sx: { color: theme.palette.getContrastText(theme.palette.background.paper) } }, { 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", sx: { color: theme.palette.getContrastText(theme.palette.background.paper) } }, { children: _jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.delete", defaultMessage: "ui.editCourse.tab.lessons.table.menu.delete" }) })) }))] }))] })) }))] })));
|
|
65
65
|
}
|
|
66
66
|
export default memo(forwardRef(LessonRow));
|
|
@@ -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 { forwardRef, Fragment, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
4
|
-
import { Collapse, Icon, IconButton, MenuItem, Stack, Table, TableBody, TableCell, TableRow, Typography } from '@mui/material';
|
|
4
|
+
import { Collapse, Icon, IconButton, MenuItem, Stack, Table, TableBody, TableCell, TableRow, Typography, useTheme } from '@mui/material';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import { PREFIX } from '../constants';
|
|
7
7
|
import LessonRow from './LessonRow';
|
|
@@ -25,8 +25,7 @@ const classes = {
|
|
|
25
25
|
cellWidth: `${PREFIX}-cell-width`,
|
|
26
26
|
cellAlignRight: `${PREFIX}-cell-align-right`,
|
|
27
27
|
cellAlignCenter: `${PREFIX}-cell-align-center`,
|
|
28
|
-
cellPadding: `${PREFIX}-cell-padding
|
|
29
|
-
contrastColor: `${PREFIX}-contrast-color`
|
|
28
|
+
cellPadding: `${PREFIX}-cell-padding`
|
|
30
29
|
};
|
|
31
30
|
function SectionRow(props, ref) {
|
|
32
31
|
// PROPS
|
|
@@ -41,6 +40,7 @@ function SectionRow(props, ref) {
|
|
|
41
40
|
const { isDisabled } = useIsDisabled();
|
|
42
41
|
const intl = useIntl();
|
|
43
42
|
const { enqueueSnackbar } = useSnackbar();
|
|
43
|
+
const theme = useTheme();
|
|
44
44
|
// EFFECTS
|
|
45
45
|
useEffect(() => {
|
|
46
46
|
if (section.lessons) {
|
|
@@ -151,6 +151,6 @@ function SectionRow(props, ref) {
|
|
|
151
151
|
? Endpoints.CreateCourseSection.url({ id: course.id })
|
|
152
152
|
: Endpoints.PatchCourseSection.url({ id: course.id, section_id: section.id }),
|
|
153
153
|
method: isNewRow ? Endpoints.CreateCourseSection.method : Endpoints.PatchCourseSection.method
|
|
154
|
-
}, row: section, isNewRow: isNewRow, handleManageRow: handleManageSection, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), course.type !== SCCourseTypologyType.SELF && (_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: "contained", disabled: isDisabled }), _jsxs(MenuRow, Object.assign({ disabled: isDisabled }, { children: [_jsx(MenuItem, Object.assign({ onClick: handleAbleEditMode }, { children: _jsx(Typography, Object.assign({ variant: "body1",
|
|
154
|
+
}, row: section, isNewRow: isNewRow, handleManageRow: handleManageSection, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), course.type !== SCCourseTypologyType.SELF && (_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: "contained", disabled: isDisabled }), _jsxs(MenuRow, Object.assign({ disabled: isDisabled }, { children: [_jsx(MenuItem, Object.assign({ onClick: handleAbleEditMode }, { children: _jsx(Typography, Object.assign({ variant: "body1", sx: { color: theme.palette.getContrastText(theme.palette.background.paper) } }, { 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({ row: RowType.SECTION, section }) }, { children: _jsx(Typography, Object.assign({ variant: "body1", sx: { color: theme.palette.getContrastText(theme.palette.background.paper) } }, { children: _jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.delete", defaultMessage: "ui.editCourse.tab.lessons.table.menu.delete" }) })) }))] }))] })) }))] })), _jsx(TableRow, { children: _jsx(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, handleOpenDialog: () => handleOpenDialog({ row: RowType.LESSON, section, lesson }), ref: innerRef }, i)) }), i))), outerProvider.placeholder] }))) })) }) })) })) })) })] }));
|
|
155
155
|
}
|
|
156
156
|
export default memo(forwardRef(SectionRow));
|