@selfcommunity/react-ui 0.8.0-alpha.2 → 0.8.0-alpha.20

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 (90) 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/EventAddress.d.ts +3 -8
  7. package/lib/cjs/components/EventForm/EventAddress.js +20 -20
  8. package/lib/cjs/components/EventForm/EventForm.d.ts +1 -1
  9. package/lib/cjs/components/EventForm/EventForm.js +90 -76
  10. package/lib/cjs/components/EventForm/constants.d.ts +4 -0
  11. package/lib/cjs/components/EventForm/constants.js +5 -1
  12. package/lib/cjs/components/EventForm/types.d.ts +27 -0
  13. package/lib/cjs/components/EventForm/types.js +2 -0
  14. package/lib/cjs/components/EventForm/utils.d.ts +4 -0
  15. package/lib/cjs/components/EventForm/utils.js +28 -0
  16. package/lib/cjs/components/EventHeader/EventHeader.js +1 -1
  17. package/lib/cjs/components/EventInfoWidget/EventInfoWidget.js +24 -1
  18. package/lib/cjs/components/Events/Events.js +4 -4
  19. package/lib/cjs/components/Feed/Feed.js +10 -2
  20. package/lib/cjs/components/GroupActionsMenu/index.d.ts +57 -0
  21. package/lib/cjs/components/GroupActionsMenu/index.js +157 -0
  22. package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -0
  23. package/lib/cjs/components/GroupHeader/GroupHeader.js +8 -4
  24. package/lib/cjs/components/Groups/Groups.js +26 -0
  25. package/lib/cjs/components/MyEventsWidget/MyEventsWidget.js +6 -2
  26. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +12 -3
  27. package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -2
  28. package/lib/cjs/components/Notification/Event/Event.js +4 -0
  29. package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.d.ts +10 -1
  30. package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.js +69 -26
  31. package/lib/cjs/components/OnBoardingWidget/Steps/Invite/Invite.js +26 -3
  32. package/lib/cjs/components/PlatformWidget/constants.d.ts +0 -4
  33. package/lib/cjs/components/PlatformWidget/constants.js +1 -5
  34. package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +7 -2
  35. package/lib/cjs/constants/GroupActionsMenu.d.ts +5 -0
  36. package/lib/cjs/constants/GroupActionsMenu.js +8 -0
  37. package/lib/cjs/index.d.ts +2 -1
  38. package/lib/cjs/index.js +6 -4
  39. package/lib/cjs/shared/ContributionActionsMenu/index.js +6 -6
  40. package/lib/cjs/shared/EventActionsMenu/index.d.ts +4 -0
  41. package/lib/cjs/shared/EventActionsMenu/index.js +13 -3
  42. package/lib/cjs/shared/InfiniteScroll/index.js +3 -3
  43. package/lib/cjs/shared/Media/Link/DisplayComponent.js +21 -5
  44. package/lib/cjs/utils/formatRelativeTime.js +2 -2
  45. package/lib/esm/components/BottomNavigation/BottomNavigation.js +11 -2
  46. package/lib/esm/components/Composer/Composer.js +10 -2
  47. package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +13 -4
  48. package/lib/esm/components/CreateEventButton/CreateEventButton.js +5 -1
  49. package/lib/esm/components/CreateEventWidget/CreateEventWidget.js +5 -1
  50. package/lib/esm/components/EventForm/EventAddress.d.ts +3 -8
  51. package/lib/esm/components/EventForm/EventAddress.js +20 -20
  52. package/lib/esm/components/EventForm/EventForm.d.ts +1 -1
  53. package/lib/esm/components/EventForm/EventForm.js +92 -78
  54. package/lib/esm/components/EventForm/constants.d.ts +4 -0
  55. package/lib/esm/components/EventForm/constants.js +4 -0
  56. package/lib/esm/components/EventForm/types.d.ts +27 -0
  57. package/lib/esm/components/EventForm/types.js +1 -0
  58. package/lib/esm/components/EventForm/utils.d.ts +4 -0
  59. package/lib/esm/components/EventForm/utils.js +21 -0
  60. package/lib/esm/components/EventHeader/EventHeader.js +1 -1
  61. package/lib/esm/components/EventInfoWidget/EventInfoWidget.js +25 -2
  62. package/lib/esm/components/Events/Events.js +4 -4
  63. package/lib/esm/components/Feed/Feed.js +12 -4
  64. package/lib/esm/components/GroupActionsMenu/index.d.ts +57 -0
  65. package/lib/esm/components/GroupActionsMenu/index.js +154 -0
  66. package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -0
  67. package/lib/esm/components/GroupHeader/GroupHeader.js +9 -5
  68. package/lib/esm/components/Groups/Groups.js +27 -1
  69. package/lib/esm/components/MyEventsWidget/MyEventsWidget.js +7 -3
  70. package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +12 -3
  71. package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -2
  72. package/lib/esm/components/Notification/Event/Event.js +4 -0
  73. package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.d.ts +10 -1
  74. package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.js +71 -28
  75. package/lib/esm/components/OnBoardingWidget/Steps/Invite/Invite.js +27 -4
  76. package/lib/esm/components/PlatformWidget/constants.d.ts +0 -4
  77. package/lib/esm/components/PlatformWidget/constants.js +0 -4
  78. package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +8 -3
  79. package/lib/esm/constants/GroupActionsMenu.d.ts +5 -0
  80. package/lib/esm/constants/GroupActionsMenu.js +5 -0
  81. package/lib/esm/index.d.ts +2 -1
  82. package/lib/esm/index.js +2 -1
  83. package/lib/esm/shared/ContributionActionsMenu/index.js +6 -6
  84. package/lib/esm/shared/EventActionsMenu/index.d.ts +4 -0
  85. package/lib/esm/shared/EventActionsMenu/index.js +13 -3
  86. package/lib/esm/shared/InfiniteScroll/index.js +3 -3
  87. package/lib/esm/shared/Media/Link/DisplayComponent.js +21 -5
  88. package/lib/esm/utils/formatRelativeTime.js +2 -2
  89. package/lib/umd/react-ui.js +1 -1
  90. package/package.json +6 -6
