@selfcommunity/react-templates 0.4.5-alpha.9 → 0.4.6-alpha.0
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.
|
@@ -6,6 +6,7 @@ const styles_1 = require("@mui/material/styles");
|
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
7
|
const react_ui_1 = require("@selfcommunity/react-ui");
|
|
8
8
|
const react_core_1 = require("@selfcommunity/react-core");
|
|
9
|
+
const types_1 = require("@selfcommunity/types");
|
|
9
10
|
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
10
11
|
const system_1 = require("@mui/system");
|
|
11
12
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
@@ -54,7 +55,12 @@ function Event(inProps) {
|
|
|
54
55
|
const { id = 'event', className, event, eventId, widgets, FeedObjectProps, FeedSidebarProps, EventFeedProps = {}, EventHeaderProps = {} } = props;
|
|
55
56
|
// HOOKS
|
|
56
57
|
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
57
|
-
|
|
58
|
+
const scUserContext = (0, react_core_1.useSCUser)();
|
|
59
|
+
if (scUserContext.user === undefined ||
|
|
60
|
+
!scEvent ||
|
|
61
|
+
(scUserContext.user &&
|
|
62
|
+
((scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC && !scEvent.subscription_status) ||
|
|
63
|
+
scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED))) {
|
|
58
64
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
59
65
|
}
|
|
60
66
|
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: [(0, jsx_runtime_1.jsx)(react_ui_1.EventHeader, Object.assign({ event: scEvent }, EventHeaderProps)), (0, jsx_runtime_1.jsx)(EventFeed_1.default, Object.assign({ className: classes.feed, event: scEvent, widgets: widgets, FeedObjectProps: FeedObjectProps, FeedSidebarProps: FeedSidebarProps }, EventFeedProps))] })));
|
|
@@ -91,12 +91,12 @@ function EventFeed(inProps) {
|
|
|
91
91
|
// REF
|
|
92
92
|
const feedRef = (0, react_1.useRef)();
|
|
93
93
|
// Hooks
|
|
94
|
-
const { scEvent
|
|
94
|
+
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
95
95
|
// HANDLERS
|
|
96
96
|
const handleComposerSuccess = (feedObject) => {
|
|
97
97
|
var _a;
|
|
98
98
|
enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composerIconButton.composer.success", defaultMessage: "ui.composerIconButton.composer.success" }), {
|
|
99
|
-
action: (
|
|
99
|
+
action: () => ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes[`${feedObject.type.toUpperCase()}_ROUTE_NAME`], react_ui_1.ContributionUtils.getRouteData(feedObject)) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composerIconButton.composer.viewContribute", defaultMessage: "ui.composerIconButton.composer.viewContribute" }) }))),
|
|
100
100
|
variant: 'success',
|
|
101
101
|
autoHideDuration: 7000
|
|
102
102
|
});
|
|
@@ -114,16 +114,20 @@ function EventFeed(inProps) {
|
|
|
114
114
|
// WIDGETS
|
|
115
115
|
const _widgets = (0, react_1.useMemo)(() => widgets.map((w) => {
|
|
116
116
|
if (scEvent) {
|
|
117
|
-
return Object.assign(Object.assign({}, w), { componentProps: Object.assign(Object.assign({}, w.componentProps), {
|
|
117
|
+
return Object.assign(Object.assign({}, w), { componentProps: Object.assign(Object.assign({}, w.componentProps), { event: scEvent }) });
|
|
118
118
|
}
|
|
119
119
|
return w;
|
|
120
120
|
}), [widgets, scEvent]);
|
|
121
|
-
if (
|
|
121
|
+
if (scUserContext.user === undefined ||
|
|
122
|
+
!scEvent ||
|
|
123
|
+
(scUserContext.user &&
|
|
124
|
+
((scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC && !scEvent.subscription_status) ||
|
|
125
|
+
scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED)) ||
|
|
126
|
+
(scEvent && ((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id)))) {
|
|
122
127
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
123
128
|
}
|
|
124
129
|
else if (scEvent.privacy === types_1.SCEventPrivacyType.PRIVATE &&
|
|
125
130
|
scEvent.subscription_status !== types_1.SCEventSubscriptionStatusType.SUBSCRIBED &&
|
|
126
|
-
scEvent.subscription_status !== types_1.SCEventSubscriptionStatusType.INVITED &&
|
|
127
131
|
scEvent.subscription_status !== types_1.SCEventSubscriptionStatusType.GOING &&
|
|
128
132
|
scEvent.subscription_status !== types_1.SCEventSubscriptionStatusType.NOT_GOING) {
|
|
129
133
|
return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(react_ui_1.EventInfoWidget, { className: classes.root, event: scEvent }) })));
|
|
@@ -142,7 +146,6 @@ function EventFeed(inProps) {
|
|
|
142
146
|
((!scUserContext.user && scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC) ||
|
|
143
147
|
(scUserContext.user &&
|
|
144
148
|
(scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.SUBSCRIBED ||
|
|
145
|
-
scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED ||
|
|
146
149
|
scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.GOING ||
|
|
147
150
|
scEvent.subscription_status === types_1.SCEventSubscriptionStatusType.NOT_GOING)))) && ((0, jsx_runtime_1.jsx)(react_ui_1.InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { event: scEvent }, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "templates.eventFeed.composer.label", defaultMessage: "templates.eventFeed.composer.label" }), feedType: types_1.SCFeedTypologyType.EVENT }))] }), CustomAdvProps: { position: types_1.SCCustomAdvPosition.POSITION_FEED, groupsId: [scEvent.id] }, enabledCustomAdvPositions: [
|
|
148
151
|
types_1.SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|
|
@@ -2,7 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
3
|
import { Box } from '@mui/material';
|
|
4
4
|
import { EventHeader } from '@selfcommunity/react-ui';
|
|
5
|
-
import { useSCFetchEvent } from '@selfcommunity/react-core';
|
|
5
|
+
import { useSCFetchEvent, useSCUser } from '@selfcommunity/react-core';
|
|
6
|
+
import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
|
|
6
7
|
import EventSkeletonTemplate from './Skeleton';
|
|
7
8
|
import { useThemeProps } from '@mui/system';
|
|
8
9
|
import classNames from 'classnames';
|
|
@@ -51,7 +52,12 @@ export default function Event(inProps) {
|
|
|
51
52
|
const { id = 'event', className, event, eventId, widgets, FeedObjectProps, FeedSidebarProps, EventFeedProps = {}, EventHeaderProps = {} } = props;
|
|
52
53
|
// HOOKS
|
|
53
54
|
const { scEvent } = useSCFetchEvent({ id: eventId, event });
|
|
54
|
-
|
|
55
|
+
const scUserContext = useSCUser();
|
|
56
|
+
if (scUserContext.user === undefined ||
|
|
57
|
+
!scEvent ||
|
|
58
|
+
(scUserContext.user &&
|
|
59
|
+
((scEvent.privacy === SCEventPrivacyType.PUBLIC && !scEvent.subscription_status) ||
|
|
60
|
+
scEvent.subscription_status === SCEventSubscriptionStatusType.INVITED))) {
|
|
55
61
|
return _jsx(EventSkeletonTemplate, {});
|
|
56
62
|
}
|
|
57
63
|
return (_jsxs(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: [_jsx(EventHeader, Object.assign({ event: scEvent }, EventHeaderProps)), _jsx(EventFeed, Object.assign({ className: classes.feed, event: scEvent, widgets: widgets, FeedObjectProps: FeedObjectProps, FeedSidebarProps: FeedSidebarProps }, EventFeedProps))] })));
|
|
@@ -88,12 +88,12 @@ export default function EventFeed(inProps) {
|
|
|
88
88
|
// REF
|
|
89
89
|
const feedRef = useRef();
|
|
90
90
|
// Hooks
|
|
91
|
-
const { scEvent
|
|
91
|
+
const { scEvent } = useSCFetchEvent({ id: eventId, event });
|
|
92
92
|
// HANDLERS
|
|
93
93
|
const handleComposerSuccess = (feedObject) => {
|
|
94
94
|
var _a;
|
|
95
95
|
enqueueSnackbar(_jsx(FormattedMessage, { id: "ui.composerIconButton.composer.success", defaultMessage: "ui.composerIconButton.composer.success" }), {
|
|
96
|
-
action: (
|
|
96
|
+
action: () => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes[`${feedObject.type.toUpperCase()}_ROUTE_NAME`], ContributionUtils.getRouteData(feedObject)) }, { children: _jsx(FormattedMessage, { id: "ui.composerIconButton.composer.viewContribute", defaultMessage: "ui.composerIconButton.composer.viewContribute" }) }))),
|
|
97
97
|
variant: 'success',
|
|
98
98
|
autoHideDuration: 7000
|
|
99
99
|
});
|
|
@@ -111,16 +111,20 @@ export default function EventFeed(inProps) {
|
|
|
111
111
|
// WIDGETS
|
|
112
112
|
const _widgets = useMemo(() => widgets.map((w) => {
|
|
113
113
|
if (scEvent) {
|
|
114
|
-
return Object.assign(Object.assign({}, w), { componentProps: Object.assign(Object.assign({}, w.componentProps), {
|
|
114
|
+
return Object.assign(Object.assign({}, w), { componentProps: Object.assign(Object.assign({}, w.componentProps), { event: scEvent }) });
|
|
115
115
|
}
|
|
116
116
|
return w;
|
|
117
117
|
}), [widgets, scEvent]);
|
|
118
|
-
if (
|
|
118
|
+
if (scUserContext.user === undefined ||
|
|
119
|
+
!scEvent ||
|
|
120
|
+
(scUserContext.user &&
|
|
121
|
+
((scEvent.privacy === SCEventPrivacyType.PUBLIC && !scEvent.subscription_status) ||
|
|
122
|
+
scEvent.subscription_status === SCEventSubscriptionStatusType.INVITED)) ||
|
|
123
|
+
(scEvent && ((eventId !== undefined && scEvent.id !== eventId) || (event && scEvent.id !== event.id)))) {
|
|
119
124
|
return _jsx(EventFeedSkeleton, {});
|
|
120
125
|
}
|
|
121
126
|
else if (scEvent.privacy === SCEventPrivacyType.PRIVATE &&
|
|
122
127
|
scEvent.subscription_status !== SCEventSubscriptionStatusType.SUBSCRIBED &&
|
|
123
|
-
scEvent.subscription_status !== SCEventSubscriptionStatusType.INVITED &&
|
|
124
128
|
scEvent.subscription_status !== SCEventSubscriptionStatusType.GOING &&
|
|
125
129
|
scEvent.subscription_status !== SCEventSubscriptionStatusType.NOT_GOING) {
|
|
126
130
|
return (_jsx(Box, Object.assign({ mt: 2 }, { children: _jsx(EventInfoWidget, { className: classes.root, event: scEvent }) })));
|
|
@@ -139,7 +143,6 @@ export default function EventFeed(inProps) {
|
|
|
139
143
|
((!scUserContext.user && scEvent.privacy === SCEventPrivacyType.PUBLIC) ||
|
|
140
144
|
(scUserContext.user &&
|
|
141
145
|
(scEvent.subscription_status === SCEventSubscriptionStatusType.SUBSCRIBED ||
|
|
142
|
-
scEvent.subscription_status === SCEventSubscriptionStatusType.INVITED ||
|
|
143
146
|
scEvent.subscription_status === SCEventSubscriptionStatusType.GOING ||
|
|
144
147
|
scEvent.subscription_status === SCEventSubscriptionStatusType.NOT_GOING)))) && (_jsx(InlineComposerWidget, { onSuccess: handleComposerSuccess, defaultValue: { event: scEvent }, label: _jsx(FormattedMessage, { id: "templates.eventFeed.composer.label", defaultMessage: "templates.eventFeed.composer.label" }), feedType: SCFeedTypologyType.EVENT }))] }), CustomAdvProps: { position: SCCustomAdvPosition.POSITION_FEED, groupsId: [scEvent.id] }, enabledCustomAdvPositions: [
|
|
145
148
|
SCCustomAdvPosition.POSITION_FEED_SIDEBAR,
|