@selfcommunity/react-ui 0.8.0-live.97 → 0.8.0-live.99
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/EventForm/EventForm.js +18 -8
- package/lib/cjs/components/EventMembersWidget/EventMembersWidget.js +7 -7
- package/lib/cjs/components/EventMembersWidget/TabContentComponent.js +11 -6
- package/lib/cjs/components/LiveStreamForm/LiveStreamForm.js +2 -6
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/useLiveStreamCheck.d.ts +1 -5
- package/lib/cjs/components/LiveStreamRoom/LiveStreamVideoConference/useLiveStreamCheck.js +93 -29
- package/lib/cjs/components/LiveStreamRoom/constants.d.ts +6 -0
- package/lib/cjs/components/LiveStreamRoom/constants.js +7 -1
- package/lib/cjs/shared/EventInfoDetails/index.js +2 -1
- package/lib/esm/components/EventForm/EventForm.js +18 -8
- package/lib/esm/components/EventMembersWidget/EventMembersWidget.js +7 -7
- package/lib/esm/components/EventMembersWidget/TabContentComponent.js +11 -6
- package/lib/esm/components/LiveStreamForm/LiveStreamForm.js +2 -6
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/useLiveStreamCheck.d.ts +1 -5
- package/lib/esm/components/LiveStreamRoom/LiveStreamVideoConference/useLiveStreamCheck.js +95 -31
- package/lib/esm/components/LiveStreamRoom/constants.d.ts +6 -0
- package/lib/esm/components/LiveStreamRoom/constants.js +6 -0
- package/lib/esm/shared/EventInfoDetails/index.js +2 -1
- package/lib/umd/react-ui.js +1 -1
- package/package.json +8 -8
|
@@ -181,6 +181,7 @@ function EventForm(inProps) {
|
|
|
181
181
|
delete error.imageOriginalError;
|
|
182
182
|
setError(error);
|
|
183
183
|
}
|
|
184
|
+
setGenericError(null);
|
|
184
185
|
}, [error]);
|
|
185
186
|
/**
|
|
186
187
|
* Notify when a group info changed
|
|
@@ -198,6 +199,7 @@ function EventForm(inProps) {
|
|
|
198
199
|
}, [event]);
|
|
199
200
|
const handleGeoData = (0, react_1.useCallback)((data) => {
|
|
200
201
|
setField((prev) => (Object.assign(Object.assign({}, prev), data)));
|
|
202
|
+
setGenericError(null);
|
|
201
203
|
}, []);
|
|
202
204
|
const handleLiveStreamSettingsData = (0, react_1.useCallback)((data) => {
|
|
203
205
|
setField((prev) => (Object.assign(Object.assign({}, prev), { liveStreamSettings: Object.assign(Object.assign({}, prev.liveStreamSettings), data) })));
|
|
@@ -251,13 +253,13 @@ function EventForm(inProps) {
|
|
|
251
253
|
})
|
|
252
254
|
.catch((e) => {
|
|
253
255
|
const _error = (0, api_services_1.formatHttpErrorCode)(e);
|
|
254
|
-
if (Object.
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
256
|
+
if (!Object.keys(_error).length) {
|
|
257
|
+
setGenericError(intl.formatMessage({
|
|
258
|
+
id: 'ui.eventForm.genericError',
|
|
259
|
+
defaultMessage: 'ui.eventForm.genericError'
|
|
260
|
+
}));
|
|
259
261
|
}
|
|
260
|
-
if ('errorsError' in _error) {
|
|
262
|
+
else if ('errorsError' in _error) {
|
|
261
263
|
setGenericError(intl.formatMessage({
|
|
262
264
|
id: 'ui.eventForm.liveStream.error.monthlyMinuteLimitReached',
|
|
263
265
|
defaultMessage: 'ui.eventForm.liveStream.error.monthlyMinuteLimitReached'
|
|
@@ -266,6 +268,14 @@ function EventForm(inProps) {
|
|
|
266
268
|
else {
|
|
267
269
|
setGenericError(null);
|
|
268
270
|
}
|
|
271
|
+
let __errors = {};
|
|
272
|
+
if ('coverError' in _error) {
|
|
273
|
+
__errors = Object.assign(Object.assign({}, __errors), { ['coverError']: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.ui.eventForm.cover.error", defaultMessage: "ui.ui.eventForm.cover.error" }) });
|
|
274
|
+
}
|
|
275
|
+
if ('titleError' in _error) {
|
|
276
|
+
__errors = Object.assign(Object.assign({}, __errors), { ['titleError']: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.name.error.unique", defaultMessage: "ui.eventForm.name.error.unique" }) });
|
|
277
|
+
}
|
|
278
|
+
setError(__errors);
|
|
269
279
|
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
270
280
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, e);
|
|
271
281
|
onError === null || onError === void 0 ? void 0 : onError(e);
|
|
@@ -314,7 +324,7 @@ function EventForm(inProps) {
|
|
|
314
324
|
/**
|
|
315
325
|
* Renders root object
|
|
316
326
|
*/
|
|
317
|
-
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [(0, jsx_runtime_1.jsx)(material_1.Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: (0, jsx_runtime_1.jsx)(UploadEventCover_1.default, { isCreationMode: true, onChange: handleChangeCover }) })), (0, jsx_runtime_1.jsxs)(material_1.FormGroup, Object.assign({ className: classes.form }, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
|
|
327
|
+
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [(0, jsx_runtime_1.jsx)(material_1.Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: (0, jsx_runtime_1.jsx)(UploadEventCover_1.default, { isCreationMode: true, onChange: handleChangeCover }) })), Boolean(error['coverError']) && (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ color: "error" }, { children: error['coverError'] })), (0, jsx_runtime_1.jsxs)(material_1.FormGroup, Object.assign({ className: classes.form }, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
|
|
318
328
|
endAdornment: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: Event_1.EVENT_TITLE_MAX_LENGTH - field.name.length }))
|
|
319
329
|
}, error: Boolean(field.name.length > Event_1.EVENT_TITLE_MAX_LENGTH) || Boolean(error['nameError']), helperText: field.name.length > Event_1.EVENT_TITLE_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.name.error.maxLength", defaultMessage: "ui.eventForm.name.error.maxLength" })) : error['nameError'] ? (error['nameError']) : null }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.dateTime }, { children: (0, jsx_runtime_1.jsxs)(x_date_pickers_1.LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.default : en_US_1.default }, { children: [(0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDatePicker, { className: classes.picker, disablePast: true, label: field.startDate && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.placeholder", defaultMessage: "ui.eventForm.date.placeholder" }), value: field.startDate, slots: {
|
|
320
330
|
textField: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.startDate)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "CalendarIcon" }) }) }))) }) })))
|
|
@@ -385,7 +395,7 @@ function EventForm(inProps) {
|
|
|
385
395
|
(field.location === types_1.SCEventLocationType.ONLINE && !field.link) ||
|
|
386
396
|
(field.location === types_1.SCEventLocationType.PERSON && !field.geolocation) ||
|
|
387
397
|
(field.recurring !== types_1.SCEventRecurrenceType.NEVER && !field.endDate && !field.endTime) ||
|
|
388
|
-
|
|
398
|
+
field.isSubmitting ||
|
|
389
399
|
field.name.length > Event_1.EVENT_TITLE_MAX_LENGTH ||
|
|
390
400
|
field.description.length > Event_1.EVENT_DESCRIPTION_MAX_LENGTH, variant: "contained", onClick: handleSubmit, color: "secondary" }, { children: event ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.button.edit", defaultMessage: "ui.eventForm.button.edit" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.button.create", defaultMessage: "ui.eventForm.button.create" })) })) }))] }))] })));
|
|
391
401
|
}
|
|
@@ -99,7 +99,7 @@ function EventMembersWidget(inProps) {
|
|
|
99
99
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
-
}, [participants.isLoadingNext, participants.initialized, scEvent, dispatchParticipants, setParticipantsCount]);
|
|
102
|
+
}, [participants.isLoadingNext, participants.initialized, scEvent, endpointQueryParams, dispatchParticipants, setParticipantsCount]);
|
|
103
103
|
const _initInvited = (0, react_1.useCallback)(() => {
|
|
104
104
|
if (!invited.initialized && !invited.isLoadingNext && hasAllow) {
|
|
105
105
|
dispatchInvited({ type: widget_1.actionWidgetTypes.LOADING_NEXT });
|
|
@@ -113,7 +113,7 @@ function EventMembersWidget(inProps) {
|
|
|
113
113
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
|
-
}, [invited.isLoadingNext, invited.initialized, scEvent, dispatchInvited, setInvitedCount]);
|
|
116
|
+
}, [invited.isLoadingNext, invited.initialized, scEvent, hasAllow, endpointQueryParams, dispatchInvited, setInvitedCount]);
|
|
117
117
|
const _initRequests = (0, react_1.useCallback)(() => {
|
|
118
118
|
if (!requests.initialized && !requests.isLoadingNext && hasAllow) {
|
|
119
119
|
dispatchRequests({ type: widget_1.actionWidgetTypes.LOADING_NEXT });
|
|
@@ -128,7 +128,7 @@ function EventMembersWidget(inProps) {
|
|
|
128
128
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
}, [requests.isLoadingNext, requests.initialized, scEvent, dispatchRequests, setRequestsCount, setRequestsUsers]);
|
|
131
|
+
}, [requests.isLoadingNext, requests.initialized, scEvent, hasAllow, endpointQueryParams, dispatchRequests, setRequestsCount, setRequestsUsers]);
|
|
132
132
|
// EFFECTS
|
|
133
133
|
(0, react_1.useEffect)(() => {
|
|
134
134
|
let _t;
|
|
@@ -152,18 +152,18 @@ function EventMembersWidget(inProps) {
|
|
|
152
152
|
clearTimeout(_t);
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
|
-
}, [scUserContext.user, scEvent, refresh]);
|
|
155
|
+
}, [scUserContext.user, scEvent, refresh, _initParticipants, _initInvited, _initRequests]);
|
|
156
156
|
(0, react_1.useEffect)(() => {
|
|
157
157
|
if (participants.initialized && scEvent && Boolean((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id))) {
|
|
158
158
|
dispatchParticipants({ type: widget_1.actionWidgetTypes.RESET, payload: {} });
|
|
159
159
|
dispatchRequests({ type: widget_1.actionWidgetTypes.RESET, payload: {} });
|
|
160
160
|
dispatchInvited({ type: widget_1.actionWidgetTypes.RESET, payload: {} });
|
|
161
161
|
}
|
|
162
|
-
}, [participants.initialized, scEvent, eventId, event]);
|
|
162
|
+
}, [participants.initialized, scEvent, eventId, event, dispatchParticipants, dispatchInvited, dispatchRequests]);
|
|
163
163
|
// HANDLERS
|
|
164
164
|
const handleTabChange = (0, react_1.useCallback)((_evt, newTabValue) => {
|
|
165
165
|
setTabValue(newTabValue);
|
|
166
|
-
}, []);
|
|
166
|
+
}, [setTabValue]);
|
|
167
167
|
const handleRefresh = (0, react_1.useCallback)((_tabValue) => {
|
|
168
168
|
if (_tabValue === types_1.TabContentEnum.PARTICIPANTS) {
|
|
169
169
|
dispatchParticipants({ type: widget_1.actionWidgetTypes.RESET });
|
|
@@ -172,7 +172,7 @@ function EventMembersWidget(inProps) {
|
|
|
172
172
|
dispatchInvited({ type: widget_1.actionWidgetTypes.RESET });
|
|
173
173
|
}
|
|
174
174
|
setRefresh(_tabValue);
|
|
175
|
-
}, []);
|
|
175
|
+
}, [dispatchParticipants, dispatchInvited, setRefresh]);
|
|
176
176
|
if (!scUserContext.user) {
|
|
177
177
|
return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
|
|
178
178
|
}
|
|
@@ -43,7 +43,7 @@ function TabContentComponent(props) {
|
|
|
43
43
|
// HOOKS
|
|
44
44
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
45
45
|
// CONSTS
|
|
46
|
-
const users = (0, react_1.useMemo)(() => (tabValue === types_1.TabContentEnum.REQUESTS ? actionProps === null || actionProps === void 0 ? void 0 : actionProps.users : state.results), [tabValue, actionProps, state]);
|
|
46
|
+
const users = (0, react_1.useMemo)(() => (tabValue === types_1.TabContentEnum.REQUESTS ? actionProps === null || actionProps === void 0 ? void 0 : actionProps.users : state.results), [tabValue, actionProps === null || actionProps === void 0 ? void 0 : actionProps.users, state.results]);
|
|
47
47
|
// EFFECTS
|
|
48
48
|
(0, react_1.useEffect)(() => {
|
|
49
49
|
updatesInvited.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.INVITE_MEMBER}`, handleInviteMember);
|
|
@@ -53,6 +53,11 @@ function TabContentComponent(props) {
|
|
|
53
53
|
updatesParticipants.current && pubsub_js_1.default.unsubscribe(updatesParticipants.current);
|
|
54
54
|
};
|
|
55
55
|
}, []);
|
|
56
|
+
(0, react_1.useEffect)(() => {
|
|
57
|
+
if (openDialog && state.next && state.initialized) {
|
|
58
|
+
handleNext();
|
|
59
|
+
}
|
|
60
|
+
}, [openDialog, state.next, state.initialized]);
|
|
56
61
|
// HANDLERS
|
|
57
62
|
/**
|
|
58
63
|
* Handles pagination
|
|
@@ -70,16 +75,16 @@ function TabContentComponent(props) {
|
|
|
70
75
|
.catch((error) => {
|
|
71
76
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
72
77
|
});
|
|
73
|
-
}, [state.next, state.isLoadingNext, state.initialized]);
|
|
78
|
+
}, [state.next, state.isLoadingNext, state.initialized, dispatch]);
|
|
74
79
|
const handleToggleDialogOpen = (0, react_1.useCallback)(() => {
|
|
75
80
|
setOpenDialog((prev) => !prev);
|
|
76
|
-
}, []);
|
|
81
|
+
}, [setOpenDialog]);
|
|
77
82
|
const handleToggleMember = (0, react_1.useCallback)(() => {
|
|
78
83
|
handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(types_1.TabContentEnum.PARTICIPANTS);
|
|
79
|
-
}, []);
|
|
84
|
+
}, [handleRefresh]);
|
|
80
85
|
const handleInviteMember = (0, react_1.useCallback)(() => {
|
|
81
86
|
handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(types_1.TabContentEnum.INVITED);
|
|
82
|
-
}, []);
|
|
87
|
+
}, [handleRefresh]);
|
|
83
88
|
const getActionsComponent = (0, react_1.useCallback)((userId) => {
|
|
84
89
|
if (tabValue === types_1.TabContentEnum.INVITED && actionProps) {
|
|
85
90
|
const _handleInvitations = (invited) => {
|
|
@@ -130,6 +135,6 @@ function TabContentComponent(props) {
|
|
|
130
135
|
else if (tabValue === types_1.TabContentEnum.REQUESTS && (actionProps === null || actionProps === void 0 ? void 0 : actionProps.count) === 0) {
|
|
131
136
|
return ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMembersWidget.noOtherRequests", defaultMessage: "ui.eventMembersWidget.noOtherRequests" }) })));
|
|
132
137
|
}
|
|
133
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.List, { children: users === null || users === void 0 ? void 0 : users.map((user) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(User_1.default, Object.assign({ elevation: 0, user: user }, userProps, { actions: getActionsComponent(user.id) })) }, user.id))) }), state.count > state.visibleItems && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: handleToggleDialogOpen, className: classes.actionButton }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "caption" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMembersWidget.showAll", defaultMessage: "ui.eventMembersWidget.showAll" }) })) }))), openDialog && ((0, jsx_runtime_1.jsx)(DialogRoot, Object.assign({ className: classes.dialogRoot, title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.eventMembersWidget.title", id: "ui.eventMembersWidget.title" }), onClose: handleToggleDialogOpen, open: openDialog }, dialogProps, { children: (0, jsx_runtime_1.jsx)(InfiniteScroll_1.default, Object.assign({ dataLength: state.results.length, next: handleNext, hasMoreNext: Boolean(state.next), loaderNext: (0, jsx_runtime_1.jsx)(User_1.UserSkeleton, Object.assign({ elevation: 0 }, userProps)), className: classes.infiniteScroll, endMessage: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.endMessage }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMembersWidget.noMoreResults", defaultMessage: "ui.eventMembersWidget.noMoreResults" }) })) }, { children: (0, jsx_runtime_1.jsx)(material_1.List, { children: state.results.map((user) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(User_1.default, Object.assign({ elevation: 0, user: user }, userProps)) }, user.id))) }) })) })))] }));
|
|
138
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.List, { children: users === null || users === void 0 ? void 0 : users.slice(0, state.visibleItems).map((user) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(User_1.default, Object.assign({ elevation: 0, user: user }, userProps, { actions: getActionsComponent(user.id) })) }, user.id))) }), state.count > state.visibleItems && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: handleToggleDialogOpen, className: classes.actionButton }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "caption" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMembersWidget.showAll", defaultMessage: "ui.eventMembersWidget.showAll" }) })) }))), openDialog && ((0, jsx_runtime_1.jsx)(DialogRoot, Object.assign({ className: classes.dialogRoot, title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.eventMembersWidget.title", id: "ui.eventMembersWidget.title" }), onClose: handleToggleDialogOpen, open: openDialog }, dialogProps, { children: (0, jsx_runtime_1.jsx)(InfiniteScroll_1.default, Object.assign({ dataLength: state.results.length, next: handleNext, hasMoreNext: Boolean(state.next), loaderNext: (0, jsx_runtime_1.jsx)(User_1.UserSkeleton, Object.assign({ elevation: 0 }, userProps)), className: classes.infiniteScroll, endMessage: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.endMessage }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMembersWidget.noMoreResults", defaultMessage: "ui.eventMembersWidget.noMoreResults" }) })) }, { children: (0, jsx_runtime_1.jsx)(material_1.List, { children: state.results.map((user) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(User_1.default, Object.assign({ elevation: 0, user: user }, userProps)) }, user.id))) }) })) })))] }));
|
|
134
139
|
}
|
|
135
140
|
exports.default = TabContentComponent;
|
|
@@ -138,10 +138,7 @@ function LiveStreamForm(inProps) {
|
|
|
138
138
|
})
|
|
139
139
|
.catch((e) => {
|
|
140
140
|
const _error = (0, api_services_1.formatHttpErrorCode)(e);
|
|
141
|
-
|
|
142
|
-
// @ts-ignore
|
|
143
|
-
console.log(_error);
|
|
144
|
-
if ('errorsError' in _error) {
|
|
141
|
+
if ('errorsError' in _error || !Object.keys(_error).length) {
|
|
145
142
|
setGenericError(intl.formatMessage({
|
|
146
143
|
id: 'ui.liveStreamForm.error.monthlyMinuteLimitReached',
|
|
147
144
|
defaultMessage: 'ui.liveStreamForm.error.monthlyMinuteLimitReached'
|
|
@@ -188,8 +185,7 @@ function LiveStreamForm(inProps) {
|
|
|
188
185
|
}, error: Boolean(field.slug.length > LiveStream_1.LIVE_STREAM_SLUG_MAX_LENGTH) || Boolean(error['slugError']), helperText: field.title.length > LiveStream_1.LIVE_STREAM_SLUG_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.liveStreamForm.slug.error.maxLength", defaultMessage: "ui.liveStreamForm.slug.error.maxLength" })) : error['slugError'] ? (error['slugError']) : null }), (0, jsx_runtime_1.jsx)(material_1.TextField, { multiline: true, rows: 4, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
|
|
189
186
|
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((_a = field.description) === null || _a === void 0 ? void 0 : _a.length) ? LiveStream_1.LIVE_STREAM_DESCRIPTION_MAX_LENGTH - field.description.length : LiveStream_1.LIVE_STREAM_DESCRIPTION_MAX_LENGTH })))
|
|
190
187
|
}, error: Boolean(((_b = field.description) === null || _b === void 0 ? void 0 : _b.length) > LiveStream_1.LIVE_STREAM_DESCRIPTION_MAX_LENGTH), helperText: ((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) > LiveStream_1.LIVE_STREAM_DESCRIPTION_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.liveStreamForm.description.error.maxLength", defaultMessage: "ui.liveStreamForm.description.error.maxLength" })) : null }), (0, jsx_runtime_1.jsx)(LiveStreamFormSettings_1.default, { settings: field.settings, onChange: handleChangeSettings }), genericError && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.genericError }, { children: (0, jsx_runtime_1.jsx)(material_1.Alert, Object.assign({ variant: "filled", severity: "error" }, { children: genericError })) }))), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.actions }, { children: (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.title ||
|
|
191
|
-
|
|
192
|
-
Boolean(genericError) ||
|
|
188
|
+
field.isSubmitting ||
|
|
193
189
|
field.title.length > LiveStream_1.LIVE_STREAM_TITLE_MAX_LENGTH ||
|
|
194
190
|
field.description.length > LiveStream_1.LIVE_STREAM_DESCRIPTION_MAX_LENGTH, variant: "contained", onClick: handleSubmit, color: "secondary" }, { children: liveStream ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.liveStreamForm.button.edit", defaultMessage: "ui.liveStreamForm.button.edit" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.liveStreamForm.button.create", defaultMessage: "ui.liveStreamForm.button.create" })) })) }))] }))] })));
|
|
195
191
|
}
|
|
@@ -4,8 +4,4 @@
|
|
|
4
4
|
* @param showWarnings
|
|
5
5
|
* @param performDisconnect
|
|
6
6
|
*/
|
|
7
|
-
export declare function useLivestreamCheck(warningThreshold?: number, showWarnings?: boolean, performDisconnect?: boolean):
|
|
8
|
-
timeRemaining: number;
|
|
9
|
-
isExpiringSoon: boolean;
|
|
10
|
-
isExpired: boolean;
|
|
11
|
-
};
|
|
7
|
+
export declare function useLivestreamCheck(warningThreshold?: number, showWarnings?: boolean, performDisconnect?: boolean): any;
|
|
@@ -10,6 +10,42 @@ const react_intl_1 = require("react-intl");
|
|
|
10
10
|
const react_core_1 = require("@selfcommunity/react-core");
|
|
11
11
|
const constants_1 = require("../constants");
|
|
12
12
|
const livekit_client_1 = require("livekit-client");
|
|
13
|
+
const _INITIAL_STATE = {
|
|
14
|
+
checkStarted: false,
|
|
15
|
+
timeRemaining: 60,
|
|
16
|
+
isExpiringSoonAloneInRoom: false,
|
|
17
|
+
isExpiringSoonMissingHost: false,
|
|
18
|
+
isExpiringSoonFewMinutesRemaining: false,
|
|
19
|
+
isExpiredSoonAloneInRoom: false,
|
|
20
|
+
isExpiredSoonMissingHost: false,
|
|
21
|
+
isExpiredSoonFewMinutesRemaining: false
|
|
22
|
+
};
|
|
23
|
+
const reducer = (state, action) => {
|
|
24
|
+
switch (action.type) {
|
|
25
|
+
case 'startChecking':
|
|
26
|
+
return Object.assign(Object.assign({}, _INITIAL_STATE), { checkStarted: true });
|
|
27
|
+
case 'stopChecking':
|
|
28
|
+
return Object.assign(Object.assign({}, _INITIAL_STATE), { checkStarted: false });
|
|
29
|
+
case 'reset':
|
|
30
|
+
return Object.assign({}, _INITIAL_STATE);
|
|
31
|
+
case 'isExpiringSoonAloneInRoom':
|
|
32
|
+
return Object.assign(Object.assign({}, state), { isExpiringSoonAloneInRoom: action.value });
|
|
33
|
+
case 'isExpiringSoonMissingHost':
|
|
34
|
+
return Object.assign(Object.assign({}, state), { isExpiringSoonMissingHost: action.value });
|
|
35
|
+
case 'isExpiringSoonFewMinutesRemaining':
|
|
36
|
+
return Object.assign(Object.assign({}, state), { isExpiringSoonFewMinutesRemaining: action.value });
|
|
37
|
+
case 'isExpiredAloneInRoom':
|
|
38
|
+
return Object.assign(Object.assign({}, state), { isExpiredAloneInRoom: action.value });
|
|
39
|
+
case 'isExpiredSoonMissingHost':
|
|
40
|
+
return Object.assign(Object.assign({}, state), { isExpiredSoonMissingHost: action.value });
|
|
41
|
+
case 'isExpiredSoonFewMinutesRemaining':
|
|
42
|
+
return Object.assign(Object.assign({}, state), { isExpiredSoonFewMinutesRemaining: action.value });
|
|
43
|
+
case 'timeRemaining':
|
|
44
|
+
return Object.assign(Object.assign({}, state), { timeRemaining: action.value });
|
|
45
|
+
default:
|
|
46
|
+
return Object.assign(Object.assign({}, state), { [action.type]: action.value });
|
|
47
|
+
}
|
|
48
|
+
};
|
|
13
49
|
/**
|
|
14
50
|
* Custom hook for monitoring livestream.
|
|
15
51
|
* @param {number} warningThreshold
|
|
@@ -18,9 +54,7 @@ const livekit_client_1 = require("livekit-client");
|
|
|
18
54
|
*/
|
|
19
55
|
function useLivestreamCheck(warningThreshold = constants_1.WARNING_THRESHOLD_EXPIRING_SOON, showWarnings = true, performDisconnect = true) {
|
|
20
56
|
// STATE
|
|
21
|
-
const [
|
|
22
|
-
const [isExpiringSoon, setIsExpiringSoon] = (0, react_1.useState)(false);
|
|
23
|
-
const [isExpired, setIsExpired] = (0, react_1.useState)(false);
|
|
57
|
+
const [state, dispatch] = (0, react_1.useReducer)(reducer, _INITIAL_STATE);
|
|
24
58
|
const intervalRef = (0, react_1.useRef)(null);
|
|
25
59
|
// HOOKS
|
|
26
60
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
@@ -47,24 +81,26 @@ function useLivestreamCheck(warningThreshold = constants_1.WARNING_THRESHOLD_EXP
|
|
|
47
81
|
const fetchLivestreamStatus = () => {
|
|
48
82
|
api_services_1.LiveStreamApiClient.getMonthlyDuration()
|
|
49
83
|
.then((r) => {
|
|
50
|
-
|
|
84
|
+
dispatch({ type: 'timeRemaining', value: r.remaining_minutes });
|
|
51
85
|
if (r.remaining_minutes > 0 && r.remaining_minutes <= warningThreshold) {
|
|
52
|
-
|
|
53
|
-
|
|
86
|
+
if (!state.isExpiringSoonFewMinutesRemaining &&
|
|
87
|
+
!state.isExpiredSoonFewMinutesRemaining &&
|
|
88
|
+
liveStream.host.id === scUserContext.user.id &&
|
|
89
|
+
showWarnings) {
|
|
54
90
|
__DEBUG && console.log('Warning: ');
|
|
55
91
|
enqueueSnackbar(intl.formatMessage({ id: 'ui.liveStreamRoom.check.fewMinutesRemaining', defaultMessage: 'ui.liveStreamRoom.check.fewMinutesRemaining' }), {
|
|
56
92
|
variant: 'warning',
|
|
57
93
|
autoHideDuration: 30000
|
|
58
94
|
});
|
|
95
|
+
dispatch({ type: 'isExpiringSoonFewMinutesRemaining', value: true });
|
|
59
96
|
}
|
|
60
97
|
}
|
|
61
98
|
else if (r.remaining_minutes <= 0) {
|
|
62
|
-
__DEBUG && console.log('Livestream
|
|
63
|
-
|
|
64
|
-
clearInterval(intervalRef.current);
|
|
99
|
+
__DEBUG && console.log('Livestream expired');
|
|
100
|
+
dispatch({ type: 'isExpiredFewMinutesRemaining', value: true });
|
|
65
101
|
}
|
|
66
|
-
else if (
|
|
67
|
-
|
|
102
|
+
else if (state.isExpiredFewMinutesRemaining) {
|
|
103
|
+
dispatch({ type: 'isExpiringSoonFewMinutesRemaining', value: false });
|
|
68
104
|
}
|
|
69
105
|
})
|
|
70
106
|
.catch((error) => {
|
|
@@ -77,55 +113,83 @@ function useLivestreamCheck(warningThreshold = constants_1.WARNING_THRESHOLD_EXP
|
|
|
77
113
|
const check = (0, react_1.useCallback)(() => {
|
|
78
114
|
if (__DEBUG) {
|
|
79
115
|
console.log('Checking live status');
|
|
80
|
-
console.log(
|
|
81
|
-
console.log('isExpiringSoon: ', isExpiringSoon);
|
|
82
|
-
console.log('isExpired: ', isExpired);
|
|
116
|
+
console.log('Status: ', state);
|
|
83
117
|
console.log('Checking participants...', participants.length);
|
|
84
118
|
console.log(participants);
|
|
85
119
|
}
|
|
86
120
|
if (participants.length <= 1) {
|
|
87
|
-
|
|
88
|
-
|
|
121
|
+
if (!state.isExpiringSoonAloneInRoom && !state.isExpiredAloneInRoom && showWarnings) {
|
|
122
|
+
__DEBUG && console.log('Set expire soon: you are alone in the room');
|
|
89
123
|
enqueueSnackbar(intl.formatMessage({ id: 'ui.liveStreamRoom.check.youAreAloneInTheRoom', defaultMessage: 'ui.liveStreamRoom.check.youAreAloneInTheRoom' }), { variant: 'warning', autoHideDuration: 10000 });
|
|
124
|
+
state.isExpiringSoonAloneInRoom
|
|
125
|
+
? dispatch({ type: 'isExpiredAloneInRoom', value: true })
|
|
126
|
+
: dispatch({ type: 'isExpiringSoonAloneInRoom', value: true });
|
|
90
127
|
}
|
|
91
|
-
else if (
|
|
128
|
+
else if (performDisconnect && (state.isExpiringSoonAloneInRoom || state.isExpiredAloneInRoom)) {
|
|
92
129
|
// Leave the room
|
|
93
130
|
__DEBUG && console.log('Leave the room: no participants');
|
|
94
131
|
buttonProps.onClick();
|
|
95
132
|
}
|
|
96
133
|
return;
|
|
97
134
|
}
|
|
98
|
-
else if (
|
|
99
|
-
|
|
135
|
+
else if (state.isExpiringSoonAloneInRoom) {
|
|
136
|
+
__DEBUG && console.log('Reset expire soon');
|
|
137
|
+
dispatch({ type: 'isExpiringSoonAloneInRoom', value: false });
|
|
100
138
|
}
|
|
101
139
|
__DEBUG && console.log('Checking live speaker...');
|
|
102
140
|
const speaker = participants.find((pt) => {
|
|
103
141
|
return pt.name === liveStream.host.username;
|
|
104
142
|
});
|
|
105
143
|
if (!speaker) {
|
|
106
|
-
|
|
107
|
-
if (!isExpiringSoon && !isExpired && liveStream.host.id !== scUserContext.user.id && showWarnings) {
|
|
144
|
+
if (!state.isExpiredSoonMissingHost && !state.isExpiringSoonMissingHost && liveStream.host.id !== scUserContext.user.id && showWarnings) {
|
|
108
145
|
enqueueSnackbar(intl.formatMessage({ id: 'ui.liveStreamRoom.check.hostMissing', defaultMessage: 'ui.liveStreamRoom.check.hostMissing' }), {
|
|
109
146
|
variant: 'warning',
|
|
110
147
|
autoHideDuration: 10000
|
|
111
148
|
});
|
|
149
|
+
state.isExpiringSoonMissingHost
|
|
150
|
+
? dispatch({ type: 'isExpiredSoonMissingHost', value: true })
|
|
151
|
+
: dispatch({ type: 'isExpiringSoonMissingHost', value: true });
|
|
112
152
|
}
|
|
113
|
-
else if (
|
|
153
|
+
else if (performDisconnect && (state.isExpiredSoonMissingHost || state.isExpiringSoonMissingHost)) {
|
|
114
154
|
// Leave the room
|
|
115
155
|
__DEBUG && console.log('Leave the room: no host');
|
|
116
156
|
buttonProps.onClick();
|
|
117
157
|
}
|
|
118
158
|
}
|
|
119
|
-
else if (
|
|
120
|
-
|
|
159
|
+
else if (state.isExpiringSoonMissingHost) {
|
|
160
|
+
dispatch({ type: 'isExpiringSoonMissingHost', value: false });
|
|
121
161
|
}
|
|
122
162
|
__DEBUG && console.log('Checking live status resources...');
|
|
123
163
|
fetchLivestreamStatus();
|
|
124
|
-
}, [
|
|
164
|
+
}, [state, buttonProps, participants]);
|
|
165
|
+
/**
|
|
166
|
+
* Check live status
|
|
167
|
+
*/
|
|
125
168
|
(0, react_1.useEffect)(() => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
169
|
+
if (state.checkStarted) {
|
|
170
|
+
intervalRef.current = setInterval(check, constants_1.LIVE_CHECKING_INTERVAL * 60000);
|
|
171
|
+
}
|
|
172
|
+
return () => {
|
|
173
|
+
intervalRef.current && clearInterval(intervalRef.current);
|
|
174
|
+
};
|
|
175
|
+
}, [state, participants]);
|
|
176
|
+
/**
|
|
177
|
+
* Start the checking after a delay
|
|
178
|
+
*/
|
|
179
|
+
(0, react_1.useEffect)(() => {
|
|
180
|
+
let _timeout;
|
|
181
|
+
if (liveStream) {
|
|
182
|
+
_timeout = setTimeout(() => {
|
|
183
|
+
// Start the checking after 5 minutes
|
|
184
|
+
dispatch({ type: 'startChecking' });
|
|
185
|
+
__DEBUG && console.log('Start checking');
|
|
186
|
+
}, (liveStream.host.id === scUserContext.user.id ? constants_1.LIVE_CHECKING_INITIAL_DELAY_HOST : constants_1.LIVE_CHECKING_INITIAL_DELAY_GUEST) * 60000);
|
|
187
|
+
}
|
|
188
|
+
return () => {
|
|
189
|
+
_timeout && clearTimeout(_timeout);
|
|
190
|
+
dispatch({ type: 'stopChecking' });
|
|
191
|
+
};
|
|
192
|
+
}, [liveStream]);
|
|
193
|
+
return state;
|
|
130
194
|
}
|
|
131
195
|
exports.useLivestreamCheck = useLivestreamCheck;
|
|
@@ -3,6 +3,12 @@ export declare const defaultVideoOptions: {
|
|
|
3
3
|
readonly hq: true;
|
|
4
4
|
readonly codec: "vp9";
|
|
5
5
|
};
|
|
6
|
+
/**
|
|
7
|
+
* Start the checking after a delay
|
|
8
|
+
* In minutes
|
|
9
|
+
*/
|
|
10
|
+
export declare const LIVE_CHECKING_INITIAL_DELAY_HOST = 4;
|
|
11
|
+
export declare const LIVE_CHECKING_INITIAL_DELAY_GUEST = 1;
|
|
6
12
|
/**
|
|
7
13
|
* Checking live status on VideoLiveConference
|
|
8
14
|
* In minutes
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WARNING_THRESHOLD_EXPIRING_SOON = exports.LIVE_CHECKING_INTERVAL = exports.defaultVideoOptions = exports.PREFIX = void 0;
|
|
3
|
+
exports.WARNING_THRESHOLD_EXPIRING_SOON = exports.LIVE_CHECKING_INTERVAL = exports.LIVE_CHECKING_INITIAL_DELAY_GUEST = exports.LIVE_CHECKING_INITIAL_DELAY_HOST = exports.defaultVideoOptions = exports.PREFIX = void 0;
|
|
4
4
|
exports.PREFIX = 'SCLiveStreamRoom';
|
|
5
5
|
exports.defaultVideoOptions = {
|
|
6
6
|
hq: true,
|
|
7
7
|
codec: 'vp9'
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Start the checking after a delay
|
|
11
|
+
* In minutes
|
|
12
|
+
*/
|
|
13
|
+
exports.LIVE_CHECKING_INITIAL_DELAY_HOST = 4;
|
|
14
|
+
exports.LIVE_CHECKING_INITIAL_DELAY_GUEST = 1;
|
|
9
15
|
/**
|
|
10
16
|
* Checking live status on VideoLiveConference
|
|
11
17
|
* In minutes
|
|
@@ -38,7 +38,8 @@ function EventInfoDetails(inProps) {
|
|
|
38
38
|
const location = (0, react_1.useMemo)(() => scEvent && scEvent.location === types_1.SCEventLocationType.ONLINE ? 'ui.eventInfoDetails.location.virtual' : 'ui.eventInfoDetails.location.inPerson', [scEvent]);
|
|
39
39
|
const disableJoinEvent = (0, react_1.useMemo)(() => Boolean(!scEvent ||
|
|
40
40
|
!scUserContext.user ||
|
|
41
|
-
(scEvent.live_stream
|
|
41
|
+
(scEvent.live_stream &&
|
|
42
|
+
scEvent.live_stream.host.id !== scUserContext.user.id &&
|
|
42
43
|
(scEvent.live_stream.closed_at_by_host || (scEvent.live_stream.last_started_at && scEvent.live_stream.last_finished_at)))), [scUserContext.user, scEvent]);
|
|
43
44
|
if (!scEvent) {
|
|
44
45
|
return null;
|
|
@@ -179,6 +179,7 @@ export default function EventForm(inProps) {
|
|
|
179
179
|
delete error.imageOriginalError;
|
|
180
180
|
setError(error);
|
|
181
181
|
}
|
|
182
|
+
setGenericError(null);
|
|
182
183
|
}, [error]);
|
|
183
184
|
/**
|
|
184
185
|
* Notify when a group info changed
|
|
@@ -196,6 +197,7 @@ export default function EventForm(inProps) {
|
|
|
196
197
|
}, [event]);
|
|
197
198
|
const handleGeoData = useCallback((data) => {
|
|
198
199
|
setField((prev) => (Object.assign(Object.assign({}, prev), data)));
|
|
200
|
+
setGenericError(null);
|
|
199
201
|
}, []);
|
|
200
202
|
const handleLiveStreamSettingsData = useCallback((data) => {
|
|
201
203
|
setField((prev) => (Object.assign(Object.assign({}, prev), { liveStreamSettings: Object.assign(Object.assign({}, prev.liveStreamSettings), data) })));
|
|
@@ -249,13 +251,13 @@ export default function EventForm(inProps) {
|
|
|
249
251
|
})
|
|
250
252
|
.catch((e) => {
|
|
251
253
|
const _error = formatHttpErrorCode(e);
|
|
252
|
-
if (Object.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
if (!Object.keys(_error).length) {
|
|
255
|
+
setGenericError(intl.formatMessage({
|
|
256
|
+
id: 'ui.eventForm.genericError',
|
|
257
|
+
defaultMessage: 'ui.eventForm.genericError'
|
|
258
|
+
}));
|
|
257
259
|
}
|
|
258
|
-
if ('errorsError' in _error) {
|
|
260
|
+
else if ('errorsError' in _error) {
|
|
259
261
|
setGenericError(intl.formatMessage({
|
|
260
262
|
id: 'ui.eventForm.liveStream.error.monthlyMinuteLimitReached',
|
|
261
263
|
defaultMessage: 'ui.eventForm.liveStream.error.monthlyMinuteLimitReached'
|
|
@@ -264,6 +266,14 @@ export default function EventForm(inProps) {
|
|
|
264
266
|
else {
|
|
265
267
|
setGenericError(null);
|
|
266
268
|
}
|
|
269
|
+
let __errors = {};
|
|
270
|
+
if ('coverError' in _error) {
|
|
271
|
+
__errors = Object.assign(Object.assign({}, __errors), { ['coverError']: _jsx(FormattedMessage, { id: "ui.ui.eventForm.cover.error", defaultMessage: "ui.ui.eventForm.cover.error" }) });
|
|
272
|
+
}
|
|
273
|
+
if ('titleError' in _error) {
|
|
274
|
+
__errors = Object.assign(Object.assign({}, __errors), { ['titleError']: _jsx(FormattedMessage, { id: "ui.eventForm.name.error.unique", defaultMessage: "ui.eventForm.name.error.unique" }) });
|
|
275
|
+
}
|
|
276
|
+
setError(__errors);
|
|
267
277
|
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
268
278
|
Logger.error(SCOPE_SC_UI, e);
|
|
269
279
|
onError === null || onError === void 0 ? void 0 : onError(e);
|
|
@@ -312,7 +322,7 @@ export default function EventForm(inProps) {
|
|
|
312
322
|
/**
|
|
313
323
|
* Renders root object
|
|
314
324
|
*/
|
|
315
|
-
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: [_jsx(Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: _jsx(UploadEventCover, { isCreationMode: true, onChange: handleChangeCover }) })), _jsxs(FormGroup, Object.assign({ className: classes.form }, { children: [_jsx(TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
|
|
325
|
+
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: [_jsx(Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: _jsx(UploadEventCover, { isCreationMode: true, onChange: handleChangeCover }) })), Boolean(error['coverError']) && _jsx(Typography, Object.assign({ color: "error" }, { children: error['coverError'] })), _jsxs(FormGroup, Object.assign({ className: classes.form }, { children: [_jsx(TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
|
|
316
326
|
endAdornment: _jsx(Typography, Object.assign({ variant: "body2" }, { children: EVENT_TITLE_MAX_LENGTH - field.name.length }))
|
|
317
327
|
}, error: Boolean(field.name.length > EVENT_TITLE_MAX_LENGTH) || Boolean(error['nameError']), helperText: field.name.length > EVENT_TITLE_MAX_LENGTH ? (_jsx(FormattedMessage, { id: "ui.eventForm.name.error.maxLength", defaultMessage: "ui.eventForm.name.error.maxLength" })) : error['nameError'] ? (error['nameError']) : null }), _jsx(Box, Object.assign({ className: classes.dateTime }, { children: _jsxs(LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? itLocale : enLocale }, { children: [_jsx(MobileDatePicker, { className: classes.picker, disablePast: true, label: field.startDate && _jsx(FormattedMessage, { id: "ui.eventForm.date.placeholder", defaultMessage: "ui.eventForm.date.placeholder" }), value: field.startDate, slots: {
|
|
318
328
|
textField: (params) => (_jsx(TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.startDate)}`, startAdornment: (_jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "CalendarIcon" }) }) }))) }) })))
|
|
@@ -383,7 +393,7 @@ export default function EventForm(inProps) {
|
|
|
383
393
|
(field.location === SCEventLocationType.ONLINE && !field.link) ||
|
|
384
394
|
(field.location === SCEventLocationType.PERSON && !field.geolocation) ||
|
|
385
395
|
(field.recurring !== SCEventRecurrenceType.NEVER && !field.endDate && !field.endTime) ||
|
|
386
|
-
|
|
396
|
+
field.isSubmitting ||
|
|
387
397
|
field.name.length > EVENT_TITLE_MAX_LENGTH ||
|
|
388
398
|
field.description.length > EVENT_DESCRIPTION_MAX_LENGTH, variant: "contained", onClick: handleSubmit, color: "secondary" }, { children: event ? (_jsx(FormattedMessage, { id: "ui.eventForm.button.edit", defaultMessage: "ui.eventForm.button.edit" })) : (_jsx(FormattedMessage, { id: "ui.eventForm.button.create", defaultMessage: "ui.eventForm.button.create" })) })) }))] }))] })));
|
|
389
399
|
}
|
|
@@ -97,7 +97,7 @@ export default function EventMembersWidget(inProps) {
|
|
|
97
97
|
Logger.error(SCOPE_SC_UI, error);
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
|
-
}, [participants.isLoadingNext, participants.initialized, scEvent, dispatchParticipants, setParticipantsCount]);
|
|
100
|
+
}, [participants.isLoadingNext, participants.initialized, scEvent, endpointQueryParams, dispatchParticipants, setParticipantsCount]);
|
|
101
101
|
const _initInvited = useCallback(() => {
|
|
102
102
|
if (!invited.initialized && !invited.isLoadingNext && hasAllow) {
|
|
103
103
|
dispatchInvited({ type: actionWidgetTypes.LOADING_NEXT });
|
|
@@ -111,7 +111,7 @@ export default function EventMembersWidget(inProps) {
|
|
|
111
111
|
Logger.error(SCOPE_SC_UI, error);
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
-
}, [invited.isLoadingNext, invited.initialized, scEvent, dispatchInvited, setInvitedCount]);
|
|
114
|
+
}, [invited.isLoadingNext, invited.initialized, scEvent, hasAllow, endpointQueryParams, dispatchInvited, setInvitedCount]);
|
|
115
115
|
const _initRequests = useCallback(() => {
|
|
116
116
|
if (!requests.initialized && !requests.isLoadingNext && hasAllow) {
|
|
117
117
|
dispatchRequests({ type: actionWidgetTypes.LOADING_NEXT });
|
|
@@ -126,7 +126,7 @@ export default function EventMembersWidget(inProps) {
|
|
|
126
126
|
Logger.error(SCOPE_SC_UI, error);
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
-
}, [requests.isLoadingNext, requests.initialized, scEvent, dispatchRequests, setRequestsCount, setRequestsUsers]);
|
|
129
|
+
}, [requests.isLoadingNext, requests.initialized, scEvent, hasAllow, endpointQueryParams, dispatchRequests, setRequestsCount, setRequestsUsers]);
|
|
130
130
|
// EFFECTS
|
|
131
131
|
useEffect(() => {
|
|
132
132
|
let _t;
|
|
@@ -150,18 +150,18 @@ export default function EventMembersWidget(inProps) {
|
|
|
150
150
|
clearTimeout(_t);
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
|
-
}, [scUserContext.user, scEvent, refresh]);
|
|
153
|
+
}, [scUserContext.user, scEvent, refresh, _initParticipants, _initInvited, _initRequests]);
|
|
154
154
|
useEffect(() => {
|
|
155
155
|
if (participants.initialized && scEvent && Boolean((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id))) {
|
|
156
156
|
dispatchParticipants({ type: actionWidgetTypes.RESET, payload: {} });
|
|
157
157
|
dispatchRequests({ type: actionWidgetTypes.RESET, payload: {} });
|
|
158
158
|
dispatchInvited({ type: actionWidgetTypes.RESET, payload: {} });
|
|
159
159
|
}
|
|
160
|
-
}, [participants.initialized, scEvent, eventId, event]);
|
|
160
|
+
}, [participants.initialized, scEvent, eventId, event, dispatchParticipants, dispatchInvited, dispatchRequests]);
|
|
161
161
|
// HANDLERS
|
|
162
162
|
const handleTabChange = useCallback((_evt, newTabValue) => {
|
|
163
163
|
setTabValue(newTabValue);
|
|
164
|
-
}, []);
|
|
164
|
+
}, [setTabValue]);
|
|
165
165
|
const handleRefresh = useCallback((_tabValue) => {
|
|
166
166
|
if (_tabValue === TabContentEnum.PARTICIPANTS) {
|
|
167
167
|
dispatchParticipants({ type: actionWidgetTypes.RESET });
|
|
@@ -170,7 +170,7 @@ export default function EventMembersWidget(inProps) {
|
|
|
170
170
|
dispatchInvited({ type: actionWidgetTypes.RESET });
|
|
171
171
|
}
|
|
172
172
|
setRefresh(_tabValue);
|
|
173
|
-
}, []);
|
|
173
|
+
}, [dispatchParticipants, dispatchInvited, setRefresh]);
|
|
174
174
|
if (!scUserContext.user) {
|
|
175
175
|
return _jsx(HiddenPlaceholder, {});
|
|
176
176
|
}
|