@@ -63,8 +63,17 @@ function BottomNavigation(inProps) {
63
63
  const { preferences, features } = (0, react_core_1.useSCPreferences)();
64
64
  // MEMO
65
65
  const privateMessagingEnabled = (0, react_1.useMemo)(() => features.includes(types_1.SCFeatureName.PRIVATE_MESSAGING), [features]);
66
- const groupsEnabled = (0, react_1.useMemo)(() => features.includes(types_1.SCFeatureName.GROUPING) && features.includes(types_1.SCFeatureName.TAGGING), [features]);
67
- const eventsEnabled = (0, react_1.useMemo)(() => features && features.includes(types_1.SCFeatureName.EVENT) && features.includes(types_1.SCFeatureName.TAGGING), [features]);
66
+ const groupsEnabled = (0, react_1.useMemo)(() => preferences &&
67
+ features &&
68
+ features.includes(types_1.SCFeatureName.TAGGING) &&
69
+ features.includes(types_1.SCFeatureName.GROUPING) &&
70
+ react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
71
+ preferences[react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
72
+ const eventsEnabled = (0, react_1.useMemo)(() => preferences &&
73
+ features &&
74
+ features.includes(types_1.SCFeatureName.TAGGING) &&
75
+ react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
76
+ preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
68
77
  const exploreStreamEnabled = preferences[react_core_1.SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value;
69
78
  const postOnlyStaffEnabled = preferences[react_core_1.SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value;
70
79
  const contentAvailable = preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value;
@@ -430,10 +430,16 @@ function Composer(inProps) {
430
430
  if (features.includes(types_1.SCFeatureName.TAGGING) && addressing !== null) {
431
431
  data.addressing = addressing.map((t) => t.id);
432
432
  }
433
- if (features.includes(types_1.SCFeatureName.GROUPING) && group !== null) {
433
+ if (features.includes(types_1.SCFeatureName.TAGGING) &&
434
+ features.includes(types_1.SCFeatureName.GROUPING) &&
435
+ preferences[react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value &&
436
+ group !== null) {
434
437
  data.group = group.id;
435
438
  }
436
- if (features.includes(types_1.SCFeatureName.EVENT) && event !== null) {
439
+ if (features.includes(types_1.SCFeatureName.TAGGING) &&
440
+ features.includes(types_1.SCFeatureName.EVENT) &&
441
+ preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value &&
442
+ event !== null) {
437
443
  data.event = event.id;
438
444
  }
439
445
  setIsSubmitting(true);
@@ -497,6 +503,8 @@ function Composer(inProps) {
497
503
  }
498
504
  else {
499
505
  onClose && onClose(e);
506
+ setLayer(null);
507
+ dispatch({ type: 'reset' });
500
508
  /*setLayer(null);
501
509
  feedType && feedType === SCFeedTypologyType.CATEGORY
502
510
  ? dispatch({type: 'resetCategoryFeed'})
@@ -60,10 +60,19 @@ const AudienceLayer = react_1.default.forwardRef((props, ref) => {
60
60
  const [value, setValue] = (0, react_1.useState)(defaultValue || undefined);
61
61
  // HOOKS
62
62
  const { scAddressingTags } = (0, react_core_1.useSCFetchAddressingTagList)({ fetch: autocompleteOpen });
63
- const { features } = (0, react_core_1.useSCPreferences)();
63
+ const { preferences, features } = (0, react_core_1.useSCPreferences)();
64
64
  // MEMO
65
- const eventsEnabled = (0, react_1.useMemo)(() => features && features.includes(types_1.SCFeatureName.EVENT) && features.includes(types_1.SCFeatureName.TAGGING), [features]);
66
- const groupsEnabled = (0, react_1.useMemo)(() => features && features.includes(types_1.SCFeatureName.GROUPING) && features.includes(types_1.SCFeatureName.TAGGING), [features]);
65
+ const groupsEnabled = (0, react_1.useMemo)(() => preferences &&
66
+ features &&
67
+ features.includes(types_1.SCFeatureName.TAGGING) &&
68
+ features.includes(types_1.SCFeatureName.GROUPING) &&
69
+ react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
70
+ preferences[react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
71
+ const eventsEnabled = (0, react_1.useMemo)(() => preferences &&
72
+ features &&
73
+ features.includes(types_1.SCFeatureName.TAGGING) &&
74
+ react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
75
+ preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
67
76
  // HANDLERS
68
77
  const handleSave = (0, react_1.useCallback)(() => {
69
78
  audience === AudienceTypes.AUDIENCE_GROUP || audience === AudienceTypes.AUDIENCE_EVENT
@@ -54,7 +54,11 @@ function CreateEventButton(inProps) {
54
54
  // CONST
55
55
  const authUserId = scUserContext.user ? scUserContext.user.id : null;
56
56
  const { preferences, features } = (0, react_core_1.useSCPreferences)();
57
- const eventsEnabled = (0, react_1.useMemo)(() => features && features.includes(types_1.SCFeatureName.EVENT) && features.includes(types_1.SCFeatureName.TAGGING), [features]);
57
+ const eventsEnabled = (0, react_1.useMemo)(() => preferences &&
58
+ features &&
59
+ features.includes(types_1.SCFeatureName.TAGGING) &&
60
+ react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
61
+ preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
58
62
  const onlyStaffEnabled = (0, react_1.useMemo)(() => preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED].value, [preferences]);
59
63
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
60
64
  // @ts-ignore
@@ -40,7 +40,11 @@ function CreateEventWidget(inProps) {
40
40
  const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
41
41
  // HOOK
42
42
  const { preferences, features } = (0, react_core_1.useSCPreferences)();
43
- const eventsEnabled = (0, react_1.useMemo)(() => features && features.includes(types_1.SCFeatureName.EVENT) && features.includes(types_1.SCFeatureName.TAGGING), [features]);
43
+ const eventsEnabled = (0, react_1.useMemo)(() => preferences &&
44
+ features &&
45
+ features.includes(types_1.SCFeatureName.TAGGING) &&
46
+ react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
47
+ preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
44
48
  const authUserId = scUserContext.user ? scUserContext.user.id : null;
45
49
  const onlyStaffEnabled = (0, react_1.useMemo)(() => preferences[react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ONLY_STAFF_ENABLED].value, [preferences]);
46
50
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
@@ -1,13 +1,8 @@
1
- import { SCEventLocationType, SCEventType } from '@selfcommunity/types';
1
+ import { SCEventType } from '@selfcommunity/types';
2
+ import { Geolocation } from './types';
2
3
  export interface EventAddressProps {
3
4
  event?: SCEventType;
4
- forwardGeolocationData: (data: {
5
- location: SCEventLocationType;
6
- geolocation?: string;
7
- lat?: number;
8
- lng?: number;
9
- link?: string;
10
- }) => void;
5
+ forwardGeolocationData: (data: Geolocation) => void;
11
6
  className?: string;
12
7
  }
13
8
  export default function EventAddress(inProps: EventAddressProps): JSX.Element;
@@ -2,20 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const styles_1 = require("@mui/material/styles");
7
5
  const material_1 = require("@mui/material");
8
6
  const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon"));
9
- const classnames_1 = tslib_1.__importDefault(require("classnames"));
7
+ const styles_1 = require("@mui/material/styles");
10
8
  const system_1 = require("@mui/system");
11
- const constants_1 = require("./constants");
12
- const react_intl_1 = require("react-intl");
13
- const UrlTextField_1 = tslib_1.__importDefault(require("../../shared/UrlTextField"));
14
- const axios_1 = tslib_1.__importDefault(require("axios"));
9
+ const api_1 = require("@react-google-maps/api");
15
10
  const react_core_1 = require("@selfcommunity/react-core");
16
- const HiddenPlaceholder_1 = tslib_1.__importDefault(require("../../shared/HiddenPlaceholder"));
17
11
  const types_1 = require("@selfcommunity/types");
18
- const api_1 = require("@react-google-maps/api");
12
+ const axios_1 = tslib_1.__importDefault(require("axios"));
13
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
14
+ const react_1 = require("react");
15
+ const react_intl_1 = require("react-intl");
16
+ const HiddenPlaceholder_1 = tslib_1.__importDefault(require("../../shared/HiddenPlaceholder"));
17
+ const UrlTextField_1 = tslib_1.__importDefault(require("../../shared/UrlTextField"));
18
+ const constants_1 = require("./constants");
19
19
  const messages = (0, react_intl_1.defineMessages)({
20
20
  virtualPlaceholder: {
21
21
  id: 'ui.eventForm.address.online.placeholder',
@@ -43,8 +43,8 @@ function EventAddress(inProps) {
43
43
  // PROPS
44
44
  const { className, forwardGeolocationData, event } = props;
45
45
  // STATE
46
- const [location, setLocation] = (0, react_1.useState)(event ? event.location : types_1.SCEventLocationType.PERSON);
47
- const [geolocation, setGeoLocation] = (0, react_1.useState)(event ? event.geolocation : null);
46
+ const [location, setLocation] = (0, react_1.useState)((event === null || event === void 0 ? void 0 : event.location) || types_1.SCEventLocationType.PERSON);
47
+ const [geolocation, setGeoLocation] = (0, react_1.useState)(event ? { description: event.geolocation } : null);
48
48
  const [inputValue, setInputValue] = (0, react_1.useState)('');
49
49
  const [suggestions, setSuggestions] = (0, react_1.useState)([]);
50
50
  const [timeoutId, setTimeoutId] = (0, react_1.useState)(null);
@@ -56,22 +56,22 @@ function EventAddress(inProps) {
56
56
  libraries: ['places', 'geocoding']
57
57
  });
58
58
  // HANDLERS
59
- const handleChange = (event, newValue) => {
59
+ const handleChange = (_event, newValue) => {
60
60
  setLocation(newValue);
61
61
  };
62
- const handleSelection = (event, newValue) => tslib_1.__awaiter(this, void 0, void 0, function* () {
62
+ const handleSelection = (_event, newValue) => tslib_1.__awaiter(this, void 0, void 0, function* () {
63
63
  if (newValue) {
64
64
  try {
65
65
  const response = yield axios_1.default.get(`https://maps.googleapis.com/maps/api/geocode/json`, {
66
66
  params: {
67
- place_id: newValue.place_id,
67
+ place_id: newValue.id,
68
68
  key: geocodingApiKey
69
69
  }
70
70
  });
71
71
  const place = response.data.results[0];
72
72
  setGeoLocation(newValue);
73
73
  forwardGeolocationData({
74
- location: location,
74
+ location,
75
75
  geolocation: place.formatted_address,
76
76
  lat: place.geometry.location.lat,
77
77
  lng: place.geometry.location.lng
@@ -82,11 +82,11 @@ function EventAddress(inProps) {
82
82
  }
83
83
  }
84
84
  });
85
- const handleLocationChange = (event, newInputValue) => {
85
+ const handleLocationChange = (_event, newInputValue) => {
86
86
  setInputValue(newInputValue);
87
87
  };
88
88
  const handleLinkChange = (event) => {
89
- forwardGeolocationData({ location: location, link: event.target.value });
89
+ forwardGeolocationData({ location, link: event.target.value });
90
90
  };
91
91
  (0, react_1.useEffect)(() => {
92
92
  if (timeoutId) {
@@ -97,13 +97,13 @@ function EventAddress(inProps) {
97
97
  return;
98
98
  }
99
99
  if (inputValue.length >= 3) {
100
- const newTimeoutId = window.setTimeout(() => {
100
+ const newTimeoutId = setTimeout(() => {
101
101
  const autocompleteService = new window.google.maps.places.AutocompleteService();
102
102
  autocompleteService.getPlacePredictions({ input: inputValue }, (predictions, status) => {
103
103
  if (status === window.google.maps.places.PlacesServiceStatus.OK && predictions) {
104
104
  setSuggestions(predictions.map((prediction) => ({
105
105
  description: prediction.description,
106
- place_id: prediction.place_id
106
+ id: prediction.place_id
107
107
  })));
108
108
  }
109
109
  });
@@ -114,7 +114,7 @@ function EventAddress(inProps) {
114
114
  if (!geocodingApiKey && !isLoaded) {
115
115
  return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
116
116
  }
117
- return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Tabs, Object.assign({ className: classes.tabs, value: location, onChange: handleChange, indicatorColor: "secondary", textColor: "secondary", variant: "fullWidth" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Tab, { value: types_1.SCEventLocationType.PERSON, classes: { root: classes.tab }, icon: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "add_location_alt" }), iconPosition: "start", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.label", defaultMessage: "ui.eventForm.address.live.label" }) }), (0, jsx_runtime_1.jsx)(material_1.Tab, { value: types_1.SCEventLocationType.ONLINE, classes: { root: classes.tab }, icon: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "play_circle_outline" }), iconPosition: "start", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.online.label", defaultMessage: "ui.eventForm.address.online.label" }) })] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.tabContent }, { children: [location === types_1.SCEventLocationType.PERSON && ((0, jsx_runtime_1.jsx)(material_1.Autocomplete, { freeSolo: true, size: "small", value: geolocation, onChange: handleSelection, inputValue: inputValue, onInputChange: handleLocationChange, options: suggestions, getOptionLabel: (option) => option.description || geolocation, noOptionsText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.noResults", defaultMessage: "ui.eventForm.address.live.noResults" }), renderInput: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.placeholder", defaultMessage: "ui.eventForm.address.live.placeholder" }), variant: "outlined", fullWidth: true, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "add_location_alt" }) })), params.InputProps.endAdornment] })) }) }))) })), location === types_1.SCEventLocationType.ONLINE && ((0, jsx_runtime_1.jsx)(UrlTextField_1.default, { size: "small", fullWidth: true, type: "url", placeholder: `${intl.formatMessage(messages.virtualPlaceholder)}`, helperText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.online.help", defaultMessage: "ui.eventForm.address.online.help" }), InputProps: {
117
+ return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Tabs, Object.assign({ className: classes.tabs, value: location, onChange: handleChange, indicatorColor: "secondary", textColor: "secondary", variant: "fullWidth" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Tab, { value: types_1.SCEventLocationType.PERSON, classes: { root: classes.tab }, icon: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "add_location_alt" }), iconPosition: "start", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.label", defaultMessage: "ui.eventForm.address.live.label" }) }), (0, jsx_runtime_1.jsx)(material_1.Tab, { value: types_1.SCEventLocationType.ONLINE, classes: { root: classes.tab }, icon: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "play_circle_outline" }), iconPosition: "start", label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.online.label", defaultMessage: "ui.eventForm.address.online.label" }) })] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.tabContent }, { children: [location === types_1.SCEventLocationType.PERSON && ((0, jsx_runtime_1.jsx)(material_1.Autocomplete, { size: "small", value: geolocation, onChange: handleSelection, inputValue: inputValue, onInputChange: handleLocationChange, options: suggestions, getOptionLabel: (option) => option.description || geolocation.description, noOptionsText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.noResults", defaultMessage: "ui.eventForm.address.live.noResults" }), isOptionEqualToValue: (option, value) => option.description === value.description, renderInput: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.live.placeholder", defaultMessage: "ui.eventForm.address.live.placeholder" }), variant: "outlined", fullWidth: true, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "add_location_alt" }) })), params.InputProps.endAdornment] })) }) }))) })), location === types_1.SCEventLocationType.ONLINE && ((0, jsx_runtime_1.jsx)(UrlTextField_1.default, { size: "small", fullWidth: true, type: "url", placeholder: `${intl.formatMessage(messages.virtualPlaceholder)}`, helperText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.address.online.help", defaultMessage: "ui.eventForm.address.online.help" }), InputProps: {
118
118
  endAdornment: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "play_circle_outline" })
119
119
  }, onChange: handleLinkChange }))] }))] })));
120
120
  }
@@ -25,7 +25,7 @@ export interface EventFormProps extends BaseDialogProps {
25
25
  * On success callback function
26
26
  * @default null
27
27
  */
28
- onSuccess?: (data: any) => void;
28
+ onSuccess?: (data: SCEventType) => void;
29
29
  /**
30
30
  * Any other properties
31
31
  */
@@ -25,6 +25,7 @@ const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"))
25
25
  const constants_1 = require("./constants");
26
26
  const EventAddress_1 = tslib_1.__importDefault(require("./EventAddress"));
27
27
  const UploadEventCover_1 = tslib_1.__importDefault(require("./UploadEventCover"));
28
+ const utils_2 = require("./utils");
28
29
  const messages = (0, react_intl_1.defineMessages)({
29
30
  name: {
30
31
  id: 'ui.eventForm.name.placeholder',
@@ -113,7 +114,7 @@ const Root = (0, styles_1.styled)(BaseDialog_1.default, {
113
114
  * @param inProps
114
115
  */
115
116
  function EventForm(inProps) {
116
- var _a, _b, _c, _d, _e, _f, _g;
117
+ var _a, _b, _c, _d;
117
118
  //PROPS
118
119
  const props = (0, system_1.useThemeProps)({
119
120
  props: inProps,
@@ -124,24 +125,25 @@ function EventForm(inProps) {
124
125
  const scContext = (0, react_core_1.useSCContext)();
125
126
  // INTL
126
127
  const intl = (0, react_intl_1.useIntl)();
128
+ const startDateTime = (0, react_1.useMemo)(() => (0, utils_2.getNewDate)(event === null || event === void 0 ? void 0 : event.start_date), [event]);
129
+ const endDateTime = (0, react_1.useMemo)(() => (0, utils_2.getNewDate)(event === null || event === void 0 ? void 0 : event.end_date), [event]);
127
130
  const initialFieldState = {
128
- imageOriginal: event ? event.image_bigger : '',
131
+ imageOriginal: (event === null || event === void 0 ? void 0 : event.image_bigger) || '',
129
132
  imageOriginalFile: '',
130
- startDate: event ? new Date(event.start_date) : null,
131
- startTime: event ? new Date(event.start_date) : null,
132
- endDate: event && event.end_date ? new Date(event.end_date) : null,
133
- endTime: event && event.end_date ? new Date(event.end_date) : null,
134
- location: event ? event.location : types_1.SCEventLocationType.PERSON,
135
- geolocation: event ? event.geolocation : '',
136
- lat: event ? event.geolocation_lat : null,
137
- lng: event ? event.geolocation_lng : null,
138
- link: event ? event.link : '',
139
- recurring: event ? event.recurring : types_1.SCEventRecurrenceType.NEVER,
140
- name: event ? event.name : '',
133
+ startDate: event ? startDateTime : (0, utils_2.getNewDate)(),
134
+ startTime: event ? startDateTime : (0, utils_2.getLaterHoursDate)(1),
135
+ endDate: (event === null || event === void 0 ? void 0 : event.end_date) ? endDateTime : (0, utils_2.getNewDate)(),
136
+ endTime: (event === null || event === void 0 ? void 0 : event.end_date) ? endDateTime : (0, utils_2.getLaterHoursDate)(3),
137
+ location: (event === null || event === void 0 ? void 0 : event.location) || types_1.SCEventLocationType.PERSON,
138
+ geolocation: (event === null || event === void 0 ? void 0 : event.geolocation) || '',
139
+ lat: (event === null || event === void 0 ? void 0 : event.geolocation_lat) || null,
140
+ lng: (event === null || event === void 0 ? void 0 : event.geolocation_lng) || null,
141
+ link: (event === null || event === void 0 ? void 0 : event.link) || '',
142
+ recurring: (event === null || event === void 0 ? void 0 : event.recurring) || types_1.SCEventRecurrenceType.NEVER,
143
+ name: (event === null || event === void 0 ? void 0 : event.name) || '',
141
144
  description: event ? event.description : '',
142
- isPublic: (_a = (event && event.privacy === types_1.SCEventPrivacyType.PUBLIC)) !== null && _a !== void 0 ? _a : true,
143
- isSubmitting: false,
144
- showEndDateTime: (_b = (event && event.end_date)) !== null && _b !== void 0 ? _b : false
145
+ isPublic: (_a = (event === null || event === void 0 ? void 0 : event.privacy) === types_1.SCEventPrivacyType.PUBLIC) !== null && _a !== void 0 ? _a : true,
146
+ isSubmitting: false
145
147
  };
146
148
  // STATE
147
149
  const [field, setField] = (0, react_1.useState)(initialFieldState);
@@ -150,23 +152,12 @@ function EventForm(inProps) {
150
152
  const scPreferences = (0, react_core_1.useSCPreferences)();
151
153
  const privateEnabled = (0, react_1.useMemo)(() => scPreferences.preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_PRIVATE_ENABLED].value, [scPreferences.preferences]);
152
154
  const visibilityEnabled = (0, react_1.useMemo)(() => scPreferences.preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_VISIBILITY_ENABLED].value, [scPreferences.preferences]);
153
- const disablePastStartTime = (0, react_1.useMemo)(() => (field.startDate ? new Date(field.startDate).getDate() === new Date().getDate() : false), [field]);
154
- const disablePastEndTime = (0, react_1.useMemo)(() => (field.endDate ? new Date(field.endDate).getDate() === new Date().getDate() : false), [field]);
155
+ const disablePastStartTime = (0, react_1.useMemo)(() => field.startDate.getDate() === (0, utils_2.getNewDate)().getDate(), [field]);
156
+ const disablePastEndTime = (0, react_1.useMemo)(() => field.endDate.getDate() === (0, utils_2.getNewDate)().getDate(), [field]);
155
157
  const _backgroundCover = Object.assign({}, (field.imageOriginal
156
158
  ? { background: `url('${field.imageOriginal}') center / cover` }
157
159
  : { background: `url('${scPreferences.preferences[react_core_1.SCPreferences.IMAGES_USER_DEFAULT_COVER].value}') center / cover` }));
158
- const combineDateAndTime = (date, time) => {
159
- if (date && time) {
160
- const combined = new Date(date);
161
- combined.setHours(time.getHours());
162
- combined.setMinutes(time.getMinutes());
163
- combined.setSeconds(time.getSeconds());
164
- combined.setMilliseconds(time.getMilliseconds());
165
- return combined.toISOString();
166
- }
167
- return null;
168
- };
169
- function handleChangeCover(cover) {
160
+ const handleChangeCover = (0, react_1.useCallback)((cover) => {
170
161
  setField((prev) => (Object.assign(Object.assign({}, prev), { ['imageOriginalFile']: cover })));
171
162
  const reader = new FileReader();
172
163
  reader.onloadend = () => {
@@ -177,52 +168,48 @@ function EventForm(inProps) {
177
168
  delete error.imageOriginalError;
178
169
  setError(error);
179
170
  }
180
- }
171
+ }, [error]);
181
172
  /**
182
173
  * Notify when a group info changed
183
174
  * @param data
184
175
  */
185
- function notifyChanges(data) {
186
- if (data) {
187
- if (event) {
188
- // Edit group
189
- pubsub_js_1.default.publish(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.EDIT}`, data);
190
- }
191
- else {
192
- // Create group
193
- pubsub_js_1.default.publish(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.CREATE}`, data);
194
- }
176
+ const notifyChanges = (0, react_1.useCallback)((data) => {
177
+ if (event) {
178
+ // Edit group
179
+ pubsub_js_1.default.publish(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.EDIT}`, data);
195
180
  }
196
- }
197
- const handleGeoData = (data) => {
181
+ else {
182
+ // Create group
183
+ pubsub_js_1.default.publish(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.CREATE}`, data);
184
+ }
185
+ }, [event]);
186
+ const handleGeoData = (0, react_1.useCallback)((data) => {
198
187
  setField((prev) => (Object.assign(Object.assign({}, prev), data)));
199
- };
200
- const handleSubmit = () => {
188
+ }, []);
189
+ const handleSubmit = (0, react_1.useCallback)(() => {
201
190
  setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: true })));
202
191
  const formData = new FormData();
203
192
  if (field.imageOriginalFile) {
204
193
  formData.append('image_original', field.imageOriginalFile);
205
194
  }
206
195
  formData.append('name', field.name);
207
- formData.append('start_date', combineDateAndTime(field.startDate, field.startTime));
196
+ formData.append('start_date', (0, utils_2.combineDateAndTime)(field.startDate, field.startTime));
208
197
  formData.append('recurring', field.recurring);
209
- if (field.endDate) {
210
- formData.append('end_date', combineDateAndTime(field.endDate, field.endTime));
211
- }
198
+ formData.append('end_date', (0, utils_2.combineDateAndTime)(field.endDate, field.endTime));
212
199
  formData.append('location', field.location);
213
200
  if (field.location === types_1.SCEventLocationType.ONLINE) {
214
201
  formData.append('link', field.link);
215
202
  }
216
- if (field.location === types_1.SCEventLocationType.PERSON) {
203
+ else if (field.location === types_1.SCEventLocationType.PERSON) {
217
204
  formData.append('geolocation', field.geolocation);
218
- formData.append('geolocation_lat', field.lat);
219
- formData.append('geolocation_lng', field.lng);
205
+ formData.append('geolocation_lat', field.lat.toString());
206
+ formData.append('geolocation_lng', field.lng.toString());
220
207
  }
221
208
  if (privateEnabled) {
222
209
  formData.append('privacy', field.isPublic ? types_1.SCEventPrivacyType.PUBLIC : types_1.SCEventPrivacyType.PRIVATE);
223
210
  }
224
211
  if (visibilityEnabled) {
225
- formData.append('visible', true);
212
+ formData.append('visible', 'true');
226
213
  }
227
214
  formData.append('description', field.description);
228
215
  let eventService;
@@ -234,9 +221,9 @@ function EventForm(inProps) {
234
221
  }
235
222
  eventService
236
223
  .then((data) => {
237
- onSuccess && onSuccess(data);
224
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
238
225
  notifyChanges(data);
239
- onClose && onClose();
226
+ onClose === null || onClose === void 0 ? void 0 : onClose();
240
227
  setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
241
228
  })
242
229
  .catch((e) => {
@@ -252,28 +239,56 @@ function EventForm(inProps) {
252
239
  setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
253
240
  utils_1.Logger.error(Errors_1.SCOPE_SC_UI, e);
254
241
  });
255
- };
256
- const handleChange = (event) => {
242
+ }, [field, privateEnabled, visibilityEnabled]);
243
+ const handleChange = (0, react_1.useCallback)((event) => {
257
244
  const { name, value } = event.target;
258
245
  setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
259
246
  if (error[`${name}Error`]) {
260
247
  delete error[`${name}Error`];
261
248
  setError(error);
262
249
  }
263
- };
264
- const handleChangeDateTime = (value, name) => {
250
+ }, [error]);
251
+ const handleChangeDateTime = (0, react_1.useCallback)((value, name) => {
265
252
  setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
266
253
  if (error[`${name}Error`]) {
267
254
  delete error[`${name}Error`];
268
255
  setError(error);
269
256
  }
270
- };
257
+ else if (error['endDateError']) {
258
+ delete error['endDateError'];
259
+ setError(error);
260
+ }
261
+ }, [error]);
262
+ const shouldDisabledDate = (0, react_1.useCallback)((date) => {
263
+ let disabled = false;
264
+ switch (field.recurring) {
265
+ case types_1.SCEventRecurrenceType.DAILY:
266
+ disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.DAILY_LATER_DAYS).getTime();
267
+ break;
268
+ case types_1.SCEventRecurrenceType.WEEKLY:
269
+ disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.WEEKLY_LATER_DAYS).getTime();
270
+ break;
271
+ case types_1.SCEventRecurrenceType.MONTHLY:
272
+ disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.MONTHLY_LATER_DAYS).getTime();
273
+ break;
274
+ case types_1.SCEventRecurrenceType.NEVER:
275
+ default:
276
+ disabled = date.getTime() > (0, utils_2.getLaterDaysDate)(constants_1.NEVER_LATER_DAYS).getTime();
277
+ }
278
+ if (field.startDate.getDate() > date.getDate()) {
279
+ disabled = true;
280
+ }
281
+ return disabled;
282
+ }, [field]);
283
+ const shouldDisabledTime = (0, react_1.useCallback)((date, _view) => field.startTime.getTime() > date.getTime(), [field]);
271
284
  /**
272
285
  * Renders root object
273
286
  */
274
287
  return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ DialogContentProps: { dividers: false }, title: event ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.title.edit", defaultMessage: "ui.eventForm.title.edit" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.title", defaultMessage: "ui.eventForm.title" })), open: open, onClose: onClose, className: (0, classnames_1.default)(classes.root, className), actions: (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.name ||
275
288
  !field.startDate ||
276
289
  !field.startTime ||
290
+ !field.endDate ||
291
+ !field.endTime ||
277
292
  (field.location === types_1.SCEventLocationType.ONLINE && !field.link) ||
278
293
  (field.location === types_1.SCEventLocationType.PERSON && !field.geolocation) ||
279
294
  (field.recurring !== types_1.SCEventRecurrenceType.NEVER && !field.endDate && !field.endTime) ||
@@ -281,7 +296,7 @@ function EventForm(inProps) {
281
296
  field.name.length > Event_1.EVENT_TITLE_MAX_LENGTH ||
282
297
  field.description.length > Event_1.EVENT_DESCRIPTION_MAX_LENGTH, variant: "contained", onClick: handleSubmit, color: "secondary" }, { children: event ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.button.edit", defaultMessage: "ui.eventForm.button.edit" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.button.create", defaultMessage: "ui.eventForm.button.create" })) })) }, rest, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: (0, jsx_runtime_1.jsx)(UploadEventCover_1.default, { isCreationMode: true, onChange: handleChangeCover }) })), (0, jsx_runtime_1.jsxs)(material_1.FormGroup, Object.assign({ className: classes.form }, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
283
298
  endAdornment: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: Event_1.EVENT_TITLE_MAX_LENGTH - field.name.length }))
284
- }, error: Boolean(((_c = field === null || field === void 0 ? void 0 : field.name) === null || _c === void 0 ? void 0 : _c.length) > Event_1.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_1.EVENT_TITLE_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.name.error.maxLength", defaultMessage: "ui.eventForm.name.error.maxLength" })) : error[`nameError`] ? (error[`nameError`]) : null }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.dateTime }, { children: (0, jsx_runtime_1.jsxs)(x_date_pickers_1.LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.default : en_US_1.default }, { children: [(0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDatePicker, { className: classes.picker, disablePast: true, label: field.startDate && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.placeholder", defaultMessage: "ui.eventForm.date.placeholder" }), value: field.startDate, slots: {
299
+ }, error: Boolean(field.name.length > Event_1.EVENT_TITLE_MAX_LENGTH) || Boolean(error['nameError']), helperText: field.name.length > Event_1.EVENT_TITLE_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.name.error.maxLength", defaultMessage: "ui.eventForm.name.error.maxLength" })) : error['nameError'] ? (error['nameError']) : null }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.dateTime }, { children: (0, jsx_runtime_1.jsxs)(x_date_pickers_1.LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.default : en_US_1.default }, { children: [(0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDatePicker, { className: classes.picker, disablePast: true, label: field.startDate && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.placeholder", defaultMessage: "ui.eventForm.date.placeholder" }), value: field.startDate, slots: {
285
300
  textField: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.startDate)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "CalendarIcon" }) }) }))) }) })))
