@selfcommunity/react-ui 0.10.5-payments.196 → 0.10.5-payments.197

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.
@@ -142,6 +142,10 @@ function EventMembersWidget(inProps) {
142
142
  _initInvited();
143
143
  setRefresh(null);
144
144
  }
145
+ else if (refresh === types_1.TabContentType.REQUESTS) {
146
+ _initRequests();
147
+ setRefresh(null);
148
+ }
145
149
  else {
146
150
  _initParticipants();
147
151
  _initInvited();
@@ -171,8 +175,11 @@ function EventMembersWidget(inProps) {
171
175
  else if (_tabValue === types_1.TabContentType.INVITED) {
172
176
  dispatchInvited({ type: widget_1.actionWidgetTypes.RESET });
173
177
  }
178
+ else if (_tabValue === types_1.TabContentType.REQUESTS) {
179
+ dispatchRequests({ type: widget_1.actionWidgetTypes.RESET });
180
+ }
174
181
  setRefresh(_tabValue);
175
- }, [dispatchParticipants, dispatchInvited, setRefresh]);
182
+ }, [dispatchParticipants, dispatchInvited, dispatchRequests, setRefresh]);
176
183
  if (!scUserContext.user) {
177
184
  return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
178
185
  }
@@ -182,7 +189,9 @@ function EventMembersWidget(inProps) {
182
189
  (tabValue === types_1.TabContentType.PARTICIPANTS && participants.isLoadingNext && !participants.initialized)) {
183
190
  return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
184
191
  }
