@selfcommunity/react-ui 0.10.5-payments.195 → 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.
@@ -120,7 +120,7 @@ function CourseForm(inProps) {
120
120
  description: course ? course.description : '',
121
121
  categories: course ? course.categories : [],
122
122
  privacy: course ? course.privacy : '',
123
- productIds: ((_a = course === null || course === void 0 ? void 0 : course.paywalls) === null || _a === void 0 ? void 0 : _a.map((p) => p.id)) || [],
123
+ products: ((_a = course === null || course === void 0 ? void 0 : course.paywalls) === null || _a === void 0 ? void 0 : _a.map((p) => p.id)) || [],
124
124
  contentAccessType: ((_b = course === null || course === void 0 ? void 0 : course.paywalls) === null || _b === void 0 ? void 0 : _b.length) ? constants_2.ContentAccessType.PAID : constants_2.ContentAccessType.FREE,
125
125
  isSubmitting: false
126
126
  };
@@ -213,11 +213,11 @@ function CourseForm(inProps) {
213
213
  formData.append(key, field.categories[key]);
214
214
  }
215
215
  }
216
- if (field.productIds.length && field.contentAccessType === constants_2.ContentAccessType.PAID && (isStaff || (course && ((_a = course.paywalls) === null || _a === void 0 ? void 0 : _a.length)))) {
217
- formData.append(`product_ids`, field.productIds.toString());
216
+ if (field.products.length && field.contentAccessType === constants_2.ContentAccessType.PAID && (isStaff || (course && ((_a = course.paywalls) === null || _a === void 0 ? void 0 : _a.length)))) {
217
+ formData.append(`products`, field.products.toString());
218
218
  }
219
219
  else {
220
- formData.append(`product_ids`, '[]');
220
+ formData.append(`products`, '[]');
221
221
  }
222
222
  let courseService;
223
223
  if (course) {
@@ -272,7 +272,7 @@ function CourseForm(inProps) {
272
272
  * @param products
273
273
  */
274
274
  const handleChangePaymentsProducts = (products) => {
275
- setField((prev) => (Object.assign(Object.assign({}, prev), { productIds: products.map((product) => product.id) })));
275
+ setField((prev) => (Object.assign(Object.assign({}, prev), { products: products.map((product) => product.id) })));
276
276
  };
277
277
  /**
278
278
  * Handles for closing confirm dialog
@@ -164,7 +164,7 @@ function EventForm(inProps) {
164
164
  link: (event === null || event === void 0 ? void 0 : event.link) || '',
165
165
  liveStreamSettings: (event === null || event === void 0 ? void 0 : event.live_stream) ? event === null || event === void 0 ? void 0 : event.live_stream.settings : null,
166
166
  recurring: (event === null || event === void 0 ? void 0 : event.recurring) || types_1.SCEventRecurrenceType.NEVER,
167
- productIds: ((_b = event === null || event === void 0 ? void 0 : event.paywalls) === null || _b === void 0 ? void 0 : _b.map((p) => p.id)) || [],
167
+ products: ((_b = event === null || event === void 0 ? void 0 : event.paywalls) === null || _b === void 0 ? void 0 : _b.map((p) => p.id)) || [],
168
168
  contentAccessType: ((_c = event === null || event === void 0 ? void 0 : event.paywalls) === null || _c === void 0 ? void 0 : _c.length) ? constants_3.ContentAccessType.PAID : constants_3.ContentAccessType.FREE,
169
169
  isPublic: (event === null || event === void 0 ? void 0 : event.privacy) ? event.privacy === types_1.SCEventPrivacyType.PUBLIC : true,
170
170
  isSubmitting: false
@@ -263,11 +263,11 @@ function EventForm(inProps) {
263
263
  if (visibilityEnabled) {
264
264
  formData.append('visible', 'true');
265
265
  }
266
- if (field.productIds.length && field.contentAccessType === constants_3.ContentAccessType.PAID && (isStaff || (event && ((_a = event.paywalls) === null || _a === void 0 ? void 0 : _a.length)))) {
267
- formData.append(`product_ids`, field.productIds.toString());
266
+ if (field.products.length && field.contentAccessType === constants_3.ContentAccessType.PAID && (isStaff || (event && ((_a = event.paywalls) === null || _a === void 0 ? void 0 : _a.length)))) {
267
+ formData.append(`products`, field.products.toString());
268
268
  }
269
269
  else {
270
- formData.append(`product_ids`, '[]');
270
+ formData.append(`products`, '[]');
271
271
  }
272
272
  formData.append('description', field.description);
273
273
  let eventService;
@@ -346,7 +346,7 @@ function EventForm(inProps) {
346
346
  * @param products
347
347
  */
348
348
  const handleChangePaymentsProducts = (products) => {
349
- setField((prev) => (Object.assign(Object.assign({}, prev), { productIds: products.map((product) => product.id) })));
349
+ setField((prev) => (Object.assign(Object.assign({}, prev), { products: products.map((product) => product.id) })));
350
350
  };
351
351
  const shouldDisableDate = (0, react_1.useCallback)((date) => {
352
352
  let disabled = false;
@@ -24,7 +24,7 @@ export declare type InitialFieldState = Geolocation & {
24
24
  description: string;
25
25
  isPublic: boolean;
26
26
  isSubmitting: boolean;
27
- productIds: number[];
27
+ products: number[];
28
28
  contentAccessType: ContentAccessType;
29
29
  };
30
30
  export declare type FieldStateKeys = keyof InitialFieldState;
@@ -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) => {
@@ -113,7 +113,7 @@ function GroupForm(inProps) {
113
113
  isVisible: group ? group.visible : true,
114
114
  invitedUsers: null,
115
115
  isSubmitting: false,
116
- productIds: ((_a = group === null || group === void 0 ? void 0 : group.paywalls) === null || _a === void 0 ? void 0 : _a.map((p) => p.id)) || [],
116
+ products: ((_a = group === null || group === void 0 ? void 0 : group.paywalls) === null || _a === void 0 ? void 0 : _a.map((p) => p.id)) || [],
117
117
  contentAccessType: ((_b = group === null || group === void 0 ? void 0 : group.paywalls) === null || _b === void 0 ? void 0 : _b.length) ? constants_2.ContentAccessType.PAID : constants_2.ContentAccessType.FREE
118
118
  };
119
119
  // CONTEXT
@@ -192,11 +192,11 @@ function GroupForm(inProps) {
192
192
  if (field.emotionalImageOriginalFile) {
193
193
  formData.append('emotional_image_original', field.emotionalImageOriginalFile);
194
194
  }
195
- if (field.productIds.length && field.contentAccessType === constants_2.ContentAccessType.PAID && (isStaff || (group && ((_a = group.paywalls) === null || _a === void 0 ? void 0 : _a.length)))) {
196
- formData.append(`product_ids`, field.productIds.toString());
195
+ if (field.products.length && field.contentAccessType === constants_2.ContentAccessType.PAID && (isStaff || (group && ((_a = group.paywalls) === null || _a === void 0 ? void 0 : _a.length)))) {
196
+ formData.append(`products`, field.products.toString());
197
197
  }
198
198
  else {
199
- formData.append(`product_ids`, '[]');
199
+ formData.append(`products`, '[]');
200
200
  }
201
201
  if (!group) {
202
202
  for (const key in field.invitedUsers) {
@@ -238,7 +238,7 @@ function GroupForm(inProps) {
238
238
  setField((prev) => (Object.assign(Object.assign({}, prev), { contentAccessType: type })));
239
239
  };
240
240
  const handleChangePaymentsProducts = (products) => {
241
- setField((prev) => (Object.assign(Object.assign({}, prev), { productIds: products.map((product) => product.id) })));
241
+ setField((prev) => (Object.assign(Object.assign({}, prev), { products: products.map((product) => product.id) })));
242
242
  };
243
243
  const handleClose = (_event, reason) => {
244
244
  if (reason === 'backdropClick' || reason === 'escapeKeyDown') {
@@ -118,7 +118,7 @@ export default function CourseForm(inProps) {
118
118
  description: course ? course.description : '',
119
119
  categories: course ? course.categories : [],
120
120
  privacy: course ? course.privacy : '',
121
- productIds: ((_a = course === null || course === void 0 ? void 0 : course.paywalls) === null || _a === void 0 ? void 0 : _a.map((p) => p.id)) || [],
121
+ products: ((_a = course === null || course === void 0 ? void 0 : course.paywalls) === null || _a === void 0 ? void 0 : _a.map((p) => p.id)) || [],
122
122
  contentAccessType: ((_b = course === null || course === void 0 ? void 0 : course.paywalls) === null || _b === void 0 ? void 0 : _b.length) ? ContentAccessType.PAID : ContentAccessType.FREE,
123
123
  isSubmitting: false
124
124
  };
@@ -211,11 +211,11 @@ export default function CourseForm(inProps) {
211
211
  formData.append(key, field.categories[key]);
212
212
  }
213
213
  }
214
- if (field.productIds.length && field.contentAccessType === ContentAccessType.PAID && (isStaff || (course && ((_a = course.paywalls) === null || _a === void 0 ? void 0 : _a.length)))) {
215
- formData.append(`product_ids`, field.productIds.toString());
214
+ if (field.products.length && field.contentAccessType === ContentAccessType.PAID && (isStaff || (course && ((_a = course.paywalls) === null || _a === void 0 ? void 0 : _a.length)))) {
215
+ formData.append(`products`, field.products.toString());
216
216
  }
217
217
  else {
218
- formData.append(`product_ids`, '[]');
218
+ formData.append(`products`, '[]');
219
219
  }
220
220
  let courseService;
221
221
  if (course) {
@@ -270,7 +270,7 @@ export default function CourseForm(inProps) {
270
270
  * @param products
271
271
  */
272
272
  const handleChangePaymentsProducts = (products) => {
273
- setField((prev) => (Object.assign(Object.assign({}, prev), { productIds: products.map((product) => product.id) })));
273
+ setField((prev) => (Object.assign(Object.assign({}, prev), { products: products.map((product) => product.id) })));
274
274
  };
275
275
  /**
276
276
  * Handles for closing confirm dialog
@@ -162,7 +162,7 @@ export default function EventForm(inProps) {
162
162
  link: (event === null || event === void 0 ? void 0 : event.link) || '',
163
163
  liveStreamSettings: (event === null || event === void 0 ? void 0 : event.live_stream) ? event === null || event === void 0 ? void 0 : event.live_stream.settings : null,
164
164
  recurring: (event === null || event === void 0 ? void 0 : event.recurring) || SCEventRecurrenceType.NEVER,
165
- productIds: ((_b = event === null || event === void 0 ? void 0 : event.paywalls) === null || _b === void 0 ? void 0 : _b.map((p) => p.id)) || [],
165
+ products: ((_b = event === null || event === void 0 ? void 0 : event.paywalls) === null || _b === void 0 ? void 0 : _b.map((p) => p.id)) || [],
166
166
  contentAccessType: ((_c = event === null || event === void 0 ? void 0 : event.paywalls) === null || _c === void 0 ? void 0 : _c.length) ? ContentAccessType.PAID : ContentAccessType.FREE,
167
167
  isPublic: (event === null || event === void 0 ? void 0 : event.privacy) ? event.privacy === SCEventPrivacyType.PUBLIC : true,
168
168
  isSubmitting: false
@@ -261,11 +261,11 @@ export default function EventForm(inProps) {
261
261
  if (visibilityEnabled) {
262
262
  formData.append('visible', 'true');
263
263
  }
264
- if (field.productIds.length && field.contentAccessType === ContentAccessType.PAID && (isStaff || (event && ((_a = event.paywalls) === null || _a === void 0 ? void 0 : _a.length)))) {
265
- formData.append(`product_ids`, field.productIds.toString());
264
+ if (field.products.length && field.contentAccessType === ContentAccessType.PAID && (isStaff || (event && ((_a = event.paywalls) === null || _a === void 0 ? void 0 : _a.length)))) {
265
+ formData.append(`products`, field.products.toString());
266
266
  }
267
267
  else {
268
- formData.append(`product_ids`, '[]');
268
+ formData.append(`products`, '[]');
269
269
  }
270
270
  formData.append('description', field.description);
271
271
  let eventService;
@@ -344,7 +344,7 @@ export default function EventForm(inProps) {
344
344
  * @param products
345
345
  */
346
346
  const handleChangePaymentsProducts = (products) => {
347
- setField((prev) => (Object.assign(Object.assign({}, prev), { productIds: products.map((product) => product.id) })));
347
+ setField((prev) => (Object.assign(Object.assign({}, prev), { products: products.map((product) => product.id) })));
348
348
  };
349
349
  const shouldDisableDate = useCallback((date) => {
350
350
  let disabled = false;
@@ -24,7 +24,7 @@ export declare type InitialFieldState = Geolocation & {
24
24
  description: string;
25
25
  isPublic: boolean;
26
26
  isSubmitting: boolean;
27
- productIds: number[];
27
+ products: number[];
28
28
  contentAccessType: ContentAccessType;
29
29
  };
30
30
  export declare type FieldStateKeys = keyof InitialFieldState;
@@ -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) => {
@@ -111,7 +111,7 @@ export default function GroupForm(inProps) {
111
111
  isVisible: group ? group.visible : true,
112
112
  invitedUsers: null,
113
113
  isSubmitting: false,
114
- productIds: ((_a = group === null || group === void 0 ? void 0 : group.paywalls) === null || _a === void 0 ? void 0 : _a.map((p) => p.id)) || [],
114
+ products: ((_a = group === null || group === void 0 ? void 0 : group.paywalls) === null || _a === void 0 ? void 0 : _a.map((p) => p.id)) || [],
115
115
  contentAccessType: ((_b = group === null || group === void 0 ? void 0 : group.paywalls) === null || _b === void 0 ? void 0 : _b.length) ? ContentAccessType.PAID : ContentAccessType.FREE
116
116
  };
117
117
  // CONTEXT
@@ -190,11 +190,11 @@ export default function GroupForm(inProps) {
190
190
  if (field.emotionalImageOriginalFile) {
191
191
  formData.append('emotional_image_original', field.emotionalImageOriginalFile);
192
192
  }
193
- if (field.productIds.length && field.contentAccessType === ContentAccessType.PAID && (isStaff || (group && ((_a = group.paywalls) === null || _a === void 0 ? void 0 : _a.length)))) {
194
- formData.append(`product_ids`, field.productIds.toString());
193
+ if (field.products.length && field.contentAccessType === ContentAccessType.PAID && (isStaff || (group && ((_a = group.paywalls) === null || _a === void 0 ? void 0 : _a.length)))) {
194
+ formData.append(`products`, field.products.toString());
195
195
  }
196
196
  else {
197
- formData.append(`product_ids`, '[]');
197
+ formData.append(`products`, '[]');
198
198
  }
199
199
  if (!group) {
200
200
  for (const key in field.invitedUsers) {
@@ -236,7 +236,7 @@ export default function GroupForm(inProps) {
236
236
  setField((prev) => (Object.assign(Object.assign({}, prev), { contentAccessType: type })));
237
237
  };
238
238
  const handleChangePaymentsProducts = (products) => {
239
- setField((prev) => (Object.assign(Object.assign({}, prev), { productIds: products.map((product) => product.id) })));
239
+ setField((prev) => (Object.assign(Object.assign({}, prev), { products: products.map((product) => product.id) })));
240
240
  };
241
241
  const handleClose = (_event, reason) => {
242
242
  if (reason === 'backdropClick' || reason === 'escapeKeyDown') {