@selfcommunity/react-ui 0.7.9-alpha.27 → 0.7.9-alpha.28

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.
@@ -0,0 +1,15 @@
1
+ import { SCNotificationGroupActivityType } from '@selfcommunity/types';
2
+ import { NotificationItemProps } from '../../../shared/NotificationItem';
3
+ export interface NotificationGroupProps 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: SCNotificationGroupActivityType;
9
+ }
10
+ /**
11
+ * This component render the content of the notification of type group
12
+ * @constructor
13
+ * @param props
14
+ */
15
+ export default function GroupNotification(props: NotificationGroupProps): JSX.Element;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const react_1 = tslib_1.__importStar(require("react"));
5
+ const styles_1 = require("@mui/material/styles");
6
+ const material_1 = require("@mui/material");
7
+ const react_core_1 = require("@selfcommunity/react-core");
8
+ const types_1 = require("@selfcommunity/types");
9
+ const react_intl_1 = require("react-intl");
10
+ const DateTimeAgo_1 = tslib_1.__importDefault(require("../../../shared/DateTimeAgo"));
11
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
12
+ const types_2 = require("../../../types");
13
+ const NotificationItem_1 = tslib_1.__importDefault(require("../../../shared/NotificationItem"));
14
+ const lab_1 = require("@mui/lab");
15
+ const UserDeletedSnackBar_1 = tslib_1.__importDefault(require("../../../shared/UserDeletedSnackBar"));
16
+ const UserAvatar_1 = tslib_1.__importDefault(require("../../../shared/UserAvatar"));
17
+ const constants_1 = require("../constants");
18
+ const classes = {
19
+ root: `${constants_1.PREFIX}-group-root`,
20
+ avatar: `${constants_1.PREFIX}-avatar`,
21
+ actions: `${constants_1.PREFIX}-actions`,
22
+ replyButton: `${constants_1.PREFIX}-reply-button`,
23
+ activeAt: `${constants_1.PREFIX}-active-at`,
24
+ username: `${constants_1.PREFIX}-username`
25
+ };
26
+ const Root = (0, styles_1.styled)(NotificationItem_1.default, {
27
+ name: constants_1.PREFIX,
28
+ slot: 'GroupRoot'
29
+ })(() => ({}));
30
+ /**
31
+ * This component render the content of the notification of type group
32
+ * @constructor
33
+ * @param props
34
+ */
35
+ function GroupNotification(props) {
36
+ // PROPS
37
+ const { notificationObject, id = `n_${props.notificationObject['sid']}`, className, template = types_2.SCNotificationObjectTemplateType.DETAIL } = props, rest = tslib_1.__rest(props, ["notificationObject", "id", "className", "template"]);
38
+ // CONTEXT
39
+ const scRoutingContext = (0, react_core_1.useSCRouting)();
40
+ const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
41
+ const manager = scUserContext.managers.groups;
42
+ // STATE
43
+ const [status, setStatus] = (0, react_1.useState)(null);
44
+ const [openAlert, setOpenAlert] = (0, react_1.useState)(false);
45
+ // CONST
46
+ const isSnippetTemplate = template === types_2.SCNotificationObjectTemplateType.SNIPPET;
47
+ const isToastTemplate = template === types_2.SCNotificationObjectTemplateType.TOAST;
48
+ (0, react_1.useEffect)(() => {
49
+ setStatus(manager.subscriptionStatus(notificationObject.group));
50
+ }, [manager.subscriptionStatus, notificationObject.group]);
51
+ // RENDER
52
+ if (isSnippetTemplate || isToastTemplate) {
53
+ return (react_1.default.createElement(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, `${constants_1.PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: react_1.default.createElement(react_core_1.Link, Object.assign({}, (!notificationObject.user.deleted && {
54
+ to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
55
+ }), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }),
56
+ react_1.default.createElement(UserAvatar_1.default, { hide: !notificationObject.user.community_badge, smaller: true },
57
+ react_1.default.createElement(material_1.Avatar, { alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar, classes: { root: classes.avatar } }))), primary: react_1.default.createElement(material_1.Box, null,
58
+ notificationObject.type !== types_1.SCNotificationTypologyType.USER_ADDED_TO_GROUP && (react_1.default.createElement(react_1.default.Fragment, null,
59
+ react_1.default.createElement(react_core_1.Link, Object.assign({}, (!notificationObject.user.deleted && {
60
+ to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
61
+ }), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }), notificationObject.user.username),
62
+ ' ')),
63
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: `ui.notification.${notificationObject.type}`, defaultMessage: `ui.notification.${notificationObject.type}`, values: {
64
+ group: notificationObject.group.name,
65
+ link: (...chunks) => react_1.default.createElement(react_core_1.Link, { to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, notificationObject.group) }, chunks)
66
+ } })), footer: isToastTemplate && (react_1.default.createElement(material_1.Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 },
67
+ react_1.default.createElement(DateTimeAgo_1.default, { date: notificationObject.active_at }),
68
+ status && status !== types_1.SCGroupSubscriptionStatusType.SUBSCRIBED && (react_1.default.createElement(material_1.Typography, { color: "primary" },
69
+ react_1.default.createElement(react_core_1.Link, { to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, notificationObject.group) },
70
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupSubscribeButton.accept", defaultMessage: "ui.groupSubscribeButton.accept" })))))) }, rest)));
71
+ }
72
+ return (react_1.default.createElement(react_1.default.Fragment, null,
73
+ react_1.default.createElement(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, `${constants_1.PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, actions: react_1.default.createElement(material_1.Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 },
74
+ react_1.default.createElement(DateTimeAgo_1.default, { date: notificationObject.active_at, className: classes.activeAt }),
75
+ status && status !== types_1.SCGroupSubscriptionStatusType.SUBSCRIBED && (react_1.default.createElement(lab_1.LoadingButton, { color: 'primary', variant: "outlined", size: "small", classes: { root: classes.replyButton }, component: react_core_1.Link, loading: scUserContext.user ? status === null || manager.isLoading(notificationObject.group) : null, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, notificationObject.group) },
76
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupSubscribeButton.accept", defaultMessage: "ui.groupSubscribeButton.accept" })))) }, rest)),
77
+ openAlert && react_1.default.createElement(UserDeletedSnackBar_1.default, { open: openAlert, handleClose: () => setOpenAlert(false) })));
78
+ }
79
+ exports.default = GroupNotification;
@@ -0,0 +1,3 @@
1
+ import GroupNotification, { NotificationGroupProps } from './Group';
2
+ export default GroupNotification;
3
+ export { NotificationGroupProps };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const Group_1 = tslib_1.__importDefault(require("./Group"));
5
+ exports.default = Group_1.default;
@@ -35,6 +35,7 @@ const types_1 = require("@selfcommunity/types");
35
35
  const UserDeletedSnackBar_1 = tslib_1.__importDefault(require("../../shared/UserDeletedSnackBar"));
36
36
  const UserAvatar_1 = tslib_1.__importDefault(require("../../shared/UserAvatar"));
37
37
  const constants_1 = require("./constants");
38
+ const Group_1 = tslib_1.__importDefault(require("./Group"));
38
39
  const messages = (0, react_intl_1.defineMessages)({
39
40
  receivePrivateMessage: {
40
41
  id: 'ui.notification.receivePrivateMessage',
@@ -151,7 +152,7 @@ function UserNotification(inProps) {
151
152
  }
152
153
  /**
153
154
  * Handles vote
154
- * @param comment
155
+ * @param index
155
156
  */
156
157
  const handleVote = (index) => {
157
158
  return (contribution) => {
@@ -196,6 +197,30 @@ function UserNotification(inProps) {
196
197
  b: (...chunks) => react_1.default.createElement("strong", null, chunks)
197
198
  })) }));
198
199
  }
200
+ /**
201
+ * Group notifications header
202
+ */
203
+ if (notificationObject.aggregated &&
204
+ (notificationObject.aggregated[0].type === types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
205
+ notificationObject.aggregated[0].type === types_1.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
206
+ notificationObject.aggregated[0].type === types_1.SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
207
+ notificationObject.aggregated[0].type === types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP)) {
208
+ let groupNotification = notificationObject.aggregated[0];
209
+ return (react_1.default.createElement(material_1.CardHeader, { className: classes.header, avatar: react_1.default.createElement(react_core_1.Link, Object.assign({}, (!groupNotification.user.deleted && {
210
+ to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, groupNotification.user)
211
+ }), { onClick: groupNotification.user.deleted ? () => setOpenAlert(true) : null }),
212
+ react_1.default.createElement(UserAvatar_1.default, { hide: !groupNotification.user.community_badge, smaller: true },
213
+ react_1.default.createElement(material_1.Avatar, { className: classes.avatar, alt: groupNotification.user.username, variant: "circular", src: groupNotification.user.avatar }))), titleTypographyProps: { className: classes.title, variant: 'subtitle1' }, title: react_1.default.createElement(react_1.default.Fragment, null,
214
+ notificationObject.aggregated[0].type !== types_1.SCNotificationTypologyType.USER_ADDED_TO_GROUP && (react_1.default.createElement(react_1.default.Fragment, null,
215
+ react_1.default.createElement(react_core_1.Link, Object.assign({}, (!groupNotification.user.deleted && {
216
+ to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, groupNotification.user)
217
+ }), { onClick: groupNotification.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }), groupNotification.user.username),
218
+ ' ')),
219
+ react_1.default.createElement(react_intl_1.FormattedMessage, { id: `ui.notification.${notificationObject.aggregated[0].type}`, defaultMessage: `ui.notification.${notificationObject.aggregated[0].type}`, values: {
220
+ group: groupNotification.group.name,
221
+ link: (...chunks) => react_1.default.createElement(react_core_1.Link, { to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, groupNotification.group) }, chunks)
222
+ } })) }));
223
+ }
199
224
  /**
200
225
  * Comment, NestedComment, Follow Contribution header
201
226
  */
