@selfcommunity/react-ui 0.8.0-live.69 → 0.8.0-live.71
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.js +15 -4
- package/lib/cjs/components/CreateLiveStreamDialog/LiveStreamSelector/LiveStreamSelector.js +66 -12
- package/lib/cjs/components/EventForm/EventAddress.js +7 -2
- package/lib/cjs/components/EventForm/EventForm.js +19 -4
- package/lib/cjs/components/LiveStreamForm/LiveStreamForm.js +21 -6
- package/lib/cjs/components/Notification/LiveStream/LiveStream.js +12 -11
- package/lib/cjs/components/PlatformWidget/constants.d.ts +4 -0
- package/lib/cjs/components/PlatformWidget/constants.js +5 -1
- package/lib/cjs/components/UserLiveStreamWidget/Skeleton.js +1 -1
- package/lib/cjs/components/UserLiveStreamWidget/UserLiveStreamWidget.js +6 -2
- package/lib/cjs/constants/LiveStream.d.ts +1 -1
- package/lib/cjs/constants/LiveStream.js +1 -1
- package/lib/esm/components/CreateLiveStreamButton/CreateLiveStreamButton.js +16 -5
- package/lib/esm/components/CreateLiveStreamDialog/LiveStreamSelector/LiveStreamSelector.js +68 -15
- package/lib/esm/components/EventForm/EventAddress.js +10 -5
- package/lib/esm/components/EventForm/EventForm.js +20 -5
- package/lib/esm/components/LiveStreamForm/LiveStreamForm.js +22 -7
- package/lib/esm/components/Notification/LiveStream/LiveStream.js +12 -11
- package/lib/esm/components/PlatformWidget/constants.d.ts +4 -0
- package/lib/esm/components/PlatformWidget/constants.js +4 -0
- package/lib/esm/components/UserLiveStreamWidget/Skeleton.js +1 -1
- package/lib/esm/components/UserLiveStreamWidget/UserLiveStreamWidget.js +6 -2
- package/lib/esm/constants/LiveStream.d.ts +1 -1
- package/lib/esm/constants/LiveStream.js +1 -1
- package/lib/umd/react-ui.js +1 -1
- package/package.json +7 -7
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
4
3
|
import { styled } from '@mui/material/styles';
|
|
5
4
|
import { Box, Typography, Button, Paper, Container, Radio, Alert } from '@mui/material';
|
|
6
5
|
import Icon from '@mui/material/Icon';
|
|
@@ -8,11 +7,14 @@ import { useThemeProps } from '@mui/system';
|
|
|
8
7
|
import classNames from 'classnames';
|
|
9
8
|
import { LiveStreamType } from '../types';
|
|
10
9
|
import { useSnackbar } from 'notistack';
|
|
11
|
-
import { FormattedMessage } from 'react-intl';
|
|
10
|
+
import { FormattedMessage, useIntl } from 'react-intl';
|
|
12
11
|
import EventImage from '../../../assets/liveStream/event';
|
|
13
12
|
import LiveImage from '../../../assets/liveStream/live';
|
|
14
13
|
import { LiveStreamApiClient } from '@selfcommunity/api-services';
|
|
15
14
|
import { WARNING_THRESHOLD_EXPIRING_SOON } from '../../LiveStreamRoom/constants';
|
|
15
|
+
import { Link, SCPreferences, useSCContext, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
|
|
16
|
+
import { SCCommunitySubscriptionTier } from '@selfcommunity/types';
|
|
17
|
+
import { SELFCOMMUNITY_PRICING } from '../../PlatformWidget/constants';
|
|
16
18
|
export const PREFIX = 'SCLiveStreamSelector';
|
|
17
19
|
const classes = {
|
|
18
20
|
root: `${PREFIX}-root`,
|
|
@@ -59,34 +61,63 @@ export default function LiveStreamSelector(inProps) {
|
|
|
59
61
|
props: inProps,
|
|
60
62
|
name: PREFIX
|
|
61
63
|
});
|
|
62
|
-
const { className, liveSelected, onLiveSelected, onNext } = props
|
|
64
|
+
const { className, liveSelected, onLiveSelected, onNext } = props;
|
|
63
65
|
// CONTEXT
|
|
66
|
+
const scContext = useSCContext();
|
|
67
|
+
const scUserContext = useSCUser();
|
|
64
68
|
const { enqueueSnackbar } = useSnackbar();
|
|
65
69
|
// STATE
|
|
66
70
|
const [selectedOption, setSelectedOption] = useState(liveSelected);
|
|
67
71
|
const [timeRemaining, setTimeRemaining] = useState(null);
|
|
72
|
+
// HOOKS
|
|
73
|
+
const { preferences } = useSCPreferences();
|
|
74
|
+
const isCommunityOwner = useMemo(() => { var _a; return ((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) === 1; }, [scUserContext.user]);
|
|
75
|
+
const isFreeTrialTier = useMemo(() => preferences &&
|
|
76
|
+
SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER in preferences &&
|
|
77
|
+
preferences[SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value &&
|
|
78
|
+
preferences[SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value !== SCCommunitySubscriptionTier.FREE_TRIAL, [preferences]);
|
|
79
|
+
const intl = useIntl();
|
|
68
80
|
const options = [
|
|
69
81
|
{
|
|
70
|
-
title: '
|
|
82
|
+
title: intl.formatMessage({ id: 'ui.liveStreamForm.selector.scheduleLiveEvent', defaultMessage: 'ui.liveStreamForm.selector.scheduleLiveEvent' }),
|
|
71
83
|
image: EventImage,
|
|
72
84
|
type: LiveStreamType.EVENT_LIVE,
|
|
73
85
|
features: [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
intl.formatMessage({
|
|
87
|
+
id: 'ui.liveStreamForm.selector.scheduleLiveEventItem1',
|
|
88
|
+
defaultMessage: 'ui.liveStreamForm.selector.scheduleLiveEventItem1'
|
|
89
|
+
}),
|
|
90
|
+
intl.formatMessage({
|
|
91
|
+
id: 'ui.liveStreamForm.selector.scheduleLiveEventItem2',
|
|
92
|
+
defaultMessage: 'ui.liveStreamForm.selector.scheduleLiveEventItem2'
|
|
93
|
+
}),
|
|
94
|
+
intl.formatMessage({
|
|
95
|
+
id: 'ui.liveStreamForm.selector.scheduleLiveEventItem3',
|
|
96
|
+
defaultMessage: 'ui.liveStreamForm.selector.scheduleLiveEventItem3'
|
|
97
|
+
})
|
|
78
98
|
],
|
|
79
99
|
icons: [_jsx(Icon, { children: "chevron_right" }), _jsx(Icon, { children: "chevron_right" }), _jsx(Icon, { children: "chevron_right" }), _jsx(Icon, { children: "chevron_right" })]
|
|
80
100
|
},
|
|
81
101
|
{
|
|
82
|
-
title:
|
|
102
|
+
title: intl.formatMessage({
|
|
103
|
+
id: 'ui.liveStreamForm.selector.scheduleLiveStream',
|
|
104
|
+
defaultMessage: 'ui.liveStreamForm.selector.scheduleLiveStream'
|
|
105
|
+
}),
|
|
83
106
|
image: LiveImage,
|
|
84
107
|
type: LiveStreamType.DIRECT_LIVE,
|
|
85
108
|
features: [
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
109
|
+
intl.formatMessage({
|
|
110
|
+
id: 'ui.liveStreamForm.selector.scheduleLiveStreamItem1',
|
|
111
|
+
defaultMessage: 'ui.liveStreamForm.selector.scheduleLiveStreamItem1'
|
|
112
|
+
}),
|
|
113
|
+
intl.formatMessage({
|
|
114
|
+
id: 'ui.liveStreamForm.selector.scheduleLiveStreamItem2',
|
|
115
|
+
defaultMessage: 'ui.liveStreamForm.selector.scheduleLiveStreamItem2'
|
|
116
|
+
}),
|
|
117
|
+
intl.formatMessage({
|
|
118
|
+
id: 'ui.liveStreamForm.selector.scheduleLiveStreamItem3',
|
|
119
|
+
defaultMessage: 'ui.liveStreamForm.selector.scheduleLiveStreamItem3'
|
|
120
|
+
})
|
|
90
121
|
],
|
|
91
122
|
icons: [_jsx(Icon, { children: "chevron_right" }), _jsx(Icon, { children: "chevron_right" }), _jsx(Icon, { children: "chevron_right" }), _jsx(Icon, { children: "chevron_right" })]
|
|
92
123
|
}
|
|
@@ -118,7 +149,29 @@ export default function LiveStreamSelector(inProps) {
|
|
|
118
149
|
useEffect(() => {
|
|
119
150
|
fetchLivestreamStatus();
|
|
120
151
|
}, []);
|
|
121
|
-
|
|
152
|
+
const warning = useMemo(() => {
|
|
153
|
+
let _message;
|
|
154
|
+
if (isFreeTrialTier && isCommunityOwner) {
|
|
155
|
+
_message = (_jsx(FormattedMessage, { id: "ui.liveStreamForm.selector.warningSubscriptionRequired", defaultMessage: "ui.liveStreamForm.selector.warningSubscriptionRequired", values: {
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
157
|
+
// @ts-ignore
|
|
158
|
+
link: (...chunks) => _jsx(Link, Object.assign({ to: SELFCOMMUNITY_PRICING[scContext.settings.locale.default] }, { children: chunks }))
|
|
159
|
+
} }));
|
|
160
|
+
}
|
|
161
|
+
else if (timeRemaining !== null && timeRemaining <= WARNING_THRESHOLD_EXPIRING_SOON) {
|
|
162
|
+
if (timeRemaining <= 1) {
|
|
163
|
+
_message = (_jsx(FormattedMessage, { id: "ui.liveStreamForm.selector.warningMinutesExausted", defaultMessage: "ui.liveStreamForm.selector.warningMinutesExausted" }));
|
|
164
|
+
}
|
|
165
|
+
else if (timeRemaining <= WARNING_THRESHOLD_EXPIRING_SOON) {
|
|
166
|
+
_message = (_jsx(FormattedMessage, { id: "ui.liveStreamForm.selector.warningRemainingMinutes", defaultMessage: "ui.liveStreamForm.selector.warningRemainingMinutes", values: { minutes: timeRemaining } }));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (_message) {
|
|
170
|
+
return (_jsx(Box, Object.assign({ className: classes.warning }, { children: _jsx(Alert, Object.assign({ variant: "filled", severity: "warning" }, { children: timeRemaining <= 1 ? (_jsx(FormattedMessage, { id: "ui.liveStreamForm.selector.warningMinutesExausted", defaultMessage: "ui.liveStreamForm.selector.warningMinutesExausted" })) : timeRemaining <= WARNING_THRESHOLD_EXPIRING_SOON ? (_jsx(FormattedMessage, { id: "ui.liveStreamForm.selector.warningRemainingMinutes", defaultMessage: "ui.liveStreamForm.selector.warningRemainingMinutes", values: { minutes: timeRemaining } })) : null })) })));
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
173
|
+
}, [timeRemaining, isFreeTrialTier]);
|
|
174
|
+
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className), maxWidth: "lg", sx: { py: 4 } }, { children: [_jsx(Typography, Object.assign({ variant: "h4", component: "h1", align: "center", gutterBottom: true, sx: { mb: 4, fontWeight: 500 } }, { children: "How do you want to go live?" })), warning, _jsx(Box, Object.assign({ className: classes.options }, { children: options.map((option, index) => (_jsxs(OptionCard, Object.assign({ selected: selectedOption === option.type, onClick: () => handleOptionSelect(option.type), elevation: 0, role: "button", tabIndex: 0, onKeyDown: (e) => {
|
|
122
175
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
123
176
|
handleOptionSelect(index);
|
|
124
177
|
e.preventDefault();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { jsx as _jsx,
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Autocomplete, Box, InputAdornment, Tab, Tabs, TextField } from '@mui/material';
|
|
4
4
|
import Icon from '@mui/material/Icon';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
6
6
|
import { useThemeProps } from '@mui/system';
|
|
7
7
|
import { useLoadScript } from '@react-google-maps/api';
|
|
8
|
-
import { useSCContext, useSCUser } from '@selfcommunity/react-core';
|
|
9
|
-
import { SCEventLocationType } from '@selfcommunity/types';
|
|
8
|
+
import { SCPreferences, useSCContext, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
|
|
9
|
+
import { SCCommunitySubscriptionTier, SCEventLocationType } from '@selfcommunity/types';
|
|
10
10
|
import axios from 'axios';
|
|
11
11
|
import classNames from 'classnames';
|
|
12
12
|
import { useEffect, useMemo, useState } from 'react';
|
|
@@ -67,12 +67,17 @@ export default function EventAddress(inProps) {
|
|
|
67
67
|
// CONTEXT
|
|
68
68
|
const scContext = useSCContext();
|
|
69
69
|
const scUserContext = useSCUser();
|
|
70
|
+
const { preferences } = useSCPreferences();
|
|
70
71
|
const geocodingApiKey = useMemo(() => scContext.settings.integrations && scContext.settings.integrations.geocoding.apiKey, [scContext.settings.integrations]);
|
|
71
72
|
const { isLoaded } = useLoadScript({
|
|
72
73
|
googleMapsApiKey: scContext.settings.integrations.geocoding.apiKey,
|
|
73
74
|
libraries: ['places', 'geocoding']
|
|
74
75
|
});
|
|
75
|
-
const
|
|
76
|
+
const isFreeTrialTier = useMemo(() => preferences &&
|
|
77
|
+
SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER in preferences &&
|
|
78
|
+
preferences[SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value &&
|
|
79
|
+
preferences[SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value === SCCommunitySubscriptionTier.FREE_TRIAL, [preferences]);
|
|
80
|
+
const canViewLiveTab = useMemo(() => { var _a, _b; return !isFreeTrialTier && (((_b = (_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission) === null || _b === void 0 ? void 0 : _b.create_live_stream) || event.live_stream); }, [(_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.permission, isFreeTrialTier]);
|
|
76
81
|
// HANDLERS
|
|
77
82
|
const handleChange = (_event, newValue) => {
|
|
78
83
|
setLocation(newValue);
|
|
@@ -136,7 +141,7 @@ export default function EventAddress(inProps) {
|
|
|
136
141
|
if (!geocodingApiKey && !isLoaded) {
|
|
137
142
|
return _jsx(HiddenPlaceholder, {});
|
|
138
143
|
}
|
|
139
|
-
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, { children: [_jsxs(Tabs, Object.assign({ className: classes.tabs, value: location, onChange: handleChange, indicatorColor: "secondary", textColor: "secondary", variant: "fullWidth" }, { children: [_jsx(Tab, { value: SCEventLocationType.PERSON, classes: { root: classes.tab }, icon: _jsx(Icon, { children: "add_location_alt" }), iconPosition: "start", label: _jsx(FormattedMessage, { id: "ui.eventForm.address.live.label", defaultMessage: "ui.eventForm.address.live.label" }) }), _jsx(Tab, { value: SCEventLocationType.ONLINE, classes: { root: classes.tab }, icon: _jsx(Icon, { children: "play_circle_outline" }), iconPosition: "start", label: _jsx(FormattedMessage, { id: "ui.eventForm.address.online.label", defaultMessage: "ui.eventForm.address.online.label" }) }), canViewLiveTab && (_jsx(Tab, { value: SCEventLocationType.LIVESTREAM, classes: { root: classes.tab }, icon: _jsx(Icon, { children: "photo_camera" }), iconPosition: "start", label: _jsx(FormattedMessage, { id: "ui.eventForm.address.liveStream.label", defaultMessage: "ui.eventForm.address.liveStream.label" }) }))] })), _jsxs(Box, Object.assign({ className: classes.tabContent }, { children: [location === SCEventLocationType.PERSON && (_jsx(Autocomplete, { size: "small", value: geolocation, onChange: handleSelection, inputValue: inputValue, onInputChange: handleLocationChange, options: suggestions, getOptionLabel: (option) => option.description || geolocation.description, noOptionsText: _jsx(FormattedMessage, { id: "ui.eventForm.address.live.noResults", defaultMessage: "ui.eventForm.address.live.noResults" }), isOptionEqualToValue: (option, value) => option.description === value.description, renderInput: (params) => (_jsx(TextField, Object.assign({}, params, { label: _jsx(FormattedMessage, { id: "ui.eventForm.address.live.placeholder", defaultMessage: "ui.eventForm.address.live.placeholder" }), variant: "outlined", fullWidth: true, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (_jsxs(_Fragment, { children: [_jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(Icon, { children: "add_location_alt" }) })), params.InputProps.endAdornment] })) }) }))) })), location === SCEventLocationType.ONLINE && (_jsx(UrlTextField, { size: "small", fullWidth: true, type: "url", placeholder: `${intl.formatMessage(messages.virtualPlaceholder)}`, helperText: _jsx(FormattedMessage, { id: "ui.eventForm.address.online.help", defaultMessage: "ui.eventForm.address.online.help" }), InputProps: {
|
|
144
|
+
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, { children: [_jsxs(Tabs, Object.assign({ className: classes.tabs, value: location, onChange: handleChange, indicatorColor: "secondary", textColor: "secondary", variant: "fullWidth" }, { children: [_jsx(Tab, { value: SCEventLocationType.PERSON, classes: { root: classes.tab }, icon: _jsx(Icon, { children: "add_location_alt" }), iconPosition: "start", label: _jsx(FormattedMessage, { id: "ui.eventForm.address.live.label", defaultMessage: "ui.eventForm.address.live.label" }) }), _jsx(Tab, { value: SCEventLocationType.ONLINE, classes: { root: classes.tab }, icon: _jsx(Icon, { children: "play_circle_outline" }), iconPosition: "start", label: _jsx(FormattedMessage, { id: "ui.eventForm.address.online.label", defaultMessage: "ui.eventForm.address.online.label" }) }), canViewLiveTab && (_jsx(Tab, { value: SCEventLocationType.LIVESTREAM, classes: { root: classes.tab }, icon: _jsx(Icon, { children: "photo_camera" }), iconPosition: "start", label: _jsx(_Fragment, { children: _jsx(FormattedMessage, { id: "ui.eventForm.address.liveStream.label", defaultMessage: "ui.eventForm.address.liveStream.label" }) }) }))] })), _jsxs(Box, Object.assign({ className: classes.tabContent }, { children: [location === SCEventLocationType.PERSON && (_jsx(Autocomplete, { size: "small", value: geolocation, onChange: handleSelection, inputValue: inputValue, onInputChange: handleLocationChange, options: suggestions, getOptionLabel: (option) => option.description || geolocation.description, noOptionsText: _jsx(FormattedMessage, { id: "ui.eventForm.address.live.noResults", defaultMessage: "ui.eventForm.address.live.noResults" }), isOptionEqualToValue: (option, value) => option.description === value.description, renderInput: (params) => (_jsx(TextField, Object.assign({}, params, { label: _jsx(FormattedMessage, { id: "ui.eventForm.address.live.placeholder", defaultMessage: "ui.eventForm.address.live.placeholder" }), variant: "outlined", fullWidth: true, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (_jsxs(_Fragment, { children: [_jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(Icon, { children: "add_location_alt" }) })), params.InputProps.endAdornment] })) }) }))) })), location === SCEventLocationType.ONLINE && (_jsx(UrlTextField, { size: "small", fullWidth: true, type: "url", placeholder: `${intl.formatMessage(messages.virtualPlaceholder)}`, helperText: _jsx(FormattedMessage, { id: "ui.eventForm.address.online.help", defaultMessage: "ui.eventForm.address.online.help" }), InputProps: {
|
|
140
145
|
endAdornment: _jsx(Icon, { children: "play_circle_outline" })
|
|
141
146
|
}, onChange: handleLinkChange })), canViewLiveTab && location === SCEventLocationType.LIVESTREAM && (_jsxs(_Fragment, { children: [_jsx(LiveStream, { template: SCLiveStreamTemplateType.SNIPPET, liveStream: liveStream, actions: _jsx(_Fragment, {}) }), _jsx(LiveStreamFormSettings, { settings: liveStream.settings || LIVESTREAM_DEFAULT_SETTINGS, onChange: handleLiveStreamSettingsChange })] }))] }))] })));
|
|
142
147
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { LoadingButton } from '@mui/lab';
|
|
4
|
-
import { Box, FormControl, FormGroup, Icon, IconButton, InputAdornment, InputLabel, MenuItem, Paper, Select, Stack, Switch, TextField, Typography } from '@mui/material';
|
|
4
|
+
import { Alert, Box, FormControl, FormGroup, Icon, IconButton, InputAdornment, InputLabel, MenuItem, Paper, Select, Stack, Switch, TextField, Typography } from '@mui/material';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
6
6
|
import { useThemeProps } from '@mui/system';
|
|
7
7
|
import { LocalizationProvider, MobileDatePicker, MobileTimePicker } from '@mui/x-date-pickers';
|
|
@@ -75,7 +75,8 @@ const classes = {
|
|
|
75
75
|
actions: `${PREFIX}-actions`,
|
|
76
76
|
privacySection: `${PREFIX}-privacy-section`,
|
|
77
77
|
privacySectionInfo: `${PREFIX}-privacy-section-info`,
|
|
78
|
-
error: `${PREFIX}-error
|
|
78
|
+
error: `${PREFIX}-error`,
|
|
79
|
+
genericError: `${PREFIX}-generic-error`
|
|
79
80
|
};
|
|
80
81
|
const Root = styled(Box, {
|
|
81
82
|
name: PREFIX,
|
|
@@ -152,6 +153,7 @@ export default function EventForm(inProps) {
|
|
|
152
153
|
// STATE
|
|
153
154
|
const [field, setField] = useState(initialFieldState);
|
|
154
155
|
const [error, setError] = useState({});
|
|
156
|
+
const [genericError, setGenericError] = useState(null);
|
|
155
157
|
// PREFERENCES
|
|
156
158
|
const scPreferences = useSCPreferences();
|
|
157
159
|
const privateEnabled = useMemo(() => scPreferences.preferences[SCPreferences.CONFIGURATIONS_EVENTS_PRIVATE_ENABLED].value, [scPreferences.preferences]);
|
|
@@ -195,6 +197,7 @@ export default function EventForm(inProps) {
|
|
|
195
197
|
}, []);
|
|
196
198
|
const handleSubmit = useCallback(() => {
|
|
197
199
|
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: true })));
|
|
200
|
+
setGenericError(null);
|
|
198
201
|
const formData = new FormData();
|
|
199
202
|
if (field.imageOriginalFile) {
|
|
200
203
|
formData.append('image_original', field.imageOriginalFile);
|
|
@@ -249,6 +252,15 @@ export default function EventForm(inProps) {
|
|
|
249
252
|
else {
|
|
250
253
|
setError(Object.assign(Object.assign({}, error), _error));
|
|
251
254
|
}
|
|
255
|
+
if ('errorsError' in _error) {
|
|
256
|
+
setGenericError(intl.formatMessage({
|
|
257
|
+
id: 'ui.eventForm.liveStream.error.monthlyMinuteLimitReached',
|
|
258
|
+
defaultMessage: 'ui.eventForm.liveStream.error.monthlyMinuteLimitReached'
|
|
259
|
+
}));
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
setGenericError(null);
|
|
263
|
+
}
|
|
252
264
|
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
253
265
|
Logger.error(SCOPE_SC_UI, e);
|
|
254
266
|
onError === null || onError === void 0 ? void 0 : onError(e);
|
|
@@ -261,7 +273,8 @@ export default function EventForm(inProps) {
|
|
|
261
273
|
delete error[`${name}Error`];
|
|
262
274
|
setError(error);
|
|
263
275
|
}
|
|
264
|
-
|
|
276
|
+
setGenericError(null);
|
|
277
|
+
}, [error, setGenericError]);
|
|
265
278
|
const handleChangeDateTime = useCallback((value, name) => {
|
|
266
279
|
setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
|
|
267
280
|
if (error[`${name}Error`]) {
|
|
@@ -272,7 +285,8 @@ export default function EventForm(inProps) {
|
|
|
272
285
|
delete error['endDateError'];
|
|
273
286
|
setError(error);
|
|
274
287
|
}
|
|
275
|
-
|
|
288
|
+
setGenericError(null);
|
|
289
|
+
}, [error, setGenericError]);
|
|
276
290
|
const shouldDisabledDate = useCallback((date) => {
|
|
277
291
|
let disabled = false;
|
|
278
292
|
switch (field.recurring) {
|
|
@@ -348,11 +362,12 @@ export default function EventForm(inProps) {
|
|
|
348
362
|
b: (chunks) => _jsx("strong", { children: chunks })
|
|
349
363
|
} })) }))] }))), _jsx(TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
|
|
350
364
|
endAdornment: (_jsx(Typography, Object.assign({ variant: "body2" }, { children: ((_b = field.description) === null || _b === void 0 ? void 0 : _b.length) ? EVENT_DESCRIPTION_MAX_LENGTH - field.description.length : EVENT_DESCRIPTION_MAX_LENGTH })))
|
|
351
|
-
}, error: Boolean(((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) > EVENT_DESCRIPTION_MAX_LENGTH), helperText: ((_d = field.description) === null || _d === void 0 ? void 0 : _d.length) > EVENT_DESCRIPTION_MAX_LENGTH ? (_jsx(FormattedMessage, { id: "ui.eventForm.description.error.maxLength", defaultMessage: "ui.eventForm.description.error.maxLength" })) : null }), _jsx(Box, Object.assign({ className: classes.actions }, { children: _jsx(LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.name ||
|
|
365
|
+
}, error: Boolean(((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) > EVENT_DESCRIPTION_MAX_LENGTH), helperText: ((_d = field.description) === null || _d === void 0 ? void 0 : _d.length) > EVENT_DESCRIPTION_MAX_LENGTH ? (_jsx(FormattedMessage, { id: "ui.eventForm.description.error.maxLength", defaultMessage: "ui.eventForm.description.error.maxLength" })) : null }), genericError && (_jsx(Box, Object.assign({ className: classes.genericError }, { children: _jsx(Alert, Object.assign({ variant: "filled", severity: "error" }, { children: genericError })) }))), _jsx(Box, Object.assign({ className: classes.actions }, { children: _jsx(LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.name ||
|
|
352
366
|
!field.startDate ||
|
|
353
367
|
!field.startTime ||
|
|
354
368
|
!field.endDate ||
|
|
355
369
|
!field.endTime ||
|
|
370
|
+
Boolean(genericError) ||
|
|
356
371
|
(field.location === SCEventLocationType.ONLINE && !field.link) ||
|
|
357
372
|
(field.location === SCEventLocationType.PERSON && !field.geolocation) ||
|
|
358
373
|
(field.recurring !== SCEventRecurrenceType.NEVER && !field.endDate && !field.endTime) ||
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { LoadingButton } from '@mui/lab';
|
|
4
|
-
import { Box, FormGroup, Paper, TextField, Typography } from '@mui/material';
|
|
4
|
+
import { Alert, Box, FormGroup, Paper, TextField, Typography } from '@mui/material';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
6
6
|
import { useThemeProps } from '@mui/system';
|
|
7
7
|
import { SCPreferences, useSCPreferences } from '@selfcommunity/react-core';
|
|
@@ -24,7 +24,8 @@ const classes = {
|
|
|
24
24
|
description: `${PREFIX}-description`,
|
|
25
25
|
content: `${PREFIX}-content`,
|
|
26
26
|
actions: `${PREFIX}-actions`,
|
|
27
|
-
error: `${PREFIX}-error
|
|
27
|
+
error: `${PREFIX}-error`,
|
|
28
|
+
genericError: `${PREFIX}-generic-error`
|
|
28
29
|
};
|
|
29
30
|
const Root = styled(Box, {
|
|
30
31
|
name: PREFIX,
|
|
@@ -94,6 +95,7 @@ export default function LiveStreamForm(inProps) {
|
|
|
94
95
|
// STATE
|
|
95
96
|
const [field, setField] = useState(initialFieldState);
|
|
96
97
|
const [error, setError] = useState({});
|
|
98
|
+
const [genericError, setGenericError] = useState(null);
|
|
97
99
|
// PREFERENCES
|
|
98
100
|
const scPreferences = useSCPreferences();
|
|
99
101
|
const _backgroundCover = Object.assign({}, (field.cover
|
|
@@ -113,6 +115,7 @@ export default function LiveStreamForm(inProps) {
|
|
|
113
115
|
}, [error]);
|
|
114
116
|
const handleSubmit = useCallback(() => {
|
|
115
117
|
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: true })));
|
|
118
|
+
setGenericError(null);
|
|
116
119
|
const formData = new FormData();
|
|
117
120
|
if (field.coverFile) {
|
|
118
121
|
formData.append('cover', field.coverFile);
|
|
@@ -139,11 +142,21 @@ export default function LiveStreamForm(inProps) {
|
|
|
139
142
|
const _error = formatHttpErrorCode(e);
|
|
140
143
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
|
|
141
144
|
// @ts-ignore
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
console.log(_error);
|
|
146
|
+
if ('errorsError' in _error) {
|
|
147
|
+
setGenericError(intl.formatMessage({
|
|
148
|
+
id: 'ui.liveStreamForm.error.monthlyMinuteLimitReached',
|
|
149
|
+
defaultMessage: 'ui.liveStreamForm.error.monthlyMinuteLimitReached'
|
|
150
|
+
}));
|
|
144
151
|
}
|
|
145
152
|
else {
|
|
146
|
-
|
|
153
|
+
setGenericError(null);
|
|
154
|
+
}
|
|
155
|
+
if ('titleError' in Object.values(_error)) {
|
|
156
|
+
setError(Object.assign(Object.assign({}, error), { ['titleError']: _jsx(FormattedMessage, { id: "ui.liveStreamForm.title.error.invalid", defaultMessage: "ui.liveStreamForm.title.error.invalid" }) }));
|
|
157
|
+
}
|
|
158
|
+
if ('slugError' in Object.values(_error)) {
|
|
159
|
+
setError(Object.assign(Object.assign({}, error), { ['slugError']: _jsx(FormattedMessage, { id: "ui.liveStreamForm.slug.error.invalid", defaultMessage: "ui.liveStreamForm.slug.error.invalid" }) }));
|
|
147
160
|
}
|
|
148
161
|
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
149
162
|
Logger.error(SCOPE_SC_UI, e);
|
|
@@ -157,7 +170,8 @@ export default function LiveStreamForm(inProps) {
|
|
|
157
170
|
delete error[`${name}Error`];
|
|
158
171
|
setError(error);
|
|
159
172
|
}
|
|
160
|
-
|
|
173
|
+
setGenericError(null);
|
|
174
|
+
}, [error, setGenericError]);
|
|
161
175
|
const handleChangeSettings = useCallback((data) => {
|
|
162
176
|
setField((prev) => (Object.assign(Object.assign({}, prev), { settings: data })));
|
|
163
177
|
}, [setField]);
|
|
@@ -170,8 +184,9 @@ export default function LiveStreamForm(inProps) {
|
|
|
170
184
|
endAdornment: _jsx(Typography, Object.assign({ variant: "body2" }, { children: LIVE_STREAM_SLUG_MAX_LENGTH - field.title.length }))
|
|
171
185
|
}, 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: {
|
|
172
186
|
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 })))
|
|
173
|
-
}, 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(LiveStreamSettingsForm, { settings: field.settings, onChange: handleChangeSettings }), _jsx(Box, Object.assign({ className: classes.actions }, { children: _jsx(LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.title ||
|
|
187
|
+
}, 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(LiveStreamSettingsForm, { settings: field.settings, onChange: handleChangeSettings }), genericError && (_jsx(Box, Object.assign({ className: classes.genericError }, { children: _jsx(Alert, Object.assign({ variant: "filled", severity: "error" }, { children: genericError })) }))), _jsx(Box, Object.assign({ className: classes.actions }, { children: _jsx(LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.title ||
|
|
174
188
|
Object.keys(error).length !== 0 ||
|
|
189
|
+
Boolean(genericError) ||
|
|
175
190
|
field.title.length > LIVE_STREAM_TITLE_MAX_LENGTH ||
|
|
176
191
|
field.description.length > LIVE_STREAM_DESCRIPTION_MAX_LENGTH, variant: "contained", onClick: handleSubmit, color: "secondary" }, { children: liveStream ? (_jsx(FormattedMessage, { id: "ui.liveStreamForm.button.edit", defaultMessage: "ui.liveStreamForm.button.edit" })) : (_jsx(FormattedMessage, { id: "ui.liveStreamForm.button.create", defaultMessage: "ui.liveStreamForm.button.create" })) })) }))] }))] })));
|
|
177
192
|
}
|
|
@@ -42,13 +42,14 @@ export default function LiveStreamNotification(props) {
|
|
|
42
42
|
// CONST
|
|
43
43
|
const isSnippetTemplate = template === SCNotificationObjectTemplateType.SNIPPET;
|
|
44
44
|
const isToastTemplate = template === SCNotificationObjectTemplateType.TOAST;
|
|
45
|
+
const inProgress = Boolean(!notificationObject.live_stream.closed_at_by_host && (notificationObject.live_stream.last_started_at && !notificationObject.live_stream.last_finished_at));
|
|
45
46
|
// RENDER
|
|
46
47
|
if (isSnippetTemplate) {
|
|
47
|
-
return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: _jsx(Link, Object.assign({}, (!notificationObject.
|
|
48
|
-
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.
|
|
49
|
-
}), { onClick: notificationObject.
|
|
50
|
-
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.
|
|
51
|
-
}), { onClick: notificationObject.
|
|
48
|
+
return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: _jsx(Link, Object.assign({}, (!notificationObject.live_stream.host.deleted && {
|
|
49
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.live_stream.host)
|
|
50
|
+
}), { onClick: notificationObject.live_stream.host.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !notificationObject.live_stream.host.community_badge, smaller: true }, { children: _jsx(Avatar, { alt: notificationObject.live_stream.host.username, variant: "circular", src: notificationObject.live_stream.host.avatar, classes: { root: classes.avatar } }) })) })), primary: _jsxs(Box, { children: [_jsx(Link, Object.assign({}, (!notificationObject.live_stream.host.deleted && {
|
|
51
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.live_stream.host)
|
|
52
|
+
}), { onClick: notificationObject.live_stream.host.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.live_stream.host.username })), ' ', _jsx(FormattedMessage, { id: `ui.notification.${notificationObject.type}.title`, defaultMessage: `ui.notification.${notificationObject.type}.title`, values: {
|
|
52
53
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
53
54
|
// @ts-ignore
|
|
54
55
|
icon: (...chunks) => _jsx(Icon, { children: chunks }),
|
|
@@ -56,14 +57,14 @@ export default function LiveStreamNotification(props) {
|
|
|
56
57
|
link: (...chunks) => _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.LIVESTREAM_ROUTE_NAME, notificationObject.live_stream) }, { children: chunks }))
|
|
57
58
|
} })] }), footer: isToastTemplate ? (_jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [_jsx(DateTimeAgo, { date: notificationObject.active_at }), _jsx(Typography, Object.assign({ color: "primary" }, { children: _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.LIVESTREAM_ROUTE_NAME, notificationObject.live_stream) }, { children: _jsx(FormattedMessage, { id: "ui.notification.live_stream_started.join", defaultMessage: "ui.notification.live_stream_started.join" }) })) }))] }))) : (_jsx(DateTimeAgo, { date: notificationObject.active_at, className: classes.snippetTime })) }, rest)));
|
|
58
59
|
}
|
|
59
|
-
return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: _jsx(Link, Object.assign({}, (!notificationObject.
|
|
60
|
-
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.
|
|
61
|
-
}), { onClick: notificationObject.
|
|
62
|
-
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.
|
|
63
|
-
}), { onClick: notificationObject.
|
|
60
|
+
return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: _jsx(Link, Object.assign({}, (!notificationObject.live_stream.host.deleted && {
|
|
61
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.live_stream.host)
|
|
62
|
+
}), { onClick: notificationObject.live_stream.host.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !notificationObject.live_stream.host.community_badge, smaller: true }, { children: _jsx(Avatar, { className: classes.avatar, alt: notificationObject.live_stream.host.username, variant: "circular", src: notificationObject.live_stream.host.avatar }) })) })), primary: _jsxs(_Fragment, { children: [_jsx(Link, Object.assign({}, (!notificationObject.live_stream.host.deleted && {
|
|
63
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.live_stream.host)
|
|
64
|
+
}), { onClick: notificationObject.live_stream.host.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.live_stream.host.username })), ' ', _jsx(FormattedMessage, { id: `ui.notification.${notificationObject.type}`, defaultMessage: `ui.notification.${notificationObject.type}`, values: {
|
|
64
65
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
65
66
|
// @ts-ignore
|
|
66
67
|
live: notificationObject.live_stream.title,
|
|
67
68
|
link: (...chunks) => _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.LIVESTREAM_ROUTE_NAME, notificationObject.live_stream) }, { children: chunks }))
|
|
68
|
-
} }), _jsx(LiveStream, { liveStream: notificationObject.live_stream, actions: _jsx(_Fragment, {}), elevation: 0 })] }), actions: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [_jsx(DateTimeAgo, { date: notificationObject.active_at, className: classes.activeAt }), _jsx(LoadingButton, Object.assign({ color: 'primary', variant: "outlined", size: "small", classes: { root: classes.seeButton }, component: Link, disabled: Boolean(notificationObject.live_stream.closed_at_by_host), to: scRoutingContext.url(SCRoutes.LIVESTREAM_ROUTE_NAME, notificationObject.live_stream) }, { children: _jsx(FormattedMessage, { id: "ui.notification.live_stream_started.join", defaultMessage: "ui.notification.live_stream_started.join" }) }))] })) }, rest)), openAlert && _jsx(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })] }));
|
|
69
|
+
} }), _jsx(LiveStream, { liveStream: notificationObject.live_stream, hideInProgress: !inProgress, actions: _jsx(_Fragment, {}), elevation: 0 })] }), actions: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [_jsx(DateTimeAgo, { date: notificationObject.active_at, className: classes.activeAt }), _jsx(LoadingButton, Object.assign({ color: 'primary', variant: "outlined", size: "small", classes: { root: classes.seeButton }, component: Link, disabled: Boolean(notificationObject.live_stream.closed_at_by_host), to: scRoutingContext.url(SCRoutes.LIVESTREAM_ROUTE_NAME, notificationObject.live_stream) }, { children: _jsx(FormattedMessage, { id: "ui.notification.live_stream_started.join", defaultMessage: "ui.notification.live_stream_started.join" }) }))] })) }, rest)), openAlert && _jsx(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })] }));
|
|
69
70
|
}
|
|
@@ -3,3 +3,7 @@ export declare const HUB_STAGE = "https://hub.stage.quentrix.com/";
|
|
|
3
3
|
export declare const HUB_PROD = "https://hub.selfcommunity.com/";
|
|
4
4
|
export declare const CONTACT_STAGE = "https://hub.stage.quentrix.com/dashboard/account/contact-us";
|
|
5
5
|
export declare const CONTACT_PROD = "https://hub.selfcommunity.com/dashboard/account/contact-us";
|
|
6
|
+
export declare const SELFCOMMUNITY_PRICING: {
|
|
7
|
+
en: string;
|
|
8
|
+
it: string;
|
|
9
|
+
};
|
|
@@ -3,3 +3,7 @@ export const HUB_STAGE = 'https://hub.stage.quentrix.com/';
|
|
|
3
3
|
export const HUB_PROD = 'https://hub.selfcommunity.com/';
|
|
4
4
|
export const CONTACT_STAGE = 'https://hub.stage.quentrix.com/dashboard/account/contact-us';
|
|
5
5
|
export const CONTACT_PROD = 'https://hub.selfcommunity.com/dashboard/account/contact-us';
|
|
6
|
+
export const SELFCOMMUNITY_PRICING = {
|
|
7
|
+
en: 'https://selfcommunity.com/community-software-pricing/',
|
|
8
|
+
it: 'https://selfcommunity.com/it/community-software-prezzi/'
|
|
9
|
+
};
|
|
@@ -20,5 +20,5 @@ const Root = styled(Widget, {
|
|
|
20
20
|
overridesResolver: (_props, styles) => styles.skeletonRoot
|
|
21
21
|
})(() => ({}));
|
|
22
22
|
export default function UserLiveStreamWidgetSkeleton() {
|
|
23
|
-
return (_jsxs(Root, Object.assign({ className: classes.root }, { children: [_jsx(CardContent, Object.assign({ className: classes.content }, { children: _jsx(Stack, Object.assign({ className: classes.liveWrapper }, { children: [1, 2
|
|
23
|
+
return (_jsxs(Root, Object.assign({ className: classes.root }, { children: [_jsx(CardContent, Object.assign({ className: classes.content }, { children: _jsx(Stack, Object.assign({ className: classes.liveWrapper }, { children: [1, 2].map((_event, i, array) => (_jsxs(Fragment, { children: [_jsx(EventSkeleton, { elevation: 0, className: classes.event }), i < array.length - 1 && _jsx(Divider, {})] }, i))) })) })), _jsx(CardActions, Object.assign({ className: classes.actions }, { children: _jsx(Skeleton, { animation: "wave", width: "52px", height: "20px" }) }))] })));
|
|
24
24
|
}
|
|
@@ -4,6 +4,7 @@ import { Button, CardActions, CardContent, Divider, List, ListItem, Stack, Typog
|
|
|
4
4
|
import { styled } from '@mui/system';
|
|
5
5
|
import { Endpoints, http, UserApiClient } from '@selfcommunity/api-services';
|
|
6
6
|
import { SCCache, SCPreferences, useSCFetchUser, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
|
|
7
|
+
import { SCCommunitySubscriptionTier } from '@selfcommunity/types';
|
|
7
8
|
import { isInteger, Logger } from '@selfcommunity/utils';
|
|
8
9
|
import { Fragment, useCallback, useEffect, useMemo, useReducer, useState } from 'react';
|
|
9
10
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
@@ -73,7 +74,10 @@ export default function UserLiveStreamWidget(inProps) {
|
|
|
73
74
|
// MEMO
|
|
74
75
|
const liveStreamEnabled = useMemo(() => SCPreferences.CONFIGURATIONS_LIVE_STREAM_ENABLED in scPreferencesContext.preferences &&
|
|
75
76
|
scPreferencesContext.preferences[SCPreferences.CONFIGURATIONS_LIVE_STREAM_ENABLED].value, [scPreferencesContext.preferences]);
|
|
76
|
-
|
|
77
|
+
const isFreeTrialTier = useMemo(() => scPreferencesContext.preferences &&
|
|
78
|
+
SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER in scPreferencesContext.preferences &&
|
|
79
|
+
scPreferencesContext.preferences[SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value &&
|
|
80
|
+
scPreferencesContext.preferences[SCPreferences.CONFIGURATIONS_SUBSCRIPTION_TIER].value === SCCommunitySubscriptionTier.FREE_TRIAL, [scPreferencesContext.preferences]);
|
|
77
81
|
const _initComponent = useCallback(() => {
|
|
78
82
|
if (!state.initialized && !state.isLoadingNext) {
|
|
79
83
|
dispatch({ type: actionWidgetTypes.LOADING_NEXT });
|
|
@@ -119,7 +123,7 @@ export default function UserLiveStreamWidget(inProps) {
|
|
|
119
123
|
return _jsx(Skeleton, {});
|
|
120
124
|
}
|
|
121
125
|
// RENDER
|
|
122
|
-
if (!scUser.user || (state === null || state === void 0 ? void 0 : state.count) === 0 || !liveStreamEnabled) {
|
|
126
|
+
if (!scUser.user || (state === null || state === void 0 ? void 0 : state.count) === 0 || !liveStreamEnabled || isFreeTrialTier) {
|
|
123
127
|
return _jsx(HiddenPlaceholder, {});
|
|
124
128
|
}
|
|
125
129
|
return (_jsxs(Root, Object.assign({ className: classes.root }, rest, { children: [_jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsx(Typography, Object.assign({ variant: "h4" }, { children: _jsx("b", { children: intl.formatMessage(messages.title, { user: scUser.username }) }) })), _jsx(Stack, Object.assign({ className: classes.liveWrapper }, { children: state === null || state === void 0 ? void 0 : state.results.map((_live, i, array) => (_jsxs(Fragment, { children: [_jsx(LiveStream, Object.assign({ liveStream: _live }, liveStreamComponentProps, { className: classes.live })), i < array.length - 1 && _jsx(Divider, {})] }, i))) }))] })), state.count > state.visibleItems && (_jsx(CardActions, Object.assign({ className: classes.actions }, { children: _jsx(Button, Object.assign({ onClick: handleToggleDialogOpen, className: classes.actionButton }, { children: _jsx(Typography, Object.assign({ variant: "caption" }, { children: _jsx(FormattedMessage, { id: "ui.userLiveStreamWidget.showAll", defaultMessage: "ui.userLiveStreamWidget.showAll" }) })) })) }))), openDialog && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: intl.formatMessage(messages.title, { user: scUser.username }), onClose: handleToggleDialogOpen, open: openDialog }, dialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: state.results.length, next: handleNext, hasMoreNext: Boolean(state.next), loaderNext: _jsx(LiveStreamSkeleton, Object.assign({ elevation: 0 }, liveStreamComponentProps)), className: classes.infiniteScroll, endMessage: _jsx(Typography, Object.assign({ className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.userLiveStreamWidget.noMoreResults", defaultMessage: "ui.userLiveStreamWidget.noMoreResults" }) })) }, { children: _jsx(List, { children: state.results.map((live) => (_jsx(ListItem, { children: _jsx(LiveStream, Object.assign({ elevation: 0, liveStream: live }, liveStreamComponentProps)) }, live.id))) }) })) })))] })));
|