185
- 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.TabContentType.PARTICIPANTS }), 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.TabContentType.INVITED })), 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.TabContentType.REQUESTS }))] })), (0, jsx_runtime_1.jsx)(lab_1.TabPanel, Object.assign({ value: types_1.TabContentType.PARTICIPANTS, className: classes.tabPanel }, { children: (0, jsx_runtime_1.jsx)(TabContentComponent_1.default, { tabValue: types_1.TabContentType.PARTICIPANTS, state: participants, dispatch: dispatchParticipants, userProps: userProps, dialogProps: dialogProps, handleRefresh: handleRefresh }) })), hasAllow && ((0, jsx_runtime_1.jsx)(lab_1.TabPanel, Object.assign({ value: types_1.TabContentType.INVITED, className: classes.tabPanel }, { children: (0, jsx_runtime_1.jsx)(TabContentComponent_1.default, { tabValue: types_1.TabContentType.INVITED, state: invited, dispatch: dispatchInvited, userProps: userProps, dialogProps: dialogProps, actionProps: {
192
+ 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.TabContentType.PARTICIPANTS }), 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.TabContentType.INVITED })), 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.TabContentType.REQUESTS }))] })), (0, jsx_runtime_1.jsx)(lab_1.TabPanel, Object.assign({ value: types_1.TabContentType.PARTICIPANTS, className: classes.tabPanel }, { children: (0, jsx_runtime_1.jsx)(TabContentComponent_1.default, { tabValue: types_1.TabContentType.PARTICIPANTS, state: participants, dispatch: dispatchParticipants, userProps: userProps, dialogProps: dialogProps, actionProps: {
193
+ scEvent
194
+ }, handleRefresh: handleRefresh }) })), hasAllow && ((0, jsx_runtime_1.jsx)(lab_1.TabPanel, Object.assign({ value: types_1.TabContentType.INVITED, className: classes.tabPanel }, { children: (0, jsx_runtime_1.jsx)(TabContentComponent_1.default, { tabValue: types_1.TabContentType.INVITED, state: invited, dispatch: dispatchInvited, userProps: userProps, dialogProps: dialogProps, actionProps: {
186
195
  scEvent,
187
196
  setCount: setInvitedCount
188
197
  }, handleRefresh: handleRefresh }) }))), hasAllow && ((0, jsx_runtime_1.jsx)(lab_1.TabPanel, Object.assign({ value: types_1.TabContentType.REQUESTS, className: classes.tabPanel }, { children: (0, jsx_runtime_1.jsx)(TabContentComponent_1.default, { tabValue: types_1.TabContentType.REQUESTS, state: requests, dispatch: dispatchRequests, userProps: userProps, dialogProps: dialogProps, actionProps: {
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const material_1 = require("@mui/material");
6
6
  const api_services_1 = require("@selfcommunity/api-services");
7
+ const types_1 = require("@selfcommunity/types");
7
8
  const utils_1 = require("@selfcommunity/utils");
8
9
  const notistack_1 = require("notistack");
9
10
  const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
@@ -19,7 +20,7 @@ const EventInviteButton_1 = tslib_1.__importDefault(require("../EventInviteButto
19
20
  const InviteUserEventButton_1 = tslib_1.__importDefault(require("../InviteUserEventButton"));
20
21
  const User_1 = tslib_1.__importStar(require("../User"));
21
22
  const constants_1 = require("./constants");
22
- const types_1 = require("./types");
23
+ const types_2 = require("./types");
23
24
  const classes = {
24
25
  actionButton: `${constants_1.PREFIX}-action-button`,
25
26
  eventButton: `${constants_1.PREFIX}-event-button`,
@@ -38,19 +39,22 @@ function TabContentComponent(props) {
38
39
  // STATE
39
40
  const [openDialog, setOpenDialog] = (0, react_1.useState)(false);
40
41
  // REFS
41
- const updatesInvited = (0, react_1.useRef)(null);
42
42
  const updatesParticipants = (0, react_1.useRef)(null);
43
+ const updatesInvited = (0, react_1.useRef)(null);
44
+ const updatesRequested = (0, react_1.useRef)(null);
43
45
  // HOOKS
44
46
  const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
45
47
  // CONSTS
46
- const users = (0, react_1.useMemo)(() => (tabValue === types_1.TabContentType.REQUESTS ? actionProps === null || actionProps === void 0 ? void 0 : actionProps.users : state.results), [tabValue, actionProps === null || actionProps === void 0 ? void 0 : actionProps.users, state.results]);
48
+ const users = (0, react_1.useMemo)(() => (tabValue === types_2.TabContentType.REQUESTS ? actionProps === null || actionProps === void 0 ? void 0 : actionProps.users : state.results), [tabValue, actionProps === null || actionProps === void 0 ? void 0 : actionProps.users, state.results]);
47
49
  // EFFECTS
48
50
  (0, react_1.useEffect)(() => {
49
- updatesInvited.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.INVITE_MEMBER}`, handleInviteMember);
50
51
  updatesParticipants.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.MEMBERS}`, handleToggleMember);
52
+ updatesInvited.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.INVITE_MEMBER}`, handleInviteMember);
53
+ updatesRequested.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT}`, handleRequestMember);
51
54
  return () => {
52
- updatesInvited.current && pubsub_js_1.default.unsubscribe(updatesInvited.current);
53
55
  updatesParticipants.current && pubsub_js_1.default.unsubscribe(updatesParticipants.current);
56
+ updatesInvited.current && pubsub_js_1.default.unsubscribe(updatesInvited.current);
57
+ updatesRequested.current && pubsub_js_1.default.unsubscribe(updatesRequested.current);
54
58
  };
55
59
  }, []);
56
60
  (0, react_1.useEffect)(() => {
@@ -80,13 +84,19 @@ function TabContentComponent(props) {
80
84
  setOpenDialog((prev) => !prev);
81
85
  }, [setOpenDialog]);
82
86
  const handleToggleMember = (0, react_1.useCallback)(() => {
83
- handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(types_1.TabContentType.PARTICIPANTS);
87
+ handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(types_2.TabContentType.PARTICIPANTS);
84
88
  }, [handleRefresh]);
85
89
  const handleInviteMember = (0, react_1.useCallback)(() => {
86
- handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(types_1.TabContentType.INVITED);
90
+ handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(types_2.TabContentType.INVITED);
87
91
  }, [handleRefresh]);
92
+ const handleRequestMember = (0, react_1.useCallback)((_msg, response) => {
93
+ var _a;
94
+ if (response.data.event === ((_a = actionProps === null || actionProps === void 0 ? void 0 : actionProps.scEvent) === null || _a === void 0 ? void 0 : _a.id)) {
95
+ handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(types_2.TabContentType.REQUESTS);
96
+ }
97
+ }, [handleRefresh, actionProps === null || actionProps === void 0 ? void 0 : actionProps.scEvent]);
88
98
  const getActionsComponent = (0, react_1.useCallback)((userId) => {
89
- if (tabValue === types_1.TabContentType.INVITED && actionProps) {
99
+ if (tabValue === types_2.TabContentType.INVITED && actionProps) {
90
100
  const _handleInvitations = (invited) => {
91
101
  var _a, _b;
92
102
  if (invited) {
@@ -98,7 +108,7 @@ function TabContentComponent(props) {
98
108
  };
99
109
  return (0, jsx_runtime_1.jsx)(InviteUserEventButton_1.default, { event: actionProps.scEvent, userId: userId, handleInvitations: _handleInvitations });
100
110
  }
101
- else if (tabValue === types_1.TabContentType.REQUESTS && actionProps) {
111
+ else if (tabValue === types_2.TabContentType.REQUESTS && actionProps) {
102
112
  const handleConfirm = (id) => {
103
113
  if (id) {
104
114
  actionProps.setCount((prev) => prev - 1);
@@ -119,20 +129,20 @@ function TabContentComponent(props) {
119
129
  }
120
130
  return undefined;
121
131
  }, [tabValue, actionProps]);
122
- if (tabValue === types_1.TabContentType.PARTICIPANTS && (actionProps === null || actionProps === void 0 ? void 0 : actionProps.count) === 0) {
132
+ if (tabValue === types_2.TabContentType.PARTICIPANTS && (actionProps === null || actionProps === void 0 ? void 0 : actionProps.count) === 0) {
123
133
  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" }) })));
124
134
  }
125
- else if (tabValue === types_1.TabContentType.INVITED && state.count === 0 && actionProps) {
135
+ else if (tabValue === types_2.TabContentType.INVITED && state.count === 0 && actionProps) {
126
136
  const date = actionProps.scEvent.end_date || actionProps.scEvent.start_date;
127
137
  const disabled = new Date(date).getTime() < new Date().getTime();
128
138
  const handleInvitations = (invited) => {
129
139
  if (invited) {
130
- handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(tabValue);
140
+ handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(types_2.TabContentType.INVITED);
131
141
  }
132
142
  };
133
143
  return ((0, jsx_runtime_1.jsx)(EventInviteButton_1.default, { event: actionProps.scEvent, className: classes.eventButton, handleInvitations: handleInvitations, disabled: disabled }));
134
144
  }
135
- else if (tabValue === types_1.TabContentType.REQUESTS && (actionProps === null || actionProps === void 0 ? void 0 : actionProps.count) === 0) {
145
+ else if (tabValue === types_2.TabContentType.REQUESTS && (actionProps === null || actionProps === void 0 ? void 0 : actionProps.count) === 0) {
136
146
  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" }) })));
137
147
  }
138
148
  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.slice(0, state.visibleItems).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: true }, 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))) }) })) })))] }));
@@ -126,9 +126,11 @@ function EventSubscribeButton(inProps) {
126
126
  const toggleEventAttendance = (0, react_1.useCallback)((eventStatus) => {
127
127
  setLoading(true);
128
128
  const _event = Object.assign(Object.assign({}, scEvent), { subscription_status: status });
129
+ console.log('*** _event ***', _event);
129
130
  const isGoing = eventStatus === types_1.SCEventSubscriptionStatusType.GOING ||
130
131
  !(_event === null || _event === void 0 ? void 0 : _event.subscription_status) ||
131
132
  (_event === null || _event === void 0 ? void 0 : _event.subscription_status) === types_1.SCEventSubscriptionStatusType.INVITED;
133
+ console.log('*** isGoing ***', isGoing);
132
134
  const toggleAction = isGoing ? scEventsManager.toggleEventAttendance(_event) : scEventsManager.toggleEventNonattendance(_event);
133
135
  toggleAction
134
136
  .then((data) => {
@@ -140,6 +140,10 @@ export default function EventMembersWidget(inProps) {
140
140
  _initInvited();
141
141
  setRefresh(null);
142
142
  }
143
+ else if (refresh === TabContentType.REQUESTS) {
144
+ _initRequests();
145
+ setRefresh(null);
146
+ }
143
147
  else {
144
148
  _initParticipants();
145
149
  _initInvited();
@@ -169,8 +173,11 @@ export default function EventMembersWidget(inProps) {
169
173
  else if (_tabValue === TabContentType.INVITED) {
170
174
  dispatchInvited({ type: actionWidgetTypes.RESET });
171
175
  }
176
+ else if (_tabValue === TabContentType.REQUESTS) {
177
+ dispatchRequests({ type: actionWidgetTypes.RESET });
178
+ }
172
179
  setRefresh(_tabValue);
173
- }, [dispatchParticipants, dispatchInvited, setRefresh]);
180
+ }, [dispatchParticipants, dispatchInvited, dispatchRequests, setRefresh]);
174
181
  if (!scUserContext.user) {
175
182
  return _jsx(HiddenPlaceholder, {});
176
183
  }
@@ -180,7 +187,9 @@ export default function EventMembersWidget(inProps) {
180
187
  (tabValue === TabContentType.PARTICIPANTS && participants.isLoadingNext && !participants.initialized)) {
181
188
  return _jsx(Skeleton, {});
182
189
  }
183
- 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: TabContentType.PARTICIPANTS }), 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: TabContentType.INVITED })), 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: TabContentType.REQUESTS }))] })), _jsx(TabPanel, Object.assign({ value: TabContentType.PARTICIPANTS, className: classes.tabPanel }, { children: _jsx(TabContentComponent, { tabValue: TabContentType.PARTICIPANTS, state: participants, dispatch: dispatchParticipants, userProps: userProps, dialogProps: dialogProps, handleRefresh: handleRefresh }) })), hasAllow && (_jsx(TabPanel, Object.assign({ value: TabContentType.INVITED, className: classes.tabPanel }, { children: _jsx(TabContentComponent, { tabValue: TabContentType.INVITED, state: invited, dispatch: dispatchInvited, userProps: userProps, dialogProps: dialogProps, actionProps: {
190
+ 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: TabContentType.PARTICIPANTS }), 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: TabContentType.INVITED })), 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: TabContentType.REQUESTS }))] })), _jsx(TabPanel, Object.assign({ value: TabContentType.PARTICIPANTS, className: classes.tabPanel }, { children: _jsx(TabContentComponent, { tabValue: TabContentType.PARTICIPANTS, state: participants, dispatch: dispatchParticipants, userProps: userProps, dialogProps: dialogProps, actionProps: {
191
+ scEvent
192
+ }, handleRefresh: handleRefresh }) })), hasAllow && (_jsx(TabPanel, Object.assign({ value: TabContentType.INVITED, className: classes.tabPanel }, { children: _jsx(TabContentComponent, { tabValue: TabContentType.INVITED, state: invited, dispatch: dispatchInvited, userProps: userProps, dialogProps: dialogProps, actionProps: {
184
193
  scEvent,
185
194
  setCount: setInvitedCount
186
195
  }, handleRefresh: handleRefresh }) }))), hasAllow && (_jsx(TabPanel, Object.assign({ value: TabContentType.REQUESTS, className: classes.tabPanel }, { children: _jsx(TabContentComponent, { tabValue: TabContentType.REQUESTS, state: requests, dispatch: dispatchRequests, userProps: userProps, dialogProps: dialogProps, actionProps: {
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button, List, ListItem, styled, Typography } from '@mui/material';
3
3
  import { Endpoints, http } from '@selfcommunity/api-services';
4
+ import { SCNotificationTopicType, SCNotificationTypologyType } from '@selfcommunity/types';
4
5
  import { Logger } from '@selfcommunity/utils';
5
6
  import { useSnackbar } from 'notistack';
6
7
  import PubSub from 'pubsub-js';
@@ -35,19 +36,22 @@ export default function TabContentComponent(props) {
35
36
  // STATE
36
37
  const [openDialog, setOpenDialog] = useState(false);
37
38
  // REFS
38
- const updatesInvited = useRef(null);
39
39
  const updatesParticipants = useRef(null);
40
+ const updatesInvited = useRef(null);
41
+ const updatesRequested = useRef(null);
40
42
  // HOOKS
41
43
  const { enqueueSnackbar } = useSnackbar();
42
44
  // CONSTS
43
45
  const users = useMemo(() => (tabValue === TabContentType.REQUESTS ? actionProps === null || actionProps === void 0 ? void 0 : actionProps.users : state.results), [tabValue, actionProps === null || actionProps === void 0 ? void 0 : actionProps.users, state.results]);
44
46
  // EFFECTS
45
47
  useEffect(() => {
46
- updatesInvited.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.INVITE_MEMBER}`, handleInviteMember);
47
48
  updatesParticipants.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.MEMBERS}`, handleToggleMember);
49
+ updatesInvited.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.INVITE_MEMBER}`, handleInviteMember);
50
+ updatesRequested.current = PubSub.subscribe(`${SCNotificationTopicType.INTERACTION}.${SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT}`, handleRequestMember);
48
51
  return () => {
49
- updatesInvited.current && PubSub.unsubscribe(updatesInvited.current);
50
52
  updatesParticipants.current && PubSub.unsubscribe(updatesParticipants.current);
53
+ updatesInvited.current && PubSub.unsubscribe(updatesInvited.current);
54
+ updatesRequested.current && PubSub.unsubscribe(updatesRequested.current);
51
55
  };
52
56
  }, []);
53
57
  useEffect(() => {
@@ -82,6 +86,12 @@ export default function TabContentComponent(props) {
82
86
  const handleInviteMember = useCallback(() => {
83
87
  handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(TabContentType.INVITED);
84
88
  }, [handleRefresh]);
89
+ const handleRequestMember = useCallback((_msg, response) => {
90
+ var _a;
91
+ if (response.data.event === ((_a = actionProps === null || actionProps === void 0 ? void 0 : actionProps.scEvent) === null || _a === void 0 ? void 0 : _a.id)) {
92
+ handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(TabContentType.REQUESTS);
93
+ }
94
+ }, [handleRefresh, actionProps === null || actionProps === void 0 ? void 0 : actionProps.scEvent]);
85
95
  const getActionsComponent = useCallback((userId) => {
86
96
  if (tabValue === TabContentType.INVITED && actionProps) {
87
97
  const _handleInvitations = (invited) => {
@@ -124,7 +134,7 @@ export default function TabContentComponent(props) {
124
134
  const disabled = new Date(date).getTime() < new Date().getTime();
125
135
  const handleInvitations = (invited) => {
126
136
  if (invited) {
127
- handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(tabValue);
137
+ handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(TabContentType.INVITED);
128
138
  }
129
139
  };
130
140
  return (_jsx(EventInviteButton, { event: actionProps.scEvent, className: classes.eventButton, handleInvitations: handleInvitations, disabled: disabled }));
@@ -124,9 +124,11 @@ export default function EventSubscribeButton(inProps) {
124
124
  const toggleEventAttendance = useCallback((eventStatus) => {
125
125
  setLoading(true);
126
126
  const _event = Object.assign(Object.assign({}, scEvent), { subscription_status: status });
127
+ console.log('*** _event ***', _event);
127
128
  const isGoing = eventStatus === SCEventSubscriptionStatusType.GOING ||
128
129
  !(_event === null || _event === void 0 ? void 0 : _event.subscription_status) ||
129
130
  (_event === null || _event === void 0 ? void 0 : _event.subscription_status) === SCEventSubscriptionStatusType.INVITED;
131
+ console.log('*** isGoing ***', isGoing);
130
132
  const toggleAction = isGoing ? scEventsManager.toggleEventAttendance(_event) : scEventsManager.toggleEventNonattendance(_event);
131
133
  toggleAction
132
134
  .then((data) => {