@selfcommunity/react-ui 0.7.50-events.44 → 0.7.50-events.47
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/CreateEventButton/CreateEventButton.js +6 -4
- package/lib/cjs/components/CreateEventWidget/CreateEventWidget.d.ts +14 -0
- package/lib/cjs/components/CreateEventWidget/CreateEventWidget.js +63 -0
- package/lib/cjs/components/CreateEventWidget/Skeleton.d.ts +1 -0
- package/lib/cjs/components/CreateEventWidget/Skeleton.js +25 -0
- package/lib/cjs/components/CreateEventWidget/constants.d.ts +1 -0
- package/lib/cjs/components/CreateEventWidget/constants.js +4 -0
- package/lib/cjs/components/CreateEventWidget/index.d.ts +4 -0
- package/lib/cjs/components/CreateEventWidget/index.js +8 -0
- package/lib/cjs/components/Event/Event.d.ts +28 -0
- package/lib/cjs/components/Event/Event.js +64 -8
- package/lib/cjs/components/Event/Skeleton.d.ts +9 -3
- package/lib/cjs/components/Event/Skeleton.js +48 -6
- package/lib/cjs/components/EventHeader/EventHeader.js +10 -3
- package/lib/cjs/components/EventInfoWidget/EventInfoWidget.js +2 -1
- package/lib/cjs/components/EventInfoWidget/Skeleton.js +1 -1
- package/lib/cjs/components/EventLocationWidget/EventLocationWidget.js +8 -3
- package/lib/cjs/components/EventPartecipantsButton/EventPartecipantsButton.js +7 -8
- package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.js +3 -2
- package/lib/cjs/components/Events/Events.d.ts +6 -1
- package/lib/cjs/components/Events/Events.js +3 -3
- package/lib/cjs/components/FeedObjectMediaPreview/FeedObjectMediaPreview.d.ts +1 -1
- package/lib/cjs/components/FeedObjectMediaPreview/FeedObjectMediaPreview.js +1 -1
- package/lib/cjs/components/MyEventsWidget/MyEventsWidget.js +19 -10
- package/lib/cjs/components/MyEventsWidget/Skeleton.js +6 -26
- package/lib/cjs/components/Notification/Event/Event.d.ts +15 -0
- package/lib/cjs/components/Notification/Event/Event.js +71 -0
- package/lib/cjs/components/Notification/Event/index.d.ts +3 -0
- package/lib/cjs/components/Notification/Event/index.js +5 -0
- package/lib/cjs/components/Notification/Notification.js +26 -0
- package/lib/cjs/components/SnippetNotifications/SnippetNotifications.js +7 -0
- package/lib/cjs/components/SuggestedEventsWidget/Skeleton.d.ts +2 -0
- package/lib/cjs/components/SuggestedEventsWidget/Skeleton.js +28 -0
- package/lib/cjs/components/SuggestedEventsWidget/SuggestedEventsWidget.d.ts +14 -0
- package/lib/cjs/components/SuggestedEventsWidget/SuggestedEventsWidget.js +80 -0
- package/lib/cjs/components/SuggestedEventsWidget/constants.d.ts +1 -0
- package/lib/cjs/components/SuggestedEventsWidget/constants.js +4 -0
- package/lib/cjs/components/SuggestedEventsWidget/index.d.ts +4 -0
- package/lib/cjs/components/SuggestedEventsWidget/index.js +8 -0
- package/lib/cjs/components/ToastNotifications/ToastNotifications.js +7 -0
- package/lib/cjs/constants/EventActionsMenu.d.ts +6 -0
- package/lib/cjs/constants/EventActionsMenu.js +9 -0
- package/lib/cjs/constants/Media.d.ts +2 -0
- package/lib/cjs/constants/Media.js +3 -1
- package/lib/cjs/index.d.ts +4 -1
- package/lib/cjs/index.js +12 -4
- package/lib/cjs/shared/Calendar/index.js +1 -1
- package/lib/cjs/shared/EventActionsMenu/index.d.ts +49 -0
- package/lib/cjs/shared/EventActionsMenu/index.js +154 -0
- package/lib/cjs/shared/EventInfoDetails/index.d.ts +12 -0
- package/lib/cjs/shared/EventInfoDetails/index.js +3 -3
- package/lib/cjs/shared/Media/Event/DisplayComponent.d.ts +15 -0
- package/lib/cjs/shared/Media/Event/DisplayComponent.js +31 -0
- package/lib/cjs/shared/Media/Event/constants.d.ts +1 -0
- package/lib/cjs/shared/Media/Event/constants.js +4 -0
- package/lib/cjs/shared/Media/Event/filter.d.ts +3 -0
- package/lib/cjs/shared/Media/Event/filter.js +4 -0
- package/lib/cjs/shared/Media/Event/index.d.ts +3 -0
- package/lib/cjs/shared/Media/Event/index.js +14 -0
- package/lib/cjs/shared/Media/Link/PreviewComponent.js +1 -1
- package/lib/cjs/shared/Media/index.d.ts +2 -1
- package/lib/cjs/shared/Media/index.js +3 -1
- package/lib/cjs/types/event.d.ts +5 -0
- package/lib/cjs/types/event.js +9 -0
- package/lib/esm/components/CreateEventButton/CreateEventButton.js +6 -4
- package/lib/esm/components/CreateEventWidget/CreateEventWidget.d.ts +14 -0
- package/lib/esm/components/CreateEventWidget/CreateEventWidget.js +60 -0
- package/lib/esm/components/CreateEventWidget/Skeleton.d.ts +1 -0
- package/lib/esm/components/CreateEventWidget/Skeleton.js +21 -0
- package/lib/esm/components/CreateEventWidget/constants.d.ts +1 -0
- package/lib/esm/components/CreateEventWidget/constants.js +1 -0
- package/lib/esm/components/CreateEventWidget/index.d.ts +4 -0
- package/lib/esm/components/CreateEventWidget/index.js +4 -0
- package/lib/esm/components/Event/Event.d.ts +28 -0
- package/lib/esm/components/Event/Event.js +66 -10
- package/lib/esm/components/Event/Skeleton.d.ts +9 -3
- package/lib/esm/components/Event/Skeleton.js +50 -7
- package/lib/esm/components/EventHeader/EventHeader.js +11 -4
- package/lib/esm/components/EventInfoWidget/EventInfoWidget.js +2 -1
- package/lib/esm/components/EventInfoWidget/Skeleton.js +1 -1
- package/lib/esm/components/EventLocationWidget/EventLocationWidget.js +8 -3
- package/lib/esm/components/EventPartecipantsButton/EventPartecipantsButton.js +8 -9
- package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.js +3 -2
- package/lib/esm/components/Events/Events.d.ts +6 -1
- package/lib/esm/components/Events/Events.js +3 -3
- package/lib/esm/components/FeedObjectMediaPreview/FeedObjectMediaPreview.d.ts +1 -1
- package/lib/esm/components/FeedObjectMediaPreview/FeedObjectMediaPreview.js +2 -2
- package/lib/esm/components/MyEventsWidget/MyEventsWidget.js +23 -14
- package/lib/esm/components/MyEventsWidget/Skeleton.js +7 -27
- package/lib/esm/components/Notification/Event/Event.d.ts +15 -0
- package/lib/esm/components/Notification/Event/Event.js +68 -0
- package/lib/esm/components/Notification/Event/index.d.ts +3 -0
- package/lib/esm/components/Notification/Event/index.js +2 -0
- package/lib/esm/components/Notification/Notification.js +26 -0
- package/lib/esm/components/SnippetNotifications/SnippetNotifications.js +7 -0
- package/lib/esm/components/SuggestedEventsWidget/Skeleton.d.ts +2 -0
- package/lib/esm/components/SuggestedEventsWidget/Skeleton.js +24 -0
- package/lib/esm/components/SuggestedEventsWidget/SuggestedEventsWidget.d.ts +14 -0
- package/lib/esm/components/SuggestedEventsWidget/SuggestedEventsWidget.js +77 -0
- package/lib/esm/components/SuggestedEventsWidget/constants.d.ts +1 -0
- package/lib/esm/components/SuggestedEventsWidget/constants.js +1 -0
- package/lib/esm/components/SuggestedEventsWidget/index.d.ts +4 -0
- package/lib/esm/components/SuggestedEventsWidget/index.js +4 -0
- package/lib/esm/components/ToastNotifications/ToastNotifications.js +7 -0
- package/lib/esm/constants/EventActionsMenu.d.ts +6 -0
- package/lib/esm/constants/EventActionsMenu.js +6 -0
- package/lib/esm/constants/Media.d.ts +2 -0
- package/lib/esm/constants/Media.js +2 -0
- package/lib/esm/index.d.ts +4 -1
- package/lib/esm/index.js +6 -3
- package/lib/esm/shared/Calendar/index.js +1 -1
- package/lib/esm/shared/EventActionsMenu/index.d.ts +49 -0
- package/lib/esm/shared/EventActionsMenu/index.js +151 -0
- package/lib/esm/shared/EventInfoDetails/index.d.ts +12 -0
- package/lib/esm/shared/EventInfoDetails/index.js +3 -3
- package/lib/esm/shared/Media/Event/DisplayComponent.d.ts +15 -0
- package/lib/esm/shared/Media/Event/DisplayComponent.js +29 -0
- package/lib/esm/shared/Media/Event/constants.d.ts +1 -0
- package/lib/esm/shared/Media/Event/constants.js +1 -0
- package/lib/esm/shared/Media/Event/filter.d.ts +3 -0
- package/lib/esm/shared/Media/Event/filter.js +2 -0
- package/lib/esm/shared/Media/Event/index.d.ts +3 -0
- package/lib/esm/shared/Media/Event/index.js +11 -0
- package/lib/esm/shared/Media/Link/PreviewComponent.js +1 -1
- package/lib/esm/shared/Media/index.d.ts +2 -1
- package/lib/esm/shared/Media/index.js +2 -1
- package/lib/esm/types/event.d.ts +5 -0
- package/lib/esm/types/event.js +6 -0
- package/lib/umd/224.js +2 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +7 -7
- package/lib/umd/84.js +0 -2
- /package/lib/umd/{84.js.LICENSE.txt → 224.js.LICENSE.txt} +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { Avatar, AvatarGroup, Button, List, ListItem, Typography
|
|
3
|
+
import { Avatar, AvatarGroup, Button, List, ListItem, Typography } from '@mui/material';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
|
-
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
6
5
|
import { useThemeProps } from '@mui/system';
|
|
7
6
|
import { Endpoints, EventService, http } from '@selfcommunity/api-services';
|
|
8
7
|
import { useSCFetchEvent } from '@selfcommunity/react-core';
|
|
@@ -19,19 +18,22 @@ import User, { UserSkeleton } from '../User';
|
|
|
19
18
|
const PREFIX = 'SCEventPartecipantsButton';
|
|
20
19
|
const classes = {
|
|
21
20
|
root: `${PREFIX}-root`,
|
|
21
|
+
avatar: `${PREFIX}-avatar`,
|
|
22
|
+
partecipants: `${PREFIX}-partecipants`,
|
|
22
23
|
dialogRoot: `${PREFIX}-dialog-root`,
|
|
24
|
+
infiniteScroll: `${PREFIX}-infinite-scroll`,
|
|
23
25
|
endMessage: `${PREFIX}-end-message`
|
|
24
26
|
};
|
|
25
27
|
const Root = styled(Button, {
|
|
26
28
|
name: PREFIX,
|
|
27
29
|
slot: 'Root',
|
|
28
30
|
overridesResolver: (_props, styles) => styles.root
|
|
29
|
-
})();
|
|
31
|
+
})(() => ({}));
|
|
30
32
|
const DialogRoot = styled(BaseDialog, {
|
|
31
33
|
name: PREFIX,
|
|
32
|
-
slot: '
|
|
34
|
+
slot: 'DialogRoot',
|
|
33
35
|
overridesResolver: (_props, styles) => styles.dialogRoot
|
|
34
|
-
})();
|
|
36
|
+
})(() => ({}));
|
|
35
37
|
/**
|
|
36
38
|
*> API documentation for the Community-JS Event Partecipants Button component. Learn about the available props and the CSS API.
|
|
37
39
|
*
|
|
@@ -120,8 +122,5 @@ export default function EventPartecipantsButton(inProps) {
|
|
|
120
122
|
const handleToggleDialogOpen = useCallback(() => {
|
|
121
123
|
setOpen((prev) => !prev);
|
|
122
124
|
}, [setOpen]);
|
|
123
|
-
|
|
124
|
-
const theme = useTheme();
|
|
125
|
-
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
126
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scEvent || scEvent.goings_counter === 0 }, rest, { children: [_jsx(Typography, Object.assign({ color: "primary", variant: "caption" }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.eventPartecipantsButton.partecipants", id: "ui.eventPartecipantsButton.partecipants" }) })), loading || !scEvent ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest))) : (_jsx(AvatarGroup, Object.assign({ total: scEvent.goings_counter }, { children: followers.map((c) => (_jsx(Avatar, { alt: c.username, src: c.avatar }, c.id))) })))] })), open && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: _jsx(FormattedMessage, { defaultMessage: "ui.eventPartecipantsButton.dialogTitle", id: "ui.eventPartecipantsButton.dialogTitle", values: { total: scEvent.goings_counter } }), onClose: handleToggleDialogOpen, open: open }, DialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: followers.length, next: fetchFollowers, hasMoreNext: next !== null || loading, loaderNext: _jsx(UserSkeleton, { elevation: 0 }), height: isMobile ? '100%' : 400, endMessage: _jsx(Typography, Object.assign({ className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.eventPartecipantsButton.noOtherPartecipants", defaultMessage: "ui.eventPartecipantsButton.noOtherPartecipants" }) })) }, { children: _jsx(List, { children: followers.map((follower) => (_jsx(ListItem, { children: _jsx(User, { elevation: 0, user: follower }) }, follower.id))) }) })) })))] }));
|
|
125
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scEvent || scEvent.goings_counter === 0 }, rest, { children: [_jsx(Typography, Object.assign({ className: classes.partecipants, variant: "caption" }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.eventPartecipantsButton.partecipants", id: "ui.eventPartecipantsButton.partecipants" }) })), loading || !scEvent ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest))) : (_jsx(AvatarGroup, Object.assign({ total: scEvent.goings_counter }, { children: followers.map((c) => (_jsx(Avatar, { alt: c.username, src: c.avatar, className: classes.avatar }, c.id))) })))] })), open && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: _jsx(FormattedMessage, { defaultMessage: "ui.eventPartecipantsButton.dialogTitle", id: "ui.eventPartecipantsButton.dialogTitle", values: { total: scEvent.goings_counter } }), onClose: handleToggleDialogOpen, open: open }, DialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: followers.length, next: fetchFollowers, hasMoreNext: next !== null || loading, loaderNext: _jsx(UserSkeleton, { elevation: 0 }), className: classes.infiniteScroll, endMessage: _jsx(Typography, Object.assign({ className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.eventPartecipantsButton.noOtherPartecipants", defaultMessage: "ui.eventPartecipantsButton.noOtherPartecipants" }) })) }, { children: _jsx(List, { children: followers.map((follower) => (_jsx(ListItem, { children: _jsx(User, { elevation: 0, user: follower }) }, follower.id))) }) })) })))] }));
|
|
127
126
|
}
|
|
@@ -179,9 +179,10 @@ export default function EventSubscribeButton(inProps) {
|
|
|
179
179
|
}
|
|
180
180
|
return _status;
|
|
181
181
|
}, [status, scEvent]);
|
|
182
|
-
if (!scEvent || (isEventAdmin && (user === null || user === void 0 ? void 0 : user.id) === scUserContext.user.id) || (isEventAdmin && !(user === null || user === void 0 ? void 0 : user.id))) {
|
|
182
|
+
if (!scEvent || (isEventAdmin && (user === null || user === void 0 ? void 0 : user.id) === scUserContext.user.id) || (isEventAdmin && !(user === null || user === void 0 ? void 0 : user.id)) || scEventsManager.isLoading(scEvent)) {
|
|
183
183
|
return null;
|
|
184
184
|
}
|
|
185
|
-
return (_jsx(_Fragment, { children: (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) !== SCEventPrivacyType.PRIVATE
|
|
185
|
+
return (_jsx(_Fragment, { children: (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) !== SCEventPrivacyType.PRIVATE ||
|
|
186
|
+
((scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) !== SCEventPrivacyType.PRIVATE && status && status !== SCEventSubscriptionStatusType.REQUESTED) ? (_jsxs(_Fragment, { children: [_jsx(SelectRoot, Object.assign({ className: classNames(classes.selectRoot, className, { [classes.going]: status && status === SCEventSubscriptionStatusType.GOING }, { [classes.notGoing]: status && status === SCEventSubscriptionStatusType.NOT_GOING }), onClick: handleOpen, endIcon: _jsx(Icon, { children: open ? 'expand_less' : 'expand_more' }), startIcon: status &&
|
|
186
187
|
status !== SCEventSubscriptionStatusType.SUBSCRIBED && (_jsx(Icon, { children: status === SCEventSubscriptionStatusType.GOING ? 'circle_checked' : 'circle_closed' })) }, rest, { children: getStatus })), isMobile ? (_jsx(SwipeableDrawerRoot, Object.assign({ className: classes.drawerRoot, PaperProps: { className: classes.paper }, open: open, onClose: handleClose, onOpen: handleOpen, anchor: "bottom", disableSwipeToOpen: true }, { children: renderMenuItems() }))) : (_jsx(MenuRoot, Object.assign({ className: classes.menuRoot, anchorEl: anchorEl, open: open, onClose: handleClose }, { children: renderMenuItems() })))] })) : (_jsx(RequestRoot, Object.assign({ className: classNames(classes.requestRoot, className), variant: "outlined", size: "small", loading: scUserContext.user ? scEventsManager.isLoading(scEvent) : null, disabled: status === SCEventSubscriptionStatusType.REQUESTED }, rest, { children: getStatus }))) }));
|
|
187
188
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventProps } from '../Event';
|
|
1
|
+
import { EventProps, EventSkeletonProps } from '../Event';
|
|
2
2
|
export interface EventsProps {
|
|
3
3
|
/**
|
|
4
4
|
* Overrides or extends the styles applied to the component.
|
|
@@ -15,6 +15,11 @@ export interface EventsProps {
|
|
|
15
15
|
* @default {}
|
|
16
16
|
*/
|
|
17
17
|
EventComponentProps?: EventProps;
|
|
18
|
+
/**
|
|
19
|
+
* Props to spread to single event skeleton object
|
|
20
|
+
* @default {}
|
|
21
|
+
*/
|
|
22
|
+
EventSkeletonComponentProps?: EventSkeletonProps;
|
|
18
23
|
/**
|
|
19
24
|
* Show/Hide filters
|
|
20
25
|
* @default true
|
|
@@ -74,7 +74,7 @@ export default function Events(inProps) {
|
|
|
74
74
|
props: inProps,
|
|
75
75
|
name: PREFIX
|
|
76
76
|
});
|
|
77
|
-
const { endpointQueryParams = { limit: 8, offset: DEFAULT_PAGINATION_OFFSET }, className, EventComponentProps = {}, showFilters = false, filters, general =
|
|
77
|
+
const { endpointQueryParams = { limit: 8, offset: DEFAULT_PAGINATION_OFFSET }, className, EventComponentProps = { elevation: 0, square: true }, EventSkeletonComponentProps = { elevation: 0, square: true }, showFilters = false, filters, general = true } = props, rest = __rest(props, ["endpointQueryParams", "className", "EventComponentProps", "EventSkeletonComponentProps", "showFilters", "filters", "general"]);
|
|
78
78
|
// STATE
|
|
79
79
|
const [events, setEvents] = useState([]);
|
|
80
80
|
const [loading, setLoading] = useState(true);
|
|
@@ -186,7 +186,7 @@ export default function Events(inProps) {
|
|
|
186
186
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
187
187
|
// @ts-ignore
|
|
188
188
|
selected: selected, deleteIcon: selected ? _jsx(Icon, { children: "close" }) : null, onDelete: selected ? handleDeleteClick : null }) }))] })) }))), _jsx(_Fragment, { children: !events.length ? (_jsx(Box, Object.assign({ className: classes.noResults }, { children: (onlyStaffEnabled && !UserUtils.isStaff(scUserContext.user)) ||
|
|
189
|
-
(onlyStaffEnabled && UserUtils.isStaff(scUserContext.user) && general) ? (_jsxs(_Fragment, { children: [_jsx(EventSkeleton, {}), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.events.noEvents.title", defaultMessage: "ui.events.noEvents.title" }) }))] })) : (_jsxs(_Fragment, { children: [_jsx(EventSkeleton, {
|
|
189
|
+
(onlyStaffEnabled && UserUtils.isStaff(scUserContext.user) && general) ? (_jsxs(_Fragment, { children: [_jsx(EventSkeleton, Object.assign({}, EventSkeletonComponentProps)), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.events.noEvents.title", defaultMessage: "ui.events.noEvents.title" }) }))] })) : (_jsxs(_Fragment, { children: [_jsx(EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { actions: _jsx(CreateEventButton, {}) })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.events.noEvents.title.onlyStaff", defaultMessage: "ui.events.noEvents.title.onlyStaff" }) }))] })) }))) : (_jsxs(_Fragment, { children: [_jsx(Grid, Object.assign({ container: true, spacing: { xs: 2 }, className: classes.events }, { children: _jsxs(_Fragment, { children: [filteredEvents.map((event) => (_jsx(Grid, Object.assign({ item: true, xs: 12, sm: 8, md: 6, className: classes.item }, { children: _jsx(Event, Object.assign({ event: event, eventId: event.id }, EventComponentProps)) }), event.id))), filteredEvents.length % 2 !== 0 && (_jsx(Grid, Object.assign({ item: true, xs: 12, sm: 8, md: 6, className: classes.itemSkeleton }, { children: _jsx(EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { actions: _jsx(CreateEventButton, Object.assign({ variant: "outlined", color: "primary", size: "small" }, { children: _jsx(FormattedMessage, { id: "ui.events.skeleton.action.add", defaultMessage: "ui.events.skeleton.action.add" }) })) })) }), 'skeleton-item'))] }) })), Boolean(next) && (_jsx(Button, Object.assign({ color: "secondary", variant: "text", onClick: handleNext, className: classes.showMore }, { children: _jsx(FormattedMessage, { id: "ui.events.button.seeMore", defaultMessage: "ui.events.button.seeMore" }) })))] })) })] }));
|
|
190
190
|
/**
|
|
191
191
|
* Renders root object (if content availability community option is false and user is anonymous, component is hidden)
|
|
192
192
|
*/
|
|
@@ -194,7 +194,7 @@ export default function Events(inProps) {
|
|
|
194
194
|
return null;
|
|
195
195
|
}
|
|
196
196
|
if (loading) {
|
|
197
|
-
return _jsx(Skeleton, {});
|
|
197
|
+
return _jsx(Skeleton, { EventSkeletonProps: EventSkeletonComponentProps });
|
|
198
198
|
}
|
|
199
199
|
return (_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: c })));
|
|
200
200
|
}
|
|
@@ -8,7 +8,7 @@ export interface FeedObjectMediaPreviewProps extends BoxProps {
|
|
|
8
8
|
medias: SCMediaType[];
|
|
9
9
|
/**
|
|
10
10
|
* Media types
|
|
11
|
-
* @default 'image', 'document', 'link', 'share'
|
|
11
|
+
* @default 'image', 'document', 'link', 'share', 'Event'
|
|
12
12
|
*/
|
|
13
13
|
mediaObjectTypes?: SCMediaObjectType[];
|
|
14
14
|
}
|
|
@@ -4,7 +4,7 @@ import { styled } from '@mui/material/styles';
|
|
|
4
4
|
import Box from '@mui/material/Box';
|
|
5
5
|
import { useSCMediaClick } from '@selfcommunity/react-core';
|
|
6
6
|
import { useThemeProps } from '@mui/system';
|
|
7
|
-
import { File, Link, Share } from '../../shared/Media';
|
|
7
|
+
import { File, Link, Share, Event } from '../../shared/Media';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
const PREFIX = 'SCFeedObjectMediaPreview';
|
|
10
10
|
const classes = {
|
|
@@ -42,7 +42,7 @@ export default (inProps) => {
|
|
|
42
42
|
props: inProps,
|
|
43
43
|
name: PREFIX
|
|
44
44
|
});
|
|
45
|
-
const { className, medias, mediaObjectTypes = [File, Link, Share] } = props, rest = __rest(props, ["className", "medias", "mediaObjectTypes"]);
|
|
45
|
+
const { className, medias, mediaObjectTypes = [File, Link, Share, Event] } = props, rest = __rest(props, ["className", "medias", "mediaObjectTypes"]);
|
|
46
46
|
const { handleMediaClick } = useSCMediaClick();
|
|
47
47
|
if (!medias.length) {
|
|
48
48
|
/**
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Button, CardActions,
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button, CardActions, Icon, IconButton, Typography } from '@mui/material';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
5
|
import { Box, useThemeProps } from '@mui/system';
|
|
6
6
|
import { Endpoints, EventService, http } from '@selfcommunity/api-services';
|
|
7
|
-
import { SCCache, SCRoutes, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
7
|
+
import { SCCache, SCRoutes, useSCPreferences, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
8
|
+
import { SCFeatureName } from '@selfcommunity/types';
|
|
8
9
|
import { Logger } from '@selfcommunity/utils';
|
|
9
|
-
import { useCallback, useEffect, useReducer, useState } from 'react';
|
|
10
|
+
import { useCallback, useEffect, useMemo, useReducer, useState } from 'react';
|
|
10
11
|
import { FormattedMessage } from 'react-intl';
|
|
11
12
|
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
12
13
|
import { DEFAULT_PAGINATION_LIMIT, DEFAULT_PAGINATION_OFFSET } from '../../constants/Pagination';
|
|
13
|
-
import Calendar from '../../shared/Calendar';
|
|
14
|
-
import EventInfoDetails from '../../shared/EventInfoDetails';
|
|
15
14
|
import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
|
|
16
15
|
import { actionWidgetTypes, dataWidgetReducer, stateWidgetInitializer } from '../../utils/widget';
|
|
17
|
-
import EventPartecipantsButton from '../EventPartecipantsButton';
|
|
18
|
-
import User from '../User';
|
|
19
16
|
import Widget from '../Widget';
|
|
20
17
|
import { PREFIX } from './constants';
|
|
21
18
|
import Skeleton from './Skeleton';
|
|
19
|
+
import { SCEventTemplateType } from '../../types/event';
|
|
20
|
+
import Event from '../Event';
|
|
22
21
|
const classes = {
|
|
23
22
|
root: `${PREFIX}-root`,
|
|
24
23
|
titleWrapper: `${PREFIX}-title-wrapper`,
|
|
24
|
+
imageWrapper: `${PREFIX}-image-wrapper`,
|
|
25
|
+
image: `${PREFIX}-image`,
|
|
25
26
|
content: `${PREFIX}-content`,
|
|
27
|
+
nameWrapper: `${PREFIX}-name-wrapper`,
|
|
28
|
+
name: `${PREFIX}-name`,
|
|
29
|
+
user: `${PREFIX}-user`,
|
|
26
30
|
firstDivider: `${PREFIX}-first-divider`,
|
|
27
31
|
secondDivider: `${PREFIX}-second-divider`,
|
|
28
32
|
actions: `${PREFIX}-actions`,
|
|
@@ -33,14 +37,14 @@ const Root = styled(Widget, {
|
|
|
33
37
|
name: PREFIX,
|
|
34
38
|
slot: 'Root',
|
|
35
39
|
overridesResolver: (_props, styles) => styles.root
|
|
36
|
-
})();
|
|
40
|
+
})(() => ({}));
|
|
37
41
|
export default function MyEventsWidget(inProps) {
|
|
38
|
-
var _a, _b, _c, _d, _e, _f;
|
|
39
42
|
// PROPS
|
|
40
43
|
const props = useThemeProps({
|
|
41
44
|
props: inProps,
|
|
42
45
|
name: PREFIX
|
|
43
46
|
});
|
|
47
|
+
// CONST
|
|
44
48
|
const { endpointQueryParams = { limit: DEFAULT_PAGINATION_LIMIT, offset: DEFAULT_PAGINATION_OFFSET }, cacheStrategy } = props, rest = __rest(props, ["endpointQueryParams", "cacheStrategy"]);
|
|
45
49
|
// STATE
|
|
46
50
|
const [state, dispatch] = useReducer(dataWidgetReducer, {
|
|
@@ -54,6 +58,8 @@ export default function MyEventsWidget(inProps) {
|
|
|
54
58
|
// CONTEXT
|
|
55
59
|
const scUserContext = useSCUser();
|
|
56
60
|
const scRoutingContext = useSCRouting();
|
|
61
|
+
const { features } = useSCPreferences();
|
|
62
|
+
const eventsEnabled = useMemo(() => features && features.includes(SCFeatureName.EVENT) && features.includes(SCFeatureName.TAGGING), [features]);
|
|
57
63
|
/**
|
|
58
64
|
* Initialize component
|
|
59
65
|
* Fetch data only if the component is not initialized and it is not loading data
|
|
@@ -90,13 +96,13 @@ export default function MyEventsWidget(inProps) {
|
|
|
90
96
|
// EFFECTS
|
|
91
97
|
useEffect(() => {
|
|
92
98
|
let _t;
|
|
93
|
-
if (scUserContext.user) {
|
|
99
|
+
if (eventsEnabled && scUserContext.user) {
|
|
94
100
|
_t = setTimeout(_initComponent);
|
|
95
101
|
return () => {
|
|
96
102
|
clearTimeout(_t);
|
|
97
103
|
};
|
|
98
104
|
}
|
|
99
|
-
}, [scUserContext.user]);
|
|
105
|
+
}, [scUserContext.user, eventsEnabled]);
|
|
100
106
|
const handlePrev = useCallback(() => {
|
|
101
107
|
setEventIndex(eventIndex - 1);
|
|
102
108
|
}, [eventIndex]);
|
|
@@ -108,13 +114,16 @@ export default function MyEventsWidget(inProps) {
|
|
|
108
114
|
_fetchNext();
|
|
109
115
|
}
|
|
110
116
|
}, [eventIndex, state.results]);
|
|
117
|
+
return _jsx(Skeleton, {});
|
|
111
118
|
// RENDER
|
|
119
|
+
if (!eventsEnabled) {
|
|
120
|
+
return _jsx(HiddenPlaceholder, {});
|
|
121
|
+
}
|
|
112
122
|
if (!state.initialized || state.isLoadingNext) {
|
|
113
123
|
return _jsx(Skeleton, {});
|
|
114
124
|
}
|
|
115
125
|
if (state.count === 0) {
|
|
116
126
|
return _jsx(HiddenPlaceholder, {});
|
|
117
127
|
}
|
|
118
|
-
|
|
119
|
-
return (_jsxs(Root, Object.assign({ className: classes.root }, rest, { children: [_jsx(Box, Object.assign({ className: classes.titleWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.myEventsWidget.title", defaultMessage: "ui.myEventsWidget.title" }) })) })), _jsxs(Box, Object.assign({ position: "relative" }, { children: [_jsx(CardMedia, { component: "img", height: "170px", image: ((_a = state.results[eventIndex]) === null || _a === void 0 ? void 0 : _a.emotional_image) || ((_b = state.results[eventIndex]) === null || _b === void 0 ? void 0 : _b.image_medium), alt: (_c = state.results[eventIndex]) === null || _c === void 0 ? void 0 : _c.name }), _jsx(Calendar, { day: new Date((_d = state.results[eventIndex]) === null || _d === void 0 ? void 0 : _d.start_date).getDate() })] })), _jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsx(Typography, Object.assign({ variant: "h3", marginBottom: "10px" }, { children: (_e = state.results[eventIndex]) === null || _e === void 0 ? void 0 : _e.name })), _jsx(EventInfoDetails, { event: state.results[eventIndex] }), _jsx(User, { user: (_f = state.results[eventIndex]) === null || _f === void 0 ? void 0 : _f.managed_by, elevation: 0, secondary: _jsx(Typography, Object.assign({ variant: "caption" }, { children: _jsx(FormattedMessage, { id: "ui.myEventsWidget.planner", defaultMessage: "ui.myEventsWidget.planner" }) })) }), _jsx(Divider, { className: classes.firstDivider }), _jsx(EventPartecipantsButton, { event: state.results[eventIndex], eventId: state.results[eventIndex].id }), _jsx(Divider, { className: classes.secondDivider })] })), _jsxs(CardActions, Object.assign({ className: classes.actions }, { children: [_jsx(IconButton, Object.assign({ size: "small", disabled: eventIndex === 0, className: classes.arrows, onClick: handlePrev }, { children: _jsx(Icon, { children: "chevron_left" }) })), _jsx(Button, Object.assign({ href: scRoutingContext.url(SCRoutes.EVENTS_ROUTE_NAME, {}), className: classes.actionButton }, { children: _jsx(Typography, Object.assign({ variant: "caption" }, { children: _jsx(FormattedMessage, { id: "ui.myEventsWidget.showAll", defaultMessage: "ui.myEventsWidget.showAll" }) })) })), _jsx(IconButton, Object.assign({ size: "small", disabled: eventIndex === state.count - 1, className: classes.arrows, onClick: handleNext }, { children: _jsx(Icon, { children: "chevron_right" }) }))] }))] })));
|
|
128
|
+
return (_jsxs(Root, Object.assign({ className: classes.root }, rest, { children: [_jsx(Box, Object.assign({ className: classes.titleWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.myEventsWidget.title", defaultMessage: "ui.myEventsWidget.title" }) })) })), _jsx(Event, { event: state.results[eventIndex], template: SCEventTemplateType.DETAIL, actions: _jsx(_Fragment, {}), elevation: 0, square: true }), _jsxs(CardActions, Object.assign({ className: classes.actions }, { children: [_jsx(IconButton, Object.assign({ size: "small", disabled: eventIndex === 0, className: classes.arrows, onClick: handlePrev }, { children: _jsx(Icon, { children: "chevron_left" }) })), _jsx(Button, Object.assign({ href: scRoutingContext.url(SCRoutes.EVENTS_ROUTE_NAME, {}), className: classes.actionButton }, { children: _jsx(Typography, Object.assign({ variant: "caption" }, { children: _jsx(FormattedMessage, { id: "ui.myEventsWidget.showAll", defaultMessage: "ui.myEventsWidget.showAll" }) })) })), _jsx(IconButton, Object.assign({ size: "small", disabled: eventIndex === state.count - 1, className: classes.arrows, onClick: handleNext }, { children: _jsx(Icon, { children: "chevron_right" }) }))] }))] })));
|
|
120
129
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Box, CardActions } from '@mui/material';
|
|
3
3
|
import Skeleton from '@mui/material/Skeleton';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
5
|
import Widget from '../Widget';
|
|
6
6
|
import { PREFIX } from './constants';
|
|
7
|
+
import { SCEventTemplateType } from '../../types/event';
|
|
8
|
+
import { EventSkeleton } from '../Event';
|
|
7
9
|
const classes = {
|
|
8
10
|
root: `${PREFIX}-skeleton-root`,
|
|
9
11
|
calendar: `${PREFIX}-calendar`,
|
|
@@ -14,31 +16,9 @@ const classes = {
|
|
|
14
16
|
};
|
|
15
17
|
const Root = styled(Widget, {
|
|
16
18
|
name: PREFIX,
|
|
17
|
-
slot: 'SkeletonRoot'
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
position: 'absolute',
|
|
21
|
-
bottom: '-36px',
|
|
22
|
-
left: '24px',
|
|
23
|
-
boxShadow: '0px 3px 8px #00000040'
|
|
24
|
-
},
|
|
25
|
-
[`& .${classes.content}`]: {
|
|
26
|
-
padding: `52px ${theme.spacing(3)} 0 !important`,
|
|
27
|
-
[`& .${classes.firstDivider}`]: {
|
|
28
|
-
marginTop: '18px',
|
|
29
|
-
marginBottom: '16px'
|
|
30
|
-
},
|
|
31
|
-
[`& .${classes.secondDivider}`]: {
|
|
32
|
-
marginTop: '16px',
|
|
33
|
-
marginBottom: '18px'
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
[`& .${classes.actions}`]: {
|
|
37
|
-
padding: `0 ${theme.spacing(3)} 18px`,
|
|
38
|
-
justifyContent: 'center',
|
|
39
|
-
gap: '56px'
|
|
40
|
-
}
|
|
41
|
-
}));
|
|
19
|
+
slot: 'SkeletonRoot',
|
|
20
|
+
overridesResolver: (_props, styles) => styles.skeletonRoot
|
|
21
|
+
})(() => ({}));
|
|
42
22
|
export default function MyEventsWidgetSkeleton() {
|
|
43
|
-
return (_jsxs(Root, Object.assign({ className: classes.root }, { children: [_jsx(Box, Object.assign({ padding: "12px 16px" }, { children: _jsx(Skeleton, { animation: "wave", width: "141px", height: "
|
|
23
|
+
return (_jsxs(Root, Object.assign({ className: classes.root }, { children: [_jsx(Box, Object.assign({ padding: "12px 16px" }, { children: _jsx(Skeleton, { animation: "wave", width: "141px", height: "33px" }) })), _jsx(EventSkeleton, { template: SCEventTemplateType.DETAIL, elevation: 0, square: true }), _jsxs(CardActions, Object.assign({ className: classes.actions }, { children: [_jsx(Skeleton, { animation: "wave", variant: "rounded", width: "14px", height: "14px" }), _jsx(Skeleton, { animation: "wave", width: "52px", height: "20px" }), _jsx(Skeleton, { animation: "wave", variant: "rounded", width: "14px", height: "14px" })] }))] })));
|
|
44
24
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SCNotificationEventActivityType } from '@selfcommunity/types';
|
|
2
|
+
import { NotificationItemProps } from '../../../shared/NotificationItem';
|
|
3
|
+
export interface NotificationEventProps extends Pick<NotificationItemProps, Exclude<keyof NotificationItemProps, 'image' | 'disableTypography' | 'primary' | 'primaryTypographyProps' | 'secondary' | 'secondaryTypographyProps' | 'actions' | 'footer' | 'isNew'>> {
|
|
4
|
+
/**
|
|
5
|
+
* Notification obj
|
|
6
|
+
* @default null
|
|
7
|
+
*/
|
|
8
|
+
notificationObject: SCNotificationEventActivityType;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* This component render the content of the notification of type event
|
|
12
|
+
* @constructor
|
|
13
|
+
* @param props
|
|
14
|
+
*/
|
|
15
|
+
export default function EventNotification(props: NotificationEventProps): JSX.Element;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
|
+
import { Avatar, Box, Icon, Stack, Typography } from '@mui/material';
|
|
6
|
+
import { Link, SCRoutes, useSCRouting } from '@selfcommunity/react-core';
|
|
7
|
+
import { SCEventLocationType } from '@selfcommunity/types';
|
|
8
|
+
import { FormattedMessage, useIntl } from 'react-intl';
|
|
9
|
+
import DateTimeAgo from '../../../shared/DateTimeAgo';
|
|
10
|
+
import classNames from 'classnames';
|
|
11
|
+
import { SCNotificationObjectTemplateType } from '../../../types';
|
|
12
|
+
import NotificationItem from '../../../shared/NotificationItem';
|
|
13
|
+
import { LoadingButton } from '@mui/lab';
|
|
14
|
+
import UserDeletedSnackBar from '../../../shared/UserDeletedSnackBar';
|
|
15
|
+
import UserAvatar from '../../../shared/UserAvatar';
|
|
16
|
+
import { PREFIX } from '../constants';
|
|
17
|
+
import { default as EventItem } from '../../Event';
|
|
18
|
+
const classes = {
|
|
19
|
+
root: `${PREFIX}-event-root`,
|
|
20
|
+
avatar: `${PREFIX}-avatar`,
|
|
21
|
+
actions: `${PREFIX}-actions`,
|
|
22
|
+
seeButton: `${PREFIX}see-button`,
|
|
23
|
+
activeAt: `${PREFIX}-active-at`,
|
|
24
|
+
snippetTime: `${PREFIX}-snippet-time`,
|
|
25
|
+
username: `${PREFIX}-username`
|
|
26
|
+
};
|
|
27
|
+
const Root = styled(NotificationItem, {
|
|
28
|
+
name: PREFIX,
|
|
29
|
+
slot: 'EventRoot'
|
|
30
|
+
})(() => ({}));
|
|
31
|
+
/**
|
|
32
|
+
* This component render the content of the notification of type event
|
|
33
|
+
* @constructor
|
|
34
|
+
* @param props
|
|
35
|
+
*/
|
|
36
|
+
export default function EventNotification(props) {
|
|
37
|
+
// PROPS
|
|
38
|
+
const { notificationObject, id = `n_${props.notificationObject['sid']}`, className, template = SCNotificationObjectTemplateType.DETAIL } = props, rest = __rest(props, ["notificationObject", "id", "className", "template"]);
|
|
39
|
+
// CONTEXT
|
|
40
|
+
const scRoutingContext = useSCRouting();
|
|
41
|
+
// STATE
|
|
42
|
+
const [openAlert, setOpenAlert] = useState(false);
|
|
43
|
+
// CONST
|
|
44
|
+
const isSnippetTemplate = template === SCNotificationObjectTemplateType.SNIPPET;
|
|
45
|
+
const isToastTemplate = template === SCNotificationObjectTemplateType.TOAST;
|
|
46
|
+
const intl = useIntl();
|
|
47
|
+
// RENDER
|
|
48
|
+
if (isSnippetTemplate || isToastTemplate) {
|
|
49
|
+
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.user.deleted && {
|
|
50
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
51
|
+
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !notificationObject.user.community_badge, smaller: true }, { children: _jsx(Avatar, { alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar, classes: { root: classes.avatar } }) })) })), primary: _jsxs(Box, { children: [_jsx(Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
52
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
53
|
+
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.user.username })), ' ', _jsx(FormattedMessage, { id: `ui.notification.event.${notificationObject.type}`, defaultMessage: `ui.notification.event.${notificationObject.type}`, values: {
|
|
54
|
+
icon: (...chunks) => _jsx(Icon, { children: chunks }),
|
|
55
|
+
event: notificationObject.event.name,
|
|
56
|
+
link: (...chunks) => _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: chunks }))
|
|
57
|
+
} })] }), secondary: _jsxs(_Fragment, { children: [_jsx(Typography, Object.assign({ component: "span" }, { children: _jsx(FormattedMessage, { id: "ui.notification.event.dateTime", defaultMessage: "ui.notification.event.dateTime", values: {
|
|
58
|
+
date: intl.formatDate(notificationObject.event.start_date, {
|
|
59
|
+
weekday: 'long',
|
|
60
|
+
day: 'numeric',
|
|
61
|
+
year: 'numeric',
|
|
62
|
+
month: 'long'
|
|
63
|
+
}),
|
|
64
|
+
hour: intl.formatDate(notificationObject.event.start_date, { hour: 'numeric', minute: 'numeric' })
|
|
65
|
+
} }) })), _jsxs(Typography, Object.assign({ component: "p", variant: "body2" }, { children: [_jsx(FormattedMessage, { id: `ui.notification.event.privacy.${notificationObject.event.privacy}`, defaultMessage: `ui.notification.event.privacy.${notificationObject.event.privacy}` }), ' ', "-", ' ', notificationObject.event.location === SCEventLocationType.PERSON ? (_jsx(FormattedMessage, { id: `ui.notification.event.address.live.label`, defaultMessage: `ui.notification.event.address.live.label` })) : (_jsx(FormattedMessage, { id: `ui.notification.event.address.online.label`, defaultMessage: `ui.notification.event.address.online.label` }))] }))] }), 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.EVENT_ROUTE_NAME, notificationObject.event) }, { children: _jsx(FormattedMessage, { id: "ui.notification.event.button.see", defaultMessage: "ui.notification.event.button.see" }) })) }))] }))) : (_jsx(DateTimeAgo, { date: notificationObject.active_at, className: classes.snippetTime })) }, rest)));
|
|
66
|
+
}
|
|
67
|
+
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, primary: _jsx(EventItem, { event: notificationObject.event, showActions: false }), 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, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: _jsx(FormattedMessage, { id: "ui.notification.event.button.see", defaultMessage: "ui.notification.event.button.see" }) }))] })) }, rest)), openAlert && _jsx(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })] }));
|
|
68
|
+
}
|
|
@@ -35,6 +35,7 @@ import UserDeletedSnackBar from '../../shared/UserDeletedSnackBar';
|
|
|
35
35
|
import UserAvatar from '../../shared/UserAvatar';
|
|
36
36
|
import { PREFIX } from './constants';
|
|
37
37
|
import GroupNotification from './Group';
|
|
38
|
+
import EventNotification from './Event/Event';
|
|
38
39
|
const messages = defineMessages({
|
|
39
40
|
receivePrivateMessage: {
|
|
40
41
|
id: 'ui.notification.receivePrivateMessage',
|
|
@@ -191,6 +192,25 @@ export default function UserNotification(inProps) {
|
|
|
191
192
|
b: (...chunks) => _jsx("strong", { children: chunks })
|
|
192
193
|
})] }) }));
|
|
193
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Event notifications header
|
|
197
|
+
*/
|
|
198
|
+
if (notificationObject.aggregated &&
|
|
199
|
+
(notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_INVITED_TO_JOIN_EVENT ||
|
|
200
|
+
notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_EVENT ||
|
|
201
|
+
notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_ADDED_TO_EVENT ||
|
|
202
|
+
notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT)) {
|
|
203
|
+
let eventNotification = notificationObject.aggregated[0];
|
|
204
|
+
return (_jsx(CardHeader, { className: classes.header, avatar: _jsx(Link, Object.assign({}, (!eventNotification.user.deleted && {
|
|
205
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, eventNotification.user)
|
|
206
|
+
}), { onClick: eventNotification.user.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !eventNotification.user.community_badge, smaller: true }, { children: _jsx(Avatar, { className: classes.avatar, alt: eventNotification.user.username, variant: "circular", src: eventNotification.user.avatar }) })) })), titleTypographyProps: { className: classes.title, variant: 'subtitle1' }, title: _jsxs(_Fragment, { children: [_jsx(Link, Object.assign({}, (!eventNotification.user.deleted && {
|
|
207
|
+
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, eventNotification.user)
|
|
208
|
+
}), { onClick: eventNotification.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: eventNotification.user.username })), ' ', _jsx(FormattedMessage, { id: `ui.notification.${notificationObject.aggregated[0].type}`, defaultMessage: `ui.notification.${notificationObject.aggregated[0].type}`, values: {
|
|
209
|
+
icon: (...chunks) => _jsx(Icon, { children: chunks }),
|
|
210
|
+
event: eventNotification.event.name,
|
|
211
|
+
link: (...chunks) => _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENTS_ROUTE_NAME, eventNotification.event) }, { children: chunks }))
|
|
212
|
+
} })] }) }));
|
|
213
|
+
}
|
|
194
214
|
/**
|
|
195
215
|
* Group notifications header
|
|
196
216
|
*/
|
|
@@ -299,6 +319,12 @@ export default function UserNotification(inProps) {
|
|
|
299
319
|
n.type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP) {
|
|
300
320
|
return _jsx(GroupNotification, { notificationObject: n }, i);
|
|
301
321
|
}
|
|
322
|
+
else if (n.type === SCNotificationTypologyType.USER_ADDED_TO_EVENT ||
|
|
323
|
+
n.type === SCNotificationTypologyType.USER_INVITED_TO_JOIN_EVENT ||
|
|
324
|
+
n.type === SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_EVENT ||
|
|
325
|
+
n.type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT) {
|
|
326
|
+
return _jsx(EventNotification, { notificationObject: n }, i);
|
|
327
|
+
}
|
|
302
328
|
return null;
|
|
303
329
|
}
|
|
304
330
|
/**
|
|
@@ -33,6 +33,7 @@ import ContributionNotification from '../Notification/Contribution';
|
|
|
33
33
|
import NotificationItem from '../../shared/NotificationItem';
|
|
34
34
|
import { PREFIX } from './constants';
|
|
35
35
|
import GroupNotification from '../Notification/Group';
|
|
36
|
+
import EventNotification from '../Notification/Event/Event';
|
|
36
37
|
const classes = {
|
|
37
38
|
root: `${PREFIX}-root`,
|
|
38
39
|
notificationsWrap: `${PREFIX}-notifications-wrap`,
|
|
@@ -260,6 +261,12 @@ export default function SnippetNotifications(inProps) {
|
|
|
260
261
|
n.type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP) {
|
|
261
262
|
return _jsx(GroupNotification, { notificationObject: n, template: SCNotificationObjectTemplateType.SNIPPET }, i);
|
|
262
263
|
}
|
|
264
|
+
else if (n.type === SCNotificationTypologyType.USER_ADDED_TO_EVENT ||
|
|
265
|
+
n.type === SCNotificationTypologyType.USER_INVITED_TO_JOIN_EVENT ||
|
|
266
|
+
n.type === SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_EVENT ||
|
|
267
|
+
n.type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT) {
|
|
268
|
+
return _jsx(EventNotification, { notificationObject: n, template: SCNotificationObjectTemplateType.SNIPPET }, i);
|
|
269
|
+
}
|
|
263
270
|
if (type && handleNotification) {
|
|
264
271
|
/** Override content */
|
|
265
272
|
content = handleNotification(type, n, content);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CardActions, CardContent, Skeleton } from '@mui/material';
|
|
3
|
+
import { styled } from '@mui/system';
|
|
4
|
+
import 'swiper/css';
|
|
5
|
+
import { Swiper, SwiperSlide } from 'swiper/react';
|
|
6
|
+
import Widget from '../Widget';
|
|
7
|
+
import { PREFIX } from './constants';
|
|
8
|
+
import { EventSkeleton } from '../Event';
|
|
9
|
+
import { SCEventTemplateType } from '../../types/event';
|
|
10
|
+
const classes = {
|
|
11
|
+
root: `${PREFIX}-skeleton-root`,
|
|
12
|
+
content: `${PREFIX}-content`,
|
|
13
|
+
title: `${PREFIX}-title`,
|
|
14
|
+
swiper: `${PREFIX}-swiper`,
|
|
15
|
+
actions: `${PREFIX}-actions`
|
|
16
|
+
};
|
|
17
|
+
const Root = styled(Widget, {
|
|
18
|
+
name: PREFIX,
|
|
19
|
+
slot: 'SkeletonRoot',
|
|
20
|
+
overridesResolver: (_props, styles) => styles.skeletonRoot
|
|
21
|
+
})(() => ({}));
|
|
22
|
+
export default function SuggestedEventsWidgetSkeleton() {
|
|
23
|
+
return (_jsxs(Root, Object.assign({ className: classes.root }, { children: [_jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsx(Skeleton, { className: classes.title, animation: "wave", width: "141px", height: "23px" }), _jsx(Swiper, Object.assign({ spaceBetween: 8, slidesPerView: "auto" }, { children: [1, 2, 3, 4, 5, 6, 7].map((_element, i) => (_jsx(SwiperSlide, Object.assign({ className: classes.swiper }, { children: _jsx(EventSkeleton, { template: SCEventTemplateType.PREVIEW, variant: "outlined", actions: _jsx(_Fragment, {}) }) }), i))) }))] })), _jsx(CardActions, Object.assign({ className: classes.actions }, { children: _jsx(Skeleton, { animation: "wave", width: "52px", height: "20px" }) }))] })));
|
|
24
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import 'swiper/css';
|
|
2
|
+
import { WidgetProps } from '../Widget';
|
|
3
|
+
export interface SuggestedEventsWidgetProps extends WidgetProps {
|
|
4
|
+
/**
|
|
5
|
+
* Feed API Query Params
|
|
6
|
+
* @default [{'limit': 20, 'offset': 0}]
|
|
7
|
+
*/
|
|
8
|
+
endpointQueryParams?: Record<string, string | number>;
|
|
9
|
+
/**
|
|
10
|
+
* Other props
|
|
11
|
+
*/
|
|
12
|
+
[p: string]: any;
|
|
13
|
+
}
|
|
14
|
+
export default function SuggestedEventsWidget(inProps: SuggestedEventsWidgetProps): JSX.Element;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button, CardActions, CardContent, Typography, useThemeProps } from '@mui/material';
|
|
4
|
+
import { styled } from '@mui/system';
|
|
5
|
+
import { Endpoints, http, SuggestionService } from '@selfcommunity/api-services';
|
|
6
|
+
import { Link, SCRoutes, useSCRouting } from '@selfcommunity/react-core';
|
|
7
|
+
import { Logger } from '@selfcommunity/utils';
|
|
8
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
9
|
+
import { FormattedMessage } from 'react-intl';
|
|
10
|
+
import 'swiper/css';
|
|
11
|
+
import { Swiper, SwiperSlide } from 'swiper/react';
|
|
12
|
+
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
13
|
+
import { DEFAULT_PAGINATION_LIMIT, DEFAULT_PAGINATION_OFFSET } from '../../constants/Pagination';
|
|
14
|
+
import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
|
|
15
|
+
import Widget from '../Widget';
|
|
16
|
+
import { PREFIX } from './constants';
|
|
17
|
+
import Skeleton from './Skeleton';
|
|
18
|
+
import { SCEventTemplateType } from '../../types/event';
|
|
19
|
+
import Event from '../Event';
|
|
20
|
+
const classes = {
|
|
21
|
+
root: `${PREFIX}-root`,
|
|
22
|
+
content: `${PREFIX}-content`,
|
|
23
|
+
title: `${PREFIX}-title`,
|
|
24
|
+
swiper: `${PREFIX}-swiper`,
|
|
25
|
+
event: `${PREFIX}-event`,
|
|
26
|
+
actions: `${PREFIX}-actions`,
|
|
27
|
+
actionButton: `${PREFIX}-action-button`
|
|
28
|
+
};
|
|
29
|
+
const Root = styled(Widget, {
|
|
30
|
+
name: PREFIX,
|
|
31
|
+
slot: 'Root',
|
|
32
|
+
overridesResolver: (_props, styles) => styles.root
|
|
33
|
+
})(() => ({}));
|
|
34
|
+
export default function SuggestedEventsWidget(inProps) {
|
|
35
|
+
// PROPS
|
|
36
|
+
const props = useThemeProps({
|
|
37
|
+
props: inProps,
|
|
38
|
+
name: PREFIX
|
|
39
|
+
});
|
|
40
|
+
const { endpointQueryParams = { limit: DEFAULT_PAGINATION_LIMIT, offset: DEFAULT_PAGINATION_OFFSET } } = props, rest = __rest(props, ["endpointQueryParams"]);
|
|
41
|
+
// STATE
|
|
42
|
+
const [eventsData, setEventsData] = useState(null);
|
|
43
|
+
const [loading, setLoading] = useState(true);
|
|
44
|
+
// CONTEXT
|
|
45
|
+
const scRoutingContext = useSCRouting();
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
SuggestionService.getEventSuggestion(Object.assign({}, endpointQueryParams))
|
|
48
|
+
.then((payload) => {
|
|
49
|
+
setEventsData(payload);
|
|
50
|
+
setLoading(false);
|
|
51
|
+
})
|
|
52
|
+
.catch((error) => {
|
|
53
|
+
Logger.error(SCOPE_SC_UI, error);
|
|
54
|
+
});
|
|
55
|
+
}, []);
|
|
56
|
+
const handleReachEnd = useCallback(() => {
|
|
57
|
+
if (eventsData.count > eventsData.results.length) {
|
|
58
|
+
http
|
|
59
|
+
.request({
|
|
60
|
+
url: eventsData.next,
|
|
61
|
+
method: Endpoints.GetEventSuggestedUsers.method
|
|
62
|
+
})
|
|
63
|
+
.then((res) => console.log('*** res ***', res))
|
|
64
|
+
.catch((error) => {
|
|
65
|
+
Logger.error(SCOPE_SC_UI, error);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}, [eventsData]);
|
|
69
|
+
// RENDER
|
|
70
|
+
if (!eventsData && loading) {
|
|
71
|
+
return _jsx(Skeleton, {});
|
|
72
|
+
}
|
|
73
|
+
if (!eventsData) {
|
|
74
|
+
return _jsx(HiddenPlaceholder, {});
|
|
75
|
+
}
|
|
76
|
+
return (_jsxs(Root, Object.assign({ className: classes.root }, rest, { children: [_jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsx(Typography, Object.assign({ variant: "h5", className: classes.title }, { children: _jsx(FormattedMessage, { id: "ui.suggestedEventsWidget.title", defaultMessage: "ui.suggestedEventsWidget.title" }) })), _jsx(Swiper, Object.assign({ spaceBetween: 8, slidesPerView: "auto", onReachEnd: handleReachEnd }, { children: eventsData === null || eventsData === void 0 ? void 0 : eventsData.results.map((event, i) => (_jsx(SwiperSlide, Object.assign({ className: classes.swiper }, { children: _jsx(Event, { event: event, template: SCEventTemplateType.PREVIEW, actions: _jsx(_Fragment, {}), variant: "outlined", className: classes.event }) }), i))) }))] })), _jsx(CardActions, Object.assign({ className: classes.actions }, { children: _jsx(Button, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, {}), className: classes.actionButton }, { children: _jsx(Typography, Object.assign({ variant: "caption" }, { children: _jsx(FormattedMessage, { id: "ui.suggestedEventsWidget.showAll", defaultMessage: "ui.suggestedEventsWidget.showAll" }) })) })) }))] })));
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCSuggestedEventsWidget";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PREFIX = 'SCSuggestedEventsWidget';
|