@selfcommunity/react-ui 0.10.2-courses.206 → 0.10.2-courses.208

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.
Files changed (28) hide show
  1. package/lib/cjs/components/CreateLiveStreamButton/CreateLiveStreamButton.d.ts +0 -6
  2. package/lib/cjs/components/CreateLiveStreamButton/CreateLiveStreamButton.js +2 -9
  3. package/lib/cjs/components/CreateLiveStreamDialog/CreateLiveStreamDialog.d.ts +10 -4
  4. package/lib/cjs/components/CreateLiveStreamDialog/CreateLiveStreamDialog.js +8 -4
  5. package/lib/cjs/components/EventFormDialog/EventFormDialog.d.ts +1 -1
  6. package/lib/cjs/components/EventFormDialog/EventFormDialog.js +3 -3
  7. package/lib/cjs/components/GroupForm/GroupForm.js +2 -2
  8. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.d.ts +3 -1
  9. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.js +13 -6
  10. package/lib/cjs/components/Notification/Course/Course.js +7 -22
  11. package/lib/cjs/components/Notification/Course/utils.d.ts +5 -0
  12. package/lib/cjs/components/Notification/Course/utils.js +44 -0
  13. package/lib/cjs/components/Notification/Event/Event.js +10 -0
  14. package/lib/esm/components/CreateLiveStreamButton/CreateLiveStreamButton.d.ts +0 -6
  15. package/lib/esm/components/CreateLiveStreamButton/CreateLiveStreamButton.js +2 -9
  16. package/lib/esm/components/CreateLiveStreamDialog/CreateLiveStreamDialog.d.ts +10 -4
  17. package/lib/esm/components/CreateLiveStreamDialog/CreateLiveStreamDialog.js +8 -4
  18. package/lib/esm/components/EventFormDialog/EventFormDialog.d.ts +1 -1
  19. package/lib/esm/components/EventFormDialog/EventFormDialog.js +3 -3
  20. package/lib/esm/components/GroupForm/GroupForm.js +2 -2
  21. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.d.ts +3 -1
  22. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.js +13 -6
  23. package/lib/esm/components/Notification/Course/Course.js +5 -20
  24. package/lib/esm/components/Notification/Course/utils.d.ts +5 -0
  25. package/lib/esm/components/Notification/Course/utils.js +39 -0
  26. package/lib/esm/components/Notification/Event/Event.js +10 -0
  27. package/lib/umd/react-ui.js +1 -1
  28. package/package.json +8 -8
@@ -1,5 +1,4 @@
1
1
  import { ButtonProps } from '@mui/material/Button/Button';
2
- import { SCEventType, SCLiveStreamType } from '@selfcommunity/types';
3
2
  import { CreateLiveStreamDialogProps } from '../CreateLiveStreamDialog';
4
3
  export interface CreateLiveStreamButtonProps extends ButtonProps {
5
4
  /**
@@ -12,11 +11,6 @@ export interface CreateLiveStreamButtonProps extends ButtonProps {
12
11
  * @default empty object
13
12
  */
14
13
  CreateLiveStreamDialogComponentProps?: CreateLiveStreamDialogProps;
15
- /**
16
- * On success callback function
17
- * @default null
18
- */
19
- onSuccess?: (data: SCEventType | SCLiveStreamType) => void;
20
14
  /**
21
15
  * Any other properties
22
16
  */
@@ -45,7 +45,7 @@ function CreateLiveStreamButton(inProps) {
45
45
  props: inProps,
46
46
  name: PREFIX
47
47
  });
48
- const { className, CreateLiveStreamDialogComponentProps = {}, onSuccess, children } = props, rest = tslib_1.__rest(props, ["className", "CreateLiveStreamDialogComponentProps", "onSuccess", "children"]);
48
+ const { className, CreateLiveStreamDialogComponentProps = {}, children } = props, rest = tslib_1.__rest(props, ["className", "CreateLiveStreamDialogComponentProps", "children"]);
49
49
  // CONTEXT
50
50
  const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
51
51
  const { preferences, features } = (0, react_core_1.useSCPreferences)();
@@ -71,13 +71,6 @@ function CreateLiveStreamButton(inProps) {
71
71
  const handleClose = () => {
72
72
  setOpen((o) => !o);
73
73
  };
74
- /**
75
- * Handle close
76
- */
77
- const handleSuccess = (data) => {
78
- onSuccess && onSuccess(data);
79
- setOpen((o) => !o);
80
- };
81
74
  /**
82
75
  * If there's no authUserId, component is hidden.
83
76
  */
@@ -87,6 +80,6 @@ function CreateLiveStreamButton(inProps) {
87
80
  /**
88
81
  * Renders root object
89
82
  */
90
- return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), onClick: handleClose, variant: "contained", color: "secondary", startIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "movie" }) }, rest, { children: children !== null && children !== void 0 ? children : (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.createEventButton.goLive", defaultMessage: "ui.createEventButton.goLive" }) })), open && (0, jsx_runtime_1.jsx)(CreateLiveStreamDialog_1.default, Object.assign({ open: true, onClose: handleClose, onSuccess: handleSuccess }, CreateLiveStreamDialogComponentProps))] }));
83
+ return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), onClick: handleClose, variant: "contained", color: "secondary", startIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "movie" }) }, rest, { children: children !== null && children !== void 0 ? children : (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.createEventButton.goLive", defaultMessage: "ui.createEventButton.goLive" }) })), open && (0, jsx_runtime_1.jsx)(CreateLiveStreamDialog_1.default, Object.assign({ open: true, onClose: handleClose }, CreateLiveStreamDialogComponentProps))] }));
91
84
  }
92
85
  exports.default = CreateLiveStreamButton;
@@ -1,5 +1,6 @@
1
- import { SCEventType, SCLiveStreamType } from '@selfcommunity/types';
2
1
  import { BaseDialogProps } from '../../shared/BaseDialog';
2
+ import { EventFormProps } from '../EventForm';
3
+ import { LiveStreamFormProps } from '../LiveStreamForm';
3
4
  export interface CreateLiveStreamDialogProps extends BaseDialogProps {
4
5
  /**
5
6
  * Overrides or extends the styles applied to the component.
@@ -17,10 +18,15 @@ export interface CreateLiveStreamDialogProps extends BaseDialogProps {
17
18
  */
18
19
  onClose?: () => void;
19
20
  /**
20
- * On success callback function
21
- * @default null
21
+ * Props to spread to EventForm component
22
+ * @default {}
23
+ */
24
+ EventFormComponentProps?: EventFormProps;
25
+ /**
26
+ * Props to spread to LiveStreamForm component
27
+ * @default {}
22
28
  */
23
- onSuccess?: (data: SCEventType | SCLiveStreamType) => void;
29
+ LiveStreamFormComponentProps?: LiveStreamFormProps;
24
30
  /**
25
31
  * Any other properties
26
32
  */
@@ -65,7 +65,7 @@ function CreateLiveStreamDialog(inProps) {
65
65
  props: inProps,
66
66
  name: constants_1.PREFIX
67
67
  });
68
- const { className, open = true, onClose, onSuccess } = props, rest = tslib_1.__rest(props, ["className", "open", "onClose", "onSuccess"]);
68
+ const { className, open = true, onClose, EventFormComponentProps = {}, LiveStreamFormComponentProps = {} } = props, rest = tslib_1.__rest(props, ["className", "open", "onClose", "EventFormComponentProps", "LiveStreamFormComponentProps"]);
69
69
  // CONTEXT
70
70
  const scUserContext = (0, react_core_1.useSCUser)();
71
71
  // PERMISSION
@@ -86,8 +86,12 @@ function CreateLiveStreamDialog(inProps) {
86
86
  setStep(types_2.CreateLiveStreamStep.SELECT_TYPE);
87
87
  }, []);
