@selfcommunity/react-ui 0.8.0-alpha.3 → 0.8.0-alpha.31

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.
Files changed (107) hide show
  1. package/lib/cjs/components/BottomNavigation/BottomNavigation.js +11 -2
  2. package/lib/cjs/components/Composer/Composer.js +10 -2
  3. package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +12 -3
  4. package/lib/cjs/components/CreateEventButton/CreateEventButton.js +5 -1
  5. package/lib/cjs/components/CreateEventWidget/CreateEventWidget.js +5 -1
  6. package/lib/cjs/components/EventForm/EventForm.d.ts +1 -1
  7. package/lib/cjs/components/EventForm/EventForm.js +72 -54
  8. package/lib/cjs/components/EventForm/constants.d.ts +4 -0
  9. package/lib/cjs/components/EventForm/constants.js +5 -1
  10. package/lib/cjs/components/EventForm/types.d.ts +1 -2
  11. package/lib/cjs/components/EventForm/utils.d.ts +4 -0
  12. package/lib/cjs/components/EventForm/utils.js +28 -0
  13. package/lib/cjs/components/EventInfoWidget/EventInfoWidget.js +24 -1
  14. package/lib/cjs/components/Events/Events.js +17 -7
  15. package/lib/cjs/components/Events/LocationEventsFilter.d.ts +14 -0
  16. package/lib/cjs/components/Events/LocationEventsFilter.js +45 -0
  17. package/lib/cjs/components/Events/PastEventsFilter.js +1 -2
  18. package/lib/cjs/components/Feed/Feed.js +12 -3
  19. package/lib/cjs/components/GroupActionsMenu/index.d.ts +57 -0
  20. package/lib/cjs/components/GroupActionsMenu/index.js +157 -0
  21. package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -0
  22. package/lib/cjs/components/GroupHeader/GroupHeader.js +8 -4
  23. package/lib/cjs/components/Groups/Groups.js +26 -0
  24. package/lib/cjs/components/MyEventsWidget/MyEventsWidget.js +6 -2
  25. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.d.ts +35 -0
  26. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.js +68 -0
  27. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.d.ts +9 -20
  28. package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.js +8 -27
  29. package/lib/cjs/components/NavigationMenuIconButton/index.d.ts +2 -1
  30. package/lib/cjs/components/NavigationMenuIconButton/index.js +3 -1
  31. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.d.ts +5 -0
  32. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +14 -5
  33. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -2
  34. package/lib/cjs/components/Notification/Event/Event.js +4 -0
  35. package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.d.ts +10 -1
  36. package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.js +69 -26
  37. package/lib/cjs/components/OnBoardingWidget/Steps/Appearance/Appearance.js +8 -4
  38. package/lib/cjs/components/OnBoardingWidget/Steps/Invite/Invite.js +56 -12
  39. package/lib/cjs/components/PlatformWidget/constants.d.ts +0 -4
  40. package/lib/cjs/components/PlatformWidget/constants.js +1 -5
  41. package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +7 -2
  42. package/lib/cjs/constants/GroupActionsMenu.d.ts +5 -0
  43. package/lib/cjs/constants/GroupActionsMenu.js +8 -0
  44. package/lib/cjs/constants/PubSub.d.ts +16 -1
  45. package/lib/cjs/constants/PubSub.js +11 -1
  46. package/lib/cjs/index.d.ts +4 -2
  47. package/lib/cjs/index.js +12 -5
  48. package/lib/cjs/shared/ContributionActionsMenu/index.js +6 -6
  49. package/lib/cjs/shared/InfiniteScroll/index.js +3 -3
  50. package/lib/cjs/shared/Media/Link/DisplayComponent.js +21 -5
  51. package/lib/cjs/utils/formatRelativeTime.js +2 -2
  52. package/lib/esm/components/BottomNavigation/BottomNavigation.js +11 -2
  53. package/lib/esm/components/Composer/Composer.js +10 -2
  54. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +13 -4
  55. package/lib/esm/components/CreateEventButton/CreateEventButton.js +5 -1
  56. package/lib/esm/components/CreateEventWidget/CreateEventWidget.js +5 -1
  57. package/lib/esm/components/EventForm/EventForm.d.ts +1 -1
  58. package/lib/esm/components/EventForm/EventForm.js +74 -56
  59. package/lib/esm/components/EventForm/constants.d.ts +4 -0
  60. package/lib/esm/components/EventForm/constants.js +4 -0
  61. package/lib/esm/components/EventForm/types.d.ts +1 -2
  62. package/lib/esm/components/EventForm/utils.d.ts +4 -0
  63. package/lib/esm/components/EventForm/utils.js +21 -0
  64. package/lib/esm/components/EventInfoWidget/EventInfoWidget.js +25 -2
  65. package/lib/esm/components/Events/Events.js +18 -8
  66. package/lib/esm/components/Events/LocationEventsFilter.d.ts +14 -0
  67. package/lib/esm/components/Events/LocationEventsFilter.js +41 -0
  68. package/lib/esm/components/Events/PastEventsFilter.js +1 -2
  69. package/lib/esm/components/Feed/Feed.js +14 -5
  70. package/lib/esm/components/GroupActionsMenu/index.d.ts +57 -0
  71. package/lib/esm/components/GroupActionsMenu/index.js +154 -0
  72. package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -0
  73. package/lib/esm/components/GroupHeader/GroupHeader.js +9 -5
  74. package/lib/esm/components/Groups/Groups.js +27 -1
  75. package/lib/esm/components/MyEventsWidget/MyEventsWidget.js +7 -3
  76. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.d.ts +35 -0
  77. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.js +65 -0
  78. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.d.ts +9 -20
  79. package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +11 -30
  80. package/lib/esm/components/NavigationMenuIconButton/index.d.ts +2 -1
  81. package/lib/esm/components/NavigationMenuIconButton/index.js +2 -1
  82. package/lib/esm/components/NavigationToolbar/NavigationToolbar.d.ts +5 -0
  83. package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +14 -5
  84. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -2
  85. package/lib/esm/components/Notification/Event/Event.js +4 -0
  86. package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.d.ts +10 -1
  87. package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.js +71 -28
  88. package/lib/esm/components/OnBoardingWidget/Steps/Appearance/Appearance.js +9 -5
  89. package/lib/esm/components/OnBoardingWidget/Steps/Invite/Invite.js +59 -14
  90. package/lib/esm/components/PlatformWidget/constants.d.ts +0 -4
  91. package/lib/esm/components/PlatformWidget/constants.js +0 -4
  92. package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +8 -3
  93. package/lib/esm/constants/GroupActionsMenu.d.ts +5 -0
  94. package/lib/esm/constants/GroupActionsMenu.js +5 -0
  95. package/lib/esm/constants/PubSub.d.ts +16 -1
  96. package/lib/esm/constants/PubSub.js +10 -0
  97. package/lib/esm/index.d.ts +4 -2
  98. package/lib/esm/index.js +5 -3
  99. package/lib/esm/shared/ContributionActionsMenu/index.js +6 -6
  100. package/lib/esm/shared/InfiniteScroll/index.js +3 -3
  101. package/lib/esm/shared/Media/Link/DisplayComponent.js +21 -5
  102. package/lib/esm/utils/formatRelativeTime.js +2 -2
  103. package/lib/umd/148.js +2 -0
  104. package/lib/umd/react-ui.js +1 -1
  105. package/package.json +7 -7
  106. package/lib/umd/99.js +0 -2
  107. /package/lib/umd/{99.js.LICENSE.txt → 148.js.LICENSE.txt} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { LoadingButton } from '@mui/lab';
