@selfcommunity/react-ui 0.11.0-alpha.50 → 0.11.0-alpha.52
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/NavigationMenuIconButton/NavigationMenuDrawer.d.ts +3 -1
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.js +13 -6
- package/lib/cjs/components/Notification/Event/Event.js +11 -19
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.d.ts +3 -1
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.js +13 -6
- package/lib/esm/components/Notification/Event/Event.js +13 -21
- package/lib/umd/react-ui.js +1 -1
- package/package.json +2 -2
|
@@ -26,7 +26,9 @@ export interface NavigationMenuDrawerProps extends DrawerProps {
|
|
|
26
26
|
* Custom Drawer footer content
|
|
27
27
|
* @default null
|
|
28
28
|
*/
|
|
29
|
-
drawerFooterContent?: React.ReactNode
|
|
29
|
+
drawerFooterContent?: React.ReactNode | ((props: {
|
|
30
|
+
handleCloseMenuDrawer: (event: any, reason: 'backdropClick' | 'escapeKeyDown') => void;
|
|
31
|
+
}) => React.ReactNode);
|
|
30
32
|
/**
|
|
31
33
|
* Props to spread to ScrollContainer component
|
|
32
34
|
* This lib use 'react-custom-scrollbars' component to perform scrollbars
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const styles_1 = require("@mui/material/styles");
|
|
7
7
|
const material_1 = require("@mui/material");
|
|
8
8
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
@@ -11,7 +11,6 @@ const ScrollContainer_1 = tslib_1.__importDefault(require("../../shared/ScrollCo
|
|
|
11
11
|
const DefaultDrawerContent_1 = tslib_1.__importDefault(require("./DefaultDrawerContent"));
|
|
12
12
|
const DefaultHeaderContent_1 = tslib_1.__importDefault(require("./DefaultHeaderContent"));
|
|
13
13
|
const CreateLiveStreamButton_1 = tslib_1.__importDefault(require("../CreateLiveStreamButton"));
|
|
14
|
-
const react_core_1 = require("@selfcommunity/react-core");
|
|
15
14
|
const PREFIX = 'SCNavigationMenuDrawer';
|
|
16
15
|
const classes = {
|
|
17
16
|
root: `${PREFIX}-root`,
|
|
@@ -30,15 +29,23 @@ const Root = (0, styles_1.styled)(material_1.Drawer, {
|
|
|
30
29
|
overridesResolver: (props, styles) => styles.root
|
|
31
30
|
})(({ theme }) => ({}));
|
|
32
31
|
function NavigationMenuDrawer(inProps) {
|
|
33
|
-
var _a;
|
|
34
32
|
// PROPS
|
|
35
33
|
const props = (0, system_1.useThemeProps)({
|
|
36
34
|
props: inProps,
|
|
37
35
|
name: PREFIX
|
|
38
36
|
});
|
|
39
37
|
const { className = null, showDrawerHeader = true, drawerHeaderContent = (0, jsx_runtime_1.jsx)(DefaultHeaderContent_1.default, {}), drawerContent = (0, jsx_runtime_1.jsx)(DefaultDrawerContent_1.default, {}), showDrawerFooterContent = true, drawerFooterContent = null, ScrollContainerProps = { hideTracksWhenNotNeeded: true }, CreateLiveStreamButtonComponentProps = {}, open, onClose } = props, rest = tslib_1.__rest(props, ["className", "showDrawerHeader", "drawerHeaderContent", "drawerContent", "showDrawerFooterContent", "drawerFooterContent", "ScrollContainerProps", "CreateLiveStreamButtonComponentProps", "open", "onClose"]);
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
const footerContent = (() => {
|
|
39
|
+
if (typeof drawerFooterContent === 'function') {
|
|
40
|
+
return drawerFooterContent({ handleCloseMenuDrawer: onClose });
|
|
41
|
+
}
|
|
42
|
+
if (react_1.default.isValidElement(drawerFooterContent)) {
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
return react_1.default.cloneElement(drawerFooterContent, { handleCloseMenuDrawer: onClose });
|
|
46
|
+
}
|
|
47
|
+
return drawerFooterContent;
|
|
48
|
+
})();
|
|
49
|
+
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ anchor: "left", className: (0, classnames_1.default)(classes.root, className), open: open, onClose: onClose }, rest, { children: [showDrawerHeader && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.drawerHeader }, { children: [drawerHeaderContent, (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: classes.drawerHeaderAction, onClick: onClose }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Divider, {})] })), (0, jsx_runtime_1.jsx)(ScrollContainer_1.default, Object.assign({}, ScrollContainerProps, { children: (0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ className: classes.drawerContent, onClick: onClose }, { children: drawerContent })) })), showDrawerFooterContent && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ component: "div", className: classes.drawerFooter }, { children: footerContent || ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.drawerFooterLiveStream }, { children: (0, jsx_runtime_1.jsx)(CreateLiveStreamButton_1.default, Object.assign({ color: "primary", className: classes.drawerFooterLiveStreamButton, fullWidth: true }, CreateLiveStreamButtonComponentProps)) }))) })) }))] })));
|
|
43
50
|
}
|
|
44
51
|
exports.default = NavigationMenuDrawer;
|
|
@@ -17,7 +17,6 @@ const UserDeletedSnackBar_1 = tslib_1.__importDefault(require("../../../shared/U
|
|
|
17
17
|
const UserAvatar_1 = tslib_1.__importDefault(require("../../../shared/UserAvatar"));
|
|
18
18
|
const constants_1 = require("../constants");
|
|
19
19
|
const Event_1 = tslib_1.__importDefault(require("../../Event"));
|
|
20
|
-
const api_services_1 = require("@selfcommunity/api-services");
|
|
21
20
|
const classes = {
|
|
22
21
|
root: `${constants_1.PREFIX}-event-root`,
|
|
23
22
|
avatar: `${constants_1.PREFIX}-avatar`,
|
|
@@ -41,24 +40,22 @@ function EventNotification(props) {
|
|
|
41
40
|
const { notificationObject, id = `n_${props.notificationObject['sid']}`, className, template = types_2.SCNotificationObjectTemplateType.DETAIL } = props, rest = tslib_1.__rest(props, ["notificationObject", "id", "className", "template"]);
|
|
42
41
|
// CONTEXT
|
|
43
42
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
44
|
-
const scUserContext = (0, react_core_1.useSCUser)();
|
|
45
|
-
const scEventsManager = scUserContext.managers.events;
|
|
46
43
|
// STATE
|
|
47
44
|
const [openAlert, setOpenAlert] = (0, react_1.useState)(false);
|
|
48
|
-
const [loading, setLoading] =
|
|
49
|
-
const [disabled, setDisabled] =
|
|
45
|
+
// const [loading, setLoading] = useState<boolean>(false);
|
|
46
|
+
// const [disabled, setDisabled] = useState<boolean>(!notificationObject.is_new);
|
|
50
47
|
// CONST
|
|
51
48
|
const isSnippetTemplate = template === types_2.SCNotificationObjectTemplateType.SNIPPET;
|
|
52
49
|
const isToastTemplate = template === types_2.SCNotificationObjectTemplateType.TOAST;
|
|
53
50
|
const intl = (0, react_intl_1.useIntl)();
|
|
54
51
|
//HANDLERS
|
|
55
|
-
const acceptRequest = (event) => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
52
|
+
// const acceptRequest = (event) => {
|
|
53
|
+
// setLoading(true);
|
|
54
|
+
// EventService.inviteOrAcceptEventRequest(event.id, {users: [notificationObject.user.id]}).then(() => {
|
|
55
|
+
// setLoading(false);
|
|
56
|
+
// setDisabled(true);
|
|
57
|
+
// });
|
|
58
|
+
// };
|
|
62
59
|
// RENDER
|
|
63
60
|
if (isSnippetTemplate || isToastTemplate) {
|
|
64
61
|
return ((0, jsx_runtime_1.jsx)(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: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
@@ -79,7 +76,7 @@ function EventNotification(props) {
|
|
|
79
76
|
month: 'long'
|
|
80
77
|
}),
|
|
81
78
|
hour: intl.formatDate(notificationObject.event.start_date, { hour: 'numeric', minute: 'numeric' })
|
|
82
|
-
} }) })), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ component: "p", variant: "body2" }, { children: [(0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.notification.event.privacy.${notificationObject.event.privacy}`, defaultMessage: `ui.notification.event.privacy.${notificationObject.event.privacy}` }), ' ', "-", ' ', notificationObject.event.location === types_1.SCEventLocationType.PERSON ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.notification.event.address.live.label`, defaultMessage: `ui.notification.event.address.live.label` })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.notification.event.address.online.label`, defaultMessage: `ui.notification.event.address.online.label` }))] }))] }), footer: isToastTemplate ? ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [(0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ color: "primary" }, { children:
|
|
79
|
+
} }) })), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ component: "p", variant: "body2" }, { children: [(0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.notification.event.privacy.${notificationObject.event.privacy}`, defaultMessage: `ui.notification.event.privacy.${notificationObject.event.privacy}` }), ' ', "-", ' ', notificationObject.event.location === types_1.SCEventLocationType.PERSON ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.notification.event.address.live.label`, defaultMessage: `ui.notification.event.address.live.label` })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.notification.event.address.online.label`, defaultMessage: `ui.notification.event.address.online.label` }))] }))] }), footer: isToastTemplate ? ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [(0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ color: "primary" }, { children: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.notification.event.button.see", defaultMessage: "ui.notification.event.button.see" }) })) }))] }))) : ((0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at, className: classes.snippetTime })) }, rest)));
|
|
83
80
|
}
|
|
84
81
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(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: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
85
82
|
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
@@ -91,11 +88,6 @@ function EventNotification(props) {
|
|
|
91
88
|
icon: (...chunks) => (0, jsx_runtime_1.jsx)(material_1.Icon, { children: chunks }),
|
|
92
89
|
event: notificationObject.event.name,
|
|
93
90
|
link: (...chunks) => (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: chunks }))
|
|
94
|
-
} }), (0, jsx_runtime_1.jsx)(Event_1.default, { event: notificationObject.event, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), elevation: 0 })] }), actions: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [(0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at, className: classes.activeAt }), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({
|
|
95
|
-
component: react_core_1.Link,
|
|
96
|
-
to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, notificationObject.event)
|
|
97
|
-
}), { onClick: notificationObject.type === types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT
|
|
98
|
-
? () => acceptRequest(notificationObject.event)
|
|
99
|
-
: null }, { children: notificationObject.type === types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: disabled ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.notification.event.button.accepted", defaultMessage: "ui.notification.event.button.accepted" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.notification.event.button.accept", defaultMessage: "ui.notification.event.button.accept" })) })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.notification.event.button.see", defaultMessage: "ui.notification.event.button.see" })) }))] })) }, rest)), openAlert && (0, jsx_runtime_1.jsx)(UserDeletedSnackBar_1.default, { open: openAlert, handleClose: () => setOpenAlert(false) })] }));
|
|
91
|
+
} }), (0, jsx_runtime_1.jsx)(Event_1.default, { event: notificationObject.event, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), elevation: 0 })] }), actions: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [(0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { date: notificationObject.active_at, className: classes.activeAt }), (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ color: 'primary', variant: "outlined", size: "small", classes: { root: classes.seeButton }, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.notification.event.button.see", defaultMessage: "ui.notification.event.button.see" }) }))] })) }, rest)), openAlert && (0, jsx_runtime_1.jsx)(UserDeletedSnackBar_1.default, { open: openAlert, handleClose: () => setOpenAlert(false) })] }));
|
|
100
92
|
}
|
|
101
93
|
exports.default = EventNotification;
|
|
@@ -26,7 +26,9 @@ export interface NavigationMenuDrawerProps extends DrawerProps {
|
|
|
26
26
|
* Custom Drawer footer content
|
|
27
27
|
* @default null
|
|
28
28
|
*/
|
|
29
|
-
drawerFooterContent?: React.ReactNode
|
|
29
|
+
drawerFooterContent?: React.ReactNode | ((props: {
|
|
30
|
+
handleCloseMenuDrawer: (event: any, reason: 'backdropClick' | 'escapeKeyDown') => void;
|
|
31
|
+
}) => React.ReactNode);
|
|
30
32
|
/**
|
|
31
33
|
* Props to spread to ScrollContainer component
|
|
32
34
|
* This lib use 'react-custom-scrollbars' component to perform scrollbars
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import
|
|
3
|
+
import React from 'react';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
5
|
import { Box, Divider, Drawer, Icon, IconButton, List } from '@mui/material';
|
|
6
6
|
import classNames from 'classnames';
|
|
@@ -9,7 +9,6 @@ import ScrollContainer from '../../shared/ScrollContainer';
|
|
|
9
9
|
import DefaultDrawerContent from './DefaultDrawerContent';
|
|
10
10
|
import DefaultHeaderContent from './DefaultHeaderContent';
|
|
11
11
|
import CreateLiveStreamButton from '../CreateLiveStreamButton';
|
|
12
|
-
import { useSCUser } from '@selfcommunity/react-core';
|
|
13
12
|
const PREFIX = 'SCNavigationMenuDrawer';
|
|
14
13
|
const classes = {
|
|
15
14
|
root: `${PREFIX}-root`,
|
|
@@ -28,14 +27,22 @@ const Root = styled(Drawer, {
|
|
|
28
27
|
overridesResolver: (props, styles) => styles.root
|
|
29
28
|
})(({ theme }) => ({}));
|
|
30
29
|
export default function NavigationMenuDrawer(inProps) {
|
|
31
|
-
var _a;
|
|
32
30
|
// PROPS
|
|
33
31
|
const props = useThemeProps({
|
|
34
32
|
props: inProps,
|
|
35
33
|
name: PREFIX
|
|
36
34
|
});
|
|
37
35
|
const { className = null, showDrawerHeader = true, drawerHeaderContent = _jsx(DefaultHeaderContent, {}), drawerContent = _jsx(DefaultDrawerContent, {}), showDrawerFooterContent = true, drawerFooterContent = null, ScrollContainerProps = { hideTracksWhenNotNeeded: true }, CreateLiveStreamButtonComponentProps = {}, open, onClose } = props, rest = __rest(props, ["className", "showDrawerHeader", "drawerHeaderContent", "drawerContent", "showDrawerFooterContent", "drawerFooterContent", "ScrollContainerProps", "CreateLiveStreamButtonComponentProps", "open", "onClose"]);
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const footerContent = (() => {
|
|
37
|
+
if (typeof drawerFooterContent === 'function') {
|
|
38
|
+
return drawerFooterContent({ handleCloseMenuDrawer: onClose });
|
|
39
|
+
}
|
|
40
|
+
if (React.isValidElement(drawerFooterContent)) {
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
return React.cloneElement(drawerFooterContent, { handleCloseMenuDrawer: onClose });
|
|
44
|
+
}
|
|
45
|
+
return drawerFooterContent;
|
|
46
|
+
})();
|
|
47
|
+
return (_jsxs(Root, Object.assign({ anchor: "left", className: classNames(classes.root, className), open: open, onClose: onClose }, rest, { children: [showDrawerHeader && (_jsxs(_Fragment, { children: [_jsxs(Box, Object.assign({ className: classes.drawerHeader }, { children: [drawerHeaderContent, _jsx(IconButton, Object.assign({ className: classes.drawerHeaderAction, onClick: onClose }, { children: _jsx(Icon, { children: "close" }) }))] })), _jsx(Divider, {})] })), _jsx(ScrollContainer, Object.assign({}, ScrollContainerProps, { children: _jsx(List, Object.assign({ className: classes.drawerContent, onClick: onClose }, { children: drawerContent })) })), showDrawerFooterContent && (_jsx(_Fragment, { children: _jsx(Box, Object.assign({ component: "div", className: classes.drawerFooter }, { children: footerContent || (_jsx(Box, Object.assign({ className: classes.drawerFooterLiveStream }, { children: _jsx(CreateLiveStreamButton, Object.assign({ color: "primary", className: classes.drawerFooterLiveStreamButton, fullWidth: true }, CreateLiveStreamButtonComponentProps)) }))) })) }))] })));
|
|
41
48
|
}
|
|
@@ -3,8 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
5
|
import { Avatar, Box, Icon, Stack, Typography } from '@mui/material';
|
|
6
|
-
import { Link, SCRoutes, useSCRouting
|
|
7
|
-
import { SCEventLocationType
|
|
6
|
+
import { Link, SCRoutes, useSCRouting } from '@selfcommunity/react-core';
|
|
7
|
+
import { SCEventLocationType } from '@selfcommunity/types';
|
|
8
8
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
9
9
|
import DateTimeAgo from '../../../shared/DateTimeAgo';
|
|
10
10
|
import classNames from 'classnames';
|
|
@@ -15,7 +15,6 @@ import UserDeletedSnackBar from '../../../shared/UserDeletedSnackBar';
|
|
|
15
15
|
import UserAvatar from '../../../shared/UserAvatar';
|
|
16
16
|
import { PREFIX } from '../constants';
|
|
17
17
|
import { default as EventItem } from '../../Event';
|
|
18
|
-
import { EventService } from '@selfcommunity/api-services';
|
|
19
18
|
const classes = {
|
|
20
19
|
root: `${PREFIX}-event-root`,
|
|
21
20
|
avatar: `${PREFIX}-avatar`,
|
|
@@ -39,24 +38,22 @@ export default function EventNotification(props) {
|
|
|
39
38
|
const { notificationObject, id = `n_${props.notificationObject['sid']}`, className, template = SCNotificationObjectTemplateType.DETAIL } = props, rest = __rest(props, ["notificationObject", "id", "className", "template"]);
|
|
40
39
|
// CONTEXT
|
|
41
40
|
const scRoutingContext = useSCRouting();
|
|
42
|
-
const scUserContext = useSCUser();
|
|
43
|
-
const scEventsManager = scUserContext.managers.events;
|
|
44
41
|
// STATE
|
|
45
42
|
const [openAlert, setOpenAlert] = useState(false);
|
|
46
|
-
const [loading, setLoading] = useState(false);
|
|
47
|
-
const [disabled, setDisabled] = useState(!notificationObject.is_new);
|
|
43
|
+
// const [loading, setLoading] = useState<boolean>(false);
|
|
44
|
+
// const [disabled, setDisabled] = useState<boolean>(!notificationObject.is_new);
|
|
48
45
|
// CONST
|
|
49
46
|
const isSnippetTemplate = template === SCNotificationObjectTemplateType.SNIPPET;
|
|
50
47
|
const isToastTemplate = template === SCNotificationObjectTemplateType.TOAST;
|
|
51
48
|
const intl = useIntl();
|
|
52
49
|
//HANDLERS
|
|
53
|
-
const acceptRequest = (event) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
50
|
+
// const acceptRequest = (event) => {
|
|
51
|
+
// setLoading(true);
|
|
52
|
+
// EventService.inviteOrAcceptEventRequest(event.id, {users: [notificationObject.user.id]}).then(() => {
|
|
53
|
+
// setLoading(false);
|
|
54
|
+
// setDisabled(true);
|
|
55
|
+
// });
|
|
56
|
+
// };
|
|
60
57
|
// RENDER
|
|
61
58
|
if (isSnippetTemplate || isToastTemplate) {
|
|
62
59
|
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 && {
|
|
@@ -77,7 +74,7 @@ export default function EventNotification(props) {
|
|
|
77
74
|
month: 'long'
|
|
78
75
|
}),
|
|
79
76
|
hour: intl.formatDate(notificationObject.event.start_date, { hour: 'numeric', minute: 'numeric' })
|
|
80
|
-
} }) })), _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:
|
|
77
|
+
} }) })), _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)));
|
|
81
78
|
}
|
|
82
79
|
return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`), template: template, isNew: notificationObject.is_new, disableTypography: true, image: _jsx(Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
83
80
|
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
@@ -89,10 +86,5 @@ export default function EventNotification(props) {
|
|
|
89
86
|
icon: (...chunks) => _jsx(Icon, { children: chunks }),
|
|
90
87
|
event: notificationObject.event.name,
|
|
91
88
|
link: (...chunks) => _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: chunks }))
|
|
92
|
-
} }), _jsx(EventItem, { event: notificationObject.event, actions: _jsx(_Fragment, {}), elevation: 0 })] }), actions: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [_jsx(DateTimeAgo, { date: notificationObject.active_at, className: classes.activeAt }), _jsx(LoadingButton, Object.assign({
|
|
93
|
-
component: Link,
|
|
94
|
-
to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, notificationObject.event)
|
|
95
|
-
}), { onClick: notificationObject.type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT
|
|
96
|
-
? () => acceptRequest(notificationObject.event)
|
|
97
|
-
: null }, { children: notificationObject.type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT ? (_jsx(_Fragment, { children: disabled ? (_jsx(FormattedMessage, { id: "ui.notification.event.button.accepted", defaultMessage: "ui.notification.event.button.accepted" })) : (_jsx(FormattedMessage, { id: "ui.notification.event.button.accept", defaultMessage: "ui.notification.event.button.accept" })) })) : (_jsx(FormattedMessage, { id: "ui.notification.event.button.see", defaultMessage: "ui.notification.event.button.see" })) }))] })) }, rest)), openAlert && _jsx(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })] }));
|
|
89
|
+
} }), _jsx(EventItem, { event: notificationObject.event, actions: _jsx(_Fragment, {}), elevation: 0 })] }), actions: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [_jsx(DateTimeAgo, { date: notificationObject.active_at, className: classes.activeAt }), _jsx(LoadingButton, Object.assign({ color: 'primary', variant: "outlined", size: "small", classes: { root: classes.seeButton }, component: Link, 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) })] }));
|
|
98
90
|
}
|