88
88
  const handleSubmit = (0, react_1.useCallback)((e) => {
89
- onSuccess && onSuccess(e);
90
- }, [onSuccess]);
89
+ var _a, _b;
90
+ liveType === types_2.LiveStreamType.EVENT_LIVE
91
+ ? (_a = EventFormComponentProps.onSuccess) === null || _a === void 0 ? void 0 : _a.call(EventFormComponentProps, e)
92
+ : (_b = LiveStreamFormComponentProps.onSuccess) === null || _b === void 0 ? void 0 : _b.call(LiveStreamFormComponentProps, e);
93
+ onClose === null || onClose === void 0 ? void 0 : onClose();
94
+ }, [liveType, onClose, EventFormComponentProps, LiveStreamFormComponentProps]);
91
95
  (0, react_1.useEffect)(() => {
92
96
  if (!canCreateEvent) {
93
97
  setLiveType(types_2.LiveStreamType.DIRECT_LIVE);
@@ -100,6 +104,6 @@ function CreateLiveStreamDialog(inProps) {
100
104
  /**
101
105
  * Renders root object
102
106
  */
103
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ DialogContentProps: { dividers: false }, maxWidth: "md", title: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.title, component: "span" }, { children: [canShowBackButton && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "text", onClick: handleBack, startIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "arrow_back" }) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.createLivestreamDialog.button.back", defaultMessage: "ui.createLivestreamDialog.button.back" }) }))), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ component: "span" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.createLivestreamDialog.title", defaultMessage: "ui.createLivestreamDialog.title" }) }))] })), fullWidth: true, open: open, scroll: "body", onClose: !canShowBackButton ? onClose : undefined, className: (0, classnames_1.default)(classes.root, className), TransitionComponent: Transition, PaperProps: { elevation: 0 } }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.content }, { children: [step === types_2.CreateLiveStreamStep.SELECT_TYPE && ((0, jsx_runtime_1.jsx)(LiveStreamSelector_1.default, { liveSelected: liveType, onLiveSelected: handleLiveTypeSelected, onNext: handleLiveTypeSelectedNext })), step === types_2.CreateLiveStreamStep.CREATE_LIVE && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: liveType === types_2.LiveStreamType.EVENT_LIVE ? ((0, jsx_runtime_1.jsx)(EventForm_1.default, { EventAddressComponentProps: { locations: [types_1.SCEventLocationType.LIVESTREAM] }, onSuccess: handleSubmit })) : ((0, jsx_runtime_1.jsx)(LiveStreamForm_1.default, { onSuccess: handleSubmit })) }))] })) })));
107
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ DialogContentProps: { dividers: false }, maxWidth: "md", title: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.title, component: "span" }, { children: [canShowBackButton && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "text", onClick: handleBack, startIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "arrow_back" }) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.createLivestreamDialog.button.back", defaultMessage: "ui.createLivestreamDialog.button.back" }) }))), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ component: "span" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.createLivestreamDialog.title", defaultMessage: "ui.createLivestreamDialog.title" }) }))] })), fullWidth: true, open: open, scroll: "body", onClose: !canShowBackButton ? onClose : undefined, className: (0, classnames_1.default)(classes.root, className), TransitionComponent: Transition, PaperProps: { elevation: 0 } }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.content }, { children: [step === types_2.CreateLiveStreamStep.SELECT_TYPE && ((0, jsx_runtime_1.jsx)(LiveStreamSelector_1.default, { liveSelected: liveType, onLiveSelected: handleLiveTypeSelected, onNext: handleLiveTypeSelectedNext })), step === types_2.CreateLiveStreamStep.CREATE_LIVE && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: liveType === types_2.LiveStreamType.EVENT_LIVE ? ((0, jsx_runtime_1.jsx)(EventForm_1.default, Object.assign({}, EventFormComponentProps, { EventAddressComponentProps: { locations: [types_1.SCEventLocationType.LIVESTREAM] }, onSuccess: handleSubmit }))) : ((0, jsx_runtime_1.jsx)(LiveStreamForm_1.default, Object.assign({}, LiveStreamFormComponentProps, { onSuccess: handleSubmit }))) }))] })) })));
104
108
  }
105
109
  exports.default = CreateLiveStreamDialog;