@@ -278,6 +303,12 @@ function UserNotification(inProps) {
278
303
  else if (n.type === types_1.SCNotificationTypologyType.CONTRIBUTION) {
279
304
  return react_1.default.createElement(Contribution_1.default, { notificationObject: n, key: i, onVote: handleVote(i) });
280
305
  }
306
+ else if (n.type === types_1.SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
307
+ n.type === types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
308
+ n.type === types_1.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
309
+ n.type === types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP) {
310
+ return react_1.default.createElement(Group_1.default, { notificationObject: n, key: i });
311
+ }
281
312
  return null;
282
313
  }
283
314
  /**
@@ -33,6 +33,7 @@ const system_1 = require("@mui/system");
33
33
  const Contribution_1 = tslib_1.__importDefault(require("../Notification/Contribution"));
34
34
  const NotificationItem_1 = tslib_1.__importDefault(require("../../shared/NotificationItem"));
35
35
  const constants_1 = require("./constants");
36
+ const Group_1 = tslib_1.__importDefault(require("../Notification/Group"));
36
37
  const classes = {
37
38
  root: `${constants_1.PREFIX}-root`,
38
39
  notificationsWrap: `${constants_1.PREFIX}-notifications-wrap`,
@@ -254,6 +255,12 @@ function SnippetNotifications(inProps) {
254
255
  else if (type === types_2.SCNotificationTypologyType.CONTRIBUTION) {
255
256
  content = react_1.default.createElement(Contribution_1.default, { notificationObject: n, key: i, template: types_1.SCNotificationObjectTemplateType.SNIPPET });
256
257
  }
258
+ else if (n.type === types_2.SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
259
+ n.type === types_2.SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
260
+ n.type === types_2.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
261
+ n.type === types_2.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP) {
262
+ return react_1.default.createElement(Group_1.default, { notificationObject: n, key: i, template: types_1.SCNotificationObjectTemplateType.SNIPPET });
263
+ }
257
264
  if (type && handleNotification) {
258
265
  /** Override content */