286
301
  }, slotProps: {
287
302
  toolbar: {
@@ -302,24 +317,23 @@ function EventForm(inProps) {
302
317
  return (0, jsx_runtime_1.jsx)("em", { children: `${intl.formatMessage(messages.frequencyPlaceholder)}` });
303
318
  }
304
319
  return ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventForm.frequency.${selected}.placeholder`, defaultMessage: `ui.eventForm.frequency.${selected}.placeholder` }));
305
- }, startAdornment: (0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "frequency" }) }) })) }, { children: Object.values(types_1.SCEventRecurrenceType).map((f) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ value: f }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventForm.frequency.${f}.placeholder`, defaultMessage: `ui.eventForm.frequency.${f}.placeholder` }) }), f))) }))] })), (field.showEndDateTime || field.recurring !== types_1.SCEventRecurrenceType.NEVER) && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.dateTime }, { children: (0, jsx_runtime_1.jsxs)(x_date_pickers_1.LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.default : en_US_1.default }, { children: [(0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDatePicker, { className: classes.picker, disablePast: true, label: field.endDate && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.end.placeholder", defaultMessage: "ui.eventForm.date.end.placeholder" }), value: field.endDate, slots: {
320
+ }, startAdornment: (0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "frequency" }) }) })) }, { children: Object.values(types_1.SCEventRecurrenceType).map((f) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ value: f }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventForm.frequency.${f}.placeholder`, defaultMessage: `ui.eventForm.frequency.${f}.placeholder` }) }), f))) }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.dateTime }, { children: (0, jsx_runtime_1.jsxs)(x_date_pickers_1.LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.default : en_US_1.default }, { children: [(0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDatePicker, { className: classes.picker, disablePast: true, minDate: field.startDate, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.end.placeholder", defaultMessage: "ui.eventForm.date.end.placeholder" }), value: field.endDate, slots: {
306
321
  textField: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endDate)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "calendar_off" }) }) }))) }) })))
307
- }, onChange: (value) => handleChangeDateTime(value, 'endDate') }), (0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileTimePicker, { className: classes.picker, disablePast: disablePastEndTime, label: field.endTime && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.end.placeholder", defaultMessage: "ui.eventForm.time.end.placeholder" }), value: field.endTime, slots: {
308
- textField: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endTime)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "access_time" }) }) }))) }) })))
309
- }, onChange: (value) => handleChangeDateTime(value, 'endTime') })] })) }))), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "text", color: "secondary", onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['showEndDateTime']: !field.showEndDateTime }))), disabled: field.showEndDateTime && field.recurring !== types_1.SCEventRecurrenceType.NEVER }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.dateTime.placeholder", defaultMessage: "ui.eventForm.dateTime.placeholder", values: { symbol: field.showEndDateTime ? '-' : '+' } }) })), (0, jsx_runtime_1.jsx)(EventAddress_1.default, { forwardGeolocationData: handleGeoData, event: event !== null && event !== void 0 ? event : null }), privateEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.privacySection }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), (0, jsx_runtime_1.jsx)(material_1.Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))) }), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" })] }))] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, { children: field.isPublic ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
322
+ }, onChange: (value) => handleChangeDateTime(value, 'endDate'), shouldDisableDate: shouldDisabledDate }), (0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileTimePicker, { className: classes.picker, disablePast: disablePastEndTime, label: field.endTime && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.end.placeholder", defaultMessage: "ui.eventForm.time.end.placeholder" }), value: field.endTime, slots: {
323
+ textField: (params) => {
324
+ var _a;
325
+ return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endTime)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "access_time" }) }) }))) }), error: Boolean(error['endDateError']), helperText: ((_a = error['endDateError']) === null || _a === void 0 ? void 0 : _a.error) ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.end.error.invalid", defaultMessage: "ui.eventForm.time.end.error.invalid" })) : null })));
326
+ }
327
+ }, onChange: (value) => handleChangeDateTime(value, 'endTime'), shouldDisableTime: shouldDisabledTime })] })) })), (0, jsx_runtime_1.jsx)(EventAddress_1.default, { forwardGeolocationData: handleGeoData, event: event !== null && event !== void 0 ? event : null }), privateEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.privacySection }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), (0, jsx_runtime_1.jsx)(material_1.Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: event && !field.isPublic }), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" })] }))] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, { children: field.isPublic ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
310
328
  // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
311
329
  // @ts-ignore
312
330
  b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
313
- } })) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: field.privacy === true ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private.info.edit", defaultMessage: "ui.eventForm.private.public.info.edit", values: {
314
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
315
- // @ts-ignore
316
- b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
317
- } })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private.info", defaultMessage: "ui.eventForm.private.public.info", values: {
318
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
319
- // @ts-ignore
320
- b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
321
- } })) })) }))] }))), (0, jsx_runtime_1.jsx)(material_1.TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
322
- endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((_e = field.description) === null || _e === void 0 ? void 0 : _e.length) ? Event_1.EVENT_DESCRIPTION_MAX_LENGTH - field.description.length : Event_1.EVENT_DESCRIPTION_MAX_LENGTH })))
323
- }, error: Boolean(((_f = field.description) === null || _f === void 0 ? void 0 : _f.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH), helperText: ((_g = field.description) === null || _g === void 0 ? void 0 : _g.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.description.error.maxLength", defaultMessage: "ui.eventForm.description.error.maxLength" })) : null })] }))] }) })));
331
+ } })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private.info", defaultMessage: "ui.eventForm.private.public.info", values: {
332
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
333
+ // @ts-ignore
334
+ b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
335
+ } })) }))] }))), (0, jsx_runtime_1.jsx)(material_1.TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
336
+ endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((_b = field.description) === null || _b === void 0 ? void 0 : _b.length) ? Event_1.EVENT_DESCRIPTION_MAX_LENGTH - field.description.length : Event_1.EVENT_DESCRIPTION_MAX_LENGTH })))
337
+ }, error: Boolean(((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH), helperText: ((_d = field.description) === null || _d === void 0 ? void 0 : _d.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.description.error.maxLength", defaultMessage: "ui.eventForm.description.error.maxLength" })) : null })] }))] }) })));
324
338
  }
325
339
  exports.default = EventForm;
@@ -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,4 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PREFIX = void 0;
3
+ exports.MONTHLY_LATER_DAYS = exports.WEEKLY_LATER_DAYS = exports.DAILY_LATER_DAYS = exports.NEVER_LATER_DAYS = exports.PREFIX = void 0;
4
4
  exports.PREFIX = 'SCEventForm';
5
+ exports.NEVER_LATER_DAYS = 14;
6
+ exports.DAILY_LATER_DAYS = 60;
7
+ exports.WEEKLY_LATER_DAYS = 360;
8
+ exports.MONTHLY_LATER_DAYS = 730;
@@ -0,0 +1,27 @@
1
+ import { SCEventLocationType, SCEventRecurrenceType } from '@selfcommunity/types';
2
+ export declare type Place = {
3
+ description: string;
4
+ id?: string;
5
+ };
6
+ export declare type Geolocation = {
7
+ location: SCEventLocationType;
8
+ geolocation?: string;
9
+ lat?: number;
10
+ lng?: number;
11
+ link?: string;
12
+ };
13
+ export declare type InitialFieldState = Geolocation & {
14
+ imageOriginal: string | ArrayBuffer;
15
+ imageOriginalFile: string | Blob;
16
+ startDate: Date | null;
17
+ startTime: Date | null;
18
+ endDate: Date | null;
19
+ endTime: Date | null;
20
+ recurring: SCEventRecurrenceType;
21
+ name: string;
22
+ description: string;
23
+ isPublic: boolean;
24
+ isSubmitting: boolean;
25
+ };
26
+ export declare type FieldStateKeys = keyof InitialFieldState;
27
+ export declare type FieldStateValues = InitialFieldState[FieldStateKeys];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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;