@@ -18,7 +18,7 @@ export interface EventFormDialogProps extends BaseDialogProps {
18
18
  onClose?: () => void;
19
19
  /**
20
20
  * Props to spread to EventForm component
21
- * @default undefined
21
+ * @default {}
22
22
  */
23
23
  EventFormComponentProps?: EventFormProps;
24
24
  /**
@@ -42,15 +42,15 @@ function EventFormDialog(inProps) {
42
42
  props: inProps,
43
43
  name: constants_1.PREFIX
44
44
  });
45
- const { className, open = true, onClose, EventFormComponentProps } = props, rest = tslib_1.__rest(props, ["className", "open", "onClose", "EventFormComponentProps"]);
45
+ const { className, open = true, onClose, EventFormComponentProps = {} } = props, rest = tslib_1.__rest(props, ["className", "open", "onClose", "EventFormComponentProps"]);
46
46
  const handleSuccess = (0, react_1.useCallback)((event) => {
47
47
  var _a;
48
- (_a = EventFormComponentProps === null || EventFormComponentProps === void 0 ? void 0 : EventFormComponentProps.onSuccess) === null || _a === void 0 ? void 0 : _a.call(EventFormComponentProps, event);
48
+ (_a = EventFormComponentProps.onSuccess) === null || _a === void 0 ? void 0 : _a.call(EventFormComponentProps, event);
49
49
  onClose === null || onClose === void 0 ? void 0 : onClose();
50
50
  }, [onClose, EventFormComponentProps]);
51
51
  /**
52
52
  * Renders root object
53
53
  */
54
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ DialogContentProps: { dividers: false }, title: (EventFormComponentProps === null || EventFormComponentProps === void 0 ? void 0 : EventFormComponentProps.event) ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.title.edit", defaultMessage: "ui.eventForm.title.edit" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.title", defaultMessage: "ui.eventForm.title" })), open: open, onClose: onClose, className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsx)(EventForm_1.default, Object.assign({}, (EventFormComponentProps && EventFormComponentProps), { onSuccess: handleSuccess })) })));
54
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ DialogContentProps: { dividers: false }, title: (EventFormComponentProps === null || EventFormComponentProps === void 0 ? void 0 : EventFormComponentProps.event) ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.title.edit", defaultMessage: "ui.eventForm.title.edit" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.title", defaultMessage: "ui.eventForm.title" })), open: open, onClose: onClose, className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsx)(EventForm_1.default, Object.assign({}, EventFormComponentProps, { onSuccess: handleSuccess })) })));
55
55
  }
56
56
  exports.default = EventFormDialog;
@@ -195,10 +195,10 @@ function GroupForm(inProps) {
195
195
  }
196
196
  groupService
197
197
  .then((data) => {
198
- onSuccess && onSuccess(data);
198
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
199
199
  notifyChanges(data);
200
- onClose && onClose();
201
200
  setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
201
+ onClose === null || onClose === void 0 ? void 0 : onClose();
202
202
  })