259
266
  content = handleNotification(type, n, content);
@@ -24,6 +24,7 @@ const Message_1 = tslib_1.__importDefault(require("../BroadcastMessages/Message"
24
24
  const system_1 = require("@mui/system");
25
25
  const Contribution_1 = tslib_1.__importDefault(require("../Notification/Contribution"));
26
26
  const constants_1 = require("./constants");
27
+ const Group_1 = tslib_1.__importDefault(require("../Notification/Group"));
27
28
  const Root = (0, styles_1.styled)(material_1.Box, {
28
29
  name: constants_1.PREFIX,
29
30
  slot: 'Root'
@@ -111,6 +112,12 @@ function UserToastNotifications(inProps) {
111
112
  else if (type === types_1.SCNotificationTypologyType.CONTRIBUTION) {
112
113
  content = react_1.default.createElement(Contribution_1.default, { notificationObject: n.notification_obj, template: types_2.SCNotificationObjectTemplateType.TOAST });
113
114
  }
115
+ else if (type === types_1.SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
116
+ type === types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
117
+ type === types_1.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
118
+ type === types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP) {
119
+ content = react_1.default.createElement(Group_1.default, { notificationObject: n.notification_obj, template: types_2.SCNotificationObjectTemplateType.TOAST });
120
+ }
114
121
  }
115
122
  if (n.activity_type && n.activity_type === types_1.SCNotificationTypologyType.NOTIFICATION_BANNER) {
116
123
  /** Notification of type: 'notification_banner' */
@@ -0,0 +1,15 @@
1
+ import { SCNotificationGroupActivityType } from '@selfcommunity/types';
2
+ import { NotificationItemProps } from '../../../shared/NotificationItem';
3
+ export interface NotificationGroupProps 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: SCNotificationGroupActivityType;
9
+ }
10
+ /**
11
+ * This component render the content of the notification of type group
12
+ * @constructor
13
+ * @param props
14
+ */
15
+ export default function GroupNotification(props: NotificationGroupProps): JSX.Element;
@@ -0,0 +1,76 @@
1
+ import { __rest } from "tslib";
2
+ import React, { useContext, useEffect, useState } from 'react';
3
+ import { styled } from '@mui/material/styles';
4
+ import { Avatar, Box, Stack, Typography } from '@mui/material';
5
+ import { Link, SCRoutes, SCUserContext, useSCRouting } from '@selfcommunity/react-core';
6
+ import { SCGroupSubscriptionStatusType, SCNotificationTypologyType } from '@selfcommunity/types';
7
+ import { FormattedMessage } from 'react-intl';
8
+ import DateTimeAgo from '../../../shared/DateTimeAgo';
9
+ import classNames from 'classnames';
10
+ import { SCNotificationObjectTemplateType } from '../../../types';
11
+ import NotificationItem from '../../../shared/NotificationItem';
12
+ import { LoadingButton } from '@mui/lab';
13
+ import UserDeletedSnackBar from '../../../shared/UserDeletedSnackBar';
14
+ import UserAvatar from '../../../shared/UserAvatar';
15
+ import { PREFIX } from '../constants';
16
+ const classes = {
17
+ root: `${PREFIX}-group-root`,
18
+ avatar: `${PREFIX}-avatar`,
19
+ actions: `${PREFIX}-actions`,
20
+ replyButton: `${PREFIX}-reply-button`,
21
+ activeAt: `${PREFIX}-active-at`,
22
+ username: `${PREFIX}-username`
23
+ };
24
+ const Root = styled(NotificationItem, {
25
+ name: PREFIX,
26
+ slot: 'GroupRoot'
27
+ })(() => ({}));
28
+ /**
29
+ * This component render the content of the notification of type group
30
+ * @constructor
31
+ * @param props
32
+ */
33
+ export default function GroupNotification(props) {
34
+ // PROPS
35
+ const { notificationObject, id = `n_${props.notificationObject['sid']}`, className, template = SCNotificationObjectTemplateType.DETAIL } = props, rest = __rest(props, ["notificationObject", "id", "className", "template"]);
36
+ // CONTEXT
37
+ const scRoutingContext = useSCRouting();
38
+ const scUserContext = useContext(SCUserContext);
39
+ const manager = scUserContext.managers.groups;
40
+ // STATE
41
+ const [status, setStatus] = useState(null);
42
+ const [openAlert, setOpenAlert] = useState(false);
43
+ // CONST
44
+ const isSnippetTemplate = template === SCNotificationObjectTemplateType.SNIPPET;
45
+ const isToastTemplate = template === SCNotificationObjectTemplateType.TOAST;
46
+ useEffect(() => {
47
+ setStatus(manager.subscriptionStatus(notificationObject.group));
48
+ }, [manager.subscriptionStatus, notificationObject.group]);
49
+ // RENDER
50
+ if (isSnippetTemplate || isToastTemplate) {
51
+ return (React.createElement(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: React.createElement(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 }),
54
+ React.createElement(UserAvatar, { hide: !notificationObject.user.community_badge, smaller: true },
55
+ React.createElement(Avatar, { alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar, classes: { root: classes.avatar } }))), primary: React.createElement(Box, null,
56
+ notificationObject.type !== SCNotificationTypologyType.USER_ADDED_TO_GROUP && (React.createElement(React.Fragment, null,
57
+ React.createElement(Link, Object.assign({}, (!notificationObject.user.deleted && {
58
+ to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
59
+ }), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }), notificationObject.user.username),
60
+ ' ')),
61
+ React.createElement(FormattedMessage, { id: `ui.notification.${notificationObject.type}`, defaultMessage: `ui.notification.${notificationObject.type}`, values: {
62
+ group: notificationObject.group.name,
63
+ link: (...chunks) => React.createElement(Link, { to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, notificationObject.group) }, chunks)
64
+ } })), footer: isToastTemplate && (React.createElement(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 },
65
+ React.createElement(DateTimeAgo, { date: notificationObject.active_at }),
66
+ status && status !== SCGroupSubscriptionStatusType.SUBSCRIBED && (React.createElement(Typography, { color: "primary" },
67
+ React.createElement(Link, { to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, notificationObject.group) },
68
+ React.createElement(FormattedMessage, { id: "ui.groupSubscribeButton.accept", defaultMessage: "ui.groupSubscribeButton.accept" })))))) }, rest)));
69
+ }
70
+ return (React.createElement(React.Fragment, null,
71
+ React.createElement(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, actions: React.createElement(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 },
72
+ React.createElement(DateTimeAgo, { date: notificationObject.active_at, className: classes.activeAt }),
73
+ status && status !== SCGroupSubscriptionStatusType.SUBSCRIBED && (React.createElement(LoadingButton, { color: 'primary', variant: "outlined", size: "small", classes: { root: classes.replyButton }, component: Link, loading: scUserContext.user ? status === null || manager.isLoading(notificationObject.group) : null, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, notificationObject.group) },
74
+ React.createElement(FormattedMessage, { id: "ui.groupSubscribeButton.accept", defaultMessage: "ui.groupSubscribeButton.accept" })))) }, rest)),
75
+ openAlert && React.createElement(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })));
76
+ }
@@ -0,0 +1,3 @@
1
+ import GroupNotification, { NotificationGroupProps } from './Group';
2
+ export default GroupNotification;
3
+ export { NotificationGroupProps };
@@ -0,0 +1,2 @@
1
+ import GroupNotification from './Group';
2
+ export default GroupNotification;
@@ -33,6 +33,7 @@ import { SCNotificationTypologyType } from '@selfcommunity/types';
33
33
  import UserDeletedSnackBar from '../../shared/UserDeletedSnackBar';
