@selfcommunity/react-ui 0.8.0-live.43 → 0.8.0-live.45
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/LiveStreamForm/LiveStreamForm.js +22 -16
- package/lib/cjs/components/LiveStreamRoom/LiveStreamRoom.js +1 -1
- package/lib/esm/components/LiveStreamForm/LiveStreamForm.js +21 -15
- package/lib/esm/components/LiveStreamRoom/LiveStreamRoom.js +1 -1
- package/lib/umd/react-ui.js +1 -1
- package/package.json +7 -7
|
@@ -8,11 +8,9 @@ const styles_1 = require("@mui/material/styles");
|
|
|
8
8
|
const system_1 = require("@mui/system");
|
|
9
9
|
const api_services_1 = require("@selfcommunity/api-services");
|
|
10
10
|
const react_core_1 = require("@selfcommunity/react-core");
|
|
11
|
-
const utils_1 = require("@selfcommunity/utils");
|
|
12
11
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
13
12
|
const react_1 = require("react");
|
|
14
13
|
const react_intl_1 = require("react-intl");
|
|
15
|
-
const Errors_1 = require("../../constants/Errors");
|
|
16
14
|
const LiveStream_1 = require("../../constants/LiveStream");
|
|
17
15
|
const constants_1 = require("./constants");
|
|
18
16
|
const UploadEventCover_1 = tslib_1.__importDefault(require("../EventForm/UploadEventCover"));
|
|
@@ -133,25 +131,33 @@ function LiveStreamForm(inProps) {
|
|
|
133
131
|
else {
|
|
134
132
|
eventService = api_services_1.EventService.createEvent(formData, { headers: { 'Content-Type': 'multipart/form-data' } });
|
|
135
133
|
}
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
setTimeout(() => {
|
|
135
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess({});
|
|
138
136
|
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
137
|
+
}, 1000);
|
|
138
|
+
/* eventService
|
|
139
|
+
.then((data) => {
|
|
140
|
+
setField((prev) => ({...prev, ['isSubmitting']: false}));
|
|
139
141
|
// onSuccess?.(data);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const _error =
|
|
142
|
+
})
|
|
143
|
+
.catch((e) => {
|
|
144
|
+
const _error = formatHttpErrorCode(e);
|
|
145
|
+
|
|
143
146
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
|
|
144
147
|
// @ts-ignore
|
|
145
148
|
if (Object.values(_error)[0].error === 'unique') {
|
|
146
|
-
|
|
149
|
+
setError({
|
|
150
|
+
...error,
|
|
151
|
+
['titleError']: <FormattedMessage id="ui.liveStreamForm.title.error.unique" defaultMessage="ui.liveStreamForm.title.error.unique" />
|
|
152
|
+
});
|
|
153
|
+
} else {
|
|
154
|
+
setError({...error, ..._error});
|
|
147
155
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
onError === null || onError === void 0 ? void 0 : onError(e);
|
|
154
|
-
});
|
|
156
|
+
|
|
157
|
+
setField((prev) => ({...prev, ['isSubmitting']: false}));
|
|
158
|
+
Logger.error(SCOPE_SC_UI, e);
|
|
159
|
+
onError?.(e);
|
|
160
|
+
}); */
|
|
155
161
|
}, [field, privateEnabled, visibilityEnabled, onSuccess, onError]);
|
|
156
162
|
const handleChange = (0, react_1.useCallback)((event) => {
|
|
157
163
|
const { name, value } = event.target;
|
|
@@ -168,7 +174,7 @@ function LiveStreamForm(inProps) {
|
|
|
168
174
|
endAdornment: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: LiveStream_1.LIVE_STREAM_TITLE_MAX_LENGTH - field.title.length }))
|
|
169
175
|
}, error: Boolean(field.title.length > LiveStream_1.LIVE_STREAM_TITLE_MAX_LENGTH) || Boolean(error['titleError']), helperText: field.title.length > LiveStream_1.LIVE_STREAM_TITLE_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.liveStreamForm.title.error.maxLength", defaultMessage: "ui.liveStreamForm.title.error.maxLength" })) : error['titleError'] ? (error['titleError']) : null }), (0, jsx_runtime_1.jsx)(material_1.TextField, { required: true, className: classes.slug, placeholder: `${intl.formatMessage(messages.slug)}`, margin: "normal", value: field.slug, name: "slug", onChange: handleChange, InputProps: {
|
|
170
176
|
endAdornment: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: LiveStream_1.LIVE_STREAM_SLUG_MAX_LENGTH - field.title.length }))
|
|
171
|
-
}, error: Boolean(field.slug.length > LiveStream_1.LIVE_STREAM_SLUG_MAX_LENGTH) || Boolean(error['
|
|
177
|
+
}, 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: {
|
|
172
178
|
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 })))
|
|
173
179
|
}, 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)(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 ||
|
|
174
180
|
Object.keys(error).length !== 0 ||
|
|
@@ -125,6 +125,6 @@ function LiveStreamRoom(inProps) {
|
|
|
125
125
|
/**
|
|
126
126
|
* Renders root object
|
|
127
127
|
*/
|
|
128
|
-
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.content, "data-lk-theme": "default" }, { children: connectionDetails === undefined || preJoinChoices === undefined ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [startPrejoinContent && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.startPrejoinContent }, { children: startPrejoinContent })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.title) && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.title }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.title })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.description) && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.description }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.description })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.preJoin }, { children: (0, jsx_runtime_1.jsx)(components_react_1.PreJoin, { persistUserChoices: true, defaults: preJoinDefaults, onSubmit: handlePreJoinSubmit, onError: handlePreJoinError }) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.endPrejoinContent }, { children:
|
|
128
|
+
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.content, "data-lk-theme": "default" }, { children: connectionDetails === undefined || preJoinChoices === undefined ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [startPrejoinContent && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.startPrejoinContent }, { children: startPrejoinContent })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.title) && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.title }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.title })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.description) && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.description }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.description })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.preJoin }, { children: (0, jsx_runtime_1.jsx)(components_react_1.PreJoin, { persistUserChoices: true, defaults: preJoinDefaults, onSubmit: handlePreJoinSubmit, onError: handlePreJoinError }) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.endPrejoinContent }, { children: endPrejoinContent }))] })) : ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.conference }, { children: (0, jsx_runtime_1.jsx)(LiveStreamVideoConference_1.default, { connectionDetails: connectionDetails, userChoices: preJoinChoices, options: { codec: props.codec, hq: props.hq } }) }))) })) })));
|
|
129
129
|
}
|
|
130
130
|
exports.default = LiveStreamRoom;
|
|
@@ -4,13 +4,11 @@ import { LoadingButton } from '@mui/lab';
|
|
|
4
4
|
import { Box, FormGroup, Paper, TextField, Typography } from '@mui/material';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
6
6
|
import { useThemeProps } from '@mui/system';
|
|
7
|
-
import { EventService
|
|
7
|
+
import { EventService } from '@selfcommunity/api-services';
|
|
8
8
|
import { SCPreferences, useSCContext, useSCPreferences } from '@selfcommunity/react-core';
|
|
9
|
-
import { Logger } from '@selfcommunity/utils';
|
|
10
9
|
import classNames from 'classnames';
|
|
11
10
|
import { useCallback, useMemo, useState } from 'react';
|
|
12
11
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
13
|
-
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
14
12
|
import { LIVE_STREAM_DESCRIPTION_MAX_LENGTH, LIVE_STREAM_TITLE_MAX_LENGTH, LIVE_STREAM_SLUG_MAX_LENGTH } from '../../constants/LiveStream';
|
|
15
13
|
import { PREFIX } from './constants';
|
|
16
14
|
import UploadEventCover from '../EventForm/UploadEventCover';
|
|
@@ -131,25 +129,33 @@ export default function LiveStreamForm(inProps) {
|
|
|
131
129
|
else {
|
|
132
130
|
eventService = EventService.createEvent(formData, { headers: { 'Content-Type': 'multipart/form-data' } });
|
|
133
131
|
}
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
setTimeout(() => {
|
|
133
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess({});
|
|
136
134
|
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
135
|
+
}, 1000);
|
|
136
|
+
/* eventService
|
|
137
|
+
.then((data) => {
|
|
138
|
+
setField((prev) => ({...prev, ['isSubmitting']: false}));
|
|
137
139
|
// onSuccess?.(data);
|
|
138
|
-
|
|
139
|
-
|
|
140
|
+
})
|
|
141
|
+
.catch((e) => {
|
|
140
142
|
const _error = formatHttpErrorCode(e);
|
|
143
|
+
|
|
141
144
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
|
|
142
145
|
// @ts-ignore
|
|
143
146
|
if (Object.values(_error)[0].error === 'unique') {
|
|
144
|
-
|
|
147
|
+
setError({
|
|
148
|
+
...error,
|
|
149
|
+
['titleError']: <FormattedMessage id="ui.liveStreamForm.title.error.unique" defaultMessage="ui.liveStreamForm.title.error.unique" />
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
setError({...error, ..._error});
|
|
145
153
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
154
|
+
|
|
155
|
+
setField((prev) => ({...prev, ['isSubmitting']: false}));
|
|
150
156
|
Logger.error(SCOPE_SC_UI, e);
|
|
151
|
-
onError
|
|
152
|
-
|
|
157
|
+
onError?.(e);
|
|
158
|
+
}); */
|
|
153
159
|
}, [field, privateEnabled, visibilityEnabled, onSuccess, onError]);
|
|
154
160
|
const handleChange = useCallback((event) => {
|
|
155
161
|
const { name, value } = event.target;
|
|
@@ -166,7 +172,7 @@ export default function LiveStreamForm(inProps) {
|
|
|
166
172
|
endAdornment: _jsx(Typography, Object.assign({ variant: "body2" }, { children: LIVE_STREAM_TITLE_MAX_LENGTH - field.title.length }))
|
|
167
173
|
}, error: Boolean(field.title.length > LIVE_STREAM_TITLE_MAX_LENGTH) || Boolean(error['titleError']), helperText: field.title.length > LIVE_STREAM_TITLE_MAX_LENGTH ? (_jsx(FormattedMessage, { id: "ui.liveStreamForm.title.error.maxLength", defaultMessage: "ui.liveStreamForm.title.error.maxLength" })) : error['titleError'] ? (error['titleError']) : null }), _jsx(TextField, { required: true, className: classes.slug, placeholder: `${intl.formatMessage(messages.slug)}`, margin: "normal", value: field.slug, name: "slug", onChange: handleChange, InputProps: {
|
|
168
174
|
endAdornment: _jsx(Typography, Object.assign({ variant: "body2" }, { children: LIVE_STREAM_SLUG_MAX_LENGTH - field.title.length }))
|
|
169
|
-
}, error: Boolean(field.slug.length > LIVE_STREAM_SLUG_MAX_LENGTH) || Boolean(error['
|
|
175
|
+
}, error: Boolean(field.slug.length > LIVE_STREAM_SLUG_MAX_LENGTH) || Boolean(error['slugError']), helperText: field.title.length > LIVE_STREAM_SLUG_MAX_LENGTH ? (_jsx(FormattedMessage, { id: "ui.liveStreamForm.slug.error.maxLength", defaultMessage: "ui.liveStreamForm.slug.error.maxLength" })) : error['slugError'] ? (error['slugError']) : null }), _jsx(TextField, { multiline: true, rows: 4, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
|
|
170
176
|
endAdornment: (_jsx(Typography, Object.assign({ variant: "body2" }, { children: ((_a = field.description) === null || _a === void 0 ? void 0 : _a.length) ? LIVE_STREAM_DESCRIPTION_MAX_LENGTH - field.description.length : LIVE_STREAM_DESCRIPTION_MAX_LENGTH })))
|
|
171
177
|
}, error: Boolean(((_b = field.description) === null || _b === void 0 ? void 0 : _b.length) > LIVE_STREAM_DESCRIPTION_MAX_LENGTH), helperText: ((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) > LIVE_STREAM_DESCRIPTION_MAX_LENGTH ? (_jsx(FormattedMessage, { id: "ui.liveStreamForm.description.error.maxLength", defaultMessage: "ui.liveStreamForm.description.error.maxLength" })) : null }), _jsx(Box, Object.assign({ className: classes.actions }, { children: _jsx(LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.title ||
|
|
172
178
|
Object.keys(error).length !== 0 ||
|
|
@@ -123,5 +123,5 @@ export default function LiveStreamRoom(inProps) {
|
|
|
123
123
|
/**
|
|
124
124
|
* Renders root object
|
|
125
125
|
*/
|
|
126
|
-
return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: _jsx(Box, Object.assign({ className: classes.content, "data-lk-theme": "default" }, { children: connectionDetails === undefined || preJoinChoices === undefined ? (_jsxs(_Fragment, { children: [startPrejoinContent && _jsx(Box, Object.assign({ className: classes.startPrejoinContent }, { children: startPrejoinContent })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.title) && _jsx(Box, Object.assign({ className: classes.title }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.title })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.description) && _jsx(Box, Object.assign({ className: classes.description }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.description })), _jsx(Box, Object.assign({ className: classes.preJoin }, { children: _jsx(PreJoin, { persistUserChoices: true, defaults: preJoinDefaults, onSubmit: handlePreJoinSubmit, onError: handlePreJoinError }) })), _jsx(Box, Object.assign({ className: classes.endPrejoinContent }, { children:
|
|
126
|
+
return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: _jsx(Box, Object.assign({ className: classes.content, "data-lk-theme": "default" }, { children: connectionDetails === undefined || preJoinChoices === undefined ? (_jsxs(_Fragment, { children: [startPrejoinContent && _jsx(Box, Object.assign({ className: classes.startPrejoinContent }, { children: startPrejoinContent })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.title) && _jsx(Box, Object.assign({ className: classes.title }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.title })), (liveStream === null || liveStream === void 0 ? void 0 : liveStream.description) && _jsx(Box, Object.assign({ className: classes.description }, { children: liveStream === null || liveStream === void 0 ? void 0 : liveStream.description })), _jsx(Box, Object.assign({ className: classes.preJoin }, { children: _jsx(PreJoin, { persistUserChoices: true, defaults: preJoinDefaults, onSubmit: handlePreJoinSubmit, onError: handlePreJoinError }) })), _jsx(Box, Object.assign({ className: classes.endPrejoinContent }, { children: endPrejoinContent }))] })) : (_jsx(Box, Object.assign({ className: classes.conference }, { children: _jsx(LiveStreamVideoConference, { connectionDetails: connectionDetails, userChoices: preJoinChoices, options: { codec: props.codec, hq: props.hq } }) }))) })) })));
|
|
127
127
|
}
|