@selfcommunity/react-ui 0.7.50-events.111 → 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/shared/EventInfoDetails/index.d.ts +1 -0
- package/lib/cjs/shared/EventInfoDetails/index.js +13 -9
- 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/shared/EventInfoDetails/index.d.ts +1 -0
- package/lib/esm/shared/EventInfoDetails/index.js +14 -10
- package/lib/umd/react-ui.js +1 -1
- package/package.json +7 -7
|
@@ -8,6 +8,7 @@ const system_1 = require("@mui/system");
|
|
|
8
8
|
const react_core_1 = require("@selfcommunity/react-core");
|
|
9
9
|
const types_1 = require("@selfcommunity/types");
|
|
10
10
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
11
|
+
const react_1 = require("react");
|
|
11
12
|
const react_intl_1 = require("react-intl");
|
|
12
13
|
const BaseItem_1 = tslib_1.__importDefault(require("../../shared/BaseItem"));
|
|
13
14
|
const Calendar_1 = tslib_1.__importDefault(require("../../shared/Calendar"));
|
|
@@ -25,6 +26,7 @@ const classes = {
|
|
|
25
26
|
snippetRoot: `${constants_1.PREFIX}-snippet-root`,
|
|
26
27
|
detailImageWrapper: `${constants_1.PREFIX}-detail-image-wrapper`,
|
|
27
28
|
detailImage: `${constants_1.PREFIX}-detail-image`,
|
|
29
|
+
detailInProgress: `${constants_1.PREFIX}-detail-in-progress`,
|
|
28
30
|
detailNameWrapper: `${constants_1.PREFIX}-detail-name-wrapper`,
|
|
29
31
|
detailName: `${constants_1.PREFIX}-detail-name`,
|
|
30
32
|
detailContent: `${constants_1.PREFIX}-detail-content`,
|
|
@@ -34,11 +36,14 @@ const classes = {
|
|
|
34
36
|
detailActions: `${constants_1.PREFIX}-detail-actions`,
|
|
35
37
|
previewImageWrapper: `${constants_1.PREFIX}-preview-image-wrapper`,
|
|
36
38
|
previewImage: `${constants_1.PREFIX}-preview-image`,
|
|
39
|
+
previewInProgress: `${constants_1.PREFIX}-preview-in-progress`,
|
|
37
40
|
previewNameWrapper: `${constants_1.PREFIX}-preview-name-wrapper`,
|
|
38
41
|
previewName: `${constants_1.PREFIX}-preview-name`,
|
|
39
42
|
previewContent: `${constants_1.PREFIX}-preview-content`,
|
|
40
43
|
previewActions: `${constants_1.PREFIX}-preview-actions`,
|
|
44
|
+
snippetImage: `${constants_1.PREFIX}-snippet-image`,
|
|
41
45
|
snippetAvatar: `${constants_1.PREFIX}-snippet-avatar`,
|
|
46
|
+
snippetInProgress: `${constants_1.PREFIX}-snippet-in-progress`,
|
|
42
47
|
snippetPrimary: `${constants_1.PREFIX}-snippet-primary`,
|
|
43
48
|
snippetSecondary: `${constants_1.PREFIX}-snippet-secondary`,
|
|
44
49
|
snippetActions: `${constants_1.PREFIX}-snippet-actions`
|
|
@@ -101,9 +106,10 @@ function Event(inProps) {
|
|
|
101
106
|
props: inProps,
|
|
102
107
|
name: constants_1.PREFIX
|
|
103
108
|
});
|
|
104
|
-
const { id = `event_object_${props.eventId ? props.eventId : props.event ? props.event.id : ''}`, eventId = null, event = null, className = null, template = event_1.SCEventTemplateType.SNIPPET, hideEventParticipants = false, hideEventPlanner = false, actions, EventParticipantsButtonComponentProps = {}, EventSkeletonComponentProps = {} } = props, rest = tslib_1.__rest(props, ["id", "eventId", "event", "className", "template", "hideEventParticipants", "hideEventPlanner", "actions", "EventParticipantsButtonComponentProps", "EventSkeletonComponentProps"]);
|
|
109
|
+
const { id = `event_object_${props.eventId ? props.eventId : props.event ? props.event.id : ''}`, eventId = null, event = null, className = null, template = event_1.SCEventTemplateType.SNIPPET, hideInProgress = false, hideEventParticipants = false, hideEventPlanner = false, actions, EventParticipantsButtonComponentProps = {}, EventSkeletonComponentProps = {} } = props, rest = tslib_1.__rest(props, ["id", "eventId", "event", "className", "template", "hideInProgress", "hideEventParticipants", "hideEventPlanner", "actions", "EventParticipantsButtonComponentProps", "EventSkeletonComponentProps"]);
|
|
105
110
|
// STATE
|
|
106
111
|
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
112
|
+
const inProgress = (0, react_1.useMemo)(() => scEvent && scEvent.active && scEvent.running, [scEvent]);
|
|
107
113
|
// CONTEXT
|
|
108
114
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
109
115
|
// HOOKS
|
|
@@ -119,13 +125,13 @@ function Event(inProps) {
|
|
|
119
125
|
*/
|
|
120
126
|
let contentObj;
|
|
121
127
|
if (template === event_1.SCEventTemplateType.DETAIL) {
|
|
122
|
-
contentObj = ((0, jsx_runtime_1.jsxs)(DetailRoot, Object.assign({ className: classes.detailRoot }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.detailImageWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.CardMedia, { component: "img", image: scEvent.image_medium, alt: scEvent.name, className: classes.detailImage }), (0, jsx_runtime_1.jsx)(Calendar_1.default, { day: new Date(scEvent.start_date).getDate() })] })), (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.detailContent }, { children: [scEvent.active ? ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.detailNameWrapper }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3", className: classes.detailName }, { children: scEvent.name })) }))) : ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.detailNameWrapper }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3", className: classes.detailName }, { children: scEvent.name })) }))), (0, jsx_runtime_1.jsx)(EventInfoDetails_1.default, { event: scEvent }), !hideEventPlanner && ((0, jsx_runtime_1.jsx)(User_1.default, { user: scEvent.managed_by, elevation: 0, secondary: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "caption" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.myEventsWidget.planner", defaultMessage: "ui.myEventsWidget.planner" }) })), actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), className: classes.detailUser })), !hideEventParticipants && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Divider, { className: classes.detailFirstDivider }), (0, jsx_runtime_1.jsx)(EventParticipantsButton_1.default, Object.assign({ event: scEvent }, EventParticipantsButtonComponentProps))] })), (0, jsx_runtime_1.jsx)(material_1.Divider, { className: classes.detailSecondDivider })] })), actions !== null && actions !== void 0 ? actions : ((0, jsx_runtime_1.jsx)(material_1.CardActions, Object.assign({ className: classes.detailActions }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", variant: "outlined", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })))] })));
|
|
128
|
+
contentObj = ((0, jsx_runtime_1.jsxs)(DetailRoot, Object.assign({ className: classes.detailRoot }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.detailImageWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.CardMedia, { component: "img", image: scEvent.image_medium, alt: scEvent.name, className: classes.detailImage }), !hideInProgress && inProgress && ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", component: "div", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.event.inProgress", defaultMessage: "ui.event.inProgress" }), className: classes.detailInProgress })), (0, jsx_runtime_1.jsx)(Calendar_1.default, { day: new Date(scEvent.start_date).getDate() })] })), (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.detailContent }, { children: [scEvent.active ? ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.detailNameWrapper }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3", className: classes.detailName }, { children: scEvent.name })) }))) : ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.detailNameWrapper }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3", className: classes.detailName }, { children: scEvent.name })) }))), (0, jsx_runtime_1.jsx)(EventInfoDetails_1.default, { event: scEvent }), !hideEventPlanner && ((0, jsx_runtime_1.jsx)(User_1.default, { user: scEvent.managed_by, elevation: 0, secondary: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "caption" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.myEventsWidget.planner", defaultMessage: "ui.myEventsWidget.planner" }) })), actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), className: classes.detailUser })), !hideEventParticipants && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Divider, { className: classes.detailFirstDivider }), (0, jsx_runtime_1.jsx)(EventParticipantsButton_1.default, Object.assign({ event: scEvent }, EventParticipantsButtonComponentProps))] })), (0, jsx_runtime_1.jsx)(material_1.Divider, { className: classes.detailSecondDivider })] })), actions !== null && actions !== void 0 ? actions : ((0, jsx_runtime_1.jsx)(material_1.CardActions, Object.assign({ className: classes.detailActions }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", variant: "outlined", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })))] })));
|
|
123
129
|
}
|
|
124
130
|
else if (template === event_1.SCEventTemplateType.PREVIEW) {
|
|
125
|
-
contentObj = ((0, jsx_runtime_1.jsxs)(PreviewRoot, Object.assign({ className: classes.previewRoot }, { children: [(0, jsx_runtime_1.
|
|
131
|
+
contentObj = ((0, jsx_runtime_1.jsxs)(PreviewRoot, Object.assign({ className: classes.previewRoot }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ position: "relative", className: classes.previewImageWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.CardMedia, { component: "img", image: scEvent.image_medium, alt: scEvent.name, className: classes.previewImage }), !hideInProgress && inProgress && ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", component: "div", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.event.inProgress", defaultMessage: "ui.event.inProgress" }), className: classes.previewInProgress }))] })), (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.previewContent }, { children: [(0, jsx_runtime_1.jsx)(EventInfoDetails_1.default, { event: scEvent, hidePrivacyIcon: true, hasLocationInfo: false, beforePrivacyInfo: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.previewNameWrapper }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.previewName }, { children: scEvent.name })) })) }), !hideEventParticipants && (0, jsx_runtime_1.jsx)(EventParticipantsButton_1.default, Object.assign({ event: scEvent, hideCaption: true }, EventParticipantsButtonComponentProps))] })), actions !== null && actions !== void 0 ? actions : ((0, jsx_runtime_1.jsx)(material_1.CardActions, Object.assign({ className: classes.previewActions }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", variant: "outlined", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })))] })));
|
|
126
132
|
}
|
|
127
133
|
else {
|
|
128
|
-
contentObj = ((0, jsx_runtime_1.jsx)(SnippetRoot, { elevation: 0, square: true, disableTypography: true, className: classes.snippetRoot, image: (0, jsx_runtime_1.jsx)(material_1.Avatar, { variant: "square", alt: scEvent.name, src: scEvent.image_medium, className: classes.snippetAvatar }), primary: (0, jsx_runtime_1.jsxs)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.snippetPrimary }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ component: "span" }, { children: `${intl.formatDate(scEvent.start_date, {
|
|
134
|
+
contentObj = ((0, jsx_runtime_1.jsx)(SnippetRoot, { elevation: 0, square: true, disableTypography: true, className: classes.snippetRoot, image: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.snippetImage }, { children: [(0, jsx_runtime_1.jsx)(material_1.Avatar, { variant: "square", alt: scEvent.name, src: scEvent.image_medium, className: classes.snippetAvatar }), ' ', !hideInProgress && inProgress && ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", component: "div", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.event.inProgress", defaultMessage: "ui.event.inProgress" }), className: classes.snippetInProgress }))] })), primary: (0, jsx_runtime_1.jsxs)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.snippetPrimary }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ component: "span" }, { children: `${intl.formatDate(scEvent.start_date, {
|
|
129
135
|
weekday: 'long',
|
|
130
136
|
month: 'long',
|
|
131
137
|
day: 'numeric'
|
|
@@ -120,7 +120,7 @@ function EventHeader(inProps) {
|
|
|
120
120
|
/**
|
|
121
121
|
* Handles callback subscribe/unsubscribe event
|
|
122
122
|
*/
|
|
123
|
-
const handleSubscribe = (
|
|
123
|
+
const handleSubscribe = (_event, status) => {
|
|
124
124
|
setSCEvent(Object.assign({}, scEvent, { subscription_status: status }));
|
|
125
125
|
};
|
|
126
126
|
/**
|
|
@@ -74,6 +74,6 @@ function EventInfoWidget(inProps) {
|
|
|
74
74
|
if (!scEvent) {
|
|
75
75
|
return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
|
|
76
76
|
}
|
|
77
|
-
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: classes.root }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.content }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.titleWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "info" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.infoEventWidget.title", defaultMessage: "ui.infoEventWidget.title" }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.textWrapper }, { children: (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ component: "span", variant: "body1" }, { children: [description, showButton && !expanded && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", variant: "text", className: classes.showMore, onClick: handleToggleSummary }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.infoEventWidget.showMore", defaultMessage: "ui.infoEventWidget.showMore" }) })))] })) })), (0, jsx_runtime_1.jsx)(EventInfoDetails_1.default, { event: scEvent, hasRecurringInfo: true, hasCreatedInfo: true, hasLocationInfo: showInfo
|
|
77
|
+
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: classes.root }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.content }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.titleWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "info" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.infoEventWidget.title", defaultMessage: "ui.infoEventWidget.title" }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.textWrapper }, { children: (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ component: "span", variant: "body1" }, { children: [description, showButton && !expanded && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", variant: "text", className: classes.showMore, onClick: handleToggleSummary }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.infoEventWidget.showMore", defaultMessage: "ui.infoEventWidget.showMore" }) })))] })) })), (0, jsx_runtime_1.jsx)(EventInfoDetails_1.default, { event: scEvent, hasRecurringInfo: true, hasCreatedInfo: true, hasLocationInfo: showInfo })] })) })));
|
|
78
78
|
}
|
|
79
79
|
exports.default = EventInfoWidget;
|
|
@@ -19,6 +19,7 @@ const Widget_1 = tslib_1.__importDefault(require("../Widget"));
|
|
|
19
19
|
const constants_1 = require("./constants");
|
|
20
20
|
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
21
21
|
const TabContentComponent_1 = tslib_1.__importDefault(require("./TabContentComponent"));
|
|
22
|
+
const types_1 = require("./types");
|
|
22
23
|
const classes = {
|
|
23
24
|
root: `${constants_1.PREFIX}-root`,
|
|
24
25
|
content: `${constants_1.PREFIX}-content`,
|
|
@@ -61,18 +62,29 @@ function EventMembersWidget(inProps) {
|
|
|
61
62
|
cacheStrategy,
|
|
62
63
|
visibleItems: limit
|
|
63
64
|
}, widget_1.stateWidgetInitializer);
|
|
65
|
+
const [participantsCount, setParticipantsCount] = (0, react_1.useState)(0);
|
|
64
66
|
const [invitedCount, setInvitedCount] = (0, react_1.useState)(0);
|
|
65
67
|
const [requestsCount, setRequestsCount] = (0, react_1.useState)(0);
|
|
66
68
|
const [requestsUsers, setRequestsUsers] = (0, react_1.useState)([]);
|
|
67
69
|
const [tabValue, setTabValue] = (0, react_1.useState)('1');
|
|
68
|
-
const [refresh, setRefresh] = (0, react_1.useState)(
|
|
70
|
+
const [refresh, setRefresh] = (0, react_1.useState)(null);
|
|
69
71
|
// CONTEXT
|
|
70
72
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
71
73
|
// HOOKS
|
|
72
74
|
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
73
75
|
// CONSTS
|
|
74
76
|
const hasAllow = (0, react_1.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]);
|
|
75
|
-
const title = (0, react_1.useMemo)(() =>
|
|
77
|
+
const title = (0, react_1.useMemo)(() => {
|
|
78
|
+
switch (tabValue) {
|
|
79
|
+
case types_1.TabValueEnum.THREE:
|
|
80
|
+
return 'ui.eventMembersWidget.requests';
|
|
81
|
+
case types_1.TabValueEnum.TWO:
|
|
82
|
+
return 'ui.eventMembersWidget.invited';
|
|
83
|
+
case types_1.TabValueEnum.ONE:
|
|
84
|
+
default:
|
|
85
|
+
return 'ui.eventMembersWidget.participants';
|
|
86
|
+
}
|
|
87
|
+
}, [tabValue]);
|
|
76
88
|
// CALLBACKS
|
|
77
89
|
const _initParticipants = (0, react_1.useCallback)(() => {
|
|
78
90
|
if (!participants.initialized && !participants.isLoadingNext) {
|
|
@@ -80,13 +92,14 @@ function EventMembersWidget(inProps) {
|
|
|
80
92
|
api_services_1.EventService.getUsersGoingToEvent(scEvent.id, Object.assign({}, endpointQueryParams))
|
|
81
93
|
.then((payload) => {
|
|
82
94
|
dispatchParticipants({ type: widget_1.actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: Object.assign(Object.assign({}, payload), { initialized: true }) });
|
|
95
|
+
setParticipantsCount(payload.count);
|
|
83
96
|
})
|
|
84
97
|
.catch((error) => {
|
|
85
98
|
dispatchParticipants({ type: widget_1.actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
|
|
86
99
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
87
100
|
});
|
|
88
101
|
}
|
|
89
|
-
}, [participants.isLoadingNext, participants.initialized,
|
|
102
|
+
}, [participants.isLoadingNext, participants.initialized, scEvent]);
|
|
90
103
|
const _initInvited = (0, react_1.useCallback)(() => {
|
|
91
104
|
if (!invited.initialized && !invited.isLoadingNext && hasAllow) {
|
|
92
105
|
dispatchInvited({ type: widget_1.actionWidgetTypes.LOADING_NEXT });
|
|
@@ -100,7 +113,7 @@ function EventMembersWidget(inProps) {
|
|
|
100
113
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
101
114
|
});
|
|
102
115
|
}
|
|
103
|
-
}, [invited.isLoadingNext, invited.initialized,
|
|
116
|
+
}, [invited.isLoadingNext, invited.initialized, scUserContext.user, scEvent]);
|
|
104
117
|
const _initRequests = (0, react_1.useCallback)(() => {
|
|
105
118
|
if (!requests.initialized && !requests.isLoadingNext && hasAllow) {
|
|
106
119
|
dispatchRequests({ type: widget_1.actionWidgetTypes.LOADING_NEXT });
|
|
@@ -115,15 +128,19 @@ function EventMembersWidget(inProps) {
|
|
|
115
128
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
116
129
|
});
|
|
117
130
|
}
|
|
118
|
-
}, [requests.isLoadingNext, requests.initialized,
|
|
131
|
+
}, [requests.isLoadingNext, requests.initialized, scUserContext.user, scEvent]);
|
|
119
132
|
// EFFECTS
|
|
120
133
|
(0, react_1.useEffect)(() => {
|
|
121
134
|
let _t;
|
|
122
135
|
if (scUserContext.user && scEvent) {
|
|
123
136
|
_t = setTimeout(() => {
|
|
124
|
-
if (refresh) {
|
|
137
|
+
if (refresh === types_1.TabValueEnum.ONE) {
|
|
138
|
+
_initParticipants();
|
|
139
|
+
setRefresh(null);
|
|
140
|
+
}
|
|
141
|
+
else if (refresh === types_1.TabValueEnum.TWO) {
|
|
125
142
|
_initInvited();
|
|
126
|
-
setRefresh(
|
|
143
|
+
setRefresh(null);
|
|
127
144
|
}
|
|
128
145
|
else {
|
|
129
146
|
_initParticipants();
|
|
@@ -140,6 +157,15 @@ function EventMembersWidget(inProps) {
|
|
|
140
157
|
const handleTabChange = (0, react_1.useCallback)((_evt, newTabValue) => {
|
|
141
158
|
setTabValue(newTabValue);
|
|
142
159
|
}, []);
|
|
160
|
+
const handleRefresh = (0, react_1.useCallback)((_tabValue) => {
|
|
161
|
+
if (_tabValue === types_1.TabValueEnum.ONE) {
|
|
162
|
+
dispatchParticipants({ type: widget_1.actionWidgetTypes.RESET });
|
|
163
|
+
}
|
|
164
|
+
else if (_tabValue === types_1.TabValueEnum.TWO) {
|
|
165
|
+
dispatchInvited({ type: widget_1.actionWidgetTypes.RESET });
|
|
166
|
+
}
|
|
167
|
+
setRefresh(_tabValue);
|
|
168
|
+
}, []);
|
|
143
169
|
if (!scEvent && !participants.initialized) {
|
|
144
170
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
145
171
|
}
|
|
@@ -147,15 +173,15 @@ function EventMembersWidget(inProps) {
|
|
|
147
173
|
if (!scEvent) {
|
|
148
174
|
return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
|
|
149
175
|
}
|
|
150
|
-
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: classes.root }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.content }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.title }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: title, defaultMessage: title }) })), (0, jsx_runtime_1.jsxs)(lab_1.TabContext, Object.assign({ value: tabValue }, { children: [(0, jsx_runtime_1.jsxs)(lab_1.TabList, Object.assign({ className: classes.tabsWrapper, onChange: handleTabChange, textColor: "primary", indicatorColor: "primary", variant: "fullWidth" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Tab, { label: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3" }, { children:
|
|
176
|
+
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: classes.root }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.content }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.title }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: title, defaultMessage: title }) })), (0, jsx_runtime_1.jsxs)(lab_1.TabContext, Object.assign({ value: tabValue }, { children: [(0, jsx_runtime_1.jsxs)(lab_1.TabList, Object.assign({ className: classes.tabsWrapper, onChange: handleTabChange, textColor: "primary", indicatorColor: "primary", variant: "fullWidth" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Tab, { label: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3" }, { children: participantsCount })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "subtitle2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMembersWidget.participants", defaultMessage: "ui.eventMembersWidget.participants" }) }))] })), value: types_1.TabValueEnum.ONE }), hasAllow && ((0, jsx_runtime_1.jsx)(material_1.Tab, { label: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3" }, { children: invitedCount })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "subtitle2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMembersWidget.invited", defaultMessage: "ui.eventMembersWidget.invited" }) }))] })), value: types_1.TabValueEnum.TWO })), hasAllow && ((0, jsx_runtime_1.jsx)(material_1.Tab, { label: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3" }, { children: requestsCount })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "subtitle2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMembersWidget.requests", defaultMessage: "ui.eventMembersWidget.requests" }) }))] })), value: types_1.TabValueEnum.THREE }))] })), (0, jsx_runtime_1.jsx)(lab_1.TabPanel, Object.assign({ value: types_1.TabValueEnum.ONE, className: classes.tabPanel }, { children: (0, jsx_runtime_1.jsx)(TabContentComponent_1.default, { tabValue: types_1.TabValueEnum.ONE, state: participants, dispatch: dispatchParticipants, userProps: userProps, dialogProps: dialogProps, handleRefresh: handleRefresh }) })), hasAllow && ((0, jsx_runtime_1.jsx)(lab_1.TabPanel, Object.assign({ value: types_1.TabValueEnum.TWO, className: classes.tabPanel }, { children: (0, jsx_runtime_1.jsx)(TabContentComponent_1.default, { tabValue: types_1.TabValueEnum.TWO, state: invited, dispatch: dispatchInvited, userProps: userProps, dialogProps: dialogProps, actionProps: {
|
|
151
177
|
scEvent,
|
|
152
178
|
setCount: setInvitedCount
|
|
153
|
-
},
|
|
179
|
+
}, handleRefresh: handleRefresh }) }))), hasAllow && ((0, jsx_runtime_1.jsx)(lab_1.TabPanel, Object.assign({ value: types_1.TabValueEnum.THREE, className: classes.tabPanel }, { children: (0, jsx_runtime_1.jsx)(TabContentComponent_1.default, { tabValue: types_1.TabValueEnum.THREE, state: requests, dispatch: dispatchRequests, userProps: userProps, dialogProps: dialogProps, actionProps: {
|
|
154
180
|
scEvent,
|
|
155
181
|
count: requestsCount,
|
|
156
182
|
setCount: setRequestsCount,
|
|
157
183
|
users: requestsUsers,
|
|
158
184
|
setUsers: setRequestsUsers
|
|
159
|
-
} }) })))] }))] })) })));
|
|
185
|
+
}, handleRefresh: handleRefresh }) })))] }))] })) })));
|
|
160
186
|
}
|
|
161
187
|
exports.default = EventMembersWidget;
|
|
@@ -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 {};
|
|
@@ -6,9 +6,11 @@ const material_1 = require("@mui/material");
|
|
|
6
6
|
const api_services_1 = require("@selfcommunity/api-services");
|
|
7
7
|
const utils_1 = require("@selfcommunity/utils");
|
|
8
8
|
const notistack_1 = require("notistack");
|
|
9
|
+
const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
|
|
9
10
|
const react_1 = require("react");
|
|
10
11
|
const react_intl_1 = require("react-intl");
|
|
11
12
|
const Errors_1 = require("../../constants/Errors");
|
|
13
|
+
const PubSub_1 = require("../../constants/PubSub");
|
|
12
14
|
const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"));
|
|
13
15
|
const InfiniteScroll_1 = tslib_1.__importDefault(require("../../shared/InfiniteScroll"));
|
|
14
16
|
const widget_1 = require("../../utils/widget");
|
|
@@ -17,6 +19,7 @@ const EventInviteButton_1 = tslib_1.__importDefault(require("../EventInviteButto
|
|
|
17
19
|
const InviteUserEventButton_1 = tslib_1.__importDefault(require("../InviteUserEventButton"));
|
|
18
20
|
const User_1 = tslib_1.__importStar(require("../User"));
|
|
19
21
|
const constants_1 = require("./constants");
|
|
22
|
+
const types_1 = require("./types");
|
|
20
23
|
const classes = {
|
|
21
24
|
actionButton: `${constants_1.PREFIX}-action-button`,
|
|
22
25
|
eventButton: `${constants_1.PREFIX}-event-button`,
|
|
@@ -31,13 +34,25 @@ const DialogRoot = (0, material_1.styled)(BaseDialog_1.default, {
|
|
|
31
34
|
})(() => ({}));
|
|
32
35
|
function TabContentComponent(props) {
|
|
33
36
|
// PROPS
|
|
34
|
-
const { state, dispatch, userProps, dialogProps, actionProps,
|
|
37
|
+
const { tabValue, state, dispatch, userProps, dialogProps, actionProps, handleRefresh } = props;
|
|
35
38
|
// STATE
|
|
36
39
|
const [openDialog, setOpenDialog] = (0, react_1.useState)(false);
|
|
40
|
+
// REFS
|
|
41
|
+
const updatesInvited = (0, react_1.useRef)(null);
|
|
42
|
+
const updatesParticipants = (0, react_1.useRef)(null);
|
|
37
43
|
// HOOKS
|
|
38
44
|
const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
|
|
39
45
|
// CONSTS
|
|
40
|
-
const users = (0, react_1.useMemo)(() => (tabValue ===
|
|
46
|
+
const users = (0, react_1.useMemo)(() => (tabValue === types_1.TabValueEnum.THREE ? actionProps === null || actionProps === void 0 ? void 0 : actionProps.users : state.results), [tabValue, actionProps, state]);
|
|
47
|
+
// EFFECTS
|
|
48
|
+
(0, react_1.useEffect)(() => {
|
|
49
|
+
updatesInvited.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.INVITE_MEMBER}`, handleInviteMember);
|
|
50
|
+
updatesParticipants.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.ADD_MEMBER}`, handleToggleMember);
|
|
51
|
+
return () => {
|
|
52
|
+
updatesInvited.current && pubsub_js_1.default.unsubscribe(updatesInvited.current);
|
|
53
|
+
updatesParticipants.current && pubsub_js_1.default.unsubscribe(updatesParticipants.current);
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
41
56
|
// HANDLERS
|
|
42
57
|
/**
|
|
43
58
|
* Handles pagination
|
|
@@ -55,13 +70,19 @@ function TabContentComponent(props) {
|
|
|
55
70
|
.catch((error) => {
|
|
56
71
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
57
72
|
});
|
|
58
|
-
}, [
|
|
73
|
+
}, [state.next, state.isLoadingNext, state.initialized]);
|
|
59
74
|
const handleToggleDialogOpen = (0, react_1.useCallback)(() => {
|
|
60
75
|
setOpenDialog((prev) => !prev);
|
|
61
76
|
}, []);
|
|
77
|
+
const handleToggleMember = (0, react_1.useCallback)(() => {
|
|
78
|
+
handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(types_1.TabValueEnum.ONE);
|
|
79
|
+
}, []);
|
|
80
|
+
const handleInviteMember = (0, react_1.useCallback)(() => {
|
|
81
|
+
handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(types_1.TabValueEnum.TWO);
|
|
82
|
+
}, []);
|
|
62
83
|
const getActionsComponent = (0, react_1.useCallback)((userId) => {
|
|
63
|
-
if (tabValue ===
|
|
64
|
-
const
|
|
84
|
+
if (tabValue === types_1.TabValueEnum.TWO && actionProps) {
|
|
85
|
+
const _handleInvitations = (invited) => {
|
|
65
86
|
var _a, _b;
|
|
66
87
|
if (invited) {
|
|
67
88
|
(_a = actionProps.setCount) === null || _a === void 0 ? void 0 : _a.call(actionProps, (prev) => prev - 1);
|
|
@@ -70,9 +91,9 @@ function TabContentComponent(props) {
|
|
|
70
91
|
(_b = actionProps.setCount) === null || _b === void 0 ? void 0 : _b.call(actionProps, (prev) => prev + 1);
|
|
71
92
|
}
|
|
72
93
|
};
|
|
73
|
-
return (0, jsx_runtime_1.jsx)(InviteUserEventButton_1.default, { event: actionProps.scEvent, userId: userId, handleInvitations:
|
|
94
|
+
return (0, jsx_runtime_1.jsx)(InviteUserEventButton_1.default, { event: actionProps.scEvent, userId: userId, handleInvitations: _handleInvitations });
|
|
74
95
|
}
|
|
75
|
-
else if (tabValue ===
|
|
96
|
+
else if (tabValue === types_1.TabValueEnum.THREE && actionProps) {
|
|
76
97
|
const handleConfirm = (id) => {
|
|
77
98
|
if (id) {
|
|
78
99
|
actionProps.setCount((prev) => prev - 1);
|
|
@@ -92,22 +113,21 @@ function TabContentComponent(props) {
|
|
|
92
113
|
return (0, jsx_runtime_1.jsx)(AcceptRequestUserEventButton_1.default, { event: actionProps.scEvent, userId: userId, handleConfirm: handleConfirm });
|
|
93
114
|
}
|
|
94
115
|
return undefined;
|
|
95
|
-
}, [tabValue, actionProps
|
|
96
|
-
if (tabValue ===
|
|
116
|
+
}, [tabValue, actionProps]);
|
|
117
|
+
if (tabValue === types_1.TabValueEnum.ONE && (actionProps === null || actionProps === void 0 ? void 0 : actionProps.count) === 0) {
|
|
97
118
|
return ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMembersWidget.noParticipants", defaultMessage: "ui.eventMembersWidget.noParticipants" }) })));
|
|
98
119
|
}
|
|
99
|
-
if (tabValue ===
|
|
120
|
+
else if (tabValue === types_1.TabValueEnum.TWO && state.count === 0 && actionProps) {
|
|
100
121
|
const date = actionProps.scEvent.end_date || actionProps.scEvent.start_date;
|
|
101
122
|
const disabled = new Date(date).getTime() < new Date().getTime();
|
|
102
123
|
const handleInvitations = (invited) => {
|
|
103
124
|
if (invited) {
|
|
104
|
-
|
|
105
|
-
setRefresh(true);
|
|
125
|
+
handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(tabValue);
|
|
106
126
|
}
|
|
107
127
|
};
|
|
108
128
|
return ((0, jsx_runtime_1.jsx)(EventInviteButton_1.default, { event: actionProps.scEvent, className: classes.eventButton, handleInvitations: handleInvitations, disabled: disabled }));
|
|
109
129
|
}
|
|
110
|
-
if (tabValue ===
|
|
130
|
+
else if (tabValue === types_1.TabValueEnum.THREE && (actionProps === null || actionProps === void 0 ? void 0 : actionProps.count) === 0) {
|
|
111
131
|
return ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMembersWidget.noOtherRequests", defaultMessage: "ui.eventMembersWidget.noOtherRequests" }) })));
|
|
112
132
|
}
|
|
113
133
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.List, { children: users === null || users === void 0 ? void 0 : users.map((user) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(User_1.default, Object.assign({ elevation: 0, user: user }, userProps, { actions: getActionsComponent(user.id) })) }, user.id))) }), state.count > state.visibleItems && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ onClick: handleToggleDialogOpen, className: classes.actionButton }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "caption" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMembersWidget.showAll", defaultMessage: "ui.eventMembersWidget.showAll" }) })) }))), openDialog && ((0, jsx_runtime_1.jsx)(DialogRoot, Object.assign({ className: classes.dialogRoot, title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.eventMembersWidget.title", id: "ui.eventMembersWidget.title" }), onClose: handleToggleDialogOpen, open: openDialog }, dialogProps, { children: (0, jsx_runtime_1.jsx)(InfiniteScroll_1.default, Object.assign({ dataLength: state.results.length, next: handleNext, hasMoreNext: Boolean(state.next), loaderNext: (0, jsx_runtime_1.jsx)(User_1.UserSkeleton, Object.assign({ elevation: 0 }, userProps)), className: classes.infiniteScroll, endMessage: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.endMessage }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMembersWidget.noMoreResults", defaultMessage: "ui.eventMembersWidget.noMoreResults" }) })) }, { children: (0, jsx_runtime_1.jsx)(material_1.List, { children: state.results.map((user) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(User_1.default, Object.assign({ elevation: 0, user: user }, userProps)) }, user.id))) }) })) })))] }));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TabValueEnum = void 0;
|
|
4
|
+
var TabValueEnum;
|
|
5
|
+
(function (TabValueEnum) {
|
|
6
|
+
TabValueEnum["ONE"] = "1";
|
|
7
|
+
TabValueEnum["TWO"] = "2";
|
|
8
|
+
TabValueEnum["THREE"] = "3";
|
|
9
|
+
})(TabValueEnum = exports.TabValueEnum || (exports.TabValueEnum = {}));
|
|
@@ -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
|
*/
|
|
@@ -10,9 +10,11 @@ const react_core_1 = require("@selfcommunity/react-core");
|
|
|
10
10
|
const types_1 = require("@selfcommunity/types");
|
|
11
11
|
const utils_1 = require("@selfcommunity/utils");
|
|
12
12
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
13
|
-
const
|
|
13
|
+
const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
|
|
14
|
+
const react_1 = require("react");
|
|
14
15
|
const react_intl_1 = require("react-intl");
|
|
15
16
|
const Errors_1 = require("../../constants/Errors");
|
|
17
|
+
const PubSub_1 = require("../../constants/PubSub");
|
|
16
18
|
const PREFIX = 'SCEventSubscribeButton';
|
|
17
19
|
const classes = {
|
|
18
20
|
requestRoot: `${PREFIX}-request-root`,
|
|
@@ -83,7 +85,7 @@ function EventSubscribeButton(inProps) {
|
|
|
83
85
|
// STATE
|
|
84
86
|
const [status, setStatus] = (0, react_1.useState)(undefined);
|
|
85
87
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
86
|
-
const [anchorEl, setAnchorEl] = react_1.
|
|
88
|
+
const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
|
|
87
89
|
const open = Boolean(anchorEl);
|
|
88
90
|
// CONTEXT
|
|
89
91
|
const scContext = (0, react_core_1.useSCContext)();
|
|
@@ -118,15 +120,16 @@ function EventSubscribeButton(inProps) {
|
|
|
118
120
|
const toggleEventAttendance = (eventStatus) => {
|
|
119
121
|
setLoading(true);
|
|
120
122
|
const isGoing = eventStatus === types_1.SCEventSubscriptionStatusType.GOING ||
|
|
121
|
-
!scEvent.subscription_status ||
|
|
123
|
+
!(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) ||
|
|
122
124
|
(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) === types_1.SCEventSubscriptionStatusType.INVITED;
|
|
123
125
|
const toggleAction = isGoing
|
|
124
|
-
? scEventsManager.toggleEventAttendance(scEvent, user
|
|
126
|
+
? scEventsManager.toggleEventAttendance(scEvent, (user === null || user === void 0 ? void 0 : user.id) || null)
|
|
125
127
|
: scEventsManager.toggleEventNonattendance(scEvent);
|
|
126
128
|
toggleAction
|
|
127
129
|
.then(() => {
|
|
128
|
-
onSubscribe
|
|
130
|
+
onSubscribe === null || onSubscribe === void 0 ? void 0 : onSubscribe(scEvent, (0, react_core_1.getEventStatus)(scEvent, isGoing));
|
|
129
131
|
setLoading(false);
|
|
132
|
+
pubsub_js_1.default.publish(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.ADD_MEMBER}`, scUserContext.user);
|
|
130
133
|
})
|
|
131
134
|
.catch((e) => {
|
|
132
135
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, e);
|
|
@@ -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
|
-
|
|
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, {
|
|
36
40
|
weekday: 'long',
|
|
37
41
|
day: 'numeric',
|
|
38
42
|
year: 'numeric',
|
|
39
43
|
month: 'long'
|
|
40
44
|
}),
|
|
41
|
-
start: intl.formatDate(
|
|
42
|
-
} }) })) })), hasInProgress &&
|
|
43
|
-
date: intl.formatDate(
|
|
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',
|