34
34
  import UserAvatar from '../../shared/UserAvatar';
35
35
  import { PREFIX } from './constants';
36
+ import GroupNotification from './Group';
36
37
  const messages = defineMessages({
37
38
  receivePrivateMessage: {
38
39
  id: 'ui.notification.receivePrivateMessage',
@@ -149,7 +150,7 @@ export default function UserNotification(inProps) {
149
150
  }
150
151
  /**
151
152
  * Handles vote
152
- * @param comment
153
+ * @param index
153
154
  */
154
155
  const handleVote = (index) => {
155
156
  return (contribution) => {
@@ -194,6 +195,30 @@ export default function UserNotification(inProps) {
194
195
  b: (...chunks) => React.createElement("strong", null, chunks)
195
196
  })) }));
196
197
  }
198
+ /**
199
+ * Group notifications header
200
+ */
201
+ if (notificationObject.aggregated &&
202
+ (notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
203
+ notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
204
+ notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
205
+ notificationObject.aggregated[0].type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP)) {
206
+ let groupNotification = notificationObject.aggregated[0];
207
+ return (React.createElement(CardHeader, { className: classes.header, avatar: React.createElement(Link, Object.assign({}, (!groupNotification.user.deleted && {
208
+ to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, groupNotification.user)
209
+ }), { onClick: groupNotification.user.deleted ? () => setOpenAlert(true) : null }),
210
+ React.createElement(UserAvatar, { hide: !groupNotification.user.community_badge, smaller: true },
211
+ React.createElement(Avatar, { className: classes.avatar, alt: groupNotification.user.username, variant: "circular", src: groupNotification.user.avatar }))), titleTypographyProps: { className: classes.title, variant: 'subtitle1' }, title: React.createElement(React.Fragment, null,
212
+ notificationObject.aggregated[0].type !== SCNotificationTypologyType.USER_ADDED_TO_GROUP && (React.createElement(React.Fragment, null,
213
+ React.createElement(Link, Object.assign({}, (!groupNotification.user.deleted && {
214
+ to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, groupNotification.user)
215
+ }), { onClick: groupNotification.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }), groupNotification.user.username),
216
+ ' ')),
217
+ React.createElement(FormattedMessage, { id: `ui.notification.${notificationObject.aggregated[0].type}`, defaultMessage: `ui.notification.${notificationObject.aggregated[0].type}`, values: {
218
+ group: groupNotification.group.name,
219
+ link: (...chunks) => React.createElement(Link, { to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, groupNotification.group) }, chunks)
220
+ } })) }));
221
+ }
197
222
  /**
198
223
  * Comment, NestedComment, Follow Contribution header
199
224
  */