4
- import { Box, Button, FormControl, FormGroup, Icon, IconButton, InputAdornment, InputLabel, MenuItem, Paper, Select, Stack, Switch, TextField, Typography } from '@mui/material';
4
+ import { Box, FormControl, FormGroup, Icon, IconButton, InputAdornment, InputLabel, MenuItem, Paper, Select, Stack, Switch, TextField, Typography } from '@mui/material';
5
5
  import { styled } from '@mui/material/styles';
6
6
  import { useThemeProps } from '@mui/system';
7
7
  import { LocalizationProvider, MobileDatePicker, MobileTimePicker } from '@mui/x-date-pickers';
@@ -14,15 +14,16 @@ import classNames from 'classnames';
14
14
  import enLocale from 'date-fns/locale/en-US';
15
15
  import itLocale from 'date-fns/locale/it';
16
16
  import PubSub from 'pubsub-js';
17
- import { useMemo, useState } from 'react';
17
+ import { useCallback, useMemo, useState } from 'react';
18
18
  import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
19
19
  import { SCOPE_SC_UI } from '../../constants/Errors';
20
20
  import { EVENT_DESCRIPTION_MAX_LENGTH, EVENT_TITLE_MAX_LENGTH } from '../../constants/Event';
21
21
  import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
22
22
  import BaseDialog from '../../shared/BaseDialog';
23
- import { PREFIX } from './constants';
23
+ import { DAILY_LATER_DAYS, MONTHLY_LATER_DAYS, NEVER_LATER_DAYS, PREFIX, WEEKLY_LATER_DAYS } from './constants';
24
24
  import EventAddress from './EventAddress';
25
25
  import UploadEventCover from './UploadEventCover';