203
203
  .catch((e) => {
204
204
  setError(Object.assign(Object.assign({}, error), (0, api_services_1.formatHttpErrorCode)(e)));
@@ -26,7 +26,9 @@ export interface NavigationMenuDrawerProps extends DrawerProps {
26
26
  * Custom Drawer footer content
27
27
  * @default null
28
28
  */
29
- drawerFooterContent?: React.ReactNode;
29
+ drawerFooterContent?: React.ReactNode | ((props: {
30
+ handleCloseMenuDrawer: (event: any, reason: 'backdropClick' | 'escapeKeyDown') => void;
31
+ }) => React.ReactNode);
30
32
  /**
31
33
  * Props to spread to ScrollContainer component
32
34
  * This lib use 'react-custom-scrollbars' component to perform scrollbars
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
6
  const styles_1 = require("@mui/material/styles");
7
7
  const material_1 = require("@mui/material");
8
8
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
@@ -11,7 +11,6 @@ const ScrollContainer_1 = tslib_1.__importDefault(require("../../shared/ScrollCo
11
11
  const DefaultDrawerContent_1 = tslib_1.__importDefault(require("./DefaultDrawerContent"));
12
12
  const DefaultHeaderContent_1 = tslib_1.__importDefault(require("./DefaultHeaderContent"));
13
13
  const CreateLiveStreamButton_1 = tslib_1.__importDefault(require("../CreateLiveStreamButton"));
14
- const react_core_1 = require("@selfcommunity/react-core");
15
14
  const PREFIX = 'SCNavigationMenuDrawer';
16
15
  const classes = {
17
16
  root: `${PREFIX}-root`,
@@ -30,15 +29,23 @@ const Root = (0, styles_1.styled)(material_1.Drawer, {
30
29
  overridesResolver: (props, styles) => styles.root
31
30
  })(({ theme }) => ({}));
32
31
  function NavigationMenuDrawer(inProps) {
33
- var _a;
34
32
  // PROPS
35
33
  const props = (0, system_1.useThemeProps)({
36
34
  props: inProps,
37
35
  name: PREFIX
38
36
  });
39
37
  const { className = null, showDrawerHeader = true, drawerHeaderContent = (0, jsx_runtime_1.jsx)(DefaultHeaderContent_1.default, {}), drawerContent = (0, jsx_runtime_1.jsx)(DefaultDrawerContent_1.default, {}), showDrawerFooterContent = true, drawerFooterContent = null, ScrollContainerProps = { hideTracksWhenNotNeeded: true }, CreateLiveStreamButtonComponentProps = {}, open, onClose } = props, rest = tslib_1.__rest(props, ["className", "showDrawerHeader", "drawerHeaderContent", "drawerContent", "showDrawerFooterContent", "drawerFooterContent", "ScrollContainerProps", "CreateLiveStreamButtonComponentProps", "open", "onClose"]);
40
- const scUserContext = (0, react_core_1.useSCUser)();
41
- const canCreateLiveStream = (0, react_1.useMemo)(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_live_stream; }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
42
- return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ anchor: "left", className: (0, classnames_1.default)(classes.root, className), open: open, onClose: onClose }, rest, { children: [showDrawerHeader && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.drawerHeader }, { children: [drawerHeaderContent, (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: classes.drawerHeaderAction, onClick: onClose }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Divider, {})] })), (0, jsx_runtime_1.jsx)(ScrollContainer_1.default, Object.assign({}, ScrollContainerProps, { children: (0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ className: classes.drawerContent, onClick: onClose }, { children: drawerContent })) })), showDrawerFooterContent && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.drawerFooter }, { children: drawerFooterContent ? (drawerFooterContent) : ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.drawerFooterLiveStream }, { children: (0, jsx_runtime_1.jsx)(CreateLiveStreamButton_1.default, Object.assign({ color: "primary", className: classes.drawerFooterLiveStreamButton, fullWidth: true }, CreateLiveStreamButtonComponentProps)) }))) })) }))] })));
38
+ const footerContent = (() => {
39
+ if (typeof drawerFooterContent === 'function') {
40
+ return drawerFooterContent({ handleCloseMenuDrawer: onClose });
41
+ }
42
+ if (react_1.default.isValidElement(drawerFooterContent)) {
43
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
44
+ // @ts-ignore
45
+ return react_1.default.cloneElement(drawerFooterContent, { handleCloseMenuDrawer: onClose });
46
+ }
47
+ return drawerFooterContent;
48
+ })();
49
+ return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ anchor: "left", className: (0, classnames_1.default)(classes.root, className), open: open, onClose: onClose }, rest, { children: [showDrawerHeader && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.drawerHeader }, { children: [drawerHeaderContent, (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: classes.drawerHeaderAction, onClick: onClose }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Divider, {})] })), (0, jsx_runtime_1.jsx)(ScrollContainer_1.default, Object.assign({}, ScrollContainerProps, { children: (0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ className: classes.drawerContent, onClick: onClose }, { children: drawerContent })) })), showDrawerFooterContent && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ component: "div", className: classes.drawerFooter }, { children: footerContent || ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.drawerFooterLiveStream }, { children: (0, jsx_runtime_1.jsx)(CreateLiveStreamButton_1.default, Object.assign({ color: "primary", className: classes.drawerFooterLiveStreamButton, fullWidth: true }, CreateLiveStreamButtonComponentProps)) }))) })) }))] })));
43
50
  }
44
51
  exports.default = NavigationMenuDrawer;
@@ -18,6 +18,7 @@ const UserAvatar_1 = tslib_1.__importDefault(require("../../../shared/UserAvatar
18
18
  const constants_1 = require("../constants");
19
19
  const Course_1 = tslib_1.__importDefault(require("../../Course"));
20
20
  const HiddenPlaceholder_1 = tslib_1.__importDefault(require("../../../shared/HiddenPlaceholder"));
21
+ const utils_1 = require("./utils");
21
22
  const classes = {
22
23
  root: `${constants_1.PREFIX}-course-root`,
23
24
  avatar: `${constants_1.PREFIX}-avatar`,
@@ -31,14 +32,6 @@ const Root = (0, styles_1.styled)(NotificationItem_1.default, {
31
32
  name: constants_1.PREFIX,
32
33
  slot: 'CourseRoot'
33
34
  })(() => ({}));
34
- function formatLessonUrl(notificationObject) {
35
- return {
36
- id: notificationObject.course.id,
37
- slug: notificationObject.course.slug,
38
- section_id: notificationObject.comment.section_id,
39
- lesson_id: notificationObject.comment.lesson_id
40
- };
41
- }
42
35
  /**
43
36
  * This component render the content of the notification of type course
44
37
  * @constructor
@@ -70,15 +63,11 @@ function CourseNotification(props) {
70
63
  ? notificationObject.comment.lesson_name
71
64
  : notificationObject.course.name,
72
65
  link: (...chunks) => ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
73
- ? react_core_1.SCRoutes.COURSE_LESSON_COMMENTS_ROUTE_NAME
66
+ ? react_core_1.SCRoutes.COURSE_LESSON_ROUTE_NAME
74
67
  : react_core_1.SCRoutes.COURSE_ROUTE_NAME, notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
75
- ? formatLessonUrl(notificationObject)
68
+ ? (0, utils_1.formatLessonUrl)(notificationObject)
76
69
  : notificationObject.course) }, { children: chunks })))
77
- } })] }), footer: isToastTemplate ? ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [(0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ color: "primary" }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
78
- ? react_core_1.SCRoutes.COURSE_LESSON_COMMENTS_ROUTE_NAME
79
- : react_core_1.SCRoutes.COURSE_ROUTE_NAME, notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
80
- ? formatLessonUrl(notificationObject)
81
- : notificationObject.course) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.notification.course.button.see", defaultMessage: "ui.notification.course.button.see" }) })) }))] }))) : ((0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at, className: classes.snippetTime })) }, rest)));
70
+ } })] }), footer: isToastTemplate ? ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [(0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ color: "primary" }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url((0, utils_1.getRouteName)(notificationObject), (0, utils_1.getRouteParams)(notificationObject)) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.notification.course.button.see", defaultMessage: "ui.notification.course.button.see" }) })) }))] }))) : ((0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at, className: classes.snippetTime })) }, rest)));
82
71
  }
83
72
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, `${constants_1.PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!notificationObject.user.deleted && {
84
73
  to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
@@ -91,14 +80,10 @@ function CourseNotification(props) {
91
80
  ? notificationObject.comment.lesson_name
92
81
  : notificationObject.course.name,
93
82
  link: (...chunks) => ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
94
- ? react_core_1.SCRoutes.COURSE_LESSON_COMMENTS_ROUTE_NAME
83
+ ? react_core_1.SCRoutes.COURSE_LESSON_ROUTE_NAME
95
84
  : react_core_1.SCRoutes.COURSE_ROUTE_NAME, notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
96
- ? formatLessonUrl(notificationObject)
85
+ ? (0, utils_1.formatLessonUrl)(notificationObject)
97
86
  : notificationObject.course) }, { children: chunks })))
98
- } }), notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", dangerouslySetInnerHTML: { __html: notificationObject.comment.html } })) : ((0, jsx_runtime_1.jsx)(Course_1.default, { course: notificationObject.course, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), template: types_2.SCCourseTemplateType.SNIPPET, elevation: 0 }))] }), actions: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [(0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at, className: classes.activeAt }), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ color: 'primary', variant: "outlined", size: "small", classes: { root: classes.seeButton }, component: react_core_1.Link, to: scRoutingContext.url(notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
99
- ? react_core_1.SCRoutes.COURSE_LESSON_COMMENTS_ROUTE_NAME
100
- : react_core_1.SCRoutes.COURSE_ROUTE_NAME, notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON
101
- ? formatLessonUrl(notificationObject)
102
- : notificationObject.course) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.notification.course.button.see", defaultMessage: "ui.notification.course.button.see" }) }))] })) }, rest)), openAlert && (0, jsx_runtime_1.jsx)(UserDeletedSnackBar_1.default, { open: openAlert, handleClose: () => setOpenAlert(false) })] }));
87
+ } }), notificationObject.type === types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", dangerouslySetInnerHTML: { __html: notificationObject.comment.html } })) : ((0, jsx_runtime_1.jsx)(Course_1.default, { course: notificationObject.course, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), template: types_2.SCCourseTemplateType.SNIPPET, elevation: 0 }))] }), actions: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [(0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at, className: classes.activeAt }), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ color: 'primary', variant: "outlined", size: "small", classes: { root: classes.seeButton }, component: react_core_1.Link, to: scRoutingContext.url((0, utils_1.getRouteName)(notificationObject), (0, utils_1.getRouteParams)(notificationObject)) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.notification.course.button.see", defaultMessage: "ui.notification.course.button.see" }) }))] })) }, rest)), openAlert && (0, jsx_runtime_1.jsx)(UserDeletedSnackBar_1.default, { open: openAlert, handleClose: () => setOpenAlert(false) })] }));
103
88
  }
104
89
  exports.default = CourseNotification;
@@ -0,0 +1,5 @@
1
+ import { SCNotificationCourseActivityType } from '@selfcommunity/types';
2
+ declare function formatLessonUrl(notificationObject: SCNotificationCourseActivityType): any;
3
+ declare const getRouteName: (notificationObject: SCNotificationCourseActivityType) => "course_edit" | "course_lesson_comments" | "course";
4
+ declare const getRouteParams: (notificationObject: SCNotificationCourseActivityType) => any;
5
+ export { getRouteName, getRouteParams, formatLessonUrl };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatLessonUrl = exports.getRouteParams = exports.getRouteName = void 0;
4
+ const course_1 = require("../../../types/course");
5
+ const types_1 = require("@selfcommunity/types");
6
+ const react_core_1 = require("@selfcommunity/react-core");
7
+ function formatLessonUrl(notificationObject) {
8
+ return {
9
+ id: notificationObject.course.id,
10
+ slug: notificationObject.course.slug,
11
+ section_id: notificationObject.comment.section_id,
12
+ lesson_id: notificationObject.comment.lesson_id
13
+ };
14
+ }
15
+ exports.formatLessonUrl = formatLessonUrl;
16
+ function formatCourseRequestsUrl(notificationObject) {
17
+ return {
18
+ id: notificationObject.course.id,
19
+ slug: notificationObject.course.slug,
20
+ tab: course_1.SCCourseEditTabType.REQUESTS
21
+ };
22
+ }
23
+ const getRouteName = (notificationObject) => {
24
+ switch (notificationObject.type) {
25
+ case types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON:
26
+ return react_core_1.SCRoutes.COURSE_LESSON_COMMENTS_ROUTE_NAME;
27
+ case types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_COURSE:
28
+ return react_core_1.SCRoutes.COURSE_EDIT_ROUTE_NAME;
29
+ default:
30
+ return react_core_1.SCRoutes.COURSE_ROUTE_NAME;
31
+ }
32
+ };
33
+ exports.getRouteName = getRouteName;
34
+ const getRouteParams = (notificationObject) => {
35
+ switch (notificationObject.type) {
36
+ case types_1.SCNotificationTypologyType.USER_COMMENTED_A_COURSE_LESSON:
37
+ return formatLessonUrl(notificationObject);
38
+ case types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_COURSE:
39
+ return formatCourseRequestsUrl(notificationObject);
40
+ default:
41
+ return notificationObject.course;
42
+ }
43
+ };
44
+ exports.getRouteParams = getRouteParams;
@@ -42,10 +42,20 @@ function EventNotification(props) {
42
42
  const scRoutingContext = (0, react_core_1.useSCRouting)();
43
43
  // STATE
44
44
  const [openAlert, setOpenAlert] = (0, react_1.useState)(false);
45
+ // const [loading, setLoading] = useState<boolean>(false);
46
+ // const [disabled, setDisabled] = useState<boolean>(!notificationObject.is_new);
45
47
  // CONST
46
48
  const isSnippetTemplate = template === types_2.SCNotificationObjectTemplateType.SNIPPET;
47
49
  const isToastTemplate = template === types_2.SCNotificationObjectTemplateType.TOAST;
48
50
  const intl = (0, react_intl_1.useIntl)();
51
+ //HANDLERS
52
+ // const acceptRequest = (event) => {
53
+ // setLoading(true);
54
+ // EventService.inviteOrAcceptEventRequest(event.id, {users: [notificationObject.user.id]}).then(() => {
55
+ // setLoading(false);
56
+ // setDisabled(true);
57
+ // });
58
+ // };
49
59
  // RENDER
50
60
  if (isSnippetTemplate || isToastTemplate) {
51
61
  return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, `${constants_1.PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!notificationObject.user.deleted && {
@@ -1,5 +1,4 @@
1
1
  import { ButtonProps } from '@mui/material/Button/Button';
2
- import { SCEventType, SCLiveStreamType } from '@selfcommunity/types';
3
2
  import { CreateLiveStreamDialogProps } from '../CreateLiveStreamDialog';
4
3
  export interface CreateLiveStreamButtonProps extends ButtonProps {
5
4
  /**
@@ -12,11 +11,6 @@ export interface CreateLiveStreamButtonProps extends ButtonProps {
12
11
  * @default empty object
13
12
  */
14
13
  CreateLiveStreamDialogComponentProps?: CreateLiveStreamDialogProps;
15
- /**
16
- * On success callback function
17
- * @default null
18
- */
19
- onSuccess?: (data: SCEventType | SCLiveStreamType) => void;
20
14
  /**
21
15
  * Any other properties
22
16
  */
@@ -43,7 +43,7 @@ export default function CreateLiveStreamButton(inProps) {
43
43
  props: inProps,
44
44
  name: PREFIX
45
45
  });
46
- const { className, CreateLiveStreamDialogComponentProps = {}, onSuccess, children } = props, rest = __rest(props, ["className", "CreateLiveStreamDialogComponentProps", "onSuccess", "children"]);
46
+ const { className, CreateLiveStreamDialogComponentProps = {}, children } = props, rest = __rest(props, ["className", "CreateLiveStreamDialogComponentProps", "children"]);
47
47
  // CONTEXT
48
48
  const scUserContext = useContext(SCUserContext);
49
49
  const { preferences, features } = useSCPreferences();
@@ -69,13 +69,6 @@ export default function CreateLiveStreamButton(inProps) {
69
69
  const handleClose = () => {
70
70
  setOpen((o) => !o);
71
71
  };
72
- /**
73
- * Handle close
74
- */
75
- const handleSuccess = (data) => {
76
- onSuccess && onSuccess(data);
77
- setOpen((o) => !o);
78
- };
79
72
  /**
80
73
  * If there's no authUserId, component is hidden.
81
74
  */
@@ -85,5 +78,5 @@ export default function CreateLiveStreamButton(inProps) {
85
78
  /**
86
79
  * Renders root object
87
80
  */
88
- return (_jsxs(React.Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClose, variant: "contained", color: "secondary", startIcon: _jsx(Icon, { children: "movie" }) }, rest, { children: children !== null && children !== void 0 ? children : _jsx(FormattedMessage, { id: "ui.createEventButton.goLive", defaultMessage: "ui.createEventButton.goLive" }) })), open && _jsx(CreateLivestreamDialog, Object.assign({ open: true, onClose: handleClose, onSuccess: handleSuccess }, CreateLiveStreamDialogComponentProps))] }));
81
+ return (_jsxs(React.Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClose, variant: "contained", color: "secondary", startIcon: _jsx(Icon, { children: "movie" }) }, rest, { children: children !== null && children !== void 0 ? children : _jsx(FormattedMessage, { id: "ui.createEventButton.goLive", defaultMessage: "ui.createEventButton.goLive" }) })), open && _jsx(CreateLivestreamDialog, Object.assign({ open: true, onClose: handleClose }, CreateLiveStreamDialogComponentProps))] }));
89
82
  }
@@ -1,5 +1,6 @@
1
- import { SCEventType, SCLiveStreamType } from '@selfcommunity/types';
2
1
  import { BaseDialogProps } from '../../shared/BaseDialog';
2
+ import { EventFormProps } from '../EventForm';
3
+ import { LiveStreamFormProps } from '../LiveStreamForm';
3
4
  export interface CreateLiveStreamDialogProps extends BaseDialogProps {
4
5
  /**
5
6
  * Overrides or extends the styles applied to the component.
@@ -17,10 +18,15 @@ export interface CreateLiveStreamDialogProps extends BaseDialogProps {
17
18
  */
18
19
  onClose?: () => void;
19
20
  /**
20
- * On success callback function
21
- * @default null
21
+ * Props to spread to EventForm component
22
+ * @default {}
23
+ */
24
+ EventFormComponentProps?: EventFormProps;
25
+ /**
26
+ * Props to spread to LiveStreamForm component
27
+ * @default {}
22
28
  */
23
- onSuccess?: (data: SCEventType | SCLiveStreamType) => void;
29
+ LiveStreamFormComponentProps?: LiveStreamFormProps;
24
30
  /**
25
31
  * Any other properties
26
32
  */
@@ -63,7 +63,7 @@ export default function CreateLiveStreamDialog(inProps) {
63
63
  props: inProps,
64
64
  name: PREFIX
65
65
  });
66
- const { className, open = true, onClose, onSuccess } = props, rest = __rest(props, ["className", "open", "onClose", "onSuccess"]);
66
+ const { className, open = true, onClose, EventFormComponentProps = {}, LiveStreamFormComponentProps = {} } = props, rest = __rest(props, ["className", "open", "onClose", "EventFormComponentProps", "LiveStreamFormComponentProps"]);
67
67
  // CONTEXT
68
68
  const scUserContext = useSCUser();
69
69
  // PERMISSION
@@ -84,8 +84,12 @@ export default function CreateLiveStreamDialog(inProps) {
84
84
  setStep(CreateLiveStreamStep.SELECT_TYPE);
85
85
  }, []);
86
86
  const handleSubmit = useCallback((e) => {
87
- onSuccess && onSuccess(e);
88
- }, [onSuccess]);
87
+ var _a, _b;
88
+ liveType === LiveStreamType.EVENT_LIVE
89
+ ? (_a = EventFormComponentProps.onSuccess) === null || _a === void 0 ? void 0 : _a.call(EventFormComponentProps, e)
90
+ : (_b = LiveStreamFormComponentProps.onSuccess) === null || _b === void 0 ? void 0 : _b.call(LiveStreamFormComponentProps, e);
91
+ onClose === null || onClose === void 0 ? void 0 : onClose();
92
+ }, [liveType, onClose, EventFormComponentProps, LiveStreamFormComponentProps]);
89
93
  useEffect(() => {
90
94
  if (!canCreateEvent) {
91
95
  setLiveType(LiveStreamType.DIRECT_LIVE);
@@ -98,5 +102,5 @@ export default function CreateLiveStreamDialog(inProps) {
98
102
  /**
99
103
  * Renders root object
100
104
  */
101
- return (_jsx(Root, Object.assign({ DialogContentProps: { dividers: false }, maxWidth: "md", title: _jsxs(Box, Object.assign({ className: classes.title, component: "span" }, { children: [canShowBackButton && (_jsx(Button, Object.assign({ variant: "text", onClick: handleBack, startIcon: _jsx(Icon, { children: "arrow_back" }) }, { children: _jsx(FormattedMessage, { id: "ui.createLivestreamDialog.button.back", defaultMessage: "ui.createLivestreamDialog.button.back" }) }))), _jsx(Box, Object.assign({ component: "span" }, { children: _jsx(FormattedMessage, { id: "ui.createLivestreamDialog.title", defaultMessage: "ui.createLivestreamDialog.title" }) }))] })), fullWidth: true, open: open, scroll: "body", onClose: !canShowBackButton ? onClose : undefined, className: classNames(classes.root, className), TransitionComponent: Transition, PaperProps: { elevation: 0 } }, rest, { children: _jsxs(Box, Object.assign({ className: classes.content }, { children: [step === CreateLiveStreamStep.SELECT_TYPE && (_jsx(LiveStreamSelector, { liveSelected: liveType, onLiveSelected: handleLiveTypeSelected, onNext: handleLiveTypeSelectedNext })), step === CreateLiveStreamStep.CREATE_LIVE && (_jsx(_Fragment, { children: liveType === LiveStreamType.EVENT_LIVE ? (_jsx(EventForm, { EventAddressComponentProps: { locations: [SCEventLocationType.LIVESTREAM] }, onSuccess: handleSubmit })) : (_jsx(LiveStreamForm, { onSuccess: handleSubmit })) }))] })) })));
105
+ return (_jsx(Root, Object.assign({ DialogContentProps: { dividers: false }, maxWidth: "md", title: _jsxs(Box, Object.assign({ className: classes.title, component: "span" }, { children: [canShowBackButton && (_jsx(Button, Object.assign({ variant: "text", onClick: handleBack, startIcon: _jsx(Icon, { children: "arrow_back" }) }, { children: _jsx(FormattedMessage, { id: "ui.createLivestreamDialog.button.back", defaultMessage: "ui.createLivestreamDialog.button.back" }) }))), _jsx(Box, Object.assign({ component: "span" }, { children: _jsx(FormattedMessage, { id: "ui.createLivestreamDialog.title", defaultMessage: "ui.createLivestreamDialog.title" }) }))] })), fullWidth: true, open: open, scroll: "body", onClose: !canShowBackButton ? onClose : undefined, className: classNames(classes.root, className), TransitionComponent: Transition, PaperProps: { elevation: 0 } }, rest, { children: _jsxs(Box, Object.assign({ className: classes.content }, { children: [step === CreateLiveStreamStep.SELECT_TYPE && (_jsx(LiveStreamSelector, { liveSelected: liveType, onLiveSelected: handleLiveTypeSelected, onNext: handleLiveTypeSelectedNext })), step === CreateLiveStreamStep.CREATE_LIVE && (_jsx(_Fragment, { children: liveType === LiveStreamType.EVENT_LIVE ? (_jsx(EventForm, Object.assign({}, EventFormComponentProps, { EventAddressComponentProps: { locations: [SCEventLocationType.LIVESTREAM] }, onSuccess: handleSubmit }))) : (_jsx(LiveStreamForm, Object.assign({}, LiveStreamFormComponentProps, { onSuccess: handleSubmit }))) }))] })) })));
102
106
  }
@@ -18,7 +18,7 @@ export interface EventFormDialogProps extends BaseDialogProps {
18
18
  onClose?: () => void;
19
19
  /**
20
20
  * Props to spread to EventForm component
21
- * @default undefined
21
+ * @default {}
22
22
  */
23
23
  EventFormComponentProps?: EventFormProps;
24
24
  /**
@@ -40,14 +40,14 @@ export default function EventFormDialog(inProps) {
40
40
  props: inProps,
41
41
  name: PREFIX
42
42
  });
43
- const { className, open = true, onClose, EventFormComponentProps } = props, rest = __rest(props, ["className", "open", "onClose", "EventFormComponentProps"]);
43
+ const { className, open = true, onClose, EventFormComponentProps = {} } = props, rest = __rest(props, ["className", "open", "onClose", "EventFormComponentProps"]);
44
44
  const handleSuccess = useCallback((event) => {
45
45
  var _a;
46
- (_a = EventFormComponentProps === null || EventFormComponentProps === void 0 ? void 0 : EventFormComponentProps.onSuccess) === null || _a === void 0 ? void 0 : _a.call(EventFormComponentProps, event);
46
+ (_a = EventFormComponentProps.onSuccess) === null || _a === void 0 ? void 0 : _a.call(EventFormComponentProps, event);
47
47
  onClose === null || onClose === void 0 ? void 0 : onClose();
48
48
  }, [onClose, EventFormComponentProps]);
49
49
  /**
50
50
  * Renders root object
51
51
  */
52
- return (_jsx(Root, Object.assign({ DialogContentProps: { dividers: false }, title: (EventFormComponentProps === null || EventFormComponentProps === void 0 ? void 0 : EventFormComponentProps.event) ? (_jsx(FormattedMessage, { id: "ui.eventForm.title.edit", defaultMessage: "ui.eventForm.title.edit" })) : (_jsx(FormattedMessage, { id: "ui.eventForm.title", defaultMessage: "ui.eventForm.title" })), open: open, onClose: onClose, className: classNames(classes.root, className) }, rest, { children: _jsx(EventForm, Object.assign({}, (EventFormComponentProps && EventFormComponentProps), { onSuccess: handleSuccess })) })));
52
+ return (_jsx(Root, Object.assign({ DialogContentProps: { dividers: false }, title: (EventFormComponentProps === null || EventFormComponentProps === void 0 ? void 0 : EventFormComponentProps.event) ? (_jsx(FormattedMessage, { id: "ui.eventForm.title.edit", defaultMessage: "ui.eventForm.title.edit" })) : (_jsx(FormattedMessage, { id: "ui.eventForm.title", defaultMessage: "ui.eventForm.title" })), open: open, onClose: onClose, className: classNames(classes.root, className) }, rest, { children: _jsx(EventForm, Object.assign({}, EventFormComponentProps, { onSuccess: handleSuccess })) })));
53
53
  }
@@ -193,10 +193,10 @@ export default function GroupForm(inProps) {
193
193
  }
194
194
  groupService
195
195
  .then((data) => {
196
- onSuccess && onSuccess(data);
196
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
197
197
  notifyChanges(data);
198
- onClose && onClose();
199
198
  setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
199
+ onClose === null || onClose === void 0 ? void 0 : onClose();
200
200
  })
201
201
  .catch((e) => {
202
202
  setError(Object.assign(Object.assign({}, error), formatHttpErrorCode(e)));
@@ -26,7 +26,9 @@ export interface NavigationMenuDrawerProps extends DrawerProps {
26
26
  * Custom Drawer footer content
27
27
  * @default null
28
28
  */
29
- drawerFooterContent?: React.ReactNode;
29
+ drawerFooterContent?: React.ReactNode | ((props: {
30
+ handleCloseMenuDrawer: (event: any, reason: 'backdropClick' | 'escapeKeyDown') => void;
31
+ }) => React.ReactNode);
30
32
  /**
31
33
  * Props to spread to ScrollContainer component
32
34
  * This lib use 'react-custom-scrollbars' component to perform scrollbars
@@ -1,6 +1,6 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { useMemo } from 'react';
3
+ import React from 'react';
4
4
  import { styled } from '@mui/material/styles';
5
5
  import { Box, Divider, Drawer, Icon, IconButton, List } from '@mui/material';
6
6
  import classNames from 'classnames';
@@ -9,7 +9,6 @@ import ScrollContainer from '../../shared/ScrollContainer';
9
9
  import DefaultDrawerContent from './DefaultDrawerContent';
10
10
  import DefaultHeaderContent from './DefaultHeaderContent';
11
11
  import CreateLiveStreamButton from '../CreateLiveStreamButton';
12
- import { useSCUser } from '@selfcommunity/react-core';
13
12
  const PREFIX = 'SCNavigationMenuDrawer';
14
13
  const classes = {
15
14
  root: `${PREFIX}-root`,
@@ -28,14 +27,22 @@ const Root = styled(Drawer, {
28
27
  overridesResolver: (props, styles) => styles.root
29
28
  })(({ theme }) => ({}));
30
29
  export default function NavigationMenuDrawer(inProps) {
31
- var _a;
32
30
  // PROPS
33
31
  const props = useThemeProps({
34
32
  props: inProps,
35
33
  name: PREFIX
36
34
  });
37
35
  const { className = null, showDrawerHeader = true, drawerHeaderContent = _jsx(DefaultHeaderContent, {}), drawerContent = _jsx(DefaultDrawerContent, {}), showDrawerFooterContent = true, drawerFooterContent = null, ScrollContainerProps = { hideTracksWhenNotNeeded: true }, CreateLiveStreamButtonComponentProps = {}, open, onClose } = props, rest = __rest(props, ["className", "showDrawerHeader", "drawerHeaderContent", "drawerContent", "showDrawerFooterContent", "drawerFooterContent", "ScrollContainerProps", "CreateLiveStreamButtonComponentProps", "open", "onClose"]);
38
- const scUserContext = useSCUser();
39
- const canCreateLiveStream = useMemo(() => { var _a, _b; return (_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_live_stream; }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission]);
40
- return (_jsxs(Root, Object.assign({ anchor: "left", className: classNames(classes.root, className), open: open, onClose: onClose }, rest, { children: [showDrawerHeader && (_jsxs(_Fragment, { children: [_jsxs(Box, Object.assign({ className: classes.drawerHeader }, { children: [drawerHeaderContent, _jsx(IconButton, Object.assign({ className: classes.drawerHeaderAction, onClick: onClose }, { children: _jsx(Icon, { children: "close" }) }))] })), _jsx(Divider, {})] })), _jsx(ScrollContainer, Object.assign({}, ScrollContainerProps, { children: _jsx(List, Object.assign({ className: classes.drawerContent, onClick: onClose }, { children: drawerContent })) })), showDrawerFooterContent && (_jsx(_Fragment, { children: _jsx(Box, Object.assign({ className: classes.drawerFooter }, { children: drawerFooterContent ? (drawerFooterContent) : (_jsx(Box, Object.assign({ className: classes.drawerFooterLiveStream }, { children: _jsx(CreateLiveStreamButton, Object.assign({ color: "primary", className: classes.drawerFooterLiveStreamButton, fullWidth: true }, CreateLiveStreamButtonComponentProps)) }))) })) }))] })));
36
+ const footerContent = (() => {
37
+ if (typeof drawerFooterContent === 'function') {
38
+ return drawerFooterContent({ handleCloseMenuDrawer: onClose });
39
+ }
40
+ if (React.isValidElement(drawerFooterContent)) {
41
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
42
+ // @ts-ignore
43
+ return React.cloneElement(drawerFooterContent, { handleCloseMenuDrawer: onClose });
44
+ }
45
+ return drawerFooterContent;
46
+ })();
47
+ return (_jsxs(Root, Object.assign({ anchor: "left", className: classNames(classes.root, className), open: open, onClose: onClose }, rest, { children: [showDrawerHeader && (_jsxs(_Fragment, { children: [_jsxs(Box, Object.assign({ className: classes.drawerHeader }, { children: [drawerHeaderContent, _jsx(IconButton, Object.assign({ className: classes.drawerHeaderAction, onClick: onClose }, { children: _jsx(Icon, { children: "close" }) }))] })), _jsx(Divider, {})] })), _jsx(ScrollContainer, Object.assign({}, ScrollContainerProps, { children: _jsx(List, Object.assign({ className: classes.drawerContent, onClick: onClose }, { children: drawerContent })) })), showDrawerFooterContent && (_jsx(_Fragment, { children: _jsx(Box, Object.assign({ component: "div", className: classes.drawerFooter }, { children: footerContent || (_jsx(Box, Object.assign({ className: classes.drawerFooterLiveStream }, { children: _jsx(CreateLiveStreamButton, Object.assign({ color: "primary", className: classes.drawerFooterLiveStreamButton, fullWidth: true }, CreateLiveStreamButtonComponentProps)) }))) })) }))] })));
41
48
  }