@selfcommunity/react-ui 0.10.2-courses.207 → 0.10.2-courses.209
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/CreateLiveStreamButton/CreateLiveStreamButton.d.ts +0 -6
- package/lib/cjs/components/CreateLiveStreamButton/CreateLiveStreamButton.js +2 -9
- package/lib/cjs/components/CreateLiveStreamDialog/CreateLiveStreamDialog.d.ts +10 -4
- package/lib/cjs/components/CreateLiveStreamDialog/CreateLiveStreamDialog.js +8 -4
- package/lib/cjs/components/EventFormDialog/EventFormDialog.d.ts +1 -1
- package/lib/cjs/components/EventFormDialog/EventFormDialog.js +3 -3
- package/lib/cjs/components/GroupForm/GroupForm.js +2 -2
- package/lib/cjs/components/Groups/Groups.js +18 -16
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.d.ts +3 -1
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.js +13 -6
- package/lib/cjs/components/Notification/Event/Event.js +10 -0
- package/lib/esm/components/CreateLiveStreamButton/CreateLiveStreamButton.d.ts +0 -6
- package/lib/esm/components/CreateLiveStreamButton/CreateLiveStreamButton.js +2 -9
- package/lib/esm/components/CreateLiveStreamDialog/CreateLiveStreamDialog.d.ts +10 -4
- package/lib/esm/components/CreateLiveStreamDialog/CreateLiveStreamDialog.js +8 -4
- package/lib/esm/components/EventFormDialog/EventFormDialog.d.ts +1 -1
- package/lib/esm/components/EventFormDialog/EventFormDialog.js +3 -3
- package/lib/esm/components/GroupForm/GroupForm.js +2 -2
- package/lib/esm/components/Groups/Groups.js +21 -19
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.d.ts +3 -1
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.js +13 -6
- package/lib/esm/components/Notification/Event/Event.js +10 -0
- package/lib/umd/react-ui.js +1 -1
- 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 = {},
|
|
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
|
|
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
|
-
*
|
|
21
|
-
* @default
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
90
|
-
|
|
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;
|
|
@@ -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
|
|
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({},
|
|
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
|
|
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)));
|
|
@@ -23,6 +23,7 @@ const PubSub_1 = require("../../constants/PubSub");
|
|
|
23
23
|
const classes = {
|
|
24
24
|
root: `${constants_1.PREFIX}-root`,
|
|
25
25
|
filters: `${constants_1.PREFIX}-filter`,
|
|
26
|
+
search: `${constants_1.PREFIX}-search`,
|
|
26
27
|
groups: `${constants_1.PREFIX}-groups`,
|
|
27
28
|
item: `${constants_1.PREFIX}-item`,
|
|
28
29
|
noResults: `${constants_1.PREFIX}-no-results`,
|
|
@@ -96,13 +97,14 @@ function Groups(inProps) {
|
|
|
96
97
|
/**
|
|
97
98
|
* Fetches groups list
|
|
98
99
|
*/
|
|
99
|
-
const fetchGroups = () => {
|
|
100
|
+
const fetchGroups = (searchValue = search) => {
|
|
101
|
+
setLoading(true);
|
|
100
102
|
let groupService;
|
|
101
103
|
if (general) {
|
|
102
|
-
groupService = api_services_1.GroupService.searchGroups(Object.assign(Object.assign({}, endpointQueryParams), (
|
|
104
|
+
groupService = api_services_1.GroupService.searchGroups(Object.assign(Object.assign({}, endpointQueryParams), (searchValue && { search: searchValue })));
|
|
103
105
|
}
|
|
104
106
|
else {
|
|
105
|
-
groupService = api_services_1.GroupService.getUserGroups(Object.assign(Object.assign({}, endpointQueryParams), (
|
|
107
|
+
groupService = api_services_1.GroupService.getUserGroups(Object.assign(Object.assign({}, endpointQueryParams), (searchValue && { search: searchValue })));
|
|
106
108
|
}
|
|
107
109
|
groupService
|
|
108
110
|
.then((res) => {
|
|
@@ -124,7 +126,7 @@ function Groups(inProps) {
|
|
|
124
126
|
else {
|
|
125
127
|
fetchGroups();
|
|
126
128
|
}
|
|
127
|
-
}, [contentAvailability, authUserId
|
|
129
|
+
}, [contentAvailability, authUserId]);
|
|
128
130
|
/**
|
|
129
131
|
* Subscriber for pubsub callback
|
|
130
132
|
*/
|
|
@@ -163,15 +165,6 @@ function Groups(inProps) {
|
|
|
163
165
|
.catch((error) => console.log(error))
|
|
164
166
|
.then(() => setLoading(false));
|
|
165
167
|
}, [next]);
|
|
166
|
-
/**
|
|
167
|
-
* Get groups filtered
|
|
168
|
-
*/
|
|
169
|
-
const getFilteredGroups = () => {
|
|
170
|
-
if (search) {
|
|
171
|
-
return groups.filter((g) => g.name.toLowerCase().includes(search.toLowerCase()));
|
|
172
|
-
}
|
|
173
|
-
return groups;
|
|
174
|
-
};
|
|
175
168
|
/**
|
|
176
169
|
* Handle change filter name
|
|
177
170
|
* @param event
|
|
@@ -182,12 +175,21 @@ function Groups(inProps) {
|
|
|
182
175
|
/**
|
|
183
176
|
* Renders groups list
|
|
184
177
|
*/
|
|
185
|
-
const
|
|
186
|
-
|
|
178
|
+
const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showFilters && (groups.length !== 0 || search.length !== 0) && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ container: true, direction: "row", justifyContent: "center", alignItems: "center", className: classes.filters }, { children: filters ? (filters) : ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 6 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { className: classes.search, fullWidth: true, value: search, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groups.filterByName", defaultMessage: "ui.groups.filterByName" }), variant: "outlined", onChange: handleOnChangeFilterName, disabled: loading, onKeyUp: (e) => {
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
if (e.key === 'Enter') {
|
|
181
|
+
fetchGroups();
|
|
182
|
+
}
|
|
183
|
+
}, InputProps: {
|
|
184
|
+
endAdornment: ((0, jsx_runtime_1.jsxs)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: [search.length > 0 && ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => {
|
|
185
|
+
setSearch('');
|
|
186
|
+
fetchGroups('');
|
|
187
|
+
}, disabled: loading }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) }))), isMobile ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => fetchGroups(), disabled: loading }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "search" }) }))) : ((0, jsx_runtime_1.jsx)(material_1.Button, { size: "small", variant: "contained", color: "secondary", onClick: () => fetchGroups(), endIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "search" }), disabled: loading }))] })))
|
|
188
|
+
} }) }))) }))), (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !groups.length ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.noResults }, { children: search.length ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groups.noResults", defaultMessage: "ui.groups.noResults" }) }))) : !onlyStaffEnabled ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h4" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groups.noGroups.title", defaultMessage: "ui.groups.noGroups.title" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groups.noGroups.subtitle", defaultMessage: "ui.groups.noGroups.subtitle" }) }))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h4" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groups.noGroups.title.onlyStaff", defaultMessage: "ui.groups.noGroups.title.onlyStaff" }) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groups.noGroups.subtitle.onlyStaff", defaultMessage: "ui.groups.noGroups.subtitle.onlyStaff" }) }))] })) }))) : ((0, jsx_runtime_1.jsx)(InfiniteScroll_1.default, Object.assign({ dataLength: groups.length, next: handleNext, hasMoreNext: Boolean(next), loaderNext: isMobile ? (0, jsx_runtime_1.jsx)(Group_1.GroupSkeleton, {}) : (0, jsx_runtime_1.jsx)(Skeleton_1.default, { groupsNumber: 2 }), endMessage: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ component: "div", className: classes.endMessage }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groups.endMessage", defaultMessage: "ui.groups.endMessage", values: {
|
|
187
189
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
188
190
|
// @ts-ignore
|
|
189
191
|
button: (chunk) => ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ color: "secondary", variant: "text", onClick: handleScrollUp }, { children: chunk })))
|
|
190
|
-
} }) })) }, { children: (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ container: true, spacing: { xs: 2 }, className: classes.groups }, { children:
|
|
192
|
+
} }) })) }, { children: (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ container: true, spacing: { xs: 2 }, className: classes.groups }, { children: groups.map((group) => ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, sm: 8, md: 6, className: classes.item }, { children: (0, jsx_runtime_1.jsx)(Group_1.default, Object.assign({ group: group, groupId: group.id, actionRedirect: true }, GroupComponentProps)) }), group.id))) })) }))) })] }));
|
|
191
193
|
// RENDER
|
|
192
194
|
if (!contentAvailability && !scUserContext.user) {
|
|
193
195
|
return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
|
|
@@ -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
|
|
41
|
-
|
|
42
|
-
|
|
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;
|
|
@@ -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 = {},
|
|
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
|
|
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
|
-
*
|
|
21
|
-
* @default
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
88
|
-
|
|
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
|
}
|
|
@@ -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
|
|
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({},
|
|
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
|
|
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)));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import { jsx as _jsx,
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
|
-
import { Box, Button, Grid, TextField, Typography, useMediaQuery, useTheme } from '@mui/material';
|
|
5
|
+
import { Box, Button, Grid, Icon, IconButton, InputAdornment, TextField, Typography, useMediaQuery, useTheme } from '@mui/material';
|
|
6
6
|
import { Endpoints, GroupService, http } from '@selfcommunity/api-services';
|
|
7
|
-
import { Logger
|
|
7
|
+
import { Logger } from '@selfcommunity/utils';
|
|
8
8
|
import { SCPreferences, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
|
|
9
9
|
import Skeleton from './Skeleton';
|
|
10
10
|
import { FormattedMessage } from 'react-intl';
|
|
@@ -21,6 +21,7 @@ import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
|
|
|
21
21
|
const classes = {
|
|
22
22
|
root: `${PREFIX}-root`,
|
|
23
23
|
filters: `${PREFIX}-filter`,
|
|
24
|
+
search: `${PREFIX}-search`,
|
|
24
25
|
groups: `${PREFIX}-groups`,
|
|
25
26
|
item: `${PREFIX}-item`,
|
|
26
27
|
noResults: `${PREFIX}-no-results`,
|
|
@@ -94,13 +95,14 @@ export default function Groups(inProps) {
|
|
|
94
95
|
/**
|
|
95
96
|
* Fetches groups list
|
|
96
97
|
*/
|
|
97
|
-
const fetchGroups = () => {
|
|
98
|
+
const fetchGroups = (searchValue = search) => {
|
|
99
|
+
setLoading(true);
|
|
98
100
|
let groupService;
|
|
99
101
|
if (general) {
|
|
100
|
-
groupService = GroupService.searchGroups(Object.assign(Object.assign({}, endpointQueryParams), (
|
|
102
|
+
groupService = GroupService.searchGroups(Object.assign(Object.assign({}, endpointQueryParams), (searchValue && { search: searchValue })));
|
|
101
103
|
}
|
|
102
104
|
else {
|
|
103
|
-
groupService = GroupService.getUserGroups(Object.assign(Object.assign({}, endpointQueryParams), (
|
|
105
|
+
groupService = GroupService.getUserGroups(Object.assign(Object.assign({}, endpointQueryParams), (searchValue && { search: searchValue })));
|
|
104
106
|
}
|
|
105
107
|
groupService
|
|
106
108
|
.then((res) => {
|
|
@@ -122,7 +124,7 @@ export default function Groups(inProps) {
|
|
|
122
124
|
else {
|
|
123
125
|
fetchGroups();
|
|
124
126
|
}
|
|
125
|
-
}, [contentAvailability, authUserId
|
|
127
|
+
}, [contentAvailability, authUserId]);
|
|
126
128
|
/**
|
|
127
129
|
* Subscriber for pubsub callback
|
|
128
130
|
*/
|
|
@@ -161,15 +163,6 @@ export default function Groups(inProps) {
|
|
|
161
163
|
.catch((error) => console.log(error))
|
|
162
164
|
.then(() => setLoading(false));
|
|
163
165
|
}, [next]);
|
|
164
|
-
/**
|
|
165
|
-
* Get groups filtered
|
|
166
|
-
*/
|
|
167
|
-
const getFilteredGroups = () => {
|
|
168
|
-
if (search) {
|
|
169
|
-
return groups.filter((g) => g.name.toLowerCase().includes(search.toLowerCase()));
|
|
170
|
-
}
|
|
171
|
-
return groups;
|
|
172
|
-
};
|
|
173
166
|
/**
|
|
174
167
|
* Handle change filter name
|
|
175
168
|
* @param event
|
|
@@ -180,12 +173,21 @@ export default function Groups(inProps) {
|
|
|
180
173
|
/**
|
|
181
174
|
* Renders groups list
|
|
182
175
|
*/
|
|
183
|
-
const
|
|
184
|
-
|
|
176
|
+
const content = (_jsxs(_Fragment, { children: [showFilters && (groups.length !== 0 || search.length !== 0) && (_jsx(Grid, Object.assign({ container: true, direction: "row", justifyContent: "center", alignItems: "center", className: classes.filters }, { children: filters ? (filters) : (_jsx(Grid, Object.assign({ item: true, xs: 12, md: 6 }, { children: _jsx(TextField, { className: classes.search, fullWidth: true, value: search, label: _jsx(FormattedMessage, { id: "ui.groups.filterByName", defaultMessage: "ui.groups.filterByName" }), variant: "outlined", onChange: handleOnChangeFilterName, disabled: loading, onKeyUp: (e) => {
|
|
177
|
+
e.preventDefault();
|
|
178
|
+
if (e.key === 'Enter') {
|
|
179
|
+
fetchGroups();
|
|
180
|
+
}
|
|
181
|
+
}, InputProps: {
|
|
182
|
+
endAdornment: (_jsxs(InputAdornment, Object.assign({ position: "end" }, { children: [search.length > 0 && (_jsx(IconButton, Object.assign({ onClick: () => {
|
|
183
|
+
setSearch('');
|
|
184
|
+
fetchGroups('');
|
|
185
|
+
}, disabled: loading }, { children: _jsx(Icon, { children: "close" }) }))), isMobile ? (_jsx(IconButton, Object.assign({ onClick: () => fetchGroups(), disabled: loading }, { children: _jsx(Icon, { children: "search" }) }))) : (_jsx(Button, { size: "small", variant: "contained", color: "secondary", onClick: () => fetchGroups(), endIcon: _jsx(Icon, { children: "search" }), disabled: loading }))] })))
|
|
186
|
+
} }) }))) }))), _jsx(_Fragment, { children: !groups.length ? (_jsx(Box, Object.assign({ className: classes.noResults }, { children: search.length ? (_jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.groups.noResults", defaultMessage: "ui.groups.noResults" }) }))) : !onlyStaffEnabled ? (_jsxs(_Fragment, { children: [_jsx(Typography, Object.assign({ variant: "h4" }, { children: _jsx(FormattedMessage, { id: "ui.groups.noGroups.title", defaultMessage: "ui.groups.noGroups.title" }) })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.groups.noGroups.subtitle", defaultMessage: "ui.groups.noGroups.subtitle" }) }))] })) : (_jsxs(_Fragment, { children: [_jsx(Typography, Object.assign({ variant: "h4" }, { children: _jsx(FormattedMessage, { id: "ui.groups.noGroups.title.onlyStaff", defaultMessage: "ui.groups.noGroups.title.onlyStaff" }) })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.groups.noGroups.subtitle.onlyStaff", defaultMessage: "ui.groups.noGroups.subtitle.onlyStaff" }) }))] })) }))) : (_jsx(InfiniteScroll, Object.assign({ dataLength: groups.length, next: handleNext, hasMoreNext: Boolean(next), loaderNext: isMobile ? _jsx(GroupSkeleton, {}) : _jsx(Skeleton, { groupsNumber: 2 }), endMessage: _jsx(Typography, Object.assign({ component: "div", className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.groups.endMessage", defaultMessage: "ui.groups.endMessage", values: {
|
|
185
187
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
186
188
|
// @ts-ignore
|
|
187
189
|
button: (chunk) => (_jsx(Button, Object.assign({ color: "secondary", variant: "text", onClick: handleScrollUp }, { children: chunk })))
|
|
188
|
-
} }) })) }, { children: _jsx(Grid, Object.assign({ container: true, spacing: { xs: 2 }, className: classes.groups }, { children:
|
|
190
|
+
} }) })) }, { children: _jsx(Grid, Object.assign({ container: true, spacing: { xs: 2 }, className: classes.groups }, { children: groups.map((group) => (_jsx(Grid, Object.assign({ item: true, xs: 12, sm: 8, md: 6, className: classes.item }, { children: _jsx(Group, Object.assign({ group: group, groupId: group.id, actionRedirect: true }, GroupComponentProps)) }), group.id))) })) }))) })] }));
|
|
189
191
|
// RENDER
|
|
190
192
|
if (!contentAvailability && !scUserContext.user) {
|
|
191
193
|
return _jsx(HiddenPlaceholder, {});
|
|
@@ -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
|