@selfcommunity/react-ui 0.10.5-payments.156 → 0.10.5-payments.161
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/BottomNavigation/BottomNavigation.js +3 -3
- package/lib/cjs/components/CheckoutReturnDialog/CheckoutReturnDialog.d.ts +1 -0
- package/lib/cjs/components/CheckoutReturnDialog/CheckoutReturnDialog.js +8 -3
- package/lib/cjs/components/Course/Course.d.ts +6 -5
- package/lib/cjs/components/Course/Course.js +13 -17
- package/lib/cjs/components/Course/Skeleton.d.ts +5 -0
- package/lib/cjs/components/Course/Skeleton.js +4 -4
- package/lib/cjs/components/CourseDashboard/Student.js +30 -17
- package/lib/cjs/components/CourseForm/CourseForm.js +5 -5
- package/lib/cjs/components/CourseForm/UploadCourseCover.js +26 -22
- package/lib/cjs/components/EditCourse/Lessons/FieldName.js +3 -3
- package/lib/cjs/components/EditCourse/Lessons/LessonRow.js +7 -2
- package/lib/cjs/components/EditCourse/Lessons/SectionRow.js +17 -6
- package/lib/cjs/components/EditCourse/Lessons.js +8 -2
- package/lib/cjs/components/EditCourse/Requests.js +9 -9
- package/lib/cjs/components/EditCourse/Users.js +10 -7
- package/lib/cjs/components/NavigationMenuIconButton/DefaultDrawerContent.js +1 -1
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +2 -2
- package/lib/cjs/components/PaymentOrders/PaymentOrders.js +32 -2
- package/lib/cjs/components/Paywalls/Paywalls.js +4 -6
- package/lib/cjs/components/UserCreatedCoursesWidget/Skeleton.d.ts +21 -0
- package/lib/cjs/components/UserCreatedCoursesWidget/Skeleton.js +43 -0
- package/lib/cjs/components/UserCreatedCoursesWidget/UserCreatedCoursesWidget.d.ts +63 -0
- package/lib/cjs/components/UserCreatedCoursesWidget/UserCreatedCoursesWidget.js +154 -0
- package/lib/cjs/components/UserCreatedCoursesWidget/constants.d.ts +1 -0
- package/lib/cjs/components/UserCreatedCoursesWidget/constants.js +4 -0
- package/lib/cjs/components/UserCreatedCoursesWidget/index.d.ts +4 -0
- package/lib/cjs/components/UserCreatedCoursesWidget/index.js +8 -0
- package/lib/cjs/index.d.ts +2 -1
- package/lib/cjs/index.js +5 -2
- package/lib/cjs/shared/AddUsersButton/AddUsersButton.js +1 -1
- package/lib/cjs/shared/CourseUsersTable/ChangeUsersStatus.js +1 -1
- package/lib/cjs/shared/CourseUsersTable/CourseUsersTable.js +3 -3
- package/lib/esm/components/BottomNavigation/BottomNavigation.js +3 -3
- package/lib/esm/components/CheckoutReturnDialog/CheckoutReturnDialog.d.ts +1 -0
- package/lib/esm/components/CheckoutReturnDialog/CheckoutReturnDialog.js +10 -5
- package/lib/esm/components/Course/Course.d.ts +6 -5
- package/lib/esm/components/Course/Course.js +13 -17
- package/lib/esm/components/Course/Skeleton.d.ts +5 -0
- package/lib/esm/components/Course/Skeleton.js +4 -4
- package/lib/esm/components/CourseDashboard/Student.js +31 -18
- package/lib/esm/components/CourseForm/CourseForm.js +5 -5
- package/lib/esm/components/CourseForm/UploadCourseCover.js +26 -22
- package/lib/esm/components/EditCourse/Lessons/FieldName.js +3 -3
- package/lib/esm/components/EditCourse/Lessons/LessonRow.js +7 -2
- package/lib/esm/components/EditCourse/Lessons/SectionRow.js +17 -6
- package/lib/esm/components/EditCourse/Lessons.js +8 -2
- package/lib/esm/components/EditCourse/Requests.js +9 -9
- package/lib/esm/components/EditCourse/Users.js +10 -7
- package/lib/esm/components/NavigationMenuIconButton/DefaultDrawerContent.js +1 -1
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +2 -2
- package/lib/esm/components/PaymentOrders/PaymentOrders.js +33 -3
- package/lib/esm/components/Paywalls/Paywalls.js +4 -6
- package/lib/esm/components/UserCreatedCoursesWidget/Skeleton.d.ts +21 -0
- package/lib/esm/components/UserCreatedCoursesWidget/Skeleton.js +39 -0
- package/lib/esm/components/UserCreatedCoursesWidget/UserCreatedCoursesWidget.d.ts +63 -0
- package/lib/esm/components/UserCreatedCoursesWidget/UserCreatedCoursesWidget.js +151 -0
- package/lib/esm/components/UserCreatedCoursesWidget/constants.d.ts +1 -0
- package/lib/esm/components/UserCreatedCoursesWidget/constants.js +1 -0
- package/lib/esm/components/UserCreatedCoursesWidget/index.d.ts +4 -0
- package/lib/esm/components/UserCreatedCoursesWidget/index.js +4 -0
- package/lib/esm/index.d.ts +2 -1
- package/lib/esm/index.js +2 -1
- package/lib/esm/shared/AddUsersButton/AddUsersButton.js +1 -1
- package/lib/esm/shared/CourseUsersTable/ChangeUsersStatus.js +1 -1
- package/lib/esm/shared/CourseUsersTable/CourseUsersTable.js +3 -3
- package/lib/umd/975.js +20 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +8 -8
- package/lib/umd/657.js +0 -2
- /package/lib/umd/{657.js.LICENSE.txt → 975.js.LICENSE.txt} +0 -0
|
@@ -102,13 +102,13 @@ function BottomNavigation(inProps) {
|
|
|
102
102
|
(!postOnlyStaffEnabled || (react_core_1.UserUtils.isStaff(scUserContext.user) && postOnlyStaffEnabled)) &&
|
|
103
103
|
((groupsEnabled && !eventsEnabled) || (!groupsEnabled && eventsEnabled)) &&
|
|
104
104
|
!exploreStreamEnabled ? ((0, jsx_runtime_1.jsx)(material_1.BottomNavigationAction, { className: (0, classnames_1.default)(classes.composer, classes.action), component: ComposerIconButton_1.default, disableRipple: true }, "composer")) : null,
|
|
105
|
-
coursesEnabled && scUserContext.user ? ((0, jsx_runtime_1.jsx)(material_1.BottomNavigationAction, { className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.COURSES_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.COURSES_ROUTE_NAME, {}), icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "courses" }) }, "courses")) : null,
|
|
106
|
-
groupsEnabled && scUserContext.user ? ((0, jsx_runtime_1.jsx)(material_1.BottomNavigationAction, { className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUPS_SUBSCRIBED_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.GROUPS_SUBSCRIBED_ROUTE_NAME, {}), icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "groups" }) }, "groups")) : null,
|
|
105
|
+
coursesEnabled && (scUserContext.user || contentAvailable) ? ((0, jsx_runtime_1.jsx)(material_1.BottomNavigationAction, { className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.COURSES_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.COURSES_ROUTE_NAME, {}), icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "courses" }) }, "courses")) : null,
|
|
106
|
+
groupsEnabled && (scUserContext.user || contentAvailable) ? ((0, jsx_runtime_1.jsx)(material_1.BottomNavigationAction, { className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUPS_SUBSCRIBED_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.GROUPS_SUBSCRIBED_ROUTE_NAME, {}), icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "groups" }) }, "groups")) : null,
|
|
107
107
|
(!postOnlyStaffEnabled || (react_core_1.UserUtils.isStaff(scUserContext.user) && postOnlyStaffEnabled)) &&
|
|
108
108
|
groupsEnabled &&
|
|
109
109
|
eventsEnabled &&
|
|
110
110
|
!exploreStreamEnabled ? ((0, jsx_runtime_1.jsx)(material_1.BottomNavigationAction, { className: (0, classnames_1.default)(classes.composer, classes.action), component: ComposerIconButton_1.default, disableRipple: true }, "composer")) : null,
|
|
111
|
-
eventsEnabled ? ((0, jsx_runtime_1.jsx)(material_1.BottomNavigationAction, { className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.EVENTS_ROUTE_NAME, {}), icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "CalendarIcon" }) }, "events")) : null,
|
|
111
|
+
eventsEnabled && (scUserContext.user || contentAvailable) ? ((0, jsx_runtime_1.jsx)(material_1.BottomNavigationAction, { className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.EVENTS_ROUTE_NAME, {}), icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "CalendarIcon" }) }, "events")) : null,
|
|
112
112
|
scUserContext.user && !groupsEnabled && !eventsEnabled ? ((0, jsx_runtime_1.jsx)(material_1.BottomNavigationAction, { className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_NOTIFICATIONS_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.USER_NOTIFICATIONS_ROUTE_NAME, {}), icon: (0, jsx_runtime_1.jsx)(material_1.Badge, Object.assign({ badgeContent: scUserContext.user.unseen_notification_banners_counter + scUserContext.user.unseen_interactions_counter, color: "secondary" }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "notifications_active" }) })) }, "notifications")) : null,
|
|
113
113
|
privateMessagingEnabled && scUserContext.user ? ((0, jsx_runtime_1.jsx)(material_1.BottomNavigationAction, { className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, {}), icon: (0, jsx_runtime_1.jsx)(material_1.Badge, Object.assign({ badgeContent: 0, color: "secondary" }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "email" }) })) }, "messages")) : null
|
|
114
114
|
] })));
|
|
@@ -4,5 +4,6 @@ export interface CheckoutReturnDialogProps extends DialogProps {
|
|
|
4
4
|
checkoutSessionId: string;
|
|
5
5
|
disableInitialTransition?: boolean;
|
|
6
6
|
onHandleViewContentPurchased?: (redirectUrl: string) => void;
|
|
7
|
+
returnUrl?: string;
|
|
7
8
|
}
|
|
8
9
|
export default function CheckoutReturnDialog(inProps: CheckoutReturnDialogProps): JSX.Element;
|
|
@@ -46,7 +46,7 @@ function CheckoutReturnDialog(inProps) {
|
|
|
46
46
|
props: inProps,
|
|
47
47
|
name: PREFIX
|
|
48
48
|
});
|
|
49
|
-
const { className, checkoutSessionId, disableInitialTransition = false, onHandleViewContentPurchased } = props, rest = tslib_1.__rest(props, ["className", "checkoutSessionId", "disableInitialTransition", "onHandleViewContentPurchased"]);
|
|
49
|
+
const { className, checkoutSessionId, disableInitialTransition = false, onHandleViewContentPurchased, returnUrl } = props, rest = tslib_1.__rest(props, ["className", "checkoutSessionId", "disableInitialTransition", "onHandleViewContentPurchased", "returnUrl"]);
|
|
50
50
|
// STATE
|
|
51
51
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
52
52
|
const [contentType, setContentType] = (0, react_1.useState)(null);
|
|
@@ -59,6 +59,8 @@ function CheckoutReturnDialog(inProps) {
|
|
|
59
59
|
// CONTEXT
|
|
60
60
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
61
61
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
62
|
+
const scPreferencesContext = (0, react_1.useContext)(react_core_1.SCPreferencesContext);
|
|
63
|
+
const appUrl = (0, react_1.useMemo)(() => scPreferencesContext.preferences && scPreferencesContext.preferences[react_core_1.SCPreferences.CONFIGURATIONS_APP_URL].value, [scPreferencesContext.preferences]);
|
|
62
64
|
/**
|
|
63
65
|
* Handle view new object purchased
|
|
64
66
|
*/
|
|
@@ -77,14 +79,17 @@ function CheckoutReturnDialog(inProps) {
|
|
|
77
79
|
case types_1.SCContentType.COURSE:
|
|
78
80
|
_redirectUrl = scRoutingContext.url(react_core_1.SCRoutes.COURSE_ROUTE_NAME, content);
|
|
79
81
|
break;
|
|
82
|
+
case types_1.SCContentType.COMMUNITY:
|
|
83
|
+
_redirectUrl = appUrl;
|
|
84
|
+
break;
|
|
80
85
|
default:
|
|
81
86
|
break;
|
|
82
87
|
}
|
|
83
88
|
if (onHandleViewContentPurchased) {
|
|
84
|
-
onHandleViewContentPurchased(_redirectUrl);
|
|
89
|
+
onHandleViewContentPurchased(returnUrl ? returnUrl : _redirectUrl);
|
|
85
90
|
}
|
|
86
91
|
else if (_redirectUrl) {
|
|
87
|
-
window.location.href = _redirectUrl;
|
|
92
|
+
window.location.href = returnUrl ? returnUrl : _redirectUrl;
|
|
88
93
|
}
|
|
89
94
|
}, [scRoutingContext, onHandleViewContentPurchased, content, contentType]);
|
|
90
95
|
/**
|
|
@@ -4,7 +4,7 @@ import { SCCourseTemplateType } from '../../types/course';
|
|
|
4
4
|
import { CourseParticipantsButtonProps } from '../CourseParticipantsButton';
|
|
5
5
|
import { WidgetProps } from '../Widget';
|
|
6
6
|
import { CourseSkeletonProps } from './Skeleton';
|
|
7
|
-
import { CacheStrategies } from '@selfcommunity/utils
|
|
7
|
+
import { CacheStrategies } from '@selfcommunity/utils';
|
|
8
8
|
export interface CourseProps extends WidgetProps {
|
|
9
9
|
/**
|
|
10
10
|
* Course Object
|
|
@@ -21,6 +21,10 @@ export interface CourseProps extends WidgetProps {
|
|
|
21
21
|
* @default 'preview'
|
|
22
22
|
*/
|
|
23
23
|
template?: SCCourseTemplateType;
|
|
24
|
+
/**
|
|
25
|
+
* It shows a different snippet type
|
|
26
|
+
*/
|
|
27
|
+
userProfileSnippet?: boolean;
|
|
24
28
|
/**
|
|
25
29
|
* Actions
|
|
26
30
|
* @default null
|
|
@@ -84,12 +88,9 @@ export interface CourseProps extends WidgetProps {
|
|
|
84
88
|
|previewProgress|.SCCourses-preview-progress|Styles applied to indicate the progress section in the preview template.|
|
|
85
89
|
|previewProgressBar|.SCCourses-preview-progress-bar|Styles applied to the progress bar in the preview template.|
|
|
86
90
|
|snippetRoot|.SCCourses-snippet-root|Styles applied to the root element in the snippet template.|
|
|
87
|
-
|snippetActions|.SCCourses-snippet-actions|Styles applied to the actions section in the snippet template.|
|
|
88
91
|
|snippetAvatar|.SCCourses-snippet-avatar|Styles applied to the avatar element in the snippet template.|
|
|
89
92
|
|snippetImage|.SCCourses-snippet-image|Styles applied to the image element in the snippet template.|
|
|
90
|
-
|
|
91
|
-
|snippetSecondary|.SCCourses-snippet-secondary|Styles applied to the secondary section in the snippet template.|
|
|
92
|
-
|
|
93
|
+
|
|
93
94
|
*
|
|
94
95
|
* @param inProps
|
|
95
96
|
*/
|
|
@@ -15,9 +15,9 @@ const CourseParticipantsButton_1 = tslib_1.__importDefault(require("../CoursePar
|
|
|
15
15
|
const Widget_1 = tslib_1.__importDefault(require("../Widget"));
|
|
16
16
|
const constants_1 = require("./constants");
|
|
17
17
|
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
18
|
-
const BaseItem_1 = tslib_1.__importDefault(require("../../shared/BaseItem"));
|
|
19
18
|
const course_2 = require("../../utils/course");
|
|
20
19
|
const UserAvatar_1 = tslib_1.__importDefault(require("../../shared/UserAvatar"));
|
|
20
|
+
const BaseItemButton_1 = tslib_1.__importDefault(require("../../shared/BaseItemButton"));
|
|
21
21
|
const classes = {
|
|
22
22
|
root: `${constants_1.PREFIX}-root`,
|
|
23
23
|
chip: `${constants_1.PREFIX}-chip`,
|
|
@@ -36,11 +36,9 @@ const classes = {
|
|
|
36
36
|
previewProgress: `${constants_1.PREFIX}-preview-progress`,
|
|
37
37
|
previewProgressBar: `${constants_1.PREFIX}-preview-progress-bar`,
|
|
38
38
|
snippetRoot: `${constants_1.PREFIX}-snippet-root`,
|
|
39
|
-
snippetActions: `${constants_1.PREFIX}-snippet-actions`,
|
|
40
39
|
snippetAvatar: `${constants_1.PREFIX}-snippet-avatar`,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
snippetSecondary: `${constants_1.PREFIX}-snippet-secondary`
|
|
40
|
+
snippetAvatarUserProfile: `${constants_1.PREFIX}-snippet-avatar-user-profile-view`,
|
|
41
|
+
snippetImage: `${constants_1.PREFIX}-snippet-image`
|
|
44
42
|
};
|
|
45
43
|
const Root = (0, styles_1.styled)(Widget_1.default, {
|
|
46
44
|
name: constants_1.PREFIX,
|
|
@@ -52,7 +50,7 @@ const PreviewRoot = (0, styles_1.styled)(material_1.Box, {
|
|
|
52
50
|
slot: 'PreviewRoot',
|
|
53
51
|
overridesResolver: (_props, styles) => styles.previewRoot
|
|
54
52
|
})(() => ({}));
|
|
55
|
-
const SnippetRoot = (0, styles_1.styled)(
|
|
53
|
+
const SnippetRoot = (0, styles_1.styled)(BaseItemButton_1.default, {
|
|
56
54
|
name: constants_1.PREFIX,
|
|
57
55
|
slot: 'SnippetRoot',
|
|
58
56
|
overridesResolver: (_props, styles) => styles.snippetRoot
|
|
@@ -96,22 +94,20 @@ const SnippetRoot = (0, styles_1.styled)(BaseItem_1.default, {
|
|
|
96
94
|
|previewProgress|.SCCourses-preview-progress|Styles applied to indicate the progress section in the preview template.|
|
|
97
95
|
|previewProgressBar|.SCCourses-preview-progress-bar|Styles applied to the progress bar in the preview template.|
|
|
98
96
|
|snippetRoot|.SCCourses-snippet-root|Styles applied to the root element in the snippet template.|
|
|
99
|
-
|snippetActions|.SCCourses-snippet-actions|Styles applied to the actions section in the snippet template.|
|
|
100
97
|
|snippetAvatar|.SCCourses-snippet-avatar|Styles applied to the avatar element in the snippet template.|
|
|
101
98
|
|snippetImage|.SCCourses-snippet-image|Styles applied to the image element in the snippet template.|
|
|
102
|
-
|
|
103
|
-
|snippetSecondary|.SCCourses-snippet-secondary|Styles applied to the secondary section in the snippet template.|
|
|
104
|
-
|
|
99
|
+
|
|
105
100
|
*
|
|
106
101
|
* @param inProps
|
|
107
102
|
*/
|
|
108
103
|
function Course(inProps) {
|
|
104
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
109
105
|
// PROPS
|
|
110
106
|
const props = (0, system_1.useThemeProps)({
|
|
111
107
|
props: inProps,
|
|
112
108
|
name: constants_1.PREFIX
|
|
113
109
|
});
|
|
114
|
-
const { id = `course_object_${props.courseId ? props.courseId : props.course ? props.course.id : ''}`, courseId = null, course = null, className = null, template = course_1.SCCourseTemplateType.PREVIEW, actions, CourseParticipantsButtonComponentProps = {}, CourseSkeletonComponentProps = {}, cacheStrategy } = props, rest = tslib_1.__rest(props, ["id", "courseId", "course", "className", "template", "actions", "CourseParticipantsButtonComponentProps", "CourseSkeletonComponentProps", "cacheStrategy"]);
|
|
110
|
+
const { id = `course_object_${props.courseId ? props.courseId : props.course ? props.course.id : ''}`, courseId = null, course = null, className = null, template = course_1.SCCourseTemplateType.PREVIEW, actions, CourseParticipantsButtonComponentProps = {}, CourseSkeletonComponentProps = {}, cacheStrategy, userProfileSnippet } = props, rest = tslib_1.__rest(props, ["id", "courseId", "course", "className", "template", "actions", "CourseParticipantsButtonComponentProps", "CourseSkeletonComponentProps", "cacheStrategy", "userProfileSnippet"]);
|
|
115
111
|
// STATE
|
|
116
112
|
const { scCourse } = (0, react_core_1.useSCFetchCourse)(Object.assign({ id: courseId, course }, (cacheStrategy && { cacheStrategy })));
|
|
117
113
|
// CONTEXT
|
|
@@ -155,20 +151,20 @@ function Course(inProps) {
|
|
|
155
151
|
? 'primary'
|
|
156
152
|
: isCourseAdmin && !scCourse.privacy
|
|
157
153
|
? 'default'
|
|
158
|
-
: 'secondary', label: chipLabel, className: classes.chip })), (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!scCourse.created_by.deleted && {
|
|
154
|
+
: 'secondary', label: chipLabel, className: classes.chip })), (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!((_a = scCourse.created_by) === null || _a === void 0 ? void 0 : _a.deleted) && {
|
|
159
155
|
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, scCourse.created_by)
|
|
160
|
-
}), { children: (0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !scCourse.created_by.community_badge, smaller: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: scCourse.name, src: scCourse.created_by.avatar, className: classes.previewAvatar }) })) }))] })), (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.previewContent }, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ className: classes.previewCreator }, (!scCourse.created_by.deleted && {
|
|
156
|
+
}), { children: (0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !((_b = scCourse.created_by) === null || _b === void 0 ? void 0 : _b.community_badge), smaller: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: scCourse.name, src: (_c = scCourse.created_by) === null || _c === void 0 ? void 0 : _c.avatar, className: classes.previewAvatar }) })) }))] })), (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.previewContent }, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ className: classes.previewCreator }, (!((_d = scCourse.created_by) === null || _d === void 0 ? void 0 : _d.deleted) && {
|
|
161
157
|
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, scCourse.created_by)
|
|
162
|
-
}), { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: scCourse.created_by.username })) })), (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_ROUTE_NAME, scCourse), className: classes.previewNameWrapper }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6", className: classes.previewName }, { children: scCourse.name })) })), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.previewInfo }, { children: [(0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: scCourse.privacy ? `ui.course.privacy.${scCourse.privacy}` : 'ui.course.privacy.draft', defaultMessage: scCourse.privacy ? `ui.course.privacy.${scCourse.privacy}` : 'ui.course.privacy.draft' }), "-", (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.course.type.${scCourse.type}`, defaultMessage: `ui.course.type.${scCourse.type}` })] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.previewCategory }, { children: scCourse.categories.map((category) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", label: category.name }, category.id))) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.previewProgress }, { children: renderProgress() }))] })), actions !== null && actions !== void 0 ? actions : ((0, jsx_runtime_1.jsx)(material_1.CardActions, Object.assign({ className: classes.previewActions }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "outlined", size: "small", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_ROUTE_NAME, scCourse) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.course.see
|
|
158
|
+
}), { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (_e = scCourse.created_by) === null || _e === void 0 ? void 0 : _e.username })) })), (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_ROUTE_NAME, scCourse), className: classes.previewNameWrapper }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6", className: classes.previewName }, { children: scCourse.name })) })), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.previewInfo }, { children: [(0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: scCourse.privacy ? `ui.course.privacy.${scCourse.privacy}` : 'ui.course.privacy.draft', defaultMessage: scCourse.privacy ? `ui.course.privacy.${scCourse.privacy}` : 'ui.course.privacy.draft' }), "-", (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.course.type.${scCourse.type}`, defaultMessage: `ui.course.type.${scCourse.type}` })] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.previewCategory }, { children: scCourse.categories.map((category) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", label: category.name }, category.id))) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.previewProgress }, { children: renderProgress() }))] })), actions !== null && actions !== void 0 ? actions : ((0, jsx_runtime_1.jsx)(material_1.CardActions, Object.assign({ className: classes.previewActions }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "outlined", size: "small", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_ROUTE_NAME, scCourse) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.course.see", id: "ui.course.see" }) })) })))] })));
|
|
163
159
|
}
|
|
164
160
|
else {
|
|
165
|
-
contentObj = ((0, jsx_runtime_1.jsx)(SnippetRoot, { elevation: 0, className: classes.snippetRoot, image: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.snippetImage }, { children: [(0, jsx_runtime_1.jsx)(material_1.Avatar, { variant: "square", alt: scCourse.name, src: scCourse.image_medium, className: classes.snippetAvatar }), (isCourseAdmin || (0, course_2.isCourseCompleted)(scCourse) || (0, course_2.isCourseNew)(scCourse)) && ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", component: "div", color: (0, course_2.isCourseCompleted)(scCourse) || (isCourseAdmin && scCourse.privacy)
|
|
161
|
+
contentObj = ((0, jsx_runtime_1.jsx)(SnippetRoot, { elevation: 0, className: classes.snippetRoot, image: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.snippetImage }, { children: [(0, jsx_runtime_1.jsx)(material_1.Avatar, { variant: "square", alt: scCourse.name, src: scCourse.image_medium, className: userProfileSnippet ? classes.snippetAvatarUserProfile : classes.snippetAvatar }), !userProfileSnippet && (isCourseAdmin || (0, course_2.isCourseCompleted)(scCourse) || (0, course_2.isCourseNew)(scCourse)) && ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", component: "div", color: (0, course_2.isCourseCompleted)(scCourse) || (isCourseAdmin && scCourse.privacy)
|
|
166
162
|
? 'primary'
|
|
167
163
|
: isCourseAdmin && !scCourse.privacy
|
|
168
164
|
? 'default'
|
|
169
|
-
: 'secondary', label: chipLabel, className: classes.chip }))] })), primary: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!scCourse.created_by.deleted && {
|
|
165
|
+
: 'secondary', label: chipLabel, className: classes.chip }))] })), primary: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [!userProfileSnippet && ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!((_f = scCourse.created_by) === null || _f === void 0 ? void 0 : _f.deleted) && {
|
|
170
166
|
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, scCourse.created_by)
|
|
171
|
-
}), {
|
|
167
|
+
}), { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ component: "span" }, { children: (_g = scCourse.created_by) === null || _g === void 0 ? void 0 : _g.username })) }))), (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_ROUTE_NAME, scCourse) }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: scCourse.name })) }))] }), secondary: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: userProfileSnippet ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !scCourse.hide_member_count && ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.userProfileSnippet.students", defaultMessage: "ui.course.userProfileSnippet.students", values: { students: scCourse.member_count } })) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: scCourse.privacy ? `ui.course.privacy.${scCourse.privacy}` : 'ui.course.privacy.draft', defaultMessage: scCourse.privacy ? `ui.course.privacy.${scCourse.privacy}` : 'ui.course.privacy.draft' }), "-", (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.course.type.${scCourse.type}`, defaultMessage: `ui.course.type.${scCourse.type}` })] })) }), actions: actions !== null && actions !== void 0 ? actions : ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", variant: "outlined", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_ROUTE_NAME, scCourse) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.course.see", id: "ui.course.see" }) }))) }));
|
|
172
168
|
}
|
|
173
169
|
/**
|
|
174
170
|
* Renders root object
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SCCourseTemplateType } from '../../types/course';
|
|
3
3
|
import { WidgetProps } from '../Widget';
|
|
4
|
+
import { CourseProps } from './Course';
|
|
4
5
|
export interface CourseSkeletonProps extends WidgetProps {
|
|
5
6
|
/**
|
|
6
7
|
* Overrides or extends the styles applied to the component.
|
|
@@ -20,6 +21,10 @@ export interface CourseSkeletonProps extends WidgetProps {
|
|
|
20
21
|
* Prop to pass an action to be rendered next to the skeleton
|
|
21
22
|
*/
|
|
22
23
|
actions?: React.ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* CourseProps
|
|
26
|
+
*/
|
|
27
|
+
CourseProps?: CourseProps;
|
|
23
28
|
}
|
|
24
29
|
/**
|
|
25
30
|
* > API documentation for the Community-JS Course Skeleton component. Learn about the available props and the CSS API.
|
|
@@ -7,10 +7,10 @@ const Skeleton_1 = tslib_1.__importDefault(require("@mui/material/Skeleton"));
|
|
|
7
7
|
const styles_1 = require("@mui/material/styles");
|
|
8
8
|
const system_1 = require("@mui/system");
|
|
9
9
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
10
|
-
const BaseItem_1 = tslib_1.__importDefault(require("../../shared/BaseItem"));
|
|
11
10
|
const course_1 = require("../../types/course");
|
|
12
11
|
const Widget_1 = tslib_1.__importDefault(require("../Widget"));
|
|
13
12
|
const constants_1 = require("./constants");
|
|
13
|
+
const BaseItemButton_1 = tslib_1.__importDefault(require("../../shared/BaseItemButton"));
|
|
14
14
|
const classes = {
|
|
15
15
|
root: `${constants_1.PREFIX}-skeleton-root`,
|
|
16
16
|
skeletonPreviewRoot: `${constants_1.PREFIX}-skeleton-preview-root`,
|
|
@@ -29,7 +29,7 @@ const SkeletonPreviewRoot = (0, styles_1.styled)(material_1.Box, {
|
|
|
29
29
|
name: constants_1.PREFIX,
|
|
30
30
|
slot: 'SkeletonPreviewRoot'
|
|
31
31
|
})(() => ({}));
|
|
32
|
-
const SkeletonSnippetRoot = (0, styles_1.styled)(
|
|
32
|
+
const SkeletonSnippetRoot = (0, styles_1.styled)(BaseItemButton_1.default, {
|
|
33
33
|
name: constants_1.PREFIX,
|
|
34
34
|
slot: 'SkeletonSnippetRoot'
|
|
35
35
|
})(() => ({}));
|
|
@@ -61,7 +61,7 @@ function CourseSkeleton(inProps) {
|
|
|
61
61
|
props: inProps,
|
|
62
62
|
name: constants_1.PREFIX
|
|
63
63
|
});
|
|
64
|
-
const { className, template, skeletonsAnimation = 'wave', actions } = props, rest = tslib_1.__rest(props, ["className", "template", "skeletonsAnimation", "actions"]);
|
|
64
|
+
const { className, template, skeletonsAnimation = 'wave', actions, CourseProps } = props, rest = tslib_1.__rest(props, ["className", "template", "skeletonsAnimation", "actions", "CourseProps"]);
|
|
65
65
|
/**
|
|
66
66
|
* Renders course object
|
|
67
67
|
*/
|
|
@@ -70,7 +70,7 @@ function CourseSkeleton(inProps) {
|
|
|
70
70
|
contentObj = ((0, jsx_runtime_1.jsxs)(SkeletonPreviewRoot, Object.assign({ className: classes.skeletonPreviewRoot }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ position: "relative" }, { children: [(0, jsx_runtime_1.jsx)(Skeleton_1.default, { variant: "rectangular", animation: skeletonsAnimation, width: "100%", height: "110px" }), (0, jsx_runtime_1.jsx)(Skeleton_1.default, { className: classes.skeletonPreviewAvatar, variant: "rounded", animation: skeletonsAnimation })] })), (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.skeletonPreviewContent }, { children: [(0, jsx_runtime_1.jsx)(Skeleton_1.default, { animation: skeletonsAnimation, width: "20%", height: 14, sx: { marginTop: 1 }, variant: "rectangular" }), (0, jsx_runtime_1.jsx)(Skeleton_1.default, { animation: skeletonsAnimation, width: "40%", height: 14, sx: { marginTop: 1.5 }, variant: "rectangular" }), (0, jsx_runtime_1.jsx)(Skeleton_1.default, { animation: skeletonsAnimation, width: "60%", height: 14, sx: { marginTop: 4.5 }, variant: "rectangular" })] })), (0, jsx_runtime_1.jsx)(material_1.CardActions, Object.assign({ className: classes.skeletonPreviewActions }, { children: actions !== undefined ? actions : (0, jsx_runtime_1.jsx)(Skeleton_1.default, { variant: "rounded", width: 100, height: 30 }) }))] })));
|
|
71
71
|
}
|
|
72
72
|
else {
|
|
73
|
-
contentObj = ((0, jsx_runtime_1.jsx)(SkeletonSnippetRoot, { elevation: 0, square: true, disableTypography: true, className: classes.skeletonSnippetRoot, image: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.skeletonSnippetImage }, { children: [(0, jsx_runtime_1.jsx)(Skeleton_1.default, { animation: skeletonsAnimation, variant: "rectangular", width: 100, height: 60 }),
|
|
73
|
+
contentObj = ((0, jsx_runtime_1.jsx)(SkeletonSnippetRoot, { elevation: 0, square: true, disableTypography: true, className: classes.skeletonSnippetRoot, image: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.skeletonSnippetImage }, { children: [(0, jsx_runtime_1.jsx)(Skeleton_1.default, { animation: skeletonsAnimation, variant: "rectangular", width: (CourseProps === null || CourseProps === void 0 ? void 0 : CourseProps.userProfileSnippet) ? 60 : 100, height: 60 }), (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "large" }, { children: "courses" }))] })), primary: (CourseProps === null || CourseProps === void 0 ? void 0 : CourseProps.userProfileSnippet) ? ((0, jsx_runtime_1.jsx)(Skeleton_1.default, { animation: skeletonsAnimation, variant: "rectangular", height: 10, width: 120, style: { marginBottom: 10 } })) : ((0, jsx_runtime_1.jsx)(Skeleton_1.default, { animation: skeletonsAnimation, variant: "rectangular", height: 10, width: 40, style: { marginBottom: 12 } })), secondary: (CourseProps === null || CourseProps === void 0 ? void 0 : CourseProps.userProfileSnippet) ? ((0, jsx_runtime_1.jsx)(Skeleton_1.default, { animation: skeletonsAnimation, variant: "rectangular", height: 10, width: 60 })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Skeleton_1.default, { animation: skeletonsAnimation, variant: "rectangular", height: 10, width: 120, style: { marginBottom: 10 } }), (0, jsx_runtime_1.jsx)(Skeleton_1.default, { animation: skeletonsAnimation, variant: "rectangular", height: 10, width: 60 })] })), actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: actions !== undefined ? (actions) : ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", variant: "outlined", disabled: true }, { children: (0, jsx_runtime_1.jsx)(Skeleton_1.default, { animation: skeletonsAnimation, height: 15, width: 60 }) }))) }) }));
|
|
74
74
|
}
|
|
75
75
|
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className, `${constants_1.PREFIX}-skeleton-${template}`) }, rest, { children: contentObj })));
|
|
76
76
|
}
|
|
@@ -19,15 +19,20 @@ const Errors_1 = require("../../constants/Errors");
|
|
|
19
19
|
const notistack_1 = require("notistack");
|
|
20
20
|
const Skeleton_1 = tslib_1.__importDefault(require("./Student/Skeleton"));
|
|
21
21
|
const UserAvatar_1 = tslib_1.__importDefault(require("../../shared/UserAvatar"));
|
|
22
|
-
const
|
|
23
|
-
const messages = {
|
|
22
|
+
const BUTTON_MESSAGES = {
|
|
24
23
|
dashboard: 'ui.course.dashboard.student.button.dashboard',
|
|
25
24
|
request: 'ui.course.dashboard.student.button.request',
|
|
25
|
+
signUp: 'ui.course.dashboard.student.button.signUp',
|
|
26
26
|
review: 'ui.course.dashboard.student.button.review',
|
|
27
27
|
cancel: 'ui.course.dashboard.student.button.cancel',
|
|
28
28
|
start: 'ui.course.dashboard.student.button.start',
|
|
29
29
|
continue: 'ui.course.dashboard.student.button.continue'
|
|
30
30
|
};
|
|
31
|
+
const SNACKBAR_MESSAGES = {
|
|
32
|
+
cancel: 'ui.course.dashboard.student.snackbar.success.cancel',
|
|
33
|
+
enroll: 'ui.course.dashboard.student.snackbar.success.enroll',
|
|
34
|
+
request: 'ui.course.dashboard.student.snackbar.success.request'
|
|
35
|
+
};
|
|
31
36
|
const classes = {
|
|
32
37
|
root: `${constants_1.PREFIX}-root`,
|
|
33
38
|
studentContainer: `${constants_1.PREFIX}-student-container`,
|
|
@@ -93,7 +98,7 @@ function Student(inProps) {
|
|
|
93
98
|
// CONTEXTS
|
|
94
99
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
95
100
|
// HOOKS
|
|
96
|
-
const { scCourse } = (0, react_core_1.useSCFetchCourse)({ id: courseId, course });
|
|
101
|
+
const { scCourse, setSCCourse } = (0, react_core_1.useSCFetchCourse)({ id: courseId, course });
|
|
97
102
|
const intl = (0, react_intl_1.useIntl)();
|
|
98
103
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
99
104
|
// PAYMENTS
|
|
@@ -108,20 +113,24 @@ function Student(inProps) {
|
|
|
108
113
|
const handleRequest = (0, react_1.useCallback)(() => {
|
|
109
114
|
setLoadingRequest(true);
|
|
110
115
|
let request;
|
|
116
|
+
let updatedCourse;
|
|
111
117
|
if (sentRequest) {
|
|
112
118
|
request = api_services_1.CourseService.leaveOrRemoveCourseRequest(scCourse.id);
|
|
119
|
+
updatedCourse = Object.assign(Object.assign({}, scCourse), { join_status: null });
|
|
113
120
|
}
|
|
114
121
|
else {
|
|
115
122
|
request = api_services_1.CourseService.joinOrAcceptInviteToCourse(scCourse.id);
|
|
123
|
+
updatedCourse = Object.assign(Object.assign({}, scCourse), { join_status: scCourse.privacy === types_1.SCCoursePrivacyType.PRIVATE ? types_1.SCCourseJoinStatusType.REQUESTED : types_1.SCCourseJoinStatusType.JOINED });
|
|
116
124
|
}
|
|
117
125
|
request
|
|
118
126
|
.then(() => {
|
|
119
|
-
|
|
127
|
+
setSCCourse(updatedCourse);
|
|
128
|
+
setSentRequest((prev) => !prev);
|
|
129
|
+
setLoadingRequest(false);
|
|
130
|
+
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: sentRequest ? SNACKBAR_MESSAGES.request : scCourse.join_status === null ? SNACKBAR_MESSAGES.enroll : SNACKBAR_MESSAGES.cancel, defaultMessage: sentRequest ? SNACKBAR_MESSAGES.request : scCourse.join_status === null ? SNACKBAR_MESSAGES.enroll : SNACKBAR_MESSAGES.cancel }), {
|
|
120
131
|
variant: 'success',
|
|
121
132
|
autoHideDuration: 3000
|
|
122
133
|
});
|
|
123
|
-
setSentRequest((prev) => !prev);
|
|
124
|
-
setLoadingRequest(false);
|
|
125
134
|
})
|
|
126
135
|
.catch((error) => {
|
|
127
136
|
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.common.error.action", defaultMessage: "ui.common.error.action" }), {
|
|
@@ -133,18 +142,21 @@ function Student(inProps) {
|
|
|
133
142
|
}, [scCourse, sentRequest, setLoadingRequest]);
|
|
134
143
|
// MEMOS
|
|
135
144
|
const actionButton = (0, react_1.useMemo)(() => {
|
|
136
|
-
var _a, _b
|
|
145
|
+
var _a, _b;
|
|
137
146
|
if (!scCourse) {
|
|
138
147
|
return (0, jsx_runtime_1.jsx)(material_1.Skeleton, { animation: "wave", variant: "rectangular", width: "130px", height: "20px" });
|
|
139
148
|
}
|
|
140
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.actionsWrapper }, { children: [(scCourse.join_status === types_1.SCCourseJoinStatusType.CREATOR || scCourse.join_status === types_1.SCCourseJoinStatusType.MANAGER) && ((0, jsx_runtime_1.jsx)(ActionButton_1.default, { labelId:
|
|
141
|
-
(scCourse.join_status === types_1.SCCourseJoinStatusType.MANAGER ||
|
|
142
|
-
(scCourse.privacy === types_1.SCCoursePrivacyType.OPEN &&
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
149
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.actionsWrapper }, { children: [(scCourse.join_status === types_1.SCCourseJoinStatusType.CREATOR || scCourse.join_status === types_1.SCCourseJoinStatusType.MANAGER) && ((0, jsx_runtime_1.jsx)(ActionButton_1.default, { labelId: BUTTON_MESSAGES.dashboard, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_DASHBOARD_ROUTE_NAME, scCourse), color: "inherit", variant: "outlined" })), (((scCourse.privacy === types_1.SCCoursePrivacyType.PRIVATE || scCourse.privacy === types_1.SCCoursePrivacyType.SECRET) &&
|
|
150
|
+
(scCourse.join_status === types_1.SCCourseJoinStatusType.MANAGER || scCourse.join_status === types_1.SCCourseJoinStatusType.JOINED)) ||
|
|
151
|
+
(scCourse.privacy === types_1.SCCoursePrivacyType.OPEN && scCourse.join_status !== types_1.SCCourseJoinStatusType.CREATOR)) &&
|
|
152
|
+
(!isPaymentsEnabled || !((_a = scCourse.paywalls) === null || _a === void 0 ? void 0 : _a.length) || (isPaymentsEnabled && ((_b = scCourse.paywalls) === null || _b === void 0 ? void 0 : _b.length) > 0 && scCourse.payment_order)) && ((0, jsx_runtime_1.jsx)(ActionButton_1.default, { labelId: scCourse.join_status === null
|
|
153
|
+
? BUTTON_MESSAGES.signUp
|
|
154
|
+
: scCourse.user_completion_rate === 0
|
|
155
|
+
? BUTTON_MESSAGES.start
|
|
156
|
+
: scCourse.user_completion_rate === 100
|
|
157
|
+
? BUTTON_MESSAGES.review
|
|
158
|
+
: BUTTON_MESSAGES.continue, to: scCourse.join_status !== null ? scRoutingContext.url(react_core_1.SCRoutes.COURSE_LESSON_ROUTE_NAME, getUrlNextLesson(scCourse)) : undefined, disabled: scCourse.join_status !== null ? getIsNextLessonLocked(scCourse) : undefined, color: scCourse.user_completion_rate === 100 ? 'inherit' : undefined, variant: scCourse.user_completion_rate === 100 ? 'outlined' : undefined, loading: scCourse.join_status === null ? loadingRequest : undefined, onClick: scCourse.join_status === null ? handleRequest : undefined })), scCourse.privacy === types_1.SCCoursePrivacyType.PRIVATE &&
|
|
159
|
+
(scCourse.join_status === null || scCourse.join_status === types_1.SCCourseJoinStatusType.REQUESTED) && ((0, jsx_runtime_1.jsx)(ActionButton_1.default, { labelId: sentRequest ? BUTTON_MESSAGES.cancel : BUTTON_MESSAGES.request, color: "inherit", variant: "outlined", loading: loadingRequest, onClick: handleRequest }))] })));
|
|
148
160
|
}, [scCourse, sentRequest, loadingRequest, handleRequest]);
|
|
149
161
|
if (!scCourse) {
|
|
150
162
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
@@ -153,11 +165,12 @@ function Student(inProps) {
|
|
|
153
165
|
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, scCourse.created_by)
|
|
154
166
|
}), { children: (0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !scCourse.created_by.community_badge, smaller: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { className: classes.avatar, src: scCourse.created_by.avatar, alt: scCourse.created_by.username }) })) })), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!scCourse.created_by.deleted && {
|
|
155
167
|
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, scCourse.created_by)
|
|
156
|
-
}), { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: scCourse.created_by.username })) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.header.user.creator", defaultMessage: "ui.course.dashboard.header.user.creator" }) }))] })] })), actionButton] })), (0, jsx_runtime_1.jsx)(material_1.Divider, {}), ((scCourse.privacy === types_1.SCCoursePrivacyType.PRIVATE &&
|
|
168
|
+
}), { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: scCourse.created_by.username })) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.header.user.creator", defaultMessage: "ui.course.dashboard.header.user.creator" }) }))] })] })), actionButton] })), (0, jsx_runtime_1.jsx)(material_1.Divider, {}), (((scCourse.privacy === types_1.SCCoursePrivacyType.PRIVATE || scCourse.privacy === types_1.SCCoursePrivacyType.SECRET) &&
|
|
157
169
|
(scCourse.join_status === types_1.SCCourseJoinStatusType.CREATOR ||
|
|
158
170
|
scCourse.join_status === types_1.SCCourseJoinStatusType.MANAGER ||
|
|
159
171
|
scCourse.join_status === types_1.SCCourseJoinStatusType.JOINED)) ||
|
|
160
|
-
scCourse.privacy === types_1.SCCoursePrivacyType.OPEN
|
|
172
|
+
scCourse.privacy === types_1.SCCoursePrivacyType.OPEN ||
|
|
173
|
+
scCourse.privacy === types_1.SCCoursePrivacyType.DRAFT) && ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6", className: classes.margin }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.student.description", defaultMessage: "ui.course.dashboard.student.description" }) })), (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ className: classes.box }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: scCourse.description })) }))] })), (((scCourse.privacy === types_1.SCCoursePrivacyType.PRIVATE || scCourse.privacy === types_1.SCCoursePrivacyType.SECRET) &&
|
|
161
174
|
(scCourse.join_status === types_1.SCCourseJoinStatusType.MANAGER || scCourse.join_status === types_1.SCCourseJoinStatusType.JOINED)) ||
|
|
162
175
|
(scCourse.privacy === types_1.SCCoursePrivacyType.OPEN && scCourse.join_status !== types_1.SCCourseJoinStatusType.CREATOR)) && ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6", className: classes.margin }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.student.progress", defaultMessage: "ui.course.dashboard.student.description" }) })), (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.box }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.percentageWrapper }, { 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.course.dashboard.student.progress.described", defaultMessage: "ui.course.dashboard.student.progress.described", values: { progress: scCourse.num_lessons_completed, end: scCourse.num_lessons } }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.student.progress.percentage", defaultMessage: "ui.course.dashboard.student.progress.percentage", values: { percentage: scCourse.user_completion_rate } }) }))] })), (0, jsx_runtime_1.jsx)(material_1.LinearProgress, { className: classes.progress, variant: "determinate", value: scCourse === null || scCourse === void 0 ? void 0 : scCourse.user_completion_rate })] })), scCourse.user_completion_rate === 100 && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: (0, classnames_1.default)(classes.completedWrapper, classes.margin) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.student.completed", defaultMessage: "ui.course.dashboard.student.completed" }) })), (0, jsx_runtime_1.jsx)("img", { src: clapping_1.CLAPPING, alt: intl.formatMessage({ id: 'ui.course.dashboard.student.completed', defaultMessage: 'ui.course.dashboard.student.completed' }), width: 32, height: 32 })] }))), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6", className: classes.margin }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.dashboard.student.contents", defaultMessage: "ui.course.dashboard.student.contents" }) })), (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.lessonsSections }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.course.table.sections.title", defaultMessage: "ui.course.table.sections.title", values: {
|
|
163
176
|
sectionsNumber: scCourse.num_sections
|
|
@@ -97,7 +97,7 @@ const Root = (0, styles_1.styled)(material_1.Box, {
|
|
|
97
97
|
* @param inProps
|
|
98
98
|
*/
|
|
99
99
|
function CourseForm(inProps) {
|
|
100
|
-
var _a, _b, _c;
|
|
100
|
+
var _a, _b, _c, _d;
|
|
101
101
|
//PROPS
|
|
102
102
|
const props = (0, system_1.useThemeProps)({
|
|
103
103
|
props: inProps,
|
|
@@ -186,7 +186,7 @@ function CourseForm(inProps) {
|
|
|
186
186
|
let courseService;
|
|
187
187
|
if (course) {
|
|
188
188
|
// Update
|
|
189
|
-
const data = Object.assign(
|
|
189
|
+
const data = Object.assign({ name: field.name, description: field.description, type: field.type, categories: field.categories }, (field.privacy && { privacy: field.privacy }));
|
|
190
190
|
courseService = api_services_1.CourseService.updateCourse(course.id, data, {
|
|
191
191
|
headers: { 'Content-Type': 'application/json' }
|
|
192
192
|
});
|
|
@@ -248,11 +248,11 @@ function CourseForm(inProps) {
|
|
|
248
248
|
/**
|
|
249
249
|
* Renders root object
|
|
250
250
|
*/
|
|
251
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: _step === Course_1.SCCourseFormStepType.GENERAL ? classes.stepOne : classes.stepTwo }, { children: [_step === Course_1.SCCourseFormStepType.GENERAL && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: Object.values(types_1.SCCourseTypologyType).map((option, index) => ((0, jsx_runtime_1.jsx)(material_1.Card, Object.assign({ className: (0, classnames_1.default)(classes.card, { [classes.selected]: option === field.type }) }, { children: (0, jsx_runtime_1.jsx)(material_1.CardActionArea, Object.assign({ onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['type']: option }))) }, { children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "subtitle2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.courseForm.${option}.title`, defaultMessage: `ui.courseForm.${option}.title` }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.courseForm.${option}.info`, defaultMessage: `ui.courseForm.${option}.info` }) }))] }) })) }), index))) })), _step === Course_1.SCCourseFormStepType.CUSTOMIZATION && ((0, jsx_runtime_1.jsxs)(material_1.FormGroup, Object.assign({ className: classes.form }, { children: [course && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.courseForm.edit.title.general", defaultMessage: "ui.courseForm.edit.title.general" }) }))), (0, jsx_runtime_1.jsx)(material_1.Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: (0, jsx_runtime_1.jsx)(UploadCourseCover_1.default, { isCreationMode:
|
|
251
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: _step === Course_1.SCCourseFormStepType.GENERAL ? classes.stepOne : classes.stepTwo }, { children: [_step === Course_1.SCCourseFormStepType.GENERAL && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: Object.values(types_1.SCCourseTypologyType).map((option, index) => ((0, jsx_runtime_1.jsx)(material_1.Card, Object.assign({ className: (0, classnames_1.default)(classes.card, { [classes.selected]: option === field.type }) }, { children: (0, jsx_runtime_1.jsx)(material_1.CardActionArea, Object.assign({ onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['type']: option }))) }, { children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "subtitle2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.courseForm.${option}.title`, defaultMessage: `ui.courseForm.${option}.title` }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.courseForm.${option}.info`, defaultMessage: `ui.courseForm.${option}.info` }) }))] }) })) }), index))) })), _step === Course_1.SCCourseFormStepType.CUSTOMIZATION && ((0, jsx_runtime_1.jsxs)(material_1.FormGroup, Object.assign({ className: classes.form }, { children: [course && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.courseForm.edit.title.general", defaultMessage: "ui.courseForm.edit.title.general" }) }))), (0, jsx_runtime_1.jsx)(material_1.Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: (0, jsx_runtime_1.jsx)(UploadCourseCover_1.default, { courseId: (_a = course === null || course === void 0 ? void 0 : course.id) !== null && _a !== void 0 ? _a : null, isCreationMode: !course, onChange: handleChangeCover }) })), (0, jsx_runtime_1.jsx)(material_1.TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
|
|
252
252
|
endAdornment: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: Course_1.COURSE_TITLE_MAX_LENGTH - field.name.length }))
|
|
253
253
|
}, error: Boolean(field.name.length > Course_1.COURSE_TITLE_MAX_LENGTH) || Boolean(error['nameError']), helperText: field.name.length > Course_1.COURSE_TITLE_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.courseForm.name.error.maxLength", defaultMessage: "ui.courseForm.name.error.maxLength" })) : error['nameError'] ? (error['nameError']) : null }), (0, jsx_runtime_1.jsx)(material_1.TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
|
|
254
|
-
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((
|
|
255
|
-
}, error: Boolean(((
|
|
254
|
+
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((_b = field.description) === null || _b === void 0 ? void 0 : _b.length) ? Course_1.COURSE_DESCRIPTION_MAX_LENGTH - field.description.length : Course_1.COURSE_DESCRIPTION_MAX_LENGTH })))
|
|
255
|
+
}, error: Boolean(((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) > Course_1.COURSE_DESCRIPTION_MAX_LENGTH), helperText: ((_d = field.description) === null || _d === void 0 ? void 0 : _d.length) > Course_1.COURSE_DESCRIPTION_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.courseForm.description.error.maxLength", defaultMessage: "ui.courseForm.description.error.maxLength" })) : null }), (0, jsx_runtime_1.jsx)(CategoryAutocomplete_1.default, { defaultValue: field.categories, TextFieldProps: { label: intl.formatMessage(Object.keys(field.categories).length ? messages.category : messages.categoryEmpty) }, multiple: true, onChange: handleOnChangeCategory }), course && (0, jsx_runtime_1.jsx)(Edit_1.default, { course: course, onPrivacyChange: (privacy) => setField((prev) => (Object.assign(Object.assign({}, prev), { ['privacy']: privacy }))) })] }))), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.actions }, { children: (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ size: "small", loading: field.isSubmitting, disabled: _step === Course_1.SCCourseFormStepType.GENERAL
|
|
256
256
|
? !field.type || Object.keys(error).length !== 0
|
|
257
257
|
: _step === Course_1.SCCourseFormStepType.CUSTOMIZATION &&
|
|
258
258
|
(!field.name ||
|
|
@@ -57,7 +57,7 @@ function UploadCourseCover(inProps) {
|
|
|
57
57
|
props: inProps,
|
|
58
58
|
name: constants_1.PREFIX
|
|
59
59
|
});
|
|
60
|
-
const { courseId, onChange, className = false, isCreationMode = false } = props, rest = tslib_1.__rest(props, ["courseId", "onChange", "className", "isCreationMode"]);
|
|
60
|
+
const { courseId = null, onChange, className = false, isCreationMode = false } = props, rest = tslib_1.__rest(props, ["courseId", "onChange", "className", "isCreationMode"]);
|
|
61
61
|
//CONTEXT
|
|
62
62
|
const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
|
|
63
63
|
//STATE
|
|
@@ -72,40 +72,44 @@ function UploadCourseCover(inProps) {
|
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* Handles file upload
|
|
75
|
-
* @param
|
|
75
|
+
* @param event
|
|
76
76
|
*/
|
|
77
|
-
const handleUpload = (
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
77
|
+
const handleUpload = (event) => {
|
|
78
|
+
const selectedFile = event.target.files[0];
|
|
79
|
+
if (!selectedFile)
|
|
80
|
+
return;
|
|
81
|
+
fileInput = selectedFile;
|
|
82
|
+
const reader = new FileReader();
|
|
83
|
+
reader.onload = (e) => {
|
|
84
|
+
const img = new Image();
|
|
85
|
+
img.onload = () => {
|
|
86
|
+
if (isCreationMode) {
|
|
87
|
+
onChange(fileInput);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
onChange(fileInput);
|
|
91
|
+
handleSave();
|
|
92
|
+
}
|
|
89
93
|
};
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
+
img.src = e.target.result;
|
|
95
|
+
};
|
|
96
|
+
reader.readAsDataURL(selectedFile);
|
|
94
97
|
};
|
|
95
98
|
/**
|
|
96
99
|
* Handles cover saving after upload action
|
|
97
100
|
*/
|
|
98
101
|
function handleSave() {
|
|
102
|
+
if (!fileInput) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
99
105
|
setLoading(true);
|
|
100
106
|
const formData = new FormData();
|
|
101
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
102
108
|
// @ts-ignore
|
|
103
109
|
formData.append('image_original', fileInput);
|
|
104
110
|
api_services_1.CourseService.changeCourseCover(courseId, formData, { headers: { 'Content-Type': 'multipart/form-data' } })
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
106
|
-
// @ts-ignore
|
|
107
111
|
.then((data) => {
|
|
108
|
-
onChange && onChange(data.image_medium);
|
|
112
|
+
// onChange && onChange(data.image_medium);
|
|
109
113
|
setLoading(false);
|
|
110
114
|
})
|
|
111
115
|
.catch((error) => {
|
|
@@ -25,12 +25,12 @@ function FieldName(props) {
|
|
|
25
25
|
const { endpoint, row, isNewRow, handleManageRow, editMode, handleDisableEditMode } = props;
|
|
26
26
|
// STATES
|
|
27
27
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
28
|
-
const [name, setName] = (0, react_1.useState)(
|
|
28
|
+
const [name, setName] = (0, react_1.useState)(row.name);
|
|
29
29
|
// HOOKS
|
|
30
30
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
31
31
|
// DEBOUNCE
|
|
32
|
-
const debounceSetData = (0, material_1.debounce)((
|
|
33
|
-
setName(
|
|
32
|
+
const debounceSetData = (0, material_1.debounce)((newName) => {
|
|
33
|
+
setName(newName);
|
|
34
34
|
}, 300);
|
|
35
35
|
// HANDLERS
|
|
36
36
|
const handleChange = (0, react_1.useCallback)((e) => {
|
|
@@ -17,6 +17,7 @@ const react_core_1 = require("@selfcommunity/react-core");
|
|
|
17
17
|
const Errors_1 = require("../../../constants/Errors");
|
|
18
18
|
const types_1 = require("../types");
|
|
19
19
|
const hooks_1 = require("../hooks");
|
|
20
|
+
const ConfirmDialog_1 = tslib_1.__importDefault(require("../../../shared/ConfirmDialog/ConfirmDialog"));
|
|
20
21
|
const classes = {
|
|
21
22
|
cellWidth: `${constants_1.PREFIX}-cell-width`,
|
|
22
23
|
cellAlignRight: `${constants_1.PREFIX}-cell-align-right`,
|
|
@@ -37,13 +38,14 @@ function LessonRow(props) {
|
|
|
37
38
|
const { provider, course, section, lesson, isNewRow, handleManageLesson } = props;
|
|
38
39
|
// STATES
|
|
39
40
|
const [editMode, setEditMode] = (0, react_1.useState)(false);
|
|
41
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
40
42
|
// CONTEXTS
|
|
41
43
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
42
44
|
// HOOKS
|
|
43
45
|
const { isDisabled } = (0, hooks_1.useDisabled)();
|
|
44
46
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
45
47
|
// HANDLERS
|
|
46
|
-
const handleAbleEditMode = (0, react_1.useCallback)(() => setTimeout(() => setEditMode(true)), [setEditMode]);
|
|
48
|
+
const handleAbleEditMode = (0, react_1.useCallback)(() => setTimeout(() => setEditMode(true), 100), [setEditMode]);
|
|
47
49
|
const handleDisableEditMode = (0, react_1.useCallback)(() => setEditMode(false), [setEditMode]);
|
|
48
50
|
const handleDeleteLesson = (0, react_1.useCallback)(() => {
|
|
49
51
|
api_services_1.CourseService.deleteCourseLesson(course.id, section.id, lesson.id)
|
|
@@ -62,11 +64,14 @@ function LessonRow(props) {
|
|
|
62
64
|
});
|
|
63
65
|
});
|
|
64
66
|
}, [course, section, lesson, handleManageLesson]);
|
|
67
|
+
const handleOpenDialog = (0, react_1.useCallback)(() => {
|
|
68
|
+
setOpen((prev) => !prev);
|
|
69
|
+
}, [setOpen]);
|
|
65
70
|
return ((0, jsx_runtime_1.jsxs)(material_1.TableRow, Object.assign({}, provider.draggableProps, { ref: provider.innerRef }, { children: [(0, jsx_runtime_1.jsx)(material_1.TableCell, { width: "4%" }), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ component: "th", scope: "row" }, provider.dragHandleProps, { className: (0, classnames_1.default)(classes.cellWidth, classes.cellPadding) }, { children: (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ className: classes.tableBodyIconWrapper }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ color: "disabled" }, { children: "drag" })) })) })), (0, jsx_runtime_1.jsx)(material_1.TableCell, { children: (0, jsx_runtime_1.jsx)(FieldName_1.default, { endpoint: {
|
|
66
71
|
url: () => isNewRow
|
|
67
72
|
? api_services_1.Endpoints.CreateCourseLesson.url({ id: course.id, section_id: section.id })
|
|
68
73
|
: api_services_1.Endpoints.PatchCourseLesson.url({ id: course.id, section_id: section.id, lesson_id: lesson.id }),
|
|
69
74
|
method: isNewRow ? api_services_1.Endpoints.CreateCourseLesson.method : api_services_1.Endpoints.PatchCourseLesson.method
|
|
70
|
-
}, row: lesson, isNewRow: isNewRow, handleManageRow: handleManageLesson, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, {}), (0, jsx_runtime_1.
|
|
75
|
+
}, row: lesson, isNewRow: isNewRow, handleManageRow: handleManageLesson, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, {}), (0, jsx_runtime_1.jsxs)(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)(ChangeLessonStatus_1.default, { course: course, section: section, lesson: lesson, 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({ component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_LESSON_EDIT_ROUTE_NAME, getUrlLesson(course, section, lesson)) }, { 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.edit", defaultMessage: "ui.editCourse.tab.lessons.table.menu.edit" }) })) })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_LESSON_ROUTE_NAME, getUrlLesson(course, section, lesson)) }, { 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.view", defaultMessage: "ui.editCourse.tab.lessons.table.menu.view" }) })) })), (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" }) })) }))] }))] })), open && (0, jsx_runtime_1.jsx)(ConfirmDialog_1.default, { open: true, onClose: handleOpenDialog, onConfirm: handleDeleteLesson })] }))] })));
|
|
71
76
|
}
|
|
72
77
|
exports.default = (0, react_1.memo)(LessonRow);
|