@selfcommunity/react-ui 0.7.50-events.110 → 0.7.50-events.112
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/Event/Event.d.ts +5 -0
- package/lib/cjs/components/Event/Event.js +10 -4
- package/lib/cjs/components/EventHeader/EventHeader.js +1 -1
- package/lib/cjs/components/EventInfoWidget/EventInfoWidget.js +1 -1
- package/lib/cjs/components/EventMembersWidget/EventMembersWidget.js +36 -10
- package/lib/cjs/components/EventMembersWidget/TabContentComponent.d.ts +3 -2
- package/lib/cjs/components/EventMembersWidget/TabContentComponent.js +33 -13
- package/lib/cjs/components/EventMembersWidget/types.d.ts +6 -0
- package/lib/cjs/components/EventMembersWidget/types.js +9 -0
- package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.d.ts +2 -2
- package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.js +8 -5
- package/lib/cjs/components/FeedObject/FeedObject.js +6 -2
- package/lib/cjs/shared/ContributionActionsMenu/index.js +8 -1
- package/lib/cjs/shared/EventInfoDetails/index.d.ts +1 -0
- package/lib/cjs/shared/EventInfoDetails/index.js +18 -14
- package/lib/esm/components/Event/Event.d.ts +5 -0
- package/lib/esm/components/Event/Event.js +11 -5
- package/lib/esm/components/EventHeader/EventHeader.js +1 -1
- package/lib/esm/components/EventInfoWidget/EventInfoWidget.js +1 -1
- package/lib/esm/components/EventMembersWidget/EventMembersWidget.js +36 -10
- package/lib/esm/components/EventMembersWidget/TabContentComponent.d.ts +3 -2
- package/lib/esm/components/EventMembersWidget/TabContentComponent.js +34 -14
- package/lib/esm/components/EventMembersWidget/types.d.ts +6 -0
- package/lib/esm/components/EventMembersWidget/types.js +6 -0
- package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.d.ts +2 -2
- package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.js +8 -5
- package/lib/esm/components/FeedObject/FeedObject.js +6 -2
- package/lib/esm/shared/ContributionActionsMenu/index.js +8 -1
- package/lib/esm/shared/EventInfoDetails/index.d.ts +1 -0
- package/lib/esm/shared/EventInfoDetails/index.js +19 -15
- package/lib/umd/react-ui.js +1 -1
- package/package.json +7 -7
|
@@ -10,7 +10,7 @@ const PREFIX = 'SCEventInfoDetails';
|
|
|
10
10
|
const classes = {
|
|
11
11
|
root: `${PREFIX}-root`,
|
|
12
12
|
iconTextWrapper: `${PREFIX}-icon-text-wrapper`,
|
|
13
|
-
|
|
13
|
+
inProgress: `${PREFIX}-in-progress`,
|
|
14
14
|
link: `${PREFIX}-link`,
|
|
15
15
|
url: `${PREFIX}-url`,
|
|
16
16
|
creationWrapper: `${PREFIX}-creation-wrapper`
|
|
@@ -26,21 +26,25 @@ function EventInfoDetails(inProps) {
|
|
|
26
26
|
props: inProps,
|
|
27
27
|
name: PREFIX
|
|
28
28
|
});
|
|
29
|
-
const { event, hideDateIcon = false, hideRecurringIcon = false, hidePrivacyIcon = false, hideLocationIcon = false, hideCreatedIcon = false, hasDateInfo = true, hasRecurringInfo = false, hasPrivacyInfo = true, hasLocationInfo = true, hasCreatedInfo = false, hasInProgress =
|
|
29
|
+
const { event, eventId, hideDateIcon = false, hideRecurringIcon = false, hidePrivacyIcon = false, hideLocationIcon = false, hideCreatedIcon = false, hasDateInfo = true, hasRecurringInfo = false, hasPrivacyInfo = true, hasLocationInfo = true, hasCreatedInfo = false, hasInProgress = false, beforeDateInfo, beforeRecurringInfo, beforePrivacyInfo, beforeLocationInfo, beforeCreatedInfo } = props;
|
|
30
30
|
// HOOKS
|
|
31
31
|
const intl = (0, react_intl_1.useIntl)();
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
33
|
+
const privacy = (0, react_1.useMemo)(() => (scEvent && scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC ? 'ui.eventInfoDetails.privacy.public' : 'ui.eventInfoDetails.privacy.private'), [scEvent]);
|
|
34
|
+
const location = (0, react_1.useMemo)(() => (scEvent && scEvent.location === types_1.SCEventLocationType.ONLINE ? 'ui.eventInfoDetails.location.virtual' : 'ui.eventInfoDetails.location.inPerson'), [scEvent]);
|
|
35
|
+
if (!scEvent) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: classes.root }, { children: [beforeDateInfo, hasDateInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideDateIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: scEvent.active ? 'CalendarIcon' : 'calendar_off' })), (0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: !scEvent.active ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventInfoDetails.deleted.tooltip", defaultMessage: "ui.eventInfoDetails.deleted.tooltip" })) : null }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventInfoDetails.date.startEndTime", defaultMessage: "ui.eventInfoDetails.date.startEndTime", values: {
|
|
39
|
+
date: intl.formatDate(scEvent.running ? scEvent.running_start_date : scEvent.next_start_date, {
|
|
40
|
+
weekday: 'long',
|
|
41
|
+
day: 'numeric',
|
|
42
|
+
year: 'numeric',
|
|
43
|
+
month: 'long'
|
|
44
|
+
}),
|
|
45
|
+
start: intl.formatDate(scEvent.running ? scEvent.running_start_date : scEvent.next_start_date, { hour: 'numeric', minute: 'numeric' })
|
|
46
|
+
} }) })) })), hasInProgress && scEvent.active && scEvent.running && ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventInfoDetails.inProgress", defaultMessage: "ui.eventInfoDetails.inProgress" }) }, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { className: classes.inProgress }) })))] }))), beforeRecurringInfo, hasRecurringInfo && scEvent.recurring !== types_1.SCEventRecurrenceType.NEVER && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideRecurringIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "frequency" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventInfoDetails.frequency.${scEvent.recurring}.placeholder`, defaultMessage: `ui.eventInfoDetails.frequency.${scEvent.recurring}.placeholder` }) }))] }))), beforePrivacyInfo, hasPrivacyInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hidePrivacyIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC ? 'public' : 'private' })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: privacy, defaultMessage: privacy }) })), "-", (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: location, defaultMessage: location }) }))] }))), beforeLocationInfo, hasLocationInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideLocationIcon && ((0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: scEvent.location === types_1.SCEventLocationType.ONLINE ? 'play_circle_outline' : 'add_location_alt' }))), scEvent.location === types_1.SCEventLocationType.ONLINE ? ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scEvent.link, target: "_blank", className: classes.link }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", className: classes.url }, { children: scEvent.link })) }))) : ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", className: classes.url }, { children: scEvent.geolocation })))] }))), beforeCreatedInfo, hasCreatedInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.creationWrapper }, { children: [!hideCreatedIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "create" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventInfoDetails.date.create", defaultMessage: "ui.eventInfoDetails.date.create", values: {
|
|
47
|
+
date: intl.formatDate(scEvent.created_at, {
|
|
44
48
|
weekday: 'long',
|
|
45
49
|
day: 'numeric',
|
|
46
50
|
year: 'numeric',
|
|
@@ -1,11 +1,12 @@
|
|
|
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, Box, Button, CardActions, CardContent, CardMedia, Divider, Typography } from '@mui/material';
|
|
3
|
+
import { Avatar, Box, Button, CardActions, CardContent, CardMedia, Chip, Divider, Typography } from '@mui/material';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
5
|
import { useThemeProps } from '@mui/system';
|
|
6
6
|
import { Link, SCRoutes, useSCFetchEvent, useSCRouting } from '@selfcommunity/react-core';
|
|
7
7
|
import { SCEventLocationType } from '@selfcommunity/types';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
|
+
import { useMemo } from 'react';
|
|
9
10
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
10
11
|
import BaseItem from '../../shared/BaseItem';
|
|
11
12
|
import Calendar from '../../shared/Calendar';
|
|
@@ -23,6 +24,7 @@ const classes = {
|
|
|
23
24
|
snippetRoot: `${PREFIX}-snippet-root`,
|
|
24
25
|
detailImageWrapper: `${PREFIX}-detail-image-wrapper`,
|
|
25
26
|
detailImage: `${PREFIX}-detail-image`,
|
|
27
|
+
detailInProgress: `${PREFIX}-detail-in-progress`,
|
|
26
28
|
detailNameWrapper: `${PREFIX}-detail-name-wrapper`,
|
|
27
29
|
detailName: `${PREFIX}-detail-name`,
|
|
28
30
|
detailContent: `${PREFIX}-detail-content`,
|
|
@@ -32,11 +34,14 @@ const classes = {
|
|
|
32
34
|
detailActions: `${PREFIX}-detail-actions`,
|
|
33
35
|
previewImageWrapper: `${PREFIX}-preview-image-wrapper`,
|
|
34
36
|
previewImage: `${PREFIX}-preview-image`,
|
|
37
|
+
previewInProgress: `${PREFIX}-preview-in-progress`,
|
|
35
38
|
previewNameWrapper: `${PREFIX}-preview-name-wrapper`,
|
|
36
39
|
previewName: `${PREFIX}-preview-name`,
|
|
37
40
|
previewContent: `${PREFIX}-preview-content`,
|
|
38
41
|
previewActions: `${PREFIX}-preview-actions`,
|
|
42
|
+
snippetImage: `${PREFIX}-snippet-image`,
|
|
39
43
|
snippetAvatar: `${PREFIX}-snippet-avatar`,
|
|
44
|
+
snippetInProgress: `${PREFIX}-snippet-in-progress`,
|
|
40
45
|
snippetPrimary: `${PREFIX}-snippet-primary`,
|
|
41
46
|
snippetSecondary: `${PREFIX}-snippet-secondary`,
|
|
42
47
|
snippetActions: `${PREFIX}-snippet-actions`
|
|
@@ -99,9 +104,10 @@ export default function Event(inProps) {
|
|
|
99
104
|
props: inProps,
|
|
100
105
|
name: PREFIX
|
|
101
106
|
});
|
|
102
|
-
const { id = `event_object_${props.eventId ? props.eventId : props.event ? props.event.id : ''}`, eventId = null, event = null, className = null, template = SCEventTemplateType.SNIPPET, hideEventParticipants = false, hideEventPlanner = false, actions, EventParticipantsButtonComponentProps = {}, EventSkeletonComponentProps = {} } = props, rest = __rest(props, ["id", "eventId", "event", "className", "template", "hideEventParticipants", "hideEventPlanner", "actions", "EventParticipantsButtonComponentProps", "EventSkeletonComponentProps"]);
|
|
107
|
+
const { id = `event_object_${props.eventId ? props.eventId : props.event ? props.event.id : ''}`, eventId = null, event = null, className = null, template = SCEventTemplateType.SNIPPET, hideInProgress = false, hideEventParticipants = false, hideEventPlanner = false, actions, EventParticipantsButtonComponentProps = {}, EventSkeletonComponentProps = {} } = props, rest = __rest(props, ["id", "eventId", "event", "className", "template", "hideInProgress", "hideEventParticipants", "hideEventPlanner", "actions", "EventParticipantsButtonComponentProps", "EventSkeletonComponentProps"]);
|
|
103
108
|
// STATE
|
|
104
109
|
const { scEvent } = useSCFetchEvent({ id: eventId, event });
|
|
110
|
+
const inProgress = useMemo(() => scEvent && scEvent.active && scEvent.running, [scEvent]);
|
|
105
111
|
// CONTEXT
|
|
106
112
|
const scRoutingContext = useSCRouting();
|
|
107
113
|
// HOOKS
|
|
@@ -117,13 +123,13 @@ export default function Event(inProps) {
|
|
|
117
123
|
*/
|
|
118
124
|
let contentObj;
|
|
119
125
|
if (template === SCEventTemplateType.DETAIL) {
|
|
120
|
-
contentObj = (_jsxs(DetailRoot, Object.assign({ className: classes.detailRoot }, { children: [_jsxs(Box, Object.assign({ className: classes.detailImageWrapper }, { children: [_jsx(CardMedia, { component: "img", image: scEvent.image_medium, alt: scEvent.name, className: classes.detailImage }), _jsx(Calendar, { day: new Date(scEvent.start_date).getDate() })] })), _jsxs(CardContent, Object.assign({ className: classes.detailContent }, { children: [_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.detailNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h3", className: classes.detailName }, { children: scEvent.name })) })), _jsx(EventInfoDetails, { event: scEvent }), !hideEventPlanner && (_jsx(User, { user: scEvent.managed_by, elevation: 0, secondary: _jsx(Typography, Object.assign({ variant: "caption" }, { children: _jsx(FormattedMessage, { id: "ui.myEventsWidget.planner", defaultMessage: "ui.myEventsWidget.planner" }) })), actions: _jsx(_Fragment, {}), className: classes.detailUser })), !hideEventParticipants && (_jsxs(_Fragment, { children: [_jsx(Divider, { className: classes.detailFirstDivider }), _jsx(EventParticipantsButton, Object.assign({ event: scEvent }, EventParticipantsButtonComponentProps))] })), _jsx(Divider, { className: classes.detailSecondDivider })] })), actions !== null && actions !== void 0 ? actions : (_jsx(CardActions, Object.assign({ className: classes.detailActions }, { children: _jsx(Button, Object.assign({ size: "small", variant: "outlined", component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })))] })));
|
|
126
|
+
contentObj = (_jsxs(DetailRoot, Object.assign({ className: classes.detailRoot }, { children: [_jsxs(Box, Object.assign({ className: classes.detailImageWrapper }, { children: [_jsx(CardMedia, { component: "img", image: scEvent.image_medium, alt: scEvent.name, className: classes.detailImage }), !hideInProgress && inProgress && (_jsx(Chip, { size: "small", component: "div", label: _jsx(FormattedMessage, { id: "ui.event.inProgress", defaultMessage: "ui.event.inProgress" }), className: classes.detailInProgress })), _jsx(Calendar, { day: new Date(scEvent.start_date).getDate() })] })), _jsxs(CardContent, Object.assign({ className: classes.detailContent }, { children: [scEvent.active ? (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.detailNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h3", className: classes.detailName }, { children: scEvent.name })) }))) : (_jsx(Box, Object.assign({ className: classes.detailNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h3", className: classes.detailName }, { children: scEvent.name })) }))), _jsx(EventInfoDetails, { event: scEvent }), !hideEventPlanner && (_jsx(User, { user: scEvent.managed_by, elevation: 0, secondary: _jsx(Typography, Object.assign({ variant: "caption" }, { children: _jsx(FormattedMessage, { id: "ui.myEventsWidget.planner", defaultMessage: "ui.myEventsWidget.planner" }) })), actions: _jsx(_Fragment, {}), className: classes.detailUser })), !hideEventParticipants && (_jsxs(_Fragment, { children: [_jsx(Divider, { className: classes.detailFirstDivider }), _jsx(EventParticipantsButton, Object.assign({ event: scEvent }, EventParticipantsButtonComponentProps))] })), _jsx(Divider, { className: classes.detailSecondDivider })] })), actions !== null && actions !== void 0 ? actions : (_jsx(CardActions, Object.assign({ className: classes.detailActions }, { children: _jsx(Button, Object.assign({ size: "small", variant: "outlined", component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })))] })));
|
|
121
127
|
}
|
|
122
128
|
else if (template === SCEventTemplateType.PREVIEW) {
|
|
123
|
-
contentObj = (_jsxs(PreviewRoot, Object.assign({ className: classes.previewRoot }, { children: [
|
|
129
|
+
contentObj = (_jsxs(PreviewRoot, Object.assign({ className: classes.previewRoot }, { children: [_jsxs(Box, Object.assign({ position: "relative", className: classes.previewImageWrapper }, { children: [_jsx(CardMedia, { component: "img", image: scEvent.image_medium, alt: scEvent.name, className: classes.previewImage }), !hideInProgress && inProgress && (_jsx(Chip, { size: "small", component: "div", label: _jsx(FormattedMessage, { id: "ui.event.inProgress", defaultMessage: "ui.event.inProgress" }), className: classes.previewInProgress }))] })), _jsxs(CardContent, Object.assign({ className: classes.previewContent }, { children: [_jsx(EventInfoDetails, { event: scEvent, hidePrivacyIcon: true, hasLocationInfo: false, beforePrivacyInfo: _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.previewNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h5", className: classes.previewName }, { children: scEvent.name })) })) }), !hideEventParticipants && _jsx(EventParticipantsButton, Object.assign({ event: scEvent, hideCaption: true }, EventParticipantsButtonComponentProps))] })), actions !== null && actions !== void 0 ? actions : (_jsx(CardActions, Object.assign({ className: classes.previewActions }, { children: _jsx(Button, Object.assign({ size: "small", variant: "outlined", component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })))] })));
|
|
124
130
|
}
|
|
125
131
|
else {
|
|
126
|
-
contentObj = (_jsx(SnippetRoot, { elevation: 0, square: true, disableTypography: true, className: classes.snippetRoot, image: _jsx(Avatar, { variant: "square", alt: scEvent.name, src: scEvent.image_medium, className: classes.snippetAvatar }), primary: _jsxs(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.snippetPrimary }, { children: [_jsx(Typography, Object.assign({ component: "span" }, { children: `${intl.formatDate(scEvent.start_date, {
|
|
132
|
+
contentObj = (_jsx(SnippetRoot, { elevation: 0, square: true, disableTypography: true, className: classes.snippetRoot, image: _jsxs(Box, Object.assign({ className: classes.snippetImage }, { children: [_jsx(Avatar, { variant: "square", alt: scEvent.name, src: scEvent.image_medium, className: classes.snippetAvatar }), ' ', !hideInProgress && inProgress && (_jsx(Chip, { size: "small", component: "div", label: _jsx(FormattedMessage, { id: "ui.event.inProgress", defaultMessage: "ui.event.inProgress" }), className: classes.snippetInProgress }))] })), primary: _jsxs(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.snippetPrimary }, { children: [_jsx(Typography, Object.assign({ component: "span" }, { children: `${intl.formatDate(scEvent.start_date, {
|
|
127
133
|
weekday: 'long',
|
|
128
134
|
month: 'long',
|
|
129
135
|
day: 'numeric'
|
|
@@ -118,7 +118,7 @@ export default function EventHeader(inProps) {
|
|
|
118
118
|
/**
|
|
119
119
|
* Handles callback subscribe/unsubscribe event
|
|
120
120
|
*/
|
|
121
|
-
const handleSubscribe = (
|
|
121
|
+
const handleSubscribe = (_event, status) => {
|
|
122
122
|
setSCEvent(Object.assign({}, scEvent, { subscription_status: status }));
|
|
123
123
|
};
|
|
124
124
|
/**
|
|
@@ -72,5 +72,5 @@ export default function EventInfoWidget(inProps) {
|
|
|
72
72
|
if (!scEvent) {
|
|
73
73
|
return _jsx(HiddenPlaceholder, {});
|
|
74
74
|
}
|
|
75
|
-
return (_jsx(Root, Object.assign({ className: classes.root }, rest, { children: _jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsxs(Stack, Object.assign({ className: classes.titleWrapper }, { children: [_jsx(Icon, Object.assign({ fontSize: "small" }, { children: "info" })), _jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.title", defaultMessage: "ui.infoEventWidget.title" }) }))] })), _jsx(Box, Object.assign({ className: classes.textWrapper }, { children: _jsxs(Typography, Object.assign({ component: "span", variant: "body1" }, { children: [description, showButton && !expanded && (_jsx(Button, Object.assign({ size: "small", variant: "text", className: classes.showMore, onClick: handleToggleSummary }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.showMore", defaultMessage: "ui.infoEventWidget.showMore" }) })))] })) })), _jsx(EventInfoDetails, { event: scEvent, hasRecurringInfo: true, hasCreatedInfo: true, hasLocationInfo: showInfo
|
|
75
|
+
return (_jsx(Root, Object.assign({ className: classes.root }, rest, { children: _jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsxs(Stack, Object.assign({ className: classes.titleWrapper }, { children: [_jsx(Icon, Object.assign({ fontSize: "small" }, { children: "info" })), _jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.title", defaultMessage: "ui.infoEventWidget.title" }) }))] })), _jsx(Box, Object.assign({ className: classes.textWrapper }, { children: _jsxs(Typography, Object.assign({ component: "span", variant: "body1" }, { children: [description, showButton && !expanded && (_jsx(Button, Object.assign({ size: "small", variant: "text", className: classes.showMore, onClick: handleToggleSummary }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.showMore", defaultMessage: "ui.infoEventWidget.showMore" }) })))] })) })), _jsx(EventInfoDetails, { event: scEvent, hasRecurringInfo: true, hasCreatedInfo: true, hasLocationInfo: showInfo })] })) })));
|
|
76
76
|
}
|
|
@@ -17,6 +17,7 @@ import Widget from '../Widget';
|
|
|
17
17
|
import { PREFIX } from './constants';
|
|
18
18
|
import Skeleton from './Skeleton';
|
|
19
19
|
import TabContentComponent from './TabContentComponent';
|
|
20
|
+
import { TabValueEnum } from './types';
|
|
20
21
|
const classes = {
|
|
21
22
|
root: `${PREFIX}-root`,
|
|
22
23
|
content: `${PREFIX}-content`,
|
|
@@ -59,18 +60,29 @@ export default function EventMembersWidget(inProps) {
|
|
|
59
60
|
cacheStrategy,
|
|
60
61
|
visibleItems: limit
|
|
61
62
|
}, stateWidgetInitializer);
|
|
63
|
+
const [participantsCount, setParticipantsCount] = useState(0);
|
|
62
64
|
const [invitedCount, setInvitedCount] = useState(0);
|
|
63
65
|
const [requestsCount, setRequestsCount] = useState(0);
|
|
64
66
|
const [requestsUsers, setRequestsUsers] = useState([]);
|
|
65
67
|
const [tabValue, setTabValue] = useState('1');
|
|
66
|
-
const [refresh, setRefresh] = useState(
|
|
68
|
+
const [refresh, setRefresh] = useState(null);
|
|
67
69
|
// CONTEXT
|
|
68
70
|
const scUserContext = useSCUser();
|
|
69
71
|
// HOOKS
|
|
70
72
|
const { scEvent } = useSCFetchEvent({ id: eventId, event });
|
|
71
73
|
// CONSTS
|
|
72
74
|
const hasAllow = useMemo(() => { var _a; return ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) === (scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id); }, [scUserContext, scEvent]);
|
|
73
|
-
const title = useMemo(() =>
|
|
75
|
+
const title = useMemo(() => {
|
|
76
|
+
switch (tabValue) {
|
|
77
|
+
case TabValueEnum.THREE:
|
|
78
|
+
return 'ui.eventMembersWidget.requests';
|
|
79
|
+
case TabValueEnum.TWO:
|
|
80
|
+
return 'ui.eventMembersWidget.invited';
|
|
81
|
+
case TabValueEnum.ONE:
|
|
82
|
+
default:
|
|
83
|
+
return 'ui.eventMembersWidget.participants';
|
|
84
|
+
}
|
|
85
|
+
}, [tabValue]);
|
|
74
86
|
// CALLBACKS
|
|
75
87
|
const _initParticipants = useCallback(() => {
|
|
76
88
|
if (!participants.initialized && !participants.isLoadingNext) {
|
|
@@ -78,13 +90,14 @@ export default function EventMembersWidget(inProps) {
|
|
|
78
90
|
EventService.getUsersGoingToEvent(scEvent.id, Object.assign({}, endpointQueryParams))
|
|
79
91
|
.then((payload) => {
|
|
80
92
|
dispatchParticipants({ type: actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: Object.assign(Object.assign({}, payload), { initialized: true }) });
|
|
93
|
+
setParticipantsCount(payload.count);
|
|
81
94
|
})
|
|
82
95
|
.catch((error) => {
|
|
83
96
|
dispatchParticipants({ type: actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
|
|
84
97
|
Logger.error(SCOPE_SC_UI, error);
|
|
85
98
|
});
|
|
86
99
|
}
|
|
87
|
-
}, [participants.isLoadingNext, participants.initialized,
|
|
100
|
+
}, [participants.isLoadingNext, participants.initialized, scEvent]);
|
|
88
101
|
const _initInvited = useCallback(() => {
|
|
89
102
|
if (!invited.initialized && !invited.isLoadingNext && hasAllow) {
|
|
90
103
|
dispatchInvited({ type: actionWidgetTypes.LOADING_NEXT });
|
|
@@ -98,7 +111,7 @@ export default function EventMembersWidget(inProps) {
|
|
|
98
111
|
Logger.error(SCOPE_SC_UI, error);
|
|
99
112
|
});
|
|
100
113
|
}
|
|
101
|
-
}, [invited.isLoadingNext, invited.initialized,
|
|
114
|
+
}, [invited.isLoadingNext, invited.initialized, scUserContext.user, scEvent]);
|
|
102
115
|
const _initRequests = useCallback(() => {
|
|
103
116
|
if (!requests.initialized && !requests.isLoadingNext && hasAllow) {
|
|
104
117
|
dispatchRequests({ type: actionWidgetTypes.LOADING_NEXT });
|
|
@@ -113,15 +126,19 @@ export default function EventMembersWidget(inProps) {
|
|
|
113
126
|
Logger.error(SCOPE_SC_UI, error);
|
|
114
127
|
});
|
|
115
128
|
}
|
|
116
|
-
}, [requests.isLoadingNext, requests.initialized,
|
|
129
|
+
}, [requests.isLoadingNext, requests.initialized, scUserContext.user, scEvent]);
|
|
117
130
|
// EFFECTS
|
|
118
131
|
useEffect(() => {
|
|
119
132
|
let _t;
|
|
120
133
|
if (scUserContext.user && scEvent) {
|
|
121
134
|
_t = setTimeout(() => {
|
|
122
|
-
if (refresh) {
|
|
135
|
+
if (refresh === TabValueEnum.ONE) {
|
|
136
|
+
_initParticipants();
|
|
137
|
+
setRefresh(null);
|
|
138
|
+
}
|
|
139
|
+
else if (refresh === TabValueEnum.TWO) {
|
|
123
140
|
_initInvited();
|
|
124
|
-
setRefresh(
|
|
141
|
+
setRefresh(null);
|
|
125
142
|
}
|
|
126
143
|
else {
|
|
127
144
|
_initParticipants();
|
|
@@ -138,6 +155,15 @@ export default function EventMembersWidget(inProps) {
|
|
|
138
155
|
const handleTabChange = useCallback((_evt, newTabValue) => {
|
|
139
156
|
setTabValue(newTabValue);
|
|
140
157
|
}, []);
|
|
158
|
+
const handleRefresh = useCallback((_tabValue) => {
|
|
159
|
+
if (_tabValue === TabValueEnum.ONE) {
|
|
160
|
+
dispatchParticipants({ type: actionWidgetTypes.RESET });
|
|
161
|
+
}
|
|
162
|
+
else if (_tabValue === TabValueEnum.TWO) {
|
|
163
|
+
dispatchInvited({ type: actionWidgetTypes.RESET });
|
|
164
|
+
}
|
|
165
|
+
setRefresh(_tabValue);
|
|
166
|
+
}, []);
|
|
141
167
|
if (!scEvent && !participants.initialized) {
|
|
142
168
|
return _jsx(Skeleton, {});
|
|
143
169
|
}
|
|
@@ -145,14 +171,14 @@ export default function EventMembersWidget(inProps) {
|
|
|
145
171
|
if (!scEvent) {
|
|
146
172
|
return _jsx(HiddenPlaceholder, {});
|
|
147
173
|
}
|
|
148
|
-
return (_jsx(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: title, defaultMessage: title }) })), _jsxs(TabContext, Object.assign({ value: tabValue }, { children: [_jsxs(TabList, Object.assign({ className: classes.tabsWrapper, onChange: handleTabChange, textColor: "primary", indicatorColor: "primary", variant: "fullWidth" }, { children: [_jsx(Tab, { label: _jsxs(Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "h3" }, { children:
|
|
174
|
+
return (_jsx(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: title, defaultMessage: title }) })), _jsxs(TabContext, Object.assign({ value: tabValue }, { children: [_jsxs(TabList, Object.assign({ className: classes.tabsWrapper, onChange: handleTabChange, textColor: "primary", indicatorColor: "primary", variant: "fullWidth" }, { children: [_jsx(Tab, { label: _jsxs(Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "h3" }, { children: participantsCount })), _jsx(Typography, Object.assign({ variant: "subtitle2" }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.participants", defaultMessage: "ui.eventMembersWidget.participants" }) }))] })), value: TabValueEnum.ONE }), hasAllow && (_jsx(Tab, { label: _jsxs(Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "h3" }, { children: invitedCount })), _jsx(Typography, Object.assign({ variant: "subtitle2" }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.invited", defaultMessage: "ui.eventMembersWidget.invited" }) }))] })), value: TabValueEnum.TWO })), hasAllow && (_jsx(Tab, { label: _jsxs(Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "h3" }, { children: requestsCount })), _jsx(Typography, Object.assign({ variant: "subtitle2" }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.requests", defaultMessage: "ui.eventMembersWidget.requests" }) }))] })), value: TabValueEnum.THREE }))] })), _jsx(TabPanel, Object.assign({ value: TabValueEnum.ONE, className: classes.tabPanel }, { children: _jsx(TabContentComponent, { tabValue: TabValueEnum.ONE, state: participants, dispatch: dispatchParticipants, userProps: userProps, dialogProps: dialogProps, handleRefresh: handleRefresh }) })), hasAllow && (_jsx(TabPanel, Object.assign({ value: TabValueEnum.TWO, className: classes.tabPanel }, { children: _jsx(TabContentComponent, { tabValue: TabValueEnum.TWO, state: invited, dispatch: dispatchInvited, userProps: userProps, dialogProps: dialogProps, actionProps: {
|
|
149
175
|
scEvent,
|
|
150
176
|
setCount: setInvitedCount
|
|
151
|
-
},
|
|
177
|
+
}, handleRefresh: handleRefresh }) }))), hasAllow && (_jsx(TabPanel, Object.assign({ value: TabValueEnum.THREE, className: classes.tabPanel }, { children: _jsx(TabContentComponent, { tabValue: TabValueEnum.THREE, state: requests, dispatch: dispatchRequests, userProps: userProps, dialogProps: dialogProps, actionProps: {
|
|
152
178
|
scEvent,
|
|
153
179
|
count: requestsCount,
|
|
154
180
|
setCount: setRequestsCount,
|
|
155
181
|
users: requestsUsers,
|
|
156
182
|
setUsers: setRequestsUsers
|
|
157
|
-
} }) })))] }))] })) })));
|
|
183
|
+
}, handleRefresh: handleRefresh }) })))] }))] })) })));
|
|
158
184
|
}
|
|
@@ -2,8 +2,9 @@ import { SCEventType, SCUserType } from '@selfcommunity/types';
|
|
|
2
2
|
import { Dispatch, SetStateAction } from 'react';
|
|
3
3
|
import { BaseDialogProps } from '../../shared/BaseDialog';
|
|
4
4
|
import { UserProps } from '../User';
|
|
5
|
+
import { TabValueType } from './types';
|
|
5
6
|
interface TabComponentProps {
|
|
6
|
-
tabValue:
|
|
7
|
+
tabValue: TabValueType;
|
|
7
8
|
state: any;
|
|
8
9
|
dispatch: Dispatch<any>;
|
|
9
10
|
/**
|
|
@@ -23,7 +24,7 @@ interface TabComponentProps {
|
|
|
23
24
|
users?: SCUserType[];
|
|
24
25
|
setUsers?: Dispatch<SetStateAction<SCUserType[]>>;
|
|
25
26
|
};
|
|
26
|
-
|
|
27
|
+
handleRefresh?: (tabValue: TabValueType) => void;
|
|
27
28
|
}
|
|
28
29
|
export default function TabContentComponent(props: TabComponentProps): JSX.Element;
|
|
29
30
|
export {};
|
|
@@ -3,9 +3,11 @@ import { Button, List, ListItem, styled, Typography } from '@mui/material';
|
|
|
3
3
|
import { Endpoints, http } from '@selfcommunity/api-services';
|
|
4
4
|
import { Logger } from '@selfcommunity/utils';
|
|
5
5
|
import { useSnackbar } from 'notistack';
|
|
6
|
-
import
|
|
6
|
+
import PubSub from 'pubsub-js';
|
|
7
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
8
|
import { FormattedMessage } from 'react-intl';
|
|
8
9
|
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
10
|
+
import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
|
|
9
11
|
import BaseDialog from '../../shared/BaseDialog';
|
|
10
12
|
import InfiniteScroll from '../../shared/InfiniteScroll';
|
|
11
13
|
import { actionWidgetTypes } from '../../utils/widget';
|
|
@@ -14,6 +16,7 @@ import EventInviteButton from '../EventInviteButton';
|
|
|
14
16
|
import InviteUserEventButton from '../InviteUserEventButton';
|
|
15
17
|
import User, { UserSkeleton } from '../User';
|
|
16
18
|
import { PREFIX } from './constants';
|
|
19
|
+
import { TabValueEnum } from './types';
|
|
17
20
|
const classes = {
|
|
18
21
|
actionButton: `${PREFIX}-action-button`,
|
|
19
22
|
eventButton: `${PREFIX}-event-button`,
|
|
@@ -28,13 +31,25 @@ const DialogRoot = styled(BaseDialog, {
|
|
|
28
31
|
})(() => ({}));
|
|
29
32
|
export default function TabContentComponent(props) {
|
|
30
33
|
// PROPS
|
|
31
|
-
const { state, dispatch, userProps, dialogProps, actionProps,
|
|
34
|
+
const { tabValue, state, dispatch, userProps, dialogProps, actionProps, handleRefresh } = props;
|
|
32
35
|
// STATE
|
|
33
36
|
const [openDialog, setOpenDialog] = useState(false);
|
|
37
|
+
// REFS
|
|
38
|
+
const updatesInvited = useRef(null);
|
|
39
|
+
const updatesParticipants = useRef(null);
|
|
34
40
|
// HOOKS
|
|
35
41
|
const { enqueueSnackbar } = useSnackbar();
|
|
36
42
|
// CONSTS
|
|
37
|
-
const users = useMemo(() => (tabValue ===
|
|
43
|
+
const users = useMemo(() => (tabValue === TabValueEnum.THREE ? actionProps === null || actionProps === void 0 ? void 0 : actionProps.users : state.results), [tabValue, actionProps, state]);
|
|
44
|
+
// EFFECTS
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
updatesInvited.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.INVITE_MEMBER}`, handleInviteMember);
|
|
47
|
+
updatesParticipants.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.ADD_MEMBER}`, handleToggleMember);
|
|
48
|
+
return () => {
|
|
49
|
+
updatesInvited.current && PubSub.unsubscribe(updatesInvited.current);
|
|
50
|
+
updatesParticipants.current && PubSub.unsubscribe(updatesParticipants.current);
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
38
53
|
// HANDLERS
|
|
39
54
|
/**
|
|
40
55
|
* Handles pagination
|
|
@@ -52,13 +67,19 @@ export default function TabContentComponent(props) {
|
|
|
52
67
|
.catch((error) => {
|
|
53
68
|
Logger.error(SCOPE_SC_UI, error);
|
|
54
69
|
});
|
|
55
|
-
}, [
|
|
70
|
+
}, [state.next, state.isLoadingNext, state.initialized]);
|
|
56
71
|
const handleToggleDialogOpen = useCallback(() => {
|
|
57
72
|
setOpenDialog((prev) => !prev);
|
|
58
73
|
}, []);
|
|
74
|
+
const handleToggleMember = useCallback(() => {
|
|
75
|
+
handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(TabValueEnum.ONE);
|
|
76
|
+
}, []);
|
|
77
|
+
const handleInviteMember = useCallback(() => {
|
|
78
|
+
handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(TabValueEnum.TWO);
|
|
79
|
+
}, []);
|
|
59
80
|
const getActionsComponent = useCallback((userId) => {
|
|
60
|
-
if (tabValue ===
|
|
61
|
-
const
|
|
81
|
+
if (tabValue === TabValueEnum.TWO && actionProps) {
|
|
82
|
+
const _handleInvitations = (invited) => {
|
|
62
83
|
var _a, _b;
|
|
63
84
|
if (invited) {
|
|
64
85
|
(_a = actionProps.setCount) === null || _a === void 0 ? void 0 : _a.call(actionProps, (prev) => prev - 1);
|
|
@@ -67,9 +88,9 @@ export default function TabContentComponent(props) {
|
|
|
67
88
|
(_b = actionProps.setCount) === null || _b === void 0 ? void 0 : _b.call(actionProps, (prev) => prev + 1);
|
|
68
89
|
}
|
|
69
90
|
};
|
|
70
|
-
return _jsx(InviteUserEventButton, { event: actionProps.scEvent, userId: userId, handleInvitations:
|
|
91
|
+
return _jsx(InviteUserEventButton, { event: actionProps.scEvent, userId: userId, handleInvitations: _handleInvitations });
|
|
71
92
|
}
|
|
72
|
-
else if (tabValue ===
|
|
93
|
+
else if (tabValue === TabValueEnum.THREE && actionProps) {
|
|
73
94
|
const handleConfirm = (id) => {
|
|
74
95
|
if (id) {
|
|
75
96
|
actionProps.setCount((prev) => prev - 1);
|
|
@@ -89,22 +110,21 @@ export default function TabContentComponent(props) {
|
|
|
89
110
|
return _jsx(AcceptRequestUserEventButton, { event: actionProps.scEvent, userId: userId, handleConfirm: handleConfirm });
|
|
90
111
|
}
|
|
91
112
|
return undefined;
|
|
92
|
-
}, [tabValue, actionProps
|
|
93
|
-
if (tabValue ===
|
|
113
|
+
}, [tabValue, actionProps]);
|
|
114
|
+
if (tabValue === TabValueEnum.ONE && (actionProps === null || actionProps === void 0 ? void 0 : actionProps.count) === 0) {
|
|
94
115
|
return (_jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.noParticipants", defaultMessage: "ui.eventMembersWidget.noParticipants" }) })));
|
|
95
116
|
}
|
|
96
|
-
if (tabValue ===
|
|
117
|
+
else if (tabValue === TabValueEnum.TWO && state.count === 0 && actionProps) {
|
|
97
118
|
const date = actionProps.scEvent.end_date || actionProps.scEvent.start_date;
|
|
98
119
|
const disabled = new Date(date).getTime() < new Date().getTime();
|
|
99
120
|
const handleInvitations = (invited) => {
|
|
100
121
|
if (invited) {
|
|
101
|
-
|
|
102
|
-
setRefresh(true);
|
|
122
|
+
handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(tabValue);
|
|
103
123
|
}
|
|
104
124
|
};
|
|
105
125
|
return (_jsx(EventInviteButton, { event: actionProps.scEvent, className: classes.eventButton, handleInvitations: handleInvitations, disabled: disabled }));
|
|
106
126
|
}
|
|
107
|
-
if (tabValue ===
|
|
127
|
+
else if (tabValue === TabValueEnum.THREE && (actionProps === null || actionProps === void 0 ? void 0 : actionProps.count) === 0) {
|
|
108
128
|
return (_jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.noOtherRequests", defaultMessage: "ui.eventMembersWidget.noOtherRequests" }) })));
|
|
109
129
|
}
|
|
110
130
|
return (_jsxs(_Fragment, { children: [_jsx(List, { children: users === null || users === void 0 ? void 0 : users.map((user) => (_jsx(ListItem, { children: _jsx(User, Object.assign({ elevation: 0, user: user }, userProps, { actions: getActionsComponent(user.id) })) }, user.id))) }), state.count > state.visibleItems && (_jsx(Button, Object.assign({ onClick: handleToggleDialogOpen, className: classes.actionButton }, { children: _jsx(Typography, Object.assign({ variant: "caption" }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.showAll", defaultMessage: "ui.eventMembersWidget.showAll" }) })) }))), openDialog && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: _jsx(FormattedMessage, { defaultMessage: "ui.eventMembersWidget.title", id: "ui.eventMembersWidget.title" }), onClose: handleToggleDialogOpen, open: openDialog }, dialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: state.results.length, next: handleNext, hasMoreNext: Boolean(state.next), loaderNext: _jsx(UserSkeleton, Object.assign({ elevation: 0 }, userProps)), className: classes.infiniteScroll, endMessage: _jsx(Typography, Object.assign({ className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.noMoreResults", defaultMessage: "ui.eventMembersWidget.noMoreResults" }) })) }, { children: _jsx(List, { children: state.results.map((user) => (_jsx(ListItem, { children: _jsx(User, Object.assign({ elevation: 0, user: user }, userProps)) }, user.id))) }) })) })))] }));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SCEventType, SCUserType } from '@selfcommunity/types';
|
|
1
|
+
import { SCEventSubscriptionStatusType, SCEventType, SCUserType } from '@selfcommunity/types';
|
|
2
2
|
export interface EventSubscribeButtonProps {
|
|
3
3
|
/**
|
|
4
4
|
* Overrides or extends the styles applied to the component.
|
|
@@ -25,7 +25,7 @@ export interface EventSubscribeButtonProps {
|
|
|
25
25
|
* @param user
|
|
26
26
|
* @param joined
|
|
27
27
|
*/
|
|
28
|
-
onSubscribe?: (event: SCEventType, status:
|
|
28
|
+
onSubscribe?: (event: SCEventType, status: SCEventSubscriptionStatusType | null) => any;
|
|
29
29
|
/**
|
|
30
30
|
* Others properties
|
|
31
31
|
*/
|
|
@@ -8,9 +8,11 @@ import { getEventStatus, useSCContext, useSCFetchEvent, useSCUser } from '@selfc
|
|
|
8
8
|
import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
|
|
9
9
|
import { CacheStrategies, Logger } from '@selfcommunity/utils';
|
|
10
10
|
import classNames from 'classnames';
|
|
11
|
-
import
|
|
11
|
+
import PubSub from 'pubsub-js';
|
|
12
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
12
13
|
import { FormattedMessage } from 'react-intl';
|
|
13
14
|
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
15
|
+
import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
|
|
14
16
|
const PREFIX = 'SCEventSubscribeButton';
|
|
15
17
|
const classes = {
|
|
16
18
|
requestRoot: `${PREFIX}-request-root`,
|
|
@@ -81,7 +83,7 @@ export default function EventSubscribeButton(inProps) {
|
|
|
81
83
|
// STATE
|
|
82
84
|
const [status, setStatus] = useState(undefined);
|
|
83
85
|
const [loading, setLoading] = useState(false);
|
|
84
|
-
const [anchorEl, setAnchorEl] =
|
|
86
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
85
87
|
const open = Boolean(anchorEl);
|
|
86
88
|
// CONTEXT
|
|
87
89
|
const scContext = useSCContext();
|
|
@@ -116,15 +118,16 @@ export default function EventSubscribeButton(inProps) {
|
|
|
116
118
|
const toggleEventAttendance = (eventStatus) => {
|
|
117
119
|
setLoading(true);
|
|
118
120
|
const isGoing = eventStatus === SCEventSubscriptionStatusType.GOING ||
|
|
119
|
-
!scEvent.subscription_status ||
|
|
121
|
+
!(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) ||
|
|
120
122
|
(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) === SCEventSubscriptionStatusType.INVITED;
|
|
121
123
|
const toggleAction = isGoing
|
|
122
|
-
? scEventsManager.toggleEventAttendance(scEvent, user
|
|
124
|
+
? scEventsManager.toggleEventAttendance(scEvent, (user === null || user === void 0 ? void 0 : user.id) || null)
|
|
123
125
|
: scEventsManager.toggleEventNonattendance(scEvent);
|
|
124
126
|
toggleAction
|
|
125
127
|
.then(() => {
|
|
126
|
-
onSubscribe
|
|
128
|
+
onSubscribe === null || onSubscribe === void 0 ? void 0 : onSubscribe(scEvent, getEventStatus(scEvent, isGoing));
|
|
127
129
|
setLoading(false);
|
|
130
|
+
PubSub.publish(`${SCTopicType.EVENT}.${SCGroupEventType.ADD_MEMBER}`, scUserContext.user);
|
|
128
131
|
})
|
|
129
132
|
.catch((e) => {
|
|
130
133
|
Logger.error(SCOPE_SC_UI, e);
|
|
@@ -37,6 +37,7 @@ import { MAX_SUMMARY_LENGTH } from '../../constants/Feed';
|
|
|
37
37
|
import Composer from '../Composer';
|
|
38
38
|
import FeedObjectMediaPreview from '../FeedObjectMediaPreview';
|
|
39
39
|
import { PREFIX } from './constants';
|
|
40
|
+
import { MEDIA_EMBED_SC_SHARED_EVENT } from '../../constants/Media';
|
|
40
41
|
const messages = defineMessages({
|
|
41
42
|
visibleToAll: {
|
|
42
43
|
id: 'ui.feedObject.visibleToAll',
|
|
@@ -134,7 +135,7 @@ const Root = styled(Widget, {
|
|
|
134
135
|
* @param inProps
|
|
135
136
|
*/
|
|
136
137
|
export default function FeedObject(inProps) {
|
|
137
|
-
var _a;
|
|
138
|
+
var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m;
|
|
138
139
|
// PROPS
|
|
139
140
|
const props = useThemeProps({
|
|
140
141
|
props: inProps,
|
|
@@ -163,6 +164,8 @@ export default function FeedObject(inProps) {
|
|
|
163
164
|
const [isReplying, setIsReplying] = useState(false);
|
|
164
165
|
const [selectedActivities, setSelectedActivities] = useState(getInitialSelectedActivitiesType());
|
|
165
166
|
const [expanded, setExpanded] = useState(summaryExpanded);
|
|
167
|
+
const hasEvent = useMemo(() => { var _a; return (obj === null || obj === void 0 ? void 0 : obj.medias.length) && ((_a = obj.medias[0].embed) === null || _a === void 0 ? void 0 : _a.embed_type) === MEDIA_EMBED_SC_SHARED_EVENT; }, [obj === null || obj === void 0 ? void 0 : obj.medias]);
|
|
168
|
+
const _hideFollowAction = useMemo(() => { var _a, _b, _c, _d; return hideFollowAction || (hasEvent && ((_d = (_c = (_b = (_a = obj === null || obj === void 0 ? void 0 : obj.medias) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.embed) === null || _c === void 0 ? void 0 : _c.metadata) === null || _d === void 0 ? void 0 : _d.active) === false); }, [hideFollowAction, hasEvent, obj]);
|
|
166
169
|
// INTL
|
|
167
170
|
const intl = useIntl();
|
|
168
171
|
/**
|
|
@@ -428,7 +431,8 @@ export default function FeedObject(inProps) {
|
|
|
428
431
|
template === SCFeedObjectTemplateType.SEARCH) {
|
|
429
432
|
objElement = (_jsx(React.Fragment, { children: obj ? (_jsxs(Box, Object.assign({ className: classNames({ [classes.deleted]: obj && obj.deleted }) }, { children: [obj.categories.length > 0 && (_jsxs("div", Object.assign({ className: classes.category }, { children: [_jsxs(_Fragment, { children: [obj.group && (_jsx("div", Object.assign({ className: classes.group }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && (_jsx("div", Object.assign({ className: classes.event }, { children: _jsx(Chip, { color: "secondary", size: "small", label: obj.event.name, icon: _jsx(Icon, { children: "CalendarIcon" }), component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id) })))] }), obj.categories.map((c) => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, c) }, { children: _jsx(Typography, Object.assign({ variant: "overline" }, { children: c.name })) }), c.id)))] }))), obj.group && !obj.categories.length && (_jsx("div", Object.assign({ className: classes.group }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), label: obj.group.name, component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && !obj.categories.length && (_jsx("div", Object.assign({ className: classes.event }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "CalendarIcon" }), label: obj.event.name, component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id) }))), _jsx(CardHeader, { className: classes.header, avatar: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !obj.author.community_badge }, { children: _jsx(Avatar, Object.assign({ "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, { children: obj.author.username })) })) })), title: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: obj.author.username })), subheader: _jsxs(_Fragment, { children: [_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)), className: classes.activityAt }, { children: _jsx(DateTimeAgo, { component: 'span', date: obj.added_at }) })), obj.location && (_jsxs(_Fragment, { children: [_jsx(Bullet, {}), _jsxs(Box, Object.assign({ className: classes.location }, { children: [_jsx(Icon, { children: "add_location_alt" }), (_a = obj.location) === null || _a === void 0 ? void 0 : _a.location] }))] })), _jsx(Bullet, {}), _jsx(Box, Object.assign({ className: classes.tag }, { children: obj.addressing.length > 0 ? (_jsx(Tags, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : obj.group ? (_jsx(Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToGroup, { group: obj.group.name })}` }, { children: _jsx(Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "groups" })) }))) : (_jsx(Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToAll)}` }, { children: _jsx(Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "public" })) }))) }))] }), action: renderHeaderAction() }), _jsxs(CardContent, Object.assign({ classes: { root: classes.content } }, { children: [_jsx(Box, Object.assign({ className: classes.titleSection }, { children: 'title' in obj && (_jsx(_Fragment, { children: template === SCFeedObjectTemplateType.DETAIL ? (_jsx(Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title }))) : (_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)) }, { children: _jsx(Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title })) }))) })) })), _jsx(Box, Object.assign({ className: classes.textSection }, { children: getContributionSummary(obj, template) })), _jsx(Box, Object.assign({ className: classes.mediasSection }, { children: _jsx(FeedObjectMediaPreview, Object.assign({ medias: obj.medias }, FeedObjectMediaPreviewProps)) })), _jsx(Box, Object.assign({ className: classes.pollsSection }, { children: obj['poll'] && (_jsx(PollObject, Object.assign({ visible: pollVisible ||
|
|
430
433
|
template === SCFeedObjectTemplateType.DETAIL ||
|
|
431
|
-
Boolean(obj.type !== SCContributionType.DISCUSSION && !obj.html && !obj.medias.length), feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, onToggleVisibility: handleTogglePollVisibility }, PollObjectProps))) })), _jsx(Box, Object.assign({ className: classes.infoSection }, { children: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [!hideParticipantsPreview && (_jsx(ContributorsFeedObject, Object.assign({ feedObject: obj, feedObjectType: obj.type }, ContributorsFeedObjectProps, { cacheStrategy: cacheStrategy }))), !
|
|
434
|
+
Boolean(obj.type !== SCContributionType.DISCUSSION && !obj.html && !obj.medias.length), feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, onToggleVisibility: handleTogglePollVisibility }, PollObjectProps))) })), _jsx(Box, Object.assign({ className: classes.infoSection }, { children: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [!hideParticipantsPreview && (_jsx(ContributorsFeedObject, Object.assign({ feedObject: obj, feedObjectType: obj.type }, ContributorsFeedObjectProps, { cacheStrategy: cacheStrategy }))), !_hideFollowAction && _jsx(Follow, Object.assign({ feedObject: obj, feedObjectType: obj.type, handleFollow: handleFollow }, FollowButtonProps))] })) }))] })), _jsxs(CardActions, Object.assign({ className: classes.actionsSection }, { children: [_jsx(Actions, Object.assign({ feedObjectId: feedObjectId, feedObjectType: feedObjectType, feedObject: obj, hideCommentAction: template === SCFeedObjectTemplateType.DETAIL || (hasEvent && !((_c = (_b = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.active)), handleExpandActivities: template === SCFeedObjectTemplateType.PREVIEW ? handleExpandActivities : null, hideVoteAction: hasEvent && !((_f = (_d = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _d === void 0 ? void 0 : _d.metadata) === null || _f === void 0 ? void 0 : _f.active), hideShareAction: hasEvent && !((_h = (_g = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.active), VoteActionProps: { onVoteAction: handleVoteSuccess } }, ActionsProps)), (template === SCFeedObjectTemplateType.DETAIL && (!hasEvent || ((_m = (_l = (_k = (_j = obj === null || obj === void 0 ? void 0 : obj.medias) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.embed) === null || _l === void 0 ? void 0 : _l.metadata) === null || _m === void 0 ? void 0 : _m.active) === true)) ||
|
|
435
|
+
(expandedActivities && (_jsx(Box, Object.assign({ className: classes.replyContent }, { children: _jsx(CommentObjectReplyComponent, Object.assign({ id: `reply-feedObject-${obj.id}`, onReply: handleReply, editable: !isReplying || Boolean(obj) }, CommentObjectReplyComponentProps), Number(isReplying)) }))))] })), template === SCFeedObjectTemplateType.PREVIEW && (obj.comment_count > 0 || (feedObjectActivities && feedObjectActivities.length > 0)) && (_jsx(Collapse, Object.assign({ in: expandedActivities, timeout: "auto", classes: { root: classes.activitiesSection } }, { children: _jsx(CardContent, Object.assign({ className: classes.activitiesContent }, { children: _jsx(Activities, Object.assign({ feedObject: obj, feedObjectActivities: feedObjectActivities, activitiesType: selectedActivities, onSetSelectedActivities: handleSelectedActivities, comments: comments, CommentsObjectProps: {
|
|
432
436
|
CommentComponentProps: Object.assign({ onDelete: handleDeleteComment, truncateContent: true, CommentsObjectComponentProps: { inPlaceLoadMoreContents: false } }, CommentComponentProps),
|
|
433
437
|
CommentObjectSkeletonProps: CommentObjectSkeletonProps
|
|
434
438
|
}, cacheStrategy: cacheStrategy }, ActivitiesProps), selectedActivities) })) }))), composerOpen && (_jsx(Composer, { open: composerOpen, feedObject: obj, onClose: handleToggleEdit, onSuccess: handleEditSuccess, maxWidth: "sm", fullWidth: true }))] }))) : (_jsx(FeedObjectSkeleton, Object.assign({ template: template }, FeedObjectSkeletonProps))) }));
|
|
@@ -75,6 +75,7 @@ const messages = defineMessages({
|
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
export default function ContributionActionsMenu(props) {
|
|
78
|
+
var _a, _b, _c;
|
|
78
79
|
// PROPS
|
|
79
80
|
const { className, feedObjectId, feedObject, feedObjectType = SCContributionType.POST, commentObjectId, commentObject, onFlagContribution, onEditContribution, onHideContribution, onDeleteContribution, onRestoreContribution, onSuspendNotificationContribution, onSuspendNotificationEvent, PopperProps = {} } = props, rest = __rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "commentObjectId", "commentObject", "onFlagContribution", "onEditContribution", "onHideContribution", "onDeleteContribution", "onRestoreContribution", "onSuspendNotificationContribution", "onSuspendNotificationEvent", "PopperProps"]);
|
|
80
81
|
// INTL
|
|
@@ -719,7 +720,13 @@ export default function ContributionActionsMenu(props) {
|
|
|
719
720
|
/**
|
|
720
721
|
* Renders component
|
|
721
722
|
*/
|
|
722
|
-
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, { children: [_jsx(IconButton
|
|
723
|
+
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, { children: [_jsx(IconButton
|
|
724
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
725
|
+
// @ts-ignore
|
|
726
|
+
, Object.assign({
|
|
727
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
728
|
+
// @ts-ignore
|
|
729
|
+
disabled: contributionObj && ((_a = contributionObj === null || contributionObj === void 0 ? void 0 : contributionObj.medias) === null || _a === void 0 ? void 0 : _a.length) && !((_c = (_b = contributionObj.medias[0].embed) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.active), ref: (ref) => {
|
|
723
730
|
popperRef.current = ref;
|
|
724
731
|
}, "aria-haspopup": "true", onClick: handleOpen, className: classes.button, size: "small" }, { children: contributionObj && (contributionObj.collapsed || contributionObj.deleted) ? (_jsxs("span", Object.assign({ className: classes.visibilityIcons }, { children: [contributionObj.collapsed ? _jsx(Icon, { children: "visibility_off" }) : _jsx(Icon, { children: "delete" }), _jsx(Icon, { children: "expand_more" })] }))) : (_jsx(Icon, { children: "more_vert" })) })), isMobile ? (_jsx(SwipeableDrawer, Object.assign({ open: open, onClose: handleClose, onOpen: handleOpen, anchor: "bottom", disableSwipeToOpen: true }, { children: renderContent() }))) : (_jsx(PopperRoot, Object.assign({ open: open, anchorEl: popperRef.current, role: undefined, transition: true, className: classes.popperRoot }, PopperProps, { placement: "bottom-end" }, { children: ({ TransitionProps, placement }) => (_jsx(Grow, Object.assign({}, TransitionProps, { style: { transformOrigin: placement === 'bottom' ? 'center top' : 'center bottom' } }, { children: _jsx(Paper, Object.assign({ variant: 'outlined', className: classes.paper }, { children: _jsx(ClickAwayListener, Object.assign({ onClickAway: handleClose }, { children: renderContent() })) })) }))) }))), openConfirmDialog && (_jsx(ConfirmDialog, Object.assign({ open: openConfirmDialog }, (currentAction === DELETE_CONTRIBUTION
|
|
725
732
|
? {
|