@selfcommunity/react-ui 0.10.2-courses.212 → 0.10.2-courses.213
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/CourseForm/CourseForm.js +2 -2
- package/lib/cjs/components/EditCourse/Lessons/ChangeLessonStatus.d.ts +2 -0
- package/lib/cjs/components/EditCourse/Lessons/ChangeLessonStatus.js +5 -3
- package/lib/cjs/components/EditCourse/Lessons/LessonRow.js +1 -1
- package/lib/cjs/components/EditCourse/Lessons/SectionRow.js +10 -0
- package/lib/cjs/components/EditCourse/types.d.ts +2 -1
- package/lib/cjs/components/EditCourse/types.js +1 -0
- package/lib/cjs/components/EventForm/EventForm.js +13 -7
- package/lib/cjs/components/EventForm/utils.d.ts +1 -0
- package/lib/cjs/components/EventForm/utils.js +6 -1
- package/lib/cjs/components/EventHeader/EventHeader.js +2 -1
- package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.js +1 -1
- package/lib/cjs/components/Footer/Footer.js +9 -6
- package/lib/cjs/components/Footer/constants.d.ts +1 -0
- package/lib/cjs/components/Footer/constants.js +2 -1
- package/lib/esm/components/CourseForm/CourseForm.js +2 -2
- package/lib/esm/components/EditCourse/Lessons/ChangeLessonStatus.d.ts +2 -0
- package/lib/esm/components/EditCourse/Lessons/ChangeLessonStatus.js +5 -3
- package/lib/esm/components/EditCourse/Lessons/LessonRow.js +1 -1
- package/lib/esm/components/EditCourse/Lessons/SectionRow.js +10 -0
- package/lib/esm/components/EditCourse/types.d.ts +2 -1
- package/lib/esm/components/EditCourse/types.js +1 -0
- package/lib/esm/components/EventForm/EventForm.js +14 -8
- package/lib/esm/components/EventForm/utils.d.ts +1 -0
- package/lib/esm/components/EventForm/utils.js +4 -0
- package/lib/esm/components/EventHeader/EventHeader.js +2 -1
- package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.js +1 -1
- package/lib/esm/components/Footer/Footer.js +10 -7
- package/lib/esm/components/Footer/constants.d.ts +1 -0
- package/lib/esm/components/Footer/constants.js +1 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +8 -8
|
@@ -255,9 +255,9 @@ function CourseForm(inProps) {
|
|
|
255
255
|
*/
|
|
256
256
|
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)(react_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 }, { [classes.disabled]: !courseAdvancedEnabled && option !== types_1.SCCourseTypologyType.SELF }) }, { 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.jsxs)(material_1.Typography, Object.assign({ variant: "subtitle2", className: classes.cardTitle }, { children: [(0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.courseForm.${option}.title`, defaultMessage: `ui.courseForm.${option}.title` }), !courseAdvancedEnabled && option !== types_1.SCCourseTypologyType.SELF && ((0, jsx_runtime_1.jsx)(material_1.Chip, { variant: "outlined", color: "warning", size: "small", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.courseForm.comingSoon.chip", defaultMessage: "ui.courseForm.comingSoon.chip" }) }))] })), (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)(react_1.Fragment, { children: [course && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.contrastColor }, { 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.jsxs)(material_1.FormGroup, Object.assign({ className: (0, classnames_1.default)(classes.form, _step === Course_1.SCCourseFormStepType.CUSTOMIZATION && course ? classes.stepCustomization : undefined) }, { children: [(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, { isUploading: field.isSubmitting, 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: {
|
|
257
257
|
endAdornment: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: Course_1.COURSE_TITLE_MAX_LENGTH - field.name.length }))
|
|
258
|
-
}, 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: {
|
|
258
|
+
}, error: Boolean((!!course && !field.name) || field.name.length > Course_1.COURSE_TITLE_MAX_LENGTH) || Boolean(error['nameError']), helperText: !!course && !field.name ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.courseForm.required", defaultMessage: "ui.courseForm.required" })) : 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: {
|
|
259
259
|
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((_a = field.description) === null || _a === void 0 ? void 0 : _a.length) ? Course_1.COURSE_DESCRIPTION_MAX_LENGTH - field.description.length : Course_1.COURSE_DESCRIPTION_MAX_LENGTH })))
|
|
260
|
-
}, error: Boolean(((_b = field.description) === null || _b === void 0 ? void 0 : _b.length) > Course_1.COURSE_DESCRIPTION_MAX_LENGTH), helperText: ((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) > Course_1.COURSE_DESCRIPTION_MAX_LENGTH
|
|
260
|
+
}, error: Boolean((!!field.privacy && !field.description) || ((_b = field.description) === null || _b === void 0 ? void 0 : _b.length) > Course_1.COURSE_DESCRIPTION_MAX_LENGTH), helperText: !!field.privacy && !field.description ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.courseForm.required", defaultMessage: "ui.courseForm.required" })) : (((_c = field.description) === null || _c === void 0 ? void 0 : _c.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" }))) }), (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: (0, classnames_1.default)(classes.actions, _step === Course_1.SCCourseFormStepType.CUSTOMIZATION && course ? classes.stepCustomization : undefined) }, { children: (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ size: "small", loading: field.isSubmitting, disabled: _step === Course_1.SCCourseFormStepType.GENERAL
|
|
261
261
|
? !field.type || Object.keys(error).length !== 0
|
|
262
262
|
: _step === Course_1.SCCourseFormStepType.CUSTOMIZATION &&
|
|
263
263
|
(!field.name ||
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SCCourseLessonType, SCCourseSectionType, SCCourseType } from '@selfcommunity/types';
|
|
3
|
+
import { ActionLessonType } from '../types';
|
|
3
4
|
interface ChangeLessonStatusProps {
|
|
4
5
|
course: SCCourseType;
|
|
5
6
|
section: SCCourseSectionType;
|
|
6
7
|
lesson: SCCourseLessonType;
|
|
8
|
+
onChange: (lesson: SCCourseLessonType, type: ActionLessonType) => void;
|
|
7
9
|
disabled?: boolean;
|
|
8
10
|
}
|
|
9
11
|
declare function ChangeLessonStatus(props: ChangeLessonStatusProps): JSX.Element;
|
|
@@ -13,6 +13,7 @@ const lab_1 = require("@mui/lab");
|
|
|
13
13
|
const notistack_1 = require("notistack");
|
|
14
14
|
const types_1 = require("@selfcommunity/types");
|
|
15
15
|
const api_services_1 = require("@selfcommunity/api-services");
|
|
16
|
+
const types_2 = require("../types");
|
|
16
17
|
const OPTIONS = [
|
|
17
18
|
{
|
|
18
19
|
id: 'ui.editCourse.tab.lessons.table.select.draft',
|
|
@@ -29,9 +30,8 @@ const classes = {
|
|
|
29
30
|
};
|
|
30
31
|
function ChangeLessonStatus(props) {
|
|
31
32
|
// PROPS
|
|
32
|
-
const { course, section, lesson, disabled } = props;
|
|
33
|
+
const { course, section, lesson, onChange, disabled } = props;
|
|
33
34
|
// HOOKS
|
|
34
|
-
// const intl = useIntl();
|
|
35
35
|
const theme = (0, material_1.useTheme)();
|
|
36
36
|
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
37
37
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
@@ -48,13 +48,15 @@ function ChangeLessonStatus(props) {
|
|
|
48
48
|
// HANDLERS
|
|
49
49
|
const handleAction = (0, react_1.useCallback)((newValue) => {
|
|
50
50
|
setLoading(true);
|
|
51
|
+
const newStatus = newValue.endsWith(types_1.SCCourseLessonStatusType.DRAFT) ? types_1.SCCourseLessonStatusType.DRAFT : types_1.SCCourseLessonStatusType.PUBLISHED;
|
|
51
52
|
const data = {
|
|
52
|
-
status:
|
|
53
|
+
status: newStatus
|
|
53
54
|
};
|
|
54
55
|
api_services_1.CourseService.patchCourseLesson(course.id, section.id, lesson.id, data)
|
|
55
56
|
.then(() => {
|
|
56
57
|
setValue(newValue);
|
|
57
58
|
setLoading(false);
|
|
59
|
+
onChange(Object.assign(Object.assign({}, lesson), { status: newStatus }), types_2.ActionLessonType.UPDATE);
|
|
58
60
|
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.editCourse.tab.lessons.table.snackbar.save", defaultMessage: "ui.editCourse.tab.lessons.table.snackbar.save" }), {
|
|
59
61
|
variant: 'success',
|
|
60
62
|
autoHideDuration: 3000
|
|
@@ -63,6 +63,6 @@ function LessonRow(props, ref) {
|
|
|
63
63
|
? api_services_1.Endpoints.CreateCourseLesson.url({ id: course.id, section_id: section.id })
|
|
64
64
|
: api_services_1.Endpoints.PatchCourseLesson.url({ id: course.id, section_id: section.id, lesson_id: lesson.id }),
|
|
65
65
|
method: isNewRow ? api_services_1.Endpoints.CreateCourseLesson.method : api_services_1.Endpoints.PatchCourseLesson.method
|
|
66
|
-
}, row: lesson, isNewRow: isNewRow, handleManageRow: handleManageLesson, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, {}), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ className: classes.cellAlignRight }, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.actionsWrapper }, { children: [(0, jsx_runtime_1.jsx)(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, (0, course_1.getUrlLesson)(course, lesson, section)) }, { 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_PREVIEW_ROUTE_NAME, (0, course_1.getUrlLesson)(course, lesson, section)) }, { 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.preview", defaultMessage: "ui.editCourse.tab.lessons.table.menu.preview" }) })) })), (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" }) })) }))] }))] })) }))] })));
|
|
66
|
+
}, row: lesson, isNewRow: isNewRow, handleManageRow: handleManageLesson, editMode: editMode, handleDisableEditMode: handleDisableEditMode }) }), (0, jsx_runtime_1.jsx)(material_1.TableCell, {}), (0, jsx_runtime_1.jsx)(material_1.TableCell, Object.assign({ className: classes.cellAlignRight }, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.actionsWrapper }, { children: [(0, jsx_runtime_1.jsx)(ChangeLessonStatus_1.default, { course: course, section: section, lesson: lesson, onChange: handleManageLesson, 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, (0, course_1.getUrlLesson)(course, lesson, section)) }, { 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_PREVIEW_ROUTE_NAME, (0, course_1.getUrlLesson)(course, lesson, section)) }, { 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.preview", defaultMessage: "ui.editCourse.tab.lessons.table.menu.preview" }) })) })), (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" }) })) }))] }))] })) }))] })));
|
|
67
67
|
}
|
|
68
68
|
exports.default = (0, react_1.memo)((0, react_1.forwardRef)(LessonRow));
|
|
@@ -131,6 +131,16 @@ function SectionRow(props, ref) {
|
|
|
131
131
|
case types_2.ActionLessonType.DELETE: {
|
|
132
132
|
const tempSection = Object.assign(Object.assign({}, section), { lessons: section.lessons.filter((prevLesson) => prevLesson.id !== lesson.id) });
|
|
133
133
|
handleManageSection(tempSection, types_2.ActionLessonType.DELETE_UPDATE, newRow);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case types_2.ActionLessonType.UPDATE: {
|
|
137
|
+
const tempSection = Object.assign(Object.assign({}, section), { lessons: section.lessons.map((prevLesson) => {
|
|
138
|
+
if (prevLesson.id === lesson.id) {
|
|
139
|
+
return Object.assign(Object.assign({}, prevLesson), { status: lesson.status });
|
|
140
|
+
}
|
|
141
|
+
return prevLesson;
|
|
142
|
+
}) });
|
|
143
|
+
handleManageSection(tempSection, types_2.ActionLessonType.UPDATE_UPDATE);
|
|
134
144
|
}
|
|
135
145
|
}
|
|
136
146
|
}, [section, handleManageSection]);
|
|
@@ -6,7 +6,8 @@ export declare enum ActionLessonType {
|
|
|
6
6
|
UPDATE = "update",
|
|
7
7
|
ADD_UPDATE = "add_update",
|
|
8
8
|
RENAME_UPDATE = "rename_update",
|
|
9
|
-
DELETE_UPDATE = "delete_update"
|
|
9
|
+
DELETE_UPDATE = "delete_update",
|
|
10
|
+
UPDATE_UPDATE = "update_update"
|
|
10
11
|
}
|
|
11
12
|
export interface OptionsData {
|
|
12
13
|
enforce_lessons_order: boolean;
|
|
@@ -10,6 +10,7 @@ var ActionLessonType;
|
|
|
10
10
|
ActionLessonType["ADD_UPDATE"] = "add_update";
|
|
11
11
|
ActionLessonType["RENAME_UPDATE"] = "rename_update";
|
|
12
12
|
ActionLessonType["DELETE_UPDATE"] = "delete_update";
|
|
13
|
+
ActionLessonType["UPDATE_UPDATE"] = "update_update";
|
|
13
14
|
})(ActionLessonType = exports.ActionLessonType || (exports.ActionLessonType = {}));
|
|
14
15
|
var RowType;
|
|
15
16
|
(function (RowType) {
|
|
@@ -324,17 +324,17 @@ function EventForm(inProps) {
|
|
|
324
324
|
let disabled = false;
|
|
325
325
|
switch (field.recurring) {
|
|
326
326
|
case types_1.SCEventRecurrenceType.DAILY:
|
|
327
|
-
disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.DAILY_LATER_DAYS, field.startDate).getTime();
|
|
327
|
+
disabled = date.getTime() > (0, utils_2.getDateAndHours)((0, utils_2.getLaterDaysDate)(constants_1.DAILY_LATER_DAYS, field.startDate), 23, 59, 59, 59).getTime();
|
|
328
328
|
break;
|
|
329
329
|
case types_1.SCEventRecurrenceType.WEEKLY:
|
|
330
|
-
disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.WEEKLY_LATER_DAYS, field.startDate).getTime();
|
|
330
|
+
disabled = date.getTime() > (0, utils_2.getDateAndHours)((0, utils_2.getLaterDaysDate)(constants_1.WEEKLY_LATER_DAYS, field.startDate), 23, 59, 59, 59).getTime();
|
|
331
331
|
break;
|
|
332
332
|
case types_1.SCEventRecurrenceType.MONTHLY:
|
|
333
|
-
disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.MONTHLY_LATER_DAYS, field.startDate).getTime();
|
|
333
|
+
disabled = date.getTime() > (0, utils_2.getDateAndHours)((0, utils_2.getLaterDaysDate)(constants_1.MONTHLY_LATER_DAYS, field.startDate), 23, 59, 59, 59).getTime();
|
|
334
334
|
break;
|
|
335
335
|
case types_1.SCEventRecurrenceType.NEVER:
|
|
336
336
|
default:
|
|
337
|
-
disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.NEVER_LATER_DAYS, field.startDate).getTime();
|
|
337
|
+
disabled = date.getTime() > (0, utils_2.getDateAndHours)((0, utils_2.getLaterDaysDate)(constants_1.NEVER_LATER_DAYS, field.startDate), 23, 59, 59, 59).getTime();
|
|
338
338
|
}
|
|
339
339
|
return disabled;
|
|
340
340
|
}, [field]);
|
|
@@ -365,7 +365,10 @@ function EventForm(inProps) {
|
|
|
365
365
|
// @ts-ignore
|
|
366
366
|
toolbarTitle: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.title", defaultMessage: "ui.eventForm.time.title" })
|
|
367
367
|
}
|
|
368
|
-
}, onChange: (value) =>
|
|
368
|
+
}, onChange: (value) => {
|
|
369
|
+
handleChangeDateTime(value, 'startDate');
|
|
370
|
+
handleChangeDateTime(value, 'startTime');
|
|
371
|
+
} })] })) })), (0, jsx_runtime_1.jsxs)(material_1.FormControl, Object.assign({ className: classes.frequency }, { children: [field.recurring !== types_1.SCEventRecurrenceType.NEVER && (0, jsx_runtime_1.jsx)(material_1.InputLabel, Object.assign({ id: "recurring" }, { children: `${intl.formatMessage(messages.frequency)}` })), (0, jsx_runtime_1.jsx)(material_1.Select, Object.assign({ name: "recurring", label: field.recurring !== types_1.SCEventRecurrenceType.NEVER && `${intl.formatMessage(messages.frequency)}`, labelId: "recurring", value: field.recurring, onChange: handleChange, displayEmpty: true, renderValue: (selected) => {
|
|
369
372
|
if (!selected) {
|
|
370
373
|
return (0, jsx_runtime_1.jsx)("em", { children: `${intl.formatMessage(messages.frequencyPlaceholder)}` });
|
|
371
374
|
}
|
|
@@ -391,13 +394,16 @@ function EventForm(inProps) {
|
|
|
391
394
|
// @ts-ignore
|
|
392
395
|
toolbarTitle: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.title", defaultMessage: "ui.eventForm.time.title" })
|
|
393
396
|
}
|
|
394
|
-
}, onChange: (value) =>
|
|
397
|
+
}, onChange: (value) => {
|
|
398
|
+
handleChangeDateTime(value, 'endDate');
|
|
399
|
+
handleChangeDateTime(value, 'endTime');
|
|
400
|
+
}, shouldDisableTime: shouldDisableTime })] })) })), (0, jsx_runtime_1.jsx)(EventAddress_1.default, Object.assign({ forwardGeolocationData: handleGeoData, forwardLivestreamSettingsData: handleLiveStreamSettingsData, event: Object.assign(Object.assign({}, event), {
|
|
395
401
|
name: field.name,
|
|
396
402
|
start_date: field.startDate,
|
|
397
403
|
location: field.location,
|
|
398
404
|
geolocation: field.geolocation,
|
|
399
405
|
live_stream: Object.assign(Object.assign({ title: field.name || `${intl.formatMessage(messages.name)}` }, (event && ((_c = event.live_stream) === null || _c === void 0 ? void 0 : _c.created_at) && { created_at: field.startDate })), { settings: field.liveStreamSettings })
|
|
400
|
-
}) }, EventAddressComponentProps)), privateEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.privacySection }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), (0, jsx_runtime_1.jsx)(material_1.Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: event
|
|
406
|
+
}) }, EventAddressComponentProps)), privateEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.privacySection }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), (0, jsx_runtime_1.jsx)(material_1.Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: (event === null || event === void 0 ? void 0 : event.privacy) === types_1.SCEventPrivacyType.PRIVATE }), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" })] }))] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, { children: field.isPublic ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
|
|
401
407
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
|
|
402
408
|
// @ts-ignores
|
|
403
409
|
b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
|
|
@@ -2,3 +2,4 @@ export declare function getNewDate(date?: string | Date): Date;
|
|
|
2
2
|
export declare function getLaterHoursDate(hours: number, date?: Date): Date;
|
|
3
3
|
export declare function getLaterDaysDate(days: number, date?: Date): Date;
|
|
4
4
|
export declare const combineDateAndTime: (date: Date, time: Date) => string;
|
|
5
|
+
export declare function getDateAndHours(date: Date, hours: number, min?: number, sec?: number, ms?: number): Date;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.combineDateAndTime = exports.getLaterDaysDate = exports.getLaterHoursDate = exports.getNewDate = void 0;
|
|
3
|
+
exports.getDateAndHours = exports.combineDateAndTime = exports.getLaterDaysDate = exports.getLaterHoursDate = exports.getNewDate = void 0;
|
|
4
4
|
const date_fns_1 = require("date-fns");
|
|
5
5
|
function getNewDate(date) {
|
|
6
6
|
if (date) {
|
|
@@ -29,3 +29,8 @@ const combineDateAndTime = (date, time) => {
|
|
|
29
29
|
return combined.toISOString();
|
|
30
30
|
};
|
|
31
31
|
exports.combineDateAndTime = combineDateAndTime;
|
|
32
|
+
function getDateAndHours(date, hours, min, sec, ms) {
|
|
33
|
+
date.setHours(hours, min, sec, ms);
|
|
34
|
+
return date;
|
|
35
|
+
}
|
|
36
|
+
exports.getDateAndHours = getDateAndHours;
|
|
@@ -20,6 +20,7 @@ const EventSubscribeButton_1 = tslib_1.__importDefault(require("../EventSubscrib
|
|
|
20
20
|
const User_1 = tslib_1.__importDefault(require("../User"));
|
|
21
21
|
const constants_1 = require("./constants");
|
|
22
22
|
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
23
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
23
24
|
const classes = {
|
|
24
25
|
root: `${constants_1.PREFIX}-root`,
|
|
25
26
|
cover: `${constants_1.PREFIX}-cover`,
|
|
@@ -85,7 +86,7 @@ function EventHeader(inProps) {
|
|
|
85
86
|
// CONTEXT
|
|
86
87
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
87
88
|
// HOOKS
|
|
88
|
-
const { scEvent, setSCEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
89
|
+
const { scEvent, setSCEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event, cacheStrategy: utils_1.CacheStrategies.NETWORK_ONLY });
|
|
89
90
|
const theme = (0, material_1.useTheme)();
|
|
90
91
|
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
91
92
|
// INTL
|
|
@@ -98,7 +98,7 @@ function EventSubscribeButton(inProps) {
|
|
|
98
98
|
const { scEvent, setSCEvent } = (0, react_core_1.useSCFetchEvent)({
|
|
99
99
|
id: eventId,
|
|
100
100
|
event,
|
|
101
|
-
cacheStrategy: authUserId ? utils_1.CacheStrategies.
|
|
101
|
+
cacheStrategy: authUserId ? utils_1.CacheStrategies.NETWORK_ONLY : utils_1.CacheStrategies.STALE_WHILE_REVALIDATE
|
|
102
102
|
});
|
|
103
103
|
const isEventAdmin = (0, react_1.useMemo)(() => { var _a; return scUserContext.user && ((_a = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
|
|
104
104
|
// HANDLERS
|
|
@@ -22,7 +22,7 @@ const classes = {
|
|
|
22
22
|
const Root = (0, styles_1.styled)(material_1.Box, {
|
|
23
23
|
name: constants_1.PREFIX,
|
|
24
24
|
slot: 'Root'
|
|
25
|
-
})((
|
|
25
|
+
})(() => ({}));
|
|
26
26
|
/**
|
|
27
27
|
* > API documentation for the Community-JS Footer component. Learn about the available props and the CSS API.
|
|
28
28
|
*
|
|
@@ -57,12 +57,13 @@ function Footer(inProps) {
|
|
|
57
57
|
});
|
|
58
58
|
const { className, menu = null, startActions = null, endActions = null } = props, rest = tslib_1.__rest(props, ["className", "menu", "startActions", "endActions"]);
|
|
59
59
|
// PREFERENCES
|
|
60
|
-
const
|
|
60
|
+
const { preferences } = (0, react_core_1.useSCPreferences)();
|
|
61
61
|
const copyright = (0, react_1.useMemo)(() => {
|
|
62
|
-
return
|
|
63
|
-
?
|
|
62
|
+
return preferences && react_core_1.SCPreferences.TEXT_APPLICATION_COPYRIGHT in preferences
|
|
63
|
+
? preferences[react_core_1.SCPreferences.TEXT_APPLICATION_COPYRIGHT].value.replace('$year', new Date().getFullYear())
|
|
64
64
|
: null;
|
|
65
|
-
}, [
|
|
65
|
+
}, [preferences]);
|
|
66
|
+
const exploreStreamEnabled = preferences[react_core_1.SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value;
|
|
66
67
|
// STATE
|
|
67
68
|
const [_menu, setMenu] = (0, react_1.useState)(menu);
|
|
68
69
|
const [loading, setLoading] = (0, react_1.useState)(!menu);
|
|
@@ -95,6 +96,8 @@ function Footer(inProps) {
|
|
|
95
96
|
if (loading) {
|
|
96
97
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
97
98
|
}
|
|
98
|
-
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({}, rest, { className: (0, classnames_1.default)(classes.root, className) }, { children: [startActions, (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.itemList }, { children: (0, utils_1.sortByAttr)(_menu.items, 'order')
|
|
99
|
+
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({}, rest, { className: (0, classnames_1.default)(classes.root, className) }, { children: [startActions, (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.itemList }, { children: (0, utils_1.sortByAttr)(_menu.items, 'order')
|
|
100
|
+
.filter((item) => exploreStreamEnabled || item.url !== constants_1.EXPLORE_MENU_ITEM)
|
|
101
|
+
.map((item, index) => ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ component: react_core_1.Link, className: classes.item, to: item.url, variant: "text" }, { children: item.label }), item.id))) })), endActions, (0, jsx_runtime_1.jsx)(material_1.Typography, { textAlign: "center", className: classes.copyright, variant: "body2", dangerouslySetInnerHTML: { __html: copyright } })] })));
|
|
99
102
|
}
|
|
100
103
|
exports.default = Footer;
|
|
@@ -253,9 +253,9 @@ export default function CourseForm(inProps) {
|
|
|
253
253
|
*/
|
|
254
254
|
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 && (_jsx(Fragment, { children: 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: classes.cardTitle }, { 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" }, { 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.contrastColor }, { 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, InputProps: {
|
|
255
255
|
endAdornment: _jsx(Typography, Object.assign({ variant: "body2" }, { children: COURSE_TITLE_MAX_LENGTH - field.name.length }))
|
|
256
|
-
}, error: Boolean(field.name.length > COURSE_TITLE_MAX_LENGTH) || Boolean(error['nameError']), helperText: 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, InputProps: {
|
|
256
|
+
}, 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, InputProps: {
|
|
257
257
|
endAdornment: (_jsx(Typography, Object.assign({ variant: "body2" }, { children: ((_a = field.description) === null || _a === void 0 ? void 0 : _a.length) ? COURSE_DESCRIPTION_MAX_LENGTH - field.description.length : COURSE_DESCRIPTION_MAX_LENGTH })))
|
|
258
|
-
}, error: Boolean(((_b = field.description) === null || _b === void 0 ? void 0 : _b.length) > COURSE_DESCRIPTION_MAX_LENGTH), helperText: ((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) > COURSE_DESCRIPTION_MAX_LENGTH
|
|
258
|
+
}, error: Boolean((!!field.privacy && !field.description) || ((_b = field.description) === null || _b === void 0 ? void 0 : _b.length) > COURSE_DESCRIPTION_MAX_LENGTH), helperText: !!field.privacy && !field.description ? (_jsx(FormattedMessage, { id: "ui.courseForm.required", defaultMessage: "ui.courseForm.required" })) : (((_c = field.description) === null || _c === void 0 ? void 0 : _c.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: { label: intl.formatMessage(Object.keys(field.categories).length ? messages.category : messages.categoryEmpty) }, multiple: true, onChange: handleOnChangeCategory }), course && _jsx(CourseEdit, { course: course, onPrivacyChange: (privacy) => setField((prev) => (Object.assign(Object.assign({}, prev), { ['privacy']: privacy }))) })] }))] })), _jsx(Box, Object.assign({ className: classNames(classes.actions, _step === SCCourseFormStepType.CUSTOMIZATION && course ? classes.stepCustomization : undefined) }, { children: _jsx(LoadingButton, Object.assign({ size: "small", loading: field.isSubmitting, disabled: _step === SCCourseFormStepType.GENERAL
|
|
259
259
|
? !field.type || Object.keys(error).length !== 0
|
|
260
260
|
: _step === SCCourseFormStepType.CUSTOMIZATION &&
|
|
261
261
|
(!field.name ||
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SCCourseLessonType, SCCourseSectionType, SCCourseType } from '@selfcommunity/types';
|
|
3
|
+
import { ActionLessonType } from '../types';
|
|
3
4
|
interface ChangeLessonStatusProps {
|
|
4
5
|
course: SCCourseType;
|
|
5
6
|
section: SCCourseSectionType;
|
|
6
7
|
lesson: SCCourseLessonType;
|
|
8
|
+
onChange: (lesson: SCCourseLessonType, type: ActionLessonType) => void;
|
|
7
9
|
disabled?: boolean;
|
|
8
10
|
}
|
|
9
11
|
declare function ChangeLessonStatus(props: ChangeLessonStatusProps): JSX.Element;
|
|
@@ -10,6 +10,7 @@ import { LoadingButton } from '@mui/lab';
|
|
|
10
10
|
import { useSnackbar } from 'notistack';
|
|
11
11
|
import { SCCourseLessonStatusType } from '@selfcommunity/types';
|
|
12
12
|
import { CourseService } from '@selfcommunity/api-services';
|
|
13
|
+
import { ActionLessonType } from '../types';
|
|
13
14
|
const OPTIONS = [
|
|
14
15
|
{
|
|
15
16
|
id: 'ui.editCourse.tab.lessons.table.select.draft',
|
|
@@ -26,9 +27,8 @@ const classes = {
|
|
|
26
27
|
};
|
|
27
28
|
function ChangeLessonStatus(props) {
|
|
28
29
|
// PROPS
|
|
29
|
-
const { course, section, lesson, disabled } = props;
|
|
30
|
+
const { course, section, lesson, onChange, disabled } = props;
|
|
30
31
|
// HOOKS
|
|
31
|
-
// const intl = useIntl();
|
|
32
32
|
const theme = useTheme();
|
|
33
33
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
34
34
|
const { enqueueSnackbar } = useSnackbar();
|
|
@@ -45,13 +45,15 @@ function ChangeLessonStatus(props) {
|
|
|
45
45
|
// HANDLERS
|
|
46
46
|
const handleAction = useCallback((newValue) => {
|
|
47
47
|
setLoading(true);
|
|
48
|
+
const newStatus = newValue.endsWith(SCCourseLessonStatusType.DRAFT) ? SCCourseLessonStatusType.DRAFT : SCCourseLessonStatusType.PUBLISHED;
|
|
48
49
|
const data = {
|
|
49
|
-
status:
|
|
50
|
+
status: newStatus
|
|
50
51
|
};
|
|
51
52
|
CourseService.patchCourseLesson(course.id, section.id, lesson.id, data)
|
|
52
53
|
.then(() => {
|
|
53
54
|
setValue(newValue);
|
|
54
55
|
setLoading(false);
|
|
56
|
+
onChange(Object.assign(Object.assign({}, lesson), { status: newStatus }), ActionLessonType.UPDATE);
|
|
55
57
|
enqueueSnackbar(_jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons.table.snackbar.save", defaultMessage: "ui.editCourse.tab.lessons.table.snackbar.save" }), {
|
|
56
58
|
variant: 'success',
|
|
57
59
|
autoHideDuration: 3000
|
|
@@ -60,6 +60,6 @@ function LessonRow(props, ref) {
|
|
|
60
60
|
? Endpoints.CreateCourseLesson.url({ id: course.id, section_id: section.id })
|
|
61
61
|
: Endpoints.PatchCourseLesson.url({ id: course.id, section_id: section.id, lesson_id: lesson.id }),
|
|
62
62
|
method: isNewRow ? Endpoints.CreateCourseLesson.method : Endpoints.PatchCourseLesson.method
|
|
63
|
-
}, 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, 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" }, { 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" }, { 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" }, { children: _jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.rename", defaultMessage: "ui.editCourse.tab.lessons.table.menu.rename" }) })) })), _jsx(MenuItem, Object.assign({ onClick: handleOpenDialog }, { children: _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.delete", defaultMessage: "ui.editCourse.tab.lessons.table.menu.delete" }) })) }))] }))] })) }))] })));
|
|
63
|
+
}, 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" }, { 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" }, { 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" }, { children: _jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.rename", defaultMessage: "ui.editCourse.tab.lessons.table.menu.rename" }) })) })), _jsx(MenuItem, Object.assign({ onClick: handleOpenDialog }, { children: _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.editCourse.tab.lessons.table.menu.delete", defaultMessage: "ui.editCourse.tab.lessons.table.menu.delete" }) })) }))] }))] })) }))] })));
|
|
64
64
|
}
|
|
65
65
|
export default memo(forwardRef(LessonRow));
|
|
@@ -128,6 +128,16 @@ function SectionRow(props, ref) {
|
|
|
128
128
|
case ActionLessonType.DELETE: {
|
|
129
129
|
const tempSection = Object.assign(Object.assign({}, section), { lessons: section.lessons.filter((prevLesson) => prevLesson.id !== lesson.id) });
|
|
130
130
|
handleManageSection(tempSection, ActionLessonType.DELETE_UPDATE, newRow);
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
case ActionLessonType.UPDATE: {
|
|
134
|
+
const tempSection = Object.assign(Object.assign({}, section), { lessons: section.lessons.map((prevLesson) => {
|
|
135
|
+
if (prevLesson.id === lesson.id) {
|
|
136
|
+
return Object.assign(Object.assign({}, prevLesson), { status: lesson.status });
|
|
137
|
+
}
|
|
138
|
+
return prevLesson;
|
|
139
|
+
}) });
|
|
140
|
+
handleManageSection(tempSection, ActionLessonType.UPDATE_UPDATE);
|
|
131
141
|
}
|
|
132
142
|
}
|
|
133
143
|
}, [section, handleManageSection]);
|
|
@@ -6,7 +6,8 @@ export declare enum ActionLessonType {
|
|
|
6
6
|
UPDATE = "update",
|
|
7
7
|
ADD_UPDATE = "add_update",
|
|
8
8
|
RENAME_UPDATE = "rename_update",
|
|
9
|
-
DELETE_UPDATE = "delete_update"
|
|
9
|
+
DELETE_UPDATE = "delete_update",
|
|
10
|
+
UPDATE_UPDATE = "update_update"
|
|
10
11
|
}
|
|
11
12
|
export interface OptionsData {
|
|
12
13
|
enforce_lessons_order: boolean;
|
|
@@ -7,6 +7,7 @@ export var ActionLessonType;
|
|
|
7
7
|
ActionLessonType["ADD_UPDATE"] = "add_update";
|
|
8
8
|
ActionLessonType["RENAME_UPDATE"] = "rename_update";
|
|
9
9
|
ActionLessonType["DELETE_UPDATE"] = "delete_update";
|
|
10
|
+
ActionLessonType["UPDATE_UPDATE"] = "update_update";
|
|
10
11
|
})(ActionLessonType || (ActionLessonType = {}));
|
|
11
12
|
export var RowType;
|
|
12
13
|
(function (RowType) {
|
|
@@ -22,7 +22,7 @@ import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
|
|
|
22
22
|
import { DAILY_LATER_DAYS, MONTHLY_LATER_DAYS, NEVER_LATER_DAYS, PREFIX, WEEKLY_LATER_DAYS } from './constants';
|
|
23
23
|
import EventAddress from './EventAddress';
|
|
24
24
|
import UploadEventCover from './UploadEventCover';
|
|
25
|
-
import { combineDateAndTime, getLaterDaysDate, getLaterHoursDate, getNewDate } from './utils';
|
|
25
|
+
import { combineDateAndTime, getDateAndHours, getLaterDaysDate, getLaterHoursDate, getNewDate } from './utils';
|
|
26
26
|
import { LIVESTREAM_DEFAULT_SETTINGS } from '../LiveStreamForm/constants';
|
|
27
27
|
import CoverPlaceholder from '../../assets/deafultCover';
|
|
28
28
|
const messages = defineMessages({
|
|
@@ -322,17 +322,17 @@ export default function EventForm(inProps) {
|
|
|
322
322
|
let disabled = false;
|
|
323
323
|
switch (field.recurring) {
|
|
324
324
|
case SCEventRecurrenceType.DAILY:
|
|
325
|
-
disabled = date.getTime() > getLaterDaysDate(DAILY_LATER_DAYS, field.startDate).getTime();
|
|
325
|
+
disabled = date.getTime() > getDateAndHours(getLaterDaysDate(DAILY_LATER_DAYS, field.startDate), 23, 59, 59, 59).getTime();
|
|
326
326
|
break;
|
|
327
327
|
case SCEventRecurrenceType.WEEKLY:
|
|
328
|
-
disabled = date.getTime() > getLaterDaysDate(WEEKLY_LATER_DAYS, field.startDate).getTime();
|
|
328
|
+
disabled = date.getTime() > getDateAndHours(getLaterDaysDate(WEEKLY_LATER_DAYS, field.startDate), 23, 59, 59, 59).getTime();
|
|
329
329
|
break;
|
|
330
330
|
case SCEventRecurrenceType.MONTHLY:
|
|
331
|
-
disabled = date.getTime() > getLaterDaysDate(MONTHLY_LATER_DAYS, field.startDate).getTime();
|
|
331
|
+
disabled = date.getTime() > getDateAndHours(getLaterDaysDate(MONTHLY_LATER_DAYS, field.startDate), 23, 59, 59, 59).getTime();
|
|
332
332
|
break;
|
|
333
333
|
case SCEventRecurrenceType.NEVER:
|
|
334
334
|
default:
|
|
335
|
-
disabled = date.getTime() > getLaterDaysDate(NEVER_LATER_DAYS, field.startDate).getTime();
|
|
335
|
+
disabled = date.getTime() > getDateAndHours(getLaterDaysDate(NEVER_LATER_DAYS, field.startDate), 23, 59, 59, 59).getTime();
|
|
336
336
|
}
|
|
337
337
|
return disabled;
|
|
338
338
|
}, [field]);
|
|
@@ -363,7 +363,10 @@ export default function EventForm(inProps) {
|
|
|
363
363
|
// @ts-ignore
|
|
364
364
|
toolbarTitle: _jsx(FormattedMessage, { id: "ui.eventForm.time.title", defaultMessage: "ui.eventForm.time.title" })
|
|
365
365
|
}
|
|
366
|
-
}, onChange: (value) =>
|
|
366
|
+
}, onChange: (value) => {
|
|
367
|
+
handleChangeDateTime(value, 'startDate');
|
|
368
|
+
handleChangeDateTime(value, 'startTime');
|
|
369
|
+
} })] })) })), _jsxs(FormControl, Object.assign({ className: classes.frequency }, { children: [field.recurring !== SCEventRecurrenceType.NEVER && _jsx(InputLabel, Object.assign({ id: "recurring" }, { children: `${intl.formatMessage(messages.frequency)}` })), _jsx(Select, Object.assign({ name: "recurring", label: field.recurring !== SCEventRecurrenceType.NEVER && `${intl.formatMessage(messages.frequency)}`, labelId: "recurring", value: field.recurring, onChange: handleChange, displayEmpty: true, renderValue: (selected) => {
|
|
367
370
|
if (!selected) {
|
|
368
371
|
return _jsx("em", { children: `${intl.formatMessage(messages.frequencyPlaceholder)}` });
|
|
369
372
|
}
|
|
@@ -389,13 +392,16 @@ export default function EventForm(inProps) {
|
|
|
389
392
|
// @ts-ignore
|
|
390
393
|
toolbarTitle: _jsx(FormattedMessage, { id: "ui.eventForm.time.title", defaultMessage: "ui.eventForm.time.title" })
|
|
391
394
|
}
|
|
392
|
-
}, onChange: (value) =>
|
|
395
|
+
}, onChange: (value) => {
|
|
396
|
+
handleChangeDateTime(value, 'endDate');
|
|
397
|
+
handleChangeDateTime(value, 'endTime');
|
|
398
|
+
}, shouldDisableTime: shouldDisableTime })] })) })), _jsx(EventAddress, Object.assign({ forwardGeolocationData: handleGeoData, forwardLivestreamSettingsData: handleLiveStreamSettingsData, event: Object.assign(Object.assign({}, event), {
|
|
393
399
|
name: field.name,
|
|
394
400
|
start_date: field.startDate,
|
|
395
401
|
location: field.location,
|
|
396
402
|
geolocation: field.geolocation,
|
|
397
403
|
live_stream: Object.assign(Object.assign({ title: field.name || `${intl.formatMessage(messages.name)}` }, (event && ((_c = event.live_stream) === null || _c === void 0 ? void 0 : _c.created_at) && { created_at: field.startDate })), { settings: field.liveStreamSettings })
|
|
398
|
-
}) }, EventAddressComponentProps)), privateEnabled && (_jsxs(Box, Object.assign({ className: classes.privacySection }, { children: [_jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [_jsxs(Typography, Object.assign({ className: classNames(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [_jsx(Icon, { children: "private" }), _jsx(FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), _jsx(Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: event
|
|
404
|
+
}) }, EventAddressComponentProps)), privateEnabled && (_jsxs(Box, Object.assign({ className: classes.privacySection }, { children: [_jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [_jsxs(Typography, Object.assign({ className: classNames(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [_jsx(Icon, { children: "private" }), _jsx(FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), _jsx(Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: (event === null || event === void 0 ? void 0 : event.privacy) === SCEventPrivacyType.PRIVATE }), _jsxs(Typography, Object.assign({ className: classNames(classes.switchLabel, { [classes.active]: field.isPublic }) }, { children: [_jsx(Icon, { children: "public" }), _jsx(FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" })] }))] })), _jsx(Typography, Object.assign({ variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, { children: field.isPublic ? (_jsx(FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
|
|
399
405
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
|
|
400
406
|
// @ts-ignores
|
|
401
407
|
b: (chunks) => _jsx("strong", { children: chunks })
|
|
@@ -2,3 +2,4 @@ export declare function getNewDate(date?: string | Date): Date;
|
|
|
2
2
|
export declare function getLaterHoursDate(hours: number, date?: Date): Date;
|
|
3
3
|
export declare function getLaterDaysDate(days: number, date?: Date): Date;
|
|
4
4
|
export declare const combineDateAndTime: (date: Date, time: Date) => string;
|
|
5
|
+
export declare function getDateAndHours(date: Date, hours: number, min?: number, sec?: number, ms?: number): Date;
|
|
@@ -22,3 +22,7 @@ export const combineDateAndTime = (date, time) => {
|
|
|
22
22
|
combined.setMilliseconds(time.getMilliseconds());
|
|
23
23
|
return combined.toISOString();
|
|
24
24
|
};
|
|
25
|
+
export function getDateAndHours(date, hours, min, sec, ms) {
|
|
26
|
+
date.setHours(hours, min, sec, ms);
|
|
27
|
+
return date;
|
|
28
|
+
}
|
|
@@ -18,6 +18,7 @@ import EventSubscribeButton from '../EventSubscribeButton';
|
|
|
18
18
|
import User from '../User';
|
|
19
19
|
import { PREFIX } from './constants';
|
|
20
20
|
import EventHeaderSkeleton from './Skeleton';
|
|
21
|
+
import { CacheStrategies } from '@selfcommunity/utils';
|
|
21
22
|
const classes = {
|
|
22
23
|
root: `${PREFIX}-root`,
|
|
23
24
|
cover: `${PREFIX}-cover`,
|
|
@@ -83,7 +84,7 @@ export default function EventHeader(inProps) {
|
|
|
83
84
|
// CONTEXT
|
|
84
85
|
const scUserContext = useSCUser();
|
|
85
86
|
// HOOKS
|
|
86
|
-
const { scEvent, setSCEvent } = useSCFetchEvent({ id: eventId, event });
|
|
87
|
+
const { scEvent, setSCEvent } = useSCFetchEvent({ id: eventId, event, cacheStrategy: CacheStrategies.NETWORK_ONLY });
|
|
87
88
|
const theme = useTheme();
|
|
88
89
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
89
90
|
// INTL
|
|
@@ -96,7 +96,7 @@ export default function EventSubscribeButton(inProps) {
|
|
|
96
96
|
const { scEvent, setSCEvent } = useSCFetchEvent({
|
|
97
97
|
id: eventId,
|
|
98
98
|
event,
|
|
99
|
-
cacheStrategy: authUserId ? CacheStrategies.
|
|
99
|
+
cacheStrategy: authUserId ? CacheStrategies.NETWORK_ONLY : CacheStrategies.STALE_WHILE_REVALIDATE
|
|
100
100
|
});
|
|
101
101
|
const isEventAdmin = useMemo(() => { var _a; return scUserContext.user && ((_a = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
|
|
102
102
|
// HANDLERS
|
|
@@ -10,7 +10,7 @@ import { Logger, sortByAttr } from '@selfcommunity/utils';
|
|
|
10
10
|
import { Link, SCPreferences, useSCPreferences } from '@selfcommunity/react-core';
|
|
11
11
|
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
12
12
|
import FooterSkeleton from './Skeleton';
|
|
13
|
-
import { PREFIX } from './constants';
|
|
13
|
+
import { PREFIX, EXPLORE_MENU_ITEM } from './constants';
|
|
14
14
|
const classes = {
|
|
15
15
|
root: `${PREFIX}-root`,
|
|
16
16
|
itemList: `${PREFIX}-item-list`,
|
|
@@ -20,7 +20,7 @@ const classes = {
|
|
|
20
20
|
const Root = styled(Box, {
|
|
21
21
|
name: PREFIX,
|
|
22
22
|
slot: 'Root'
|
|
23
|
-
})((
|
|
23
|
+
})(() => ({}));
|
|
24
24
|
/**
|
|
25
25
|
* > API documentation for the Community-JS Footer component. Learn about the available props and the CSS API.
|
|
26
26
|
*
|
|
@@ -55,12 +55,13 @@ export default function Footer(inProps) {
|
|
|
55
55
|
});
|
|
56
56
|
const { className, menu = null, startActions = null, endActions = null } = props, rest = __rest(props, ["className", "menu", "startActions", "endActions"]);
|
|
57
57
|
// PREFERENCES
|
|
58
|
-
const
|
|
58
|
+
const { preferences } = useSCPreferences();
|
|
59
59
|
const copyright = useMemo(() => {
|
|
60
|
-
return
|
|
61
|
-
?
|
|
60
|
+
return preferences && SCPreferences.TEXT_APPLICATION_COPYRIGHT in preferences
|
|
61
|
+
? preferences[SCPreferences.TEXT_APPLICATION_COPYRIGHT].value.replace('$year', new Date().getFullYear())
|
|
62
62
|
: null;
|
|
63
|
-
}, [
|
|
63
|
+
}, [preferences]);
|
|
64
|
+
const exploreStreamEnabled = preferences[SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value;
|
|
64
65
|
// STATE
|
|
65
66
|
const [_menu, setMenu] = useState(menu);
|
|
66
67
|
const [loading, setLoading] = useState(!menu);
|
|
@@ -93,5 +94,7 @@ export default function Footer(inProps) {
|
|
|
93
94
|
if (loading) {
|
|
94
95
|
return _jsx(FooterSkeleton, {});
|
|
95
96
|
}
|
|
96
|
-
return (_jsxs(Root, Object.assign({}, rest, { className: classNames(classes.root, className) }, { children: [startActions, _jsx(Box, Object.assign({ className: classes.itemList }, { children: sortByAttr(_menu.items, 'order')
|
|
97
|
+
return (_jsxs(Root, Object.assign({}, rest, { className: classNames(classes.root, className) }, { children: [startActions, _jsx(Box, Object.assign({ className: classes.itemList }, { children: sortByAttr(_menu.items, 'order')
|
|
98
|
+
.filter((item) => exploreStreamEnabled || item.url !== EXPLORE_MENU_ITEM)
|
|
99
|
+
.map((item, index) => (_jsx(Button, Object.assign({ component: Link, className: classes.item, to: item.url, variant: "text" }, { children: item.label }), item.id))) })), endActions, _jsx(Typography, { textAlign: "center", className: classes.copyright, variant: "body2", dangerouslySetInnerHTML: { __html: copyright } })] })));
|
|
97
100
|
}
|