26
+ import { combineDateAndTime, getLaterDaysDate, getLaterHoursDate, getNewDate } from './utils';
26
27
  const messages = defineMessages({
27
28
  name: {
28
29
  id: 'ui.eventForm.name.placeholder',
@@ -111,7 +112,7 @@ const Root = styled(BaseDialog, {
111
112
  * @param inProps
112
113
  */
113
114
  export default function EventForm(inProps) {
114
- var _a, _b, _c, _d, _e, _f, _g;
115
+ var _a, _b, _c, _d;
115
116
  //PROPS
116
117
  const props = useThemeProps({
117
118
  props: inProps,
@@ -122,13 +123,15 @@ export default function EventForm(inProps) {
122
123
  const scContext = useSCContext();
123
124
  // INTL
124
125
  const intl = useIntl();
126
+ const startDateTime = useMemo(() => getNewDate(event === null || event === void 0 ? void 0 : event.start_date), [event]);
127
+ const endDateTime = useMemo(() => getNewDate(event === null || event === void 0 ? void 0 : event.end_date), [event]);
125
128
  const initialFieldState = {
126
129
  imageOriginal: (event === null || event === void 0 ? void 0 : event.image_bigger) || '',
127
- imageOriginalFile: new Blob(),
128
- startDate: event ? new Date(event.start_date) : null,
129
- startTime: event ? new Date(event.start_date) : null,
130
- endDate: (event === null || event === void 0 ? void 0 : event.end_date) ? new Date(event.end_date) : null,
131
- endTime: (event === null || event === void 0 ? void 0 : event.end_date) ? new Date(event.end_date) : null,
130
+ imageOriginalFile: '',
131
+ startDate: event ? startDateTime : getNewDate(),
132
+ startTime: event ? startDateTime : getLaterHoursDate(1),
133
+ endDate: (event === null || event === void 0 ? void 0 : event.end_date) ? endDateTime : getNewDate(),
134
+ endTime: (event === null || event === void 0 ? void 0 : event.end_date) ? endDateTime : getLaterHoursDate(3),
132
135
  location: (event === null || event === void 0 ? void 0 : event.location) || SCEventLocationType.PERSON,
133
136
  geolocation: (event === null || event === void 0 ? void 0 : event.geolocation) || '',
134
137
  lat: (event === null || event === void 0 ? void 0 : event.geolocation_lat) || null,
@@ -138,8 +141,7 @@ export default function EventForm(inProps) {
138
141
  name: (event === null || event === void 0 ? void 0 : event.name) || '',
139
142
  description: event ? event.description : '',
140
143
  isPublic: (_a = (event === null || event === void 0 ? void 0 : event.privacy) === SCEventPrivacyType.PUBLIC) !== null && _a !== void 0 ? _a : true,
141
- isSubmitting: false,
142
- showEndDateTime: (_b = !!(event === null || event === void 0 ? void 0 : event.end_date)) !== null && _b !== void 0 ? _b : false
144
+ isSubmitting: false
143
145
  };
144
146
  // STATE
145
147
  const [field, setField] = useState(initialFieldState);
@@ -148,23 +150,12 @@ export default function EventForm(inProps) {
148
150
  const scPreferences = useSCPreferences();
149
151
  const privateEnabled = useMemo(() => scPreferences.preferences[SCPreferences.CONFIGURATIONS_EVENTS_PRIVATE_ENABLED].value, [scPreferences.preferences]);
150
152
  const visibilityEnabled = useMemo(() => scPreferences.preferences[SCPreferences.CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED].value, [scPreferences.preferences]);
151
- const disablePastStartTime = useMemo(() => (field.startDate ? new Date(field.startDate).getDate() === new Date().getDate() : false), [field]);
152
- const disablePastEndTime = useMemo(() => (field.endDate ? new Date(field.endDate).getDate() === new Date().getDate() : false), [field]);
153
+ const disablePastStartTime = useMemo(() => field.startDate.getDate() === getNewDate().getDate(), [field]);
154
+ const disablePastEndTime = useMemo(() => field.endDate.getDate() === getNewDate().getDate(), [field]);
153
155
  const _backgroundCover = Object.assign({}, (field.imageOriginal
154
156
  ? { background: `url('${field.imageOriginal}') center / cover` }
155
157
  : { background: `url('${scPreferences.preferences[SCPreferences.IMAGES_USER_DEFAULT_COVER].value}') center / cover` }));
156
- const combineDateAndTime = (date, time) => {
157
- if (date && time) {
158
- const combined = new Date(date);
159
- combined.setHours(time.getHours());
160
- combined.setMinutes(time.getMinutes());
161
- combined.setSeconds(time.getSeconds());
162
- combined.setMilliseconds(time.getMilliseconds());
163
- return combined.toISOString();
164
- }
165
- return null;
166
- };
167
- function handleChangeCover(cover) {
158
+ const handleChangeCover = useCallback((cover) => {
168
159
  setField((prev) => (Object.assign(Object.assign({}, prev), { ['imageOriginalFile']: cover })));
169
160
  const reader = new FileReader();
170
161
  reader.onloadend = () => {
@@ -175,27 +166,25 @@ export default function EventForm(inProps) {
175
166
  delete error.imageOriginalError;
176
167
  setError(error);
177
168
  }
178
- }
169
+ }, [error]);
179
170
  /**
180
171
  * Notify when a group info changed
181
172
  * @param data
182
173
  */
183
- function notifyChanges(data) {
184
- if (data) {
185
- if (event) {
186
- // Edit group
187
- PubSub.publish(`${SCTopicType.EVENT}.${SCGroupEventType.EDIT}`, data);
188
- }
189
- else {
190
- // Create group
191
- PubSub.publish(`${SCTopicType.EVENT}.${SCGroupEventType.CREATE}`, data);
192
- }
174
+ const notifyChanges = useCallback((data) => {
175
+ if (event) {
176
+ // Edit group
177
+ PubSub.publish(`${SCTopicType.EVENT}.${SCGroupEventType.EDIT}`, data);
193
178
  }
194
- }
195
- const handleGeoData = (data) => {
179
+ else {
180
+ // Create group
181
+ PubSub.publish(`${SCTopicType.EVENT}.${SCGroupEventType.CREATE}`, data);
182
+ }
183
+ }, [event]);
184
+ const handleGeoData = useCallback((data) => {
196
185
  setField((prev) => (Object.assign(Object.assign({}, prev), data)));
197
- };
198
- const handleSubmit = () => {
186
+ }, []);
187
+ const handleSubmit = useCallback(() => {
199
188
  setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: true })));
200
189
  const formData = new FormData();
201
190
  if (field.imageOriginalFile) {
@@ -204,14 +193,12 @@ export default function EventForm(inProps) {
204
193
  formData.append('name', field.name);
205
194
  formData.append('start_date', combineDateAndTime(field.startDate, field.startTime));
206
195
  formData.append('recurring', field.recurring);
207
- if (field.endDate) {
208
- formData.append('end_date', combineDateAndTime(field.endDate, field.endTime));
209
- }
196
+ formData.append('end_date', combineDateAndTime(field.endDate, field.endTime));
210
197
  formData.append('location', field.location);
211
198
  if (field.location === SCEventLocationType.ONLINE) {
212
199
  formData.append('link', field.link);
213
200
  }
214
- if (field.location === SCEventLocationType.PERSON) {
201
+ else if (field.location === SCEventLocationType.PERSON) {
215
202
  formData.append('geolocation', field.geolocation);
216
203
  formData.append('geolocation_lat', field.lat.toString());
217
204
  formData.append('geolocation_lng', field.lng.toString());
@@ -250,28 +237,56 @@ export default function EventForm(inProps) {
250
237
  setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
251
238
  Logger.error(SCOPE_SC_UI, e);
252
239
  });
253
- };
254
- const handleChange = (event) => {
240
+ }, [field, privateEnabled, visibilityEnabled]);
241
+ const handleChange = useCallback((event) => {
255
242
  const { name, value } = event.target;
256
243
  setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
257
244
  if (error[`${name}Error`]) {
258
245
  delete error[`${name}Error`];
259
246
  setError(error);
260
247
  }
261
- };
262
- const handleChangeDateTime = (value, name) => {
248
+ }, [error]);
249
+ const handleChangeDateTime = useCallback((value, name) => {
263
250
  setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
264
251
  if (error[`${name}Error`]) {
265
252
  delete error[`${name}Error`];
266
253
  setError(error);
267
254
  }
268
- };
255
+ else if (error['endDateError']) {
256
+ delete error['endDateError'];
257
+ setError(error);
258
+ }
259
+ }, [error]);
260
+ const shouldDisabledDate = useCallback((date) => {
261
+ let disabled = false;
262
+ switch (field.recurring) {
263
+ case SCEventRecurrenceType.DAILY:
264
+ disabled = date.getTime() > getLaterDaysDate(DAILY_LATER_DAYS).getTime();
265
+ break;
266
+ case SCEventRecurrenceType.WEEKLY:
267
+ disabled = date.getTime() > getLaterDaysDate(WEEKLY_LATER_DAYS).getTime();
268
+ break;
269
+ case SCEventRecurrenceType.MONTHLY:
270
+ disabled = date.getTime() > getLaterDaysDate(MONTHLY_LATER_DAYS).getTime();
271
+ break;
272
+ case SCEventRecurrenceType.NEVER:
273
+ default:
274
+ disabled = date.getTime() > getLaterDaysDate(NEVER_LATER_DAYS).getTime();
275
+ }
276
+ if (field.startDate.getDate() > date.getDate()) {
277
+ disabled = true;
278
+ }
279
+ return disabled;
280
+ }, [field]);
281
+ const shouldDisabledTime = useCallback((date, _view) => field.startTime.getTime() > date.getTime(), [field]);
269
282
  /**
270
283
  * Renders root object
271
284
  */
272
285
  return (_jsx(Root, Object.assign({ DialogContentProps: { dividers: false }, title: event ? (_jsx(FormattedMessage, { id: "ui.eventForm.title.edit", defaultMessage: "ui.eventForm.title.edit" })) : (_jsx(FormattedMessage, { id: "ui.eventForm.title", defaultMessage: "ui.eventForm.title" })), open: open, onClose: onClose, className: classNames(classes.root, className), actions: _jsx(LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.name ||
273
286
  !field.startDate ||
274
287
  !field.startTime ||
288
+ !field.endDate ||
289
+ !field.endTime ||
275
290
  (field.location === SCEventLocationType.ONLINE && !field.link) ||
276
291
  (field.location === SCEventLocationType.PERSON && !field.geolocation) ||
277
292
  (field.recurring !== SCEventRecurrenceType.NEVER && !field.endDate && !field.endTime) ||
@@ -279,7 +294,7 @@ export default function EventForm(inProps) {
279
294
  field.name.length > EVENT_TITLE_MAX_LENGTH ||
280
295
  field.description.length > EVENT_DESCRIPTION_MAX_LENGTH, variant: "contained", onClick: handleSubmit, color: "secondary" }, { children: event ? (_jsx(FormattedMessage, { id: "ui.eventForm.button.edit", defaultMessage: "ui.eventForm.button.edit" })) : (_jsx(FormattedMessage, { id: "ui.eventForm.button.create", defaultMessage: "ui.eventForm.button.create" })) })) }, rest, { children: _jsxs(_Fragment, { children: [_jsx(Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: _jsx(UploadEventCover, { isCreationMode: true, onChange: handleChangeCover }) })), _jsxs(FormGroup, Object.assign({ className: classes.form }, { children: [_jsx(TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
281
296
  endAdornment: _jsx(Typography, Object.assign({ variant: "body2" }, { children: EVENT_TITLE_MAX_LENGTH - field.name.length }))
282
- }, error: Boolean(((_c = field === null || field === void 0 ? void 0 : field.name) === null || _c === void 0 ? void 0 : _c.length) > EVENT_TITLE_MAX_LENGTH) || Boolean(error[`nameError`]), helperText: ((_d = field === null || field === void 0 ? void 0 : field.name) === null || _d === void 0 ? void 0 : _d.length) > EVENT_TITLE_MAX_LENGTH ? (_jsx(FormattedMessage, { id: "ui.eventForm.name.error.maxLength", defaultMessage: "ui.eventForm.name.error.maxLength" })) : error[`nameError`] ? (error[`nameError`]) : null }), _jsx(Box, Object.assign({ className: classes.dateTime }, { children: _jsxs(LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? itLocale : enLocale }, { children: [_jsx(MobileDatePicker, { className: classes.picker, disablePast: true, label: field.startDate && _jsx(FormattedMessage, { id: "ui.eventForm.date.placeholder", defaultMessage: "ui.eventForm.date.placeholder" }), value: field.startDate, slots: {
297
+ }, error: Boolean(field.name.length > EVENT_TITLE_MAX_LENGTH) || Boolean(error['nameError']), helperText: field.name.length > EVENT_TITLE_MAX_LENGTH ? (_jsx(FormattedMessage, { id: "ui.eventForm.name.error.maxLength", defaultMessage: "ui.eventForm.name.error.maxLength" })) : error['nameError'] ? (error['nameError']) : null }), _jsx(Box, Object.assign({ className: classes.dateTime }, { children: _jsxs(LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? itLocale : enLocale }, { children: [_jsx(MobileDatePicker, { className: classes.picker, disablePast: true, label: field.startDate && _jsx(FormattedMessage, { id: "ui.eventForm.date.placeholder", defaultMessage: "ui.eventForm.date.placeholder" }), value: field.startDate, slots: {
283
298
  textField: (params) => (_jsx(TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.startDate)}`, startAdornment: (_jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "CalendarIcon" }) }) }))) }) })))
284
299
  }, slotProps: {
285
300
  toolbar: {
@@ -300,11 +315,14 @@ export default function EventForm(inProps) {
300
315
  return _jsx("em", { children: `${intl.formatMessage(messages.frequencyPlaceholder)}` });
301
316
  }
302
317
  return (_jsx(FormattedMessage, { id: `ui.eventForm.frequency.${selected}.placeholder`, defaultMessage: `ui.eventForm.frequency.${selected}.placeholder` }));
303
- }, startAdornment: _jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "frequency" }) }) })) }, { children: Object.values(SCEventRecurrenceType).map((f) => (_jsx(MenuItem, Object.assign({ value: f }, { children: _jsx(FormattedMessage, { id: `ui.eventForm.frequency.${f}.placeholder`, defaultMessage: `ui.eventForm.frequency.${f}.placeholder` }) }), f))) }))] })), (field.showEndDateTime || field.recurring !== SCEventRecurrenceType.NEVER) && (_jsx(Box, Object.assign({ className: classes.dateTime }, { children: _jsxs(LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? itLocale : enLocale }, { children: [_jsx(MobileDatePicker, { className: classes.picker, disablePast: true, label: field.endDate && _jsx(FormattedMessage, { id: "ui.eventForm.date.end.placeholder", defaultMessage: "ui.eventForm.date.end.placeholder" }), value: field.endDate, slots: {
318
+ }, startAdornment: _jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "frequency" }) }) })) }, { children: Object.values(SCEventRecurrenceType).map((f) => (_jsx(MenuItem, Object.assign({ value: f }, { children: _jsx(FormattedMessage, { id: `ui.eventForm.frequency.${f}.placeholder`, defaultMessage: `ui.eventForm.frequency.${f}.placeholder` }) }), f))) }))] })), _jsx(Box, Object.assign({ className: classes.dateTime }, { children: _jsxs(LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? itLocale : enLocale }, { children: [_jsx(MobileDatePicker, { className: classes.picker, disablePast: true, minDate: field.startDate, label: _jsx(FormattedMessage, { id: "ui.eventForm.date.end.placeholder", defaultMessage: "ui.eventForm.date.end.placeholder" }), value: field.endDate, slots: {
304
319
  textField: (params) => (_jsx(TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endDate)}`, startAdornment: (_jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "calendar_off" }) }) }))) }) })))
305
- }, onChange: (value) => handleChangeDateTime(value, 'endDate') }), _jsx(MobileTimePicker, { className: classes.picker, disablePast: disablePastEndTime, label: field.endTime && _jsx(FormattedMessage, { id: "ui.eventForm.time.end.placeholder", defaultMessage: "ui.eventForm.time.end.placeholder" }), value: field.endTime, slots: {
306
- textField: (params) => (_jsx(TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endTime)}`, startAdornment: (_jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "access_time" }) }) }))) }) })))
307
- }, onChange: (value) => handleChangeDateTime(value, 'endTime') })] })) }))), _jsx(Button, Object.assign({ variant: "text", color: "secondary", onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['showEndDateTime']: !field.showEndDateTime }))), disabled: field.showEndDateTime && field.recurring !== SCEventRecurrenceType.NEVER }, { children: _jsx(FormattedMessage, { id: "ui.eventForm.dateTime.placeholder", defaultMessage: "ui.eventForm.dateTime.placeholder", values: { symbol: field.showEndDateTime ? '-' : '+' } }) })), _jsx(EventAddress, { forwardGeolocationData: handleGeoData, event: event !== null && event !== void 0 ? event : null }), privateEnabled && (_jsxs(Box, Object.assign({ className: classes.privacySection }, { children: [_jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [_jsxs(Typography, Object.assign({ className: classNames(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [_jsx(Icon, { children: "private" }), _jsx(FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), _jsx(Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))) }), _jsxs(Typography, Object.assign({ className: classNames(classes.switchLabel, { [classes.active]: field.isPublic }) }, { children: [_jsx(Icon, { children: "public" }), _jsx(FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" })] }))] })), _jsx(Typography, Object.assign({ variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, { children: field.isPublic ? (_jsx(FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
320
+ }, onChange: (value) => handleChangeDateTime(value, 'endDate'), shouldDisableDate: shouldDisabledDate }), _jsx(MobileTimePicker, { className: classes.picker, disablePast: disablePastEndTime, label: field.endTime && _jsx(FormattedMessage, { id: "ui.eventForm.time.end.placeholder", defaultMessage: "ui.eventForm.time.end.placeholder" }), value: field.endTime, slots: {
321
+ textField: (params) => {
322
+ var _a;
323
+ return (_jsx(TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endTime)}`, startAdornment: (_jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "access_time" }) }) }))) }), error: Boolean(error['endDateError']), helperText: ((_a = error['endDateError']) === null || _a === void 0 ? void 0 : _a.error) ? (_jsx(FormattedMessage, { id: "ui.eventForm.time.end.error.invalid", defaultMessage: "ui.eventForm.time.end.error.invalid" })) : null })));
324
+ }
325
+ }, onChange: (value) => handleChangeDateTime(value, 'endTime'), shouldDisableTime: shouldDisabledTime })] })) })), _jsx(EventAddress, { forwardGeolocationData: handleGeoData, event: event !== null && event !== void 0 ? event : null }), privateEnabled && (_jsxs(Box, Object.assign({ className: classes.privacySection }, { children: [_jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [_jsxs(Typography, Object.assign({ className: classNames(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [_jsx(Icon, { children: "private" }), _jsx(FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), _jsx(Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: event && !field.isPublic }), _jsxs(Typography, Object.assign({ className: classNames(classes.switchLabel, { [classes.active]: field.isPublic }) }, { children: [_jsx(Icon, { children: "public" }), _jsx(FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" })] }))] })), _jsx(Typography, Object.assign({ variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, { children: field.isPublic ? (_jsx(FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
308
326
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
309
327
  // @ts-ignore
310
328
  b: (chunks) => _jsx("strong", { children: chunks })
@@ -313,6 +331,6 @@ export default function EventForm(inProps) {
313
331
  // @ts-ignore
314
332
  b: (chunks) => _jsx("strong", { children: chunks })
315
333
  } })) }))] }))), _jsx(TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
316
- endAdornment: (_jsx(Typography, Object.assign({ variant: "body2" }, { children: ((_e = field.description) === null || _e === void 0 ? void 0 : _e.length) ? EVENT_DESCRIPTION_MAX_LENGTH - field.description.length : EVENT_DESCRIPTION_MAX_LENGTH })))
317
- }, error: Boolean(((_f = field.description) === null || _f === void 0 ? void 0 : _f.length) > EVENT_DESCRIPTION_MAX_LENGTH), helperText: ((_g = field.description) === null || _g === void 0 ? void 0 : _g.length) > EVENT_DESCRIPTION_MAX_LENGTH ? (_jsx(FormattedMessage, { id: "ui.eventForm.description.error.maxLength", defaultMessage: "ui.eventForm.description.error.maxLength" })) : null })] }))] }) })));
334
+ endAdornment: (_jsx(Typography, Object.assign({ variant: "body2" }, { children: ((_b = field.description) === null || _b === void 0 ? void 0 : _b.length) ? EVENT_DESCRIPTION_MAX_LENGTH - field.description.length : EVENT_DESCRIPTION_MAX_LENGTH })))
335
+ }, error: Boolean(((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) > EVENT_DESCRIPTION_MAX_LENGTH), helperText: ((_d = field.description) === null || _d === void 0 ? void 0 : _d.length) > EVENT_DESCRIPTION_MAX_LENGTH ? (_jsx(FormattedMessage, { id: "ui.eventForm.description.error.maxLength", defaultMessage: "ui.eventForm.description.error.maxLength" })) : null })] }))] }) })));
318
336
  }
