@selfcommunity/react-ui 0.11.0-alpha.51 → 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.
@@ -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] = (0, react_1.useState)(false);
49
- const [disabled, setDisabled] = (0, react_1.useState)(!notificationObject.is_new);
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
- setLoading(true);
57
- api_services_1.EventService.inviteOrAcceptEventRequest(event.id, { users: [notificationObject.user.id] }).then(() => {
58
- setLoading(false);
59
- setDisabled(true);
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: notificationObject.type === types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT ? ((0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ disabled: disabled, loading: loading || scEventsManager.isLoading(notificationObject.event), color: 'primary', variant: "text", size: "small", onClick: () => acceptRequest(notificationObject.event) }, { 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_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)));
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({ disabled: disabled, loading: loading || scEventsManager.isLoading(notificationObject.event), color: 'primary', variant: "outlined", size: "small", classes: { root: classes.seeButton } }, (notificationObject.type !== types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT && {
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;
@@ -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, useSCUser } from '@selfcommunity/react-core';
7
- import { SCEventLocationType, SCNotificationTypologyType } from '@selfcommunity/types';
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
- setLoading(true);
55
- EventService.inviteOrAcceptEventRequest(event.id, { users: [notificationObject.user.id] }).then(() => {
56
- setLoading(false);
57
- setDisabled(true);
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: notificationObject.type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT ? (_jsx(LoadingButton, Object.assign({ disabled: disabled, loading: loading || scEventsManager.isLoading(notificationObject.event), color: 'primary', variant: "text", size: "small", onClick: () => acceptRequest(notificationObject.event) }, { 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(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)));
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({ disabled: disabled, loading: loading || scEventsManager.isLoading(notificationObject.event), color: 'primary', variant: "outlined", size: "small", classes: { root: classes.seeButton } }, (notificationObject.type !== SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT && {
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
  }