@@ -276,6 +301,12 @@ export default function UserNotification(inProps) {
276
301
  else if (n.type === SCNotificationTypologyType.CONTRIBUTION) {
277
302
  return React.createElement(ContributionNotification, { notificationObject: n, key: i, onVote: handleVote(i) });
278
303
  }
304
+ else if (n.type === SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
305
+ n.type === SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
306
+ n.type === SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
307
+ n.type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP) {
308
+ return React.createElement(GroupNotification, { notificationObject: n, key: i });
309
+ }
279
310
  return null;
280
311
  }
281
312
  /**
@@ -31,6 +31,7 @@ import { useThemeProps } from '@mui/system';
31
31
  import ContributionNotification from '../Notification/Contribution';
32
32
  import NotificationItem from '../../shared/NotificationItem';
33
33
  import { PREFIX } from './constants';
34
+ import GroupNotification from '../Notification/Group';
34
35
  const classes = {
35
36
  root: `${PREFIX}-root`,
36
37
  notificationsWrap: `${PREFIX}-notifications-wrap`,
@@ -252,6 +253,12 @@ export default function SnippetNotifications(inProps) {
252
253
  else if (type === SCNotificationTypologyType.CONTRIBUTION) {
253
254
  content = React.createElement(ContributionNotification, { notificationObject: n, key: i, template: SCNotificationObjectTemplateType.SNIPPET });
254
255
  }
256
+ else if (n.type === SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
257
+ n.type === SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
258
+ n.type === SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
259
+ n.type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP) {
260
+ return React.createElement(GroupNotification, { notificationObject: n, key: i, template: SCNotificationObjectTemplateType.SNIPPET });
261
+ }
255
262
  if (type && handleNotification) {
256
263
  /** Override content */
257
264
  content = handleNotification(type, n, content);
@@ -21,6 +21,7 @@ import Message from '../BroadcastMessages/Message';
21
21
  import { useThemeProps } from '@mui/system';
22
22
  import ContributionNotification from '../Notification/Contribution';
23
23
  import { PREFIX } from './constants';
24
+ import GroupNotification from '../Notification/Group';
24
25
  const Root = styled(Box, {
25
26
  name: PREFIX,
26
27
  slot: 'Root'
@@ -108,6 +109,12 @@ export default function UserToastNotifications(inProps) {
108
109
  else if (type === SCNotificationTypologyType.CONTRIBUTION) {
109
110
  content = React.createElement(ContributionNotification, { notificationObject: n.notification_obj, template: SCNotificationObjectTemplateType.TOAST });
110
111
  }
112
+ else if (type === SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
113
+ type === SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
114
+ type === SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
115
+ type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP) {
116
+ content = React.createElement(GroupNotification, { notificationObject: n.notification_obj, template: SCNotificationObjectTemplateType.TOAST });
117
+ }
111
118
  }
112
119
  if (n.activity_type && n.activity_type === SCNotificationTypologyType.NOTIFICATION_BANNER) {
113
120
  /** Notification of type: 'notification_banner' */