@@ -1 +1,5 @@
1
1
  export declare const PREFIX = "SCEventForm";
2
+ export declare const NEVER_LATER_DAYS = 14;
3
+ export declare const DAILY_LATER_DAYS = 60;
4
+ export declare const WEEKLY_LATER_DAYS = 360;
5
+ export declare const MONTHLY_LATER_DAYS = 730;
@@ -1 +1,5 @@
1
1
  export const PREFIX = 'SCEventForm';
2
+ export const NEVER_LATER_DAYS = 14;
3
+ export const DAILY_LATER_DAYS = 60;
4
+ export const WEEKLY_LATER_DAYS = 360;
5
+ export const MONTHLY_LATER_DAYS = 730;
@@ -12,7 +12,7 @@ export declare type Geolocation = {
12
12
  };
13
13
  export declare type InitialFieldState = Geolocation & {
14
14
  imageOriginal: string | ArrayBuffer;
15
- imageOriginalFile: Blob;
15
+ imageOriginalFile: string | Blob;
16
16
  startDate: Date | null;
17
17
  startTime: Date | null;
18
18
  endDate: Date | null;
@@ -22,7 +22,6 @@ export declare type InitialFieldState = Geolocation & {
22
22
  description: string;
23
23
  isPublic: boolean;
24
24
  isSubmitting: boolean;
25
- showEndDateTime: boolean;
26
25
  };
27
26
  export declare type FieldStateKeys = keyof InitialFieldState;
28
27
  export declare type FieldStateValues = InitialFieldState[FieldStateKeys];
@@ -0,0 +1,4 @@
1
+ export declare function getNewDate(date?: string): Date;
2
+ export declare function getLaterHoursDate(h: number): Date;
3
+ export declare function getLaterDaysDate(d: number): Date;
4
+ export declare const combineDateAndTime: (date: Date, time: Date) => string;
@@ -0,0 +1,21 @@
1
+ import { addDays, addHours } from 'date-fns';
2
+ export function getNewDate(date) {
3
+ if (date) {
4
+ return new Date(date);
5
+ }
6
+ return new Date();
7
+ }
8
+ export function getLaterHoursDate(h) {
9
+ return addHours(getNewDate(), h);
10
+ }
11
+ export function getLaterDaysDate(d) {
12
+ return addDays(getNewDate(), d);
13
+ }
14
+ export const combineDateAndTime = (date, time) => {
15
+ const combined = date;
16
+ combined.setHours(time.getHours());
17
+ combined.setMinutes(time.getMinutes());
18
+ combined.setSeconds(time.getSeconds());
19
+ combined.setMilliseconds(time.getMilliseconds());
20
+ return combined.toISOString();
21
+ };
@@ -3,13 +3,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Box, Button, CardContent, Icon, Stack, styled, Typography, useThemeProps } from '@mui/material';
4
4
  import { useSCFetchEvent } from '@selfcommunity/react-core';
5
5
  import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
6
- import { useCallback, useEffect, useMemo, useState } from 'react';
6
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
7
7
  import { FormattedMessage } from 'react-intl';
8
8
  import EventInfoDetails from '../../shared/EventInfoDetails';
9
9
  import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
10
10
  import Widget from '../Widget';
11
11
  import { PREFIX } from './constants';
12
12
  import Skeleton from './Skeleton';
13
+ import PubSub from 'pubsub-js';
14
+ import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
13
15
  const classes = {
14
16
  root: `${PREFIX}-root`,
15
17
  content: `${PREFIX}-content`,
@@ -43,7 +45,9 @@ export default function EventInfoWidget(inProps) {
43
45
  const [showButton, setShowButton] = useState(!summaryExpanded);
44
46
  const [loading, setLoading] = useState(true);
45
47
  // HOOKS
46
- const { scEvent } = useSCFetchEvent({ id: eventId, event });
48
+ const { scEvent, setSCEvent } = useSCFetchEvent({ id: eventId, event });
49
+ // REFS
50
+ const updatesSubscription = useRef(null);
47
51
  useEffect(() => {
48
52
  setLoading(false);
49
53
  }, []);
@@ -65,6 +69,25 @@ export default function EventInfoWidget(inProps) {
65
69
  const showInfo = useMemo(() => (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) === SCEventPrivacyType.PUBLIC ||
66
70
  [SCEventSubscriptionStatusType.SUBSCRIBED, SCEventSubscriptionStatusType.GOING, SCEventSubscriptionStatusType.NOT_GOING].indexOf(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) > -1, [scEvent]);
67
71
  const description = useMemo(() => (expanded ? scEvent === null || scEvent === void 0 ? void 0 : scEvent.description : getTruncatedText(scEvent === null || scEvent === void 0 ? void 0 : scEvent.description, 220)), [expanded, scEvent]);
72
+ /**
73
+ * Subscriber for pubsub callback
74
+ */
75
+ const onChangeGroupHandler = useCallback((_msg, data) => {
76
+ if (data && scEvent.id === data.id) {
77
+ setSCEvent(data);
78
+ }
79
+ }, [scEvent, setSCEvent]);
80
+ /**
81
+ * On mount, subscribe to receive groups updates (only edit)
82
+ */
83
+ useEffect(() => {
84
+ if (scEvent) {
85
+ updatesSubscription.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.EDIT}`, onChangeGroupHandler);
86
+ }
87
+ return () => {
88
+ updatesSubscription.current && PubSub.unsubscribe(updatesSubscription.current);
89
+ };
90
+ }, [scEvent]);
68
91
  // RENDER
69
92
  if (!scEvent && loading) {
70
93
  return _jsx(Skeleton, {});
@@ -5,7 +5,7 @@ import { styled } from '@mui/material/styles';
5
5
  import { useThemeProps } from '@mui/system';
6
6
  import { Endpoints, http } from '@selfcommunity/api-services';
7
7
  import { SCPreferences, SCPreferencesContext, SCUserContext, UserUtils } from '@selfcommunity/react-core';
8
- import { SCEventDateFilterType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
8
+ import { SCEventDateFilterType, SCEventSubscriptionStatusType, SCEventLocationFilterType } from '@selfcommunity/types';
9
9
  import { Logger } from '@selfcommunity/utils';
10
10
  import classNames from 'classnames';
11
11
  import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
@@ -19,6 +19,7 @@ import { PREFIX } from './constants';
19
19
  import PastEventsFilter from './PastEventsFilter';
20
20
  import PubSub from 'pubsub-js';
21
21
  import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
22
+ import LocationEventsFilter from './LocationEventsFilter';
22
23
  const classes = {
23
24
  root: `${PREFIX}-root`,
24
25
  filters: `${PREFIX}-filters`,
@@ -86,6 +87,7 @@ export default function Events(inProps) {
86
87
  const [next, setNext] = useState(null);
87
88
  const [query, setQuery] = useState('');
88
89
  const [dateSearch, setDateSearch] = useState(options[0].value);
90
+ const [location, setLocation] = useState(SCEventLocationFilterType.ANY);
89
91
  const [showFollowed, setShowFollowed] = useState(false);
90
92
  const [showPastEvents, setShowPastEvents] = useState(false);
91
93
  const [showMyEvents, setShowMyEvents] = useState(false);
@@ -125,7 +127,7 @@ export default function Events(inProps) {
125
127
  url: endpoint.url({}),
126
128
  method: endpoint.method,
127
129
  params: Object.assign(Object.assign({}, endpointQueryParams), (general
128
- ? Object.assign(Object.assign(Object.assign(Object.assign({}, (search && { search: query })), (dateSearch !== SCEventDateFilterType.ANY && { date_filter: dateSearch })), (showFollowed && { follows: showFollowed })), (showPastEvents && { date_filter: SCEventDateFilterType.PAST })) : Object.assign(Object.assign({ subscription_status: SCEventSubscriptionStatusType.GOING }, (showPastEvents && { past: showPastEvents })), (showMyEvents && { created_by: authUserId }))))
130
+ ? Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (search && { search: query })), (dateSearch !== SCEventDateFilterType.ANY && { date_filter: dateSearch })), (location !== SCEventLocationFilterType.ANY && { location })), (showFollowed && { follows: showFollowed })), (showPastEvents && { date_filter: SCEventDateFilterType.PAST })) : Object.assign(Object.assign(Object.assign({ subscription_status: SCEventSubscriptionStatusType.GOING }, (location !== SCEventLocationFilterType.ANY && { location })), (showPastEvents && { past: showPastEvents })), (showMyEvents && { created_by: authUserId }))))
129
131
  })
130
132
  .then((res) => {
131
133
  setEvents(res.data.results);
@@ -146,7 +148,7 @@ export default function Events(inProps) {
146
148
  else {
147
149
  query === '' && fetchEvents();
148
150
  }
149
- }, [contentAvailability, dateSearch, showFollowed, showPastEvents, showMyEvents, query]);
151
+ }, [contentAvailability, dateSearch, location, showFollowed, showPastEvents, showMyEvents, query]);
150
152
  /**
151
153
  * Subscriber for pubsub callback
152
154
  */
@@ -199,10 +201,18 @@ export default function Events(inProps) {
199
201
  const handleOnChangeTimeFrame = (event) => {
200
202
  setDateSearch(event.target.value);
201
203
  };
204
+ /**
205
+ * Handle change location
206
+ * @param event
207
+ */
208
+ const handleOnChangeLocation = (event) => {
209
+ setLocation(event.target.value);
210
+ };
202
211
  /**
203
212
  * Renders events list
204
213
  */
205
- const c = (_jsxs(_Fragment, { children: [showFilters && (_jsx(Grid, Object.assign({ container: true, className: classes.filters, gap: 2 }, { children: filters ? (filters) : !general ? (_jsxs(_Fragment, { children: [_jsx(Grid, Object.assign({ item: true }, { children: _jsx(PastEventsFilter, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, autoHide: !events.length && !showPastEvents, disabled: loading }) })), (events.length !== 0 || (events.length === 0 && showMyEvents)) && (_jsx(Grid, Object.assign({ item: true }, { children: _jsx(EventsChipRoot
214
+ console.log(location);
215
+ const c = (_jsxs(_Fragment, { children: [showFilters && (_jsx(Grid, Object.assign({ container: true, className: classes.filters, gap: 2 }, { children: filters ? (filters) : !general ? (_jsxs(_Fragment, { children: [(events.length !== 0 || (events.length === 0 && showMyEvents)) && (_jsx(Grid, Object.assign({ item: true }, { children: _jsx(EventsChipRoot
206
216
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
207
217
  // @ts-ignore
208
218
  , {
@@ -214,14 +224,14 @@ export default function Events(inProps) {
214
224
  variant: showMyEvents ? 'filled' : 'outlined', label: _jsx(FormattedMessage, { id: "ui.events.filterByCreatedByMe", defaultMessage: "ui.events.filterByCreatedByMe" }), onClick: () => setShowMyEvents(!showMyEvents),
215
225
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
216
226
  // @ts-ignore
217
- showFollowed: showMyEvents, deleteIcon: showMyEvents ? _jsx(Icon, { children: "close" }) : null, onDelete: showMyEvents ? handleDeleteClick : null, disabled: loading }) })))] })) : (_jsxs(_Fragment, { children: [_jsx(Grid, Object.assign({ item: true, xs: 12, md: 4 }, { children: _jsx(TextField, { className: classes.search, size: 'small', fullWidth: true, value: query, label: _jsx(FormattedMessage, { id: "ui.events.filterByName", defaultMessage: "ui.events.filterByName" }), variant: "outlined", onChange: handleOnChangeFilterName, disabled: loading, onKeyUp: (e) => {
227
+ showFollowed: showMyEvents, deleteIcon: showMyEvents ? _jsx(Icon, { children: "close" }) : null, onDelete: showMyEvents ? handleDeleteClick : null, autoHide: !loading && !events.length, disabled: loading }) }))), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: _jsx(LocationEventsFilter, { value: location, autoHide: !loading && !events.length, disabled: loading || (!events.length && !location), handleOnChange: handleOnChangeLocation }) })), _jsx(Grid, Object.assign({ item: true }, { children: _jsx(PastEventsFilter, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, autoHide: !loading && !events.length && !showPastEvents, disabled: loading }) }))] })) : (_jsxs(_Fragment, { children: [_jsx(Grid, Object.assign({ item: true, xs: 12, md: 3 }, { children: _jsx(TextField, { className: classes.search, size: 'small', fullWidth: true, value: query, label: _jsx(FormattedMessage, { id: "ui.events.filterByName", defaultMessage: "ui.events.filterByName" }), variant: "outlined", onChange: handleOnChangeFilterName, disabled: loading || (!events.length && !query), onKeyUp: (e) => {
218
228
  e.preventDefault();
219
229
  if (e.key === 'Enter') {
220
230
  fetchEvents(true);
221
231
  }
222
232
  }, InputProps: {
223
- endAdornment: (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: isMobile ? (_jsx(IconButton, Object.assign({ onClick: () => fetchEvents(true), disabled: loading }, { children: _jsx(Icon, { children: "search" }) }))) : (_jsx(Button, { size: "small", variant: "contained", color: "secondary", onClick: () => fetchEvents(true), endIcon: _jsx(Icon, { children: "search" }), disabled: loading })) })))
224
- } }) })), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: _jsxs(FormControl, Object.assign({ fullWidth: true }, { children: [_jsx(InputLabel, { children: _jsx(FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }) }), _jsx(Select, Object.assign({ disabled: showPastEvents || loading, size: 'small', label: _jsx(FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }), value: dateSearch, onChange: handleOnChangeTimeFrame, renderValue: (selected) => options.find((option) => option.value === selected).label }, { children: options.map((option) => (_jsxs(MenuItem, Object.assign({ value: option.value }, { children: [_jsx(Radio, { checked: dateSearch === option.value, value: option.value, name: "radio-button-select", inputProps: { 'aria-label': option.label } }), option.label] }), option.value))) }))] })) })), authUserId && (_jsx(Grid, Object.assign({ item: true }, { children: _jsx(EventsChipRoot
233
+ endAdornment: (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: isMobile ? (_jsx(IconButton, Object.assign({ onClick: () => fetchEvents(true), disabled: loading || (!events.length && !query) }, { children: _jsx(Icon, { children: "search" }) }))) : (_jsx(Button, { size: "small", variant: "contained", color: "secondary", onClick: () => fetchEvents(true), endIcon: _jsx(Icon, { children: "search" }), disabled: loading || (!events.length && !query) })) })))
234
+ } }) })), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: _jsxs(FormControl, Object.assign({ fullWidth: true }, { children: [_jsx(InputLabel, { children: _jsx(FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }) }), _jsx(Select, Object.assign({ disabled: showPastEvents || loading || (!events.length && dateSearch === SCEventDateFilterType.ANY), size: 'small', label: _jsx(FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }), value: dateSearch, onChange: handleOnChangeTimeFrame, renderValue: (selected) => options.find((option) => option.value === selected).label }, { children: options.map((option) => (_jsxs(MenuItem, Object.assign({ value: option.value }, { children: [_jsx(Radio, { checked: dateSearch === option.value, value: option.value, name: "radio-button-select", inputProps: { 'aria-label': option.label } }), option.label] }), option.value))) }))] })) })), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: _jsx(LocationEventsFilter, { value: location, disabled: loading || (!events.length && !location), handleOnChange: handleOnChangeLocation }) })), authUserId && (_jsx(Grid, Object.assign({ item: true }, { children: _jsx(EventsChipRoot
225
235
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
226
236
  // @ts-ignore
227
237
  , {
@@ -233,7 +243,7 @@ export default function Events(inProps) {
233
243
  variant: showFollowed ? 'filled' : 'outlined', label: _jsx(FormattedMessage, { id: "ui.events.filterByFollowedInterest", defaultMessage: "ui.events.filterByFollowedInterest" }), onClick: handleChipClick,
234
244
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
235
245
  // @ts-ignore
236
- showFollowed: showFollowed, deleteIcon: showFollowed ? _jsx(Icon, { children: "close" }) : null, onDelete: showFollowed ? handleDeleteClick : null, disabled: loading }) }))), _jsx(Grid, Object.assign({ item: true }, { children: _jsx(PastEventsFilter, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, disabled: dateSearch !== SCEventDateFilterType.ANY || loading }) }))] })) }))), _jsx(_Fragment, { children: loading ? (_jsx(Skeleton, Object.assign({}, EventsSkeletonComponentProps, { EventSkeletonProps: EventSkeletonComponentProps }))) : (_jsx(_Fragment, { children: !events.length ? (_jsx(Box, Object.assign({ className: classes.noResults }, { children: (onlyStaffEnabled && !UserUtils.isStaff(scUserContext.user)) ||
246
+ showFollowed: showFollowed, deleteIcon: showFollowed ? _jsx(Icon, { children: "close" }) : null, onDelete: showFollowed ? handleDeleteClick : null, disabled: loading || (!events.length && !showFollowed) }) }))), _jsx(Grid, Object.assign({ item: true }, { children: _jsx(PastEventsFilter, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, disabled: dateSearch !== SCEventDateFilterType.ANY || loading || (!events.length && !showPastEvents) }) }))] })) }))), _jsx(_Fragment, { children: loading ? (_jsx(Skeleton, Object.assign({}, EventsSkeletonComponentProps, { EventSkeletonProps: EventSkeletonComponentProps }))) : (_jsx(_Fragment, { children: !events.length ? (_jsx(Box, Object.assign({ className: classes.noResults }, { children: (onlyStaffEnabled && !UserUtils.isStaff(scUserContext.user)) ||
237
247
  (onlyStaffEnabled && UserUtils.isStaff(scUserContext.user) && general) ? (_jsxs(_Fragment, { children: [_jsx(EventSkeleton, Object.assign({}, EventSkeletonComponentProps)), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.events.noEvents.title", defaultMessage: "ui.events.noEvents.title" }) }))] })) : (_jsxs(_Fragment, { children: [_jsx(EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: _jsx(CreateEventButton, {}) })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.events.noEvents.title.onlyStaff", defaultMessage: "ui.events.noEvents.title.onlyStaff" }) }))] })) }))) : (_jsxs(_Fragment, { children: [_jsx(Grid, Object.assign({ container: true, spacing: { xs: 2 }, className: classes.events }, GridContainerComponentProps, { children: _jsxs(_Fragment, { children: [events.map((event) => (_jsx(Grid, Object.assign({ item: true, xs: 12, sm: 12, md: 6, className: classes.item }, GridItemComponentProps, { children: _jsx(Event, Object.assign({ event: event, eventId: event.id }, EventComponentProps)) }), event.id))), authUserId && events.length % 2 !== 0 && (_jsx(Grid, Object.assign({ item: true, xs: 12, sm: 12, md: 6, className: classes.itemSkeleton }, GridItemComponentProps, { children: _jsx(EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: _jsx(CreateEventButton, Object.assign({ variant: "outlined", color: "primary", size: "small" }, { children: _jsx(FormattedMessage, { id: "ui.events.skeleton.action.add", defaultMessage: "ui.events.skeleton.action.add" }) })) })) }), 'skeleton-item'))] }) })), Boolean(next) && (_jsx(Button, Object.assign({ color: "secondary", variant: "text", onClick: handleNext, className: classes.showMore }, { children: _jsx(FormattedMessage, { id: "ui.events.button.seeMore", defaultMessage: "ui.events.button.seeMore" }) })))] })) })) })] }));
238
248
  /**
239
249
  * Renders root object (if content availability community option is false and user is anonymous, component is hidden)
@@ -0,0 +1,14 @@
1
+ import { ChipProps } from '@mui/material';
2
+ import { SCEventLocationFilterType } from '@selfcommunity/types';
3
+ export interface LocationEventsFilterProps extends ChipProps {
4
+ /**
5
+ * Overrides or extends the styles applied to the component.
6
+ * @default null
7
+ */
8
+ className?: string;
9
+ value: SCEventLocationFilterType;
10
+ disabled?: boolean;
11
+ autoHide?: boolean;
12
+ handleOnChange: (event: any) => void;
13
+ }
14
+ export default function LocationEventsFilter(inProps: LocationEventsFilterProps): JSX.Element;
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { FormControl, InputLabel, MenuItem, Radio, Select } from '@mui/material';
3
+ import { FormattedMessage } from 'react-intl';
4
+ import { useThemeProps } from '@mui/system';
5
+ import { PREFIX } from './constants';
6
+ import { styled } from '@mui/material/styles';
7
+ import { SCEventLocationFilterType } from '@selfcommunity/types';
8
+ import classNames from 'classnames';
9
+ const classes = {
10
+ root: `${PREFIX}-root`
11
+ };
12
+ const Root = styled(FormControl, {
13
+ name: PREFIX,
14
+ slot: 'Root'
15
+ })(() => ({}));
16
+ const locationOptions = [
17
+ {
18
+ value: SCEventLocationFilterType.ANY,
19
+ label: _jsx(FormattedMessage, { id: "ui.events.location.select.any", defaultMessage: "ui.events.location.select.any" })
20
+ },
21
+ {
22
+ value: SCEventLocationFilterType.PERSON,
23
+ label: _jsx(FormattedMessage, { id: "ui.eventInfoDetails.location.inPerson", defaultMessage: "ui.eventInfoDetails.location.inPerson" })
24
+ },
25
+ {
26
+ value: SCEventLocationFilterType.ONLINE,
27
+ label: _jsx(FormattedMessage, { id: "ui.eventInfoDetails.location.virtual", defaultMessage: "ui.eventInfoDetails.location.virtual" })
28
+ }
29
+ ];
30
+ export default function LocationEventsFilter(inProps) {
31
+ // PROPS
32
+ const props = useThemeProps({
33
+ props: inProps,
34
+ name: PREFIX
35
+ });
36
+ const { className, value, disabled = false, autoHide = false, handleOnChange } = props;
37
+ if (autoHide) {
38
+ return null;
39
+ }
40
+ return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className), fullWidth: true }, { children: [_jsx(InputLabel, { children: _jsx(FormattedMessage, { id: "ui.events.filterByLocation", defaultMessage: "ui.events.filterByLocation" }) }), _jsx(Select, Object.assign({ disabled: disabled, size: 'small', label: _jsx(FormattedMessage, { id: "ui.events.location", defaultMessage: "ui.events.location" }), value: value, onChange: handleOnChange, renderValue: (selected) => locationOptions.find((option) => option.value === selected).label }, { children: locationOptions.map((option) => (_jsxs(MenuItem, Object.assign({ value: option.value }, { children: [_jsx(Radio, { checked: value === option.value, value: option.value, name: "radio-button-select", inputProps: { 'aria-label': option.label } }), option.label] }), option.value))) }))] })));
41
+ }
@@ -5,7 +5,6 @@ import { FormattedMessage } from 'react-intl';
5
5
  import { useThemeProps } from '@mui/system';
6
6
  import { PREFIX } from './constants';
7
7
  import { EventsChipRoot } from './Events';
8
- import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
9
8
  export default function PastEventsFilter(inProps) {
10
9
  // PROPS
11
10
  const props = useThemeProps({
@@ -14,7 +13,7 @@ export default function PastEventsFilter(inProps) {
14
13
  });
15
14
  const { autoHide = false, showPastEvents, handleClick, handleDeleteClick } = props, rest = __rest(props, ["autoHide", "showPastEvents", "handleClick", "handleDeleteClick"]);
16
15
  if (autoHide) {
17
- return _jsx(HiddenPlaceholder, {});
16
+ return null;
18
17
  }
19
18
  return (_jsx(EventsChipRoot
20
19
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore