@selfcommunity/react-ui 0.7.50-alpha.0 → 0.7.50-event.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/assets/logo.d.ts +2 -0
- package/lib/cjs/assets/logo.js +3 -0
- package/lib/cjs/components/Category/Category.d.ts +1 -1
- package/lib/cjs/components/Category/Category.js +1 -1
- package/lib/cjs/components/ChangeCover/ChangeCover.js +3 -3
- package/lib/cjs/components/ChangePicture/ChangePictureDialog/ChangePictureDialog.js +1 -1
- package/lib/cjs/components/Composer/Composer.js +9 -7
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +1 -1
- package/lib/cjs/components/Composer/Layer/CategoryLayer/CategoryLayer.d.ts +1 -1
- package/lib/cjs/components/Composer/Layer/CloseLayer/CloseLayer.d.ts +1 -1
- package/lib/cjs/components/Composer/Layer/LocationLayer/LocationLayer.d.ts +1 -1
- package/lib/cjs/components/ComposerIconButton/ComposerIconButton.d.ts +1 -1
- package/lib/cjs/components/CreateEventButton/CreateEventButton.d.ts +38 -0
- package/lib/cjs/components/CreateEventButton/CreateEventButton.js +79 -0
- package/lib/cjs/components/CreateEventButton/index.d.ts +3 -0
- package/lib/cjs/components/CreateEventButton/index.js +5 -0
- package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +1 -1
- package/lib/cjs/components/Event/Event.d.ts +57 -0
- package/lib/cjs/components/Event/Event.js +90 -0
- package/lib/cjs/components/Event/Skeleton.d.ts +22 -0
- package/lib/cjs/components/Event/Skeleton.js +44 -0
- package/lib/cjs/components/Event/constants.d.ts +1 -0
- package/lib/cjs/components/Event/constants.js +4 -0
- package/lib/cjs/components/Event/index.d.ts +4 -0
- package/lib/cjs/components/Event/index.js +8 -0
- package/lib/cjs/components/EventForm/EventAddress.d.ts +12 -0
- package/lib/cjs/components/EventForm/EventAddress.js +129 -0
- package/lib/cjs/components/EventForm/EventForm.d.ts +59 -0
- package/lib/cjs/components/EventForm/EventForm.js +323 -0
- package/lib/cjs/components/EventForm/UploadEventCover.d.ts +40 -0
- package/lib/cjs/components/EventForm/UploadEventCover.js +98 -0
- package/lib/cjs/components/EventForm/constants.d.ts +1 -0
- package/lib/cjs/components/EventForm/constants.js +4 -0
- package/lib/cjs/components/EventForm/index.d.ts +3 -0
- package/lib/cjs/components/EventForm/index.js +5 -0
- package/lib/cjs/components/EventLocationWidget/EventLocationWidget.d.ts +55 -0
- package/lib/cjs/components/EventLocationWidget/EventLocationWidget.js +103 -0
- package/lib/cjs/components/EventLocationWidget/Skeleton.d.ts +22 -0
- package/lib/cjs/components/EventLocationWidget/Skeleton.js +47 -0
- package/lib/cjs/components/EventLocationWidget/constants.d.ts +1 -0
- package/lib/cjs/components/EventLocationWidget/constants.js +4 -0
- package/lib/cjs/components/EventLocationWidget/index.d.ts +4 -0
- package/lib/cjs/components/EventLocationWidget/index.js +8 -0
- package/lib/cjs/components/Feed/Feed.js +1 -1
- package/lib/cjs/components/FeedObject/Actions/Share/Share.js +5 -5
- package/lib/cjs/components/GroupForm/GroupForm.js +2 -2
- package/lib/cjs/components/GroupHeader/GroupHeader.js +3 -3
- package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +1 -1
- package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +3 -3
- package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.js +1 -1
- package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.js +1 -1
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +1 -1
- package/lib/cjs/components/IncubatorListWidget/IncubatorListWidget.js +1 -1
- package/lib/cjs/components/NavigationMenuIconButton/DefaultDrawerContent.d.ts +3 -2
- package/lib/cjs/components/NavigationMenuIconButton/DefaultDrawerContent.js +19 -3
- package/lib/cjs/components/NavigationMenuIconButton/DefaultHeaderContent.d.ts +3 -1
- package/lib/cjs/components/NavigationMenuIconButton/DefaultHeaderContent.js +22 -3
- package/lib/cjs/components/NavigationMenuIconButton/index.d.ts +2 -1
- package/lib/cjs/components/NavigationMenuIconButton/index.js +3 -1
- package/lib/cjs/components/Notification/Notification.js +1 -1
- package/lib/cjs/components/PlatformWidget/PlatformWidget.d.ts +24 -2
- package/lib/cjs/components/PlatformWidget/PlatformWidget.js +256 -18
- package/lib/cjs/components/PlatformWidget/constants.d.ts +4 -0
- package/lib/cjs/components/PlatformWidget/constants.js +5 -1
- package/lib/cjs/components/PrivateMessageEditor/MessageMediaUploader/index.js +1 -1
- package/lib/cjs/components/PrivateMessageSettingsIconButton/PrivateMessageSettingsIconButton.js +6 -6
- package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.js +1 -1
- package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.js +1 -1
- package/lib/cjs/constants/Event.d.ts +2 -0
- package/lib/cjs/constants/Event.js +5 -0
- package/lib/cjs/constants/PubSub.d.ts +1 -1
- package/lib/cjs/constants/PubSub.js +10 -10
- package/lib/cjs/index.d.ts +12 -4
- package/lib/cjs/index.js +21 -5
- package/lib/cjs/shared/BaseDialog/BaseDialog.js +3 -2
- package/lib/cjs/shared/EmojiPicker/EmojiPicker.js +4 -2
- package/lib/cjs/shared/Media/File/PreviewComponent.d.ts +1 -1
- package/lib/cjs/shared/Media/Link/LayerComponent.d.ts +1 -1
- package/lib/cjs/shared/Media/Link/PreviewComponent.d.ts +1 -1
- package/lib/cjs/shared/MetadataField/index.d.ts +2 -1
- package/lib/cjs/types/index.d.ts +2 -1
- package/lib/cjs/types/platformWidget.d.ts +15 -0
- package/lib/cjs/types/platformWidget.js +2 -0
- package/lib/cjs/utils/string.d.ts +1 -0
- package/lib/cjs/utils/string.js +9 -1
- package/lib/esm/assets/logo.d.ts +2 -0
- package/lib/esm/assets/logo.js +1 -0
- package/lib/esm/components/Category/Category.d.ts +1 -1
- package/lib/esm/components/Category/Category.js +1 -1
- package/lib/esm/components/ChangeCover/ChangeCover.js +3 -3
- package/lib/esm/components/ChangePicture/ChangePictureDialog/ChangePictureDialog.js +1 -1
- package/lib/esm/components/Composer/Composer.js +9 -7
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +1 -1
- package/lib/esm/components/Composer/Layer/CategoryLayer/CategoryLayer.d.ts +1 -1
- package/lib/esm/components/Composer/Layer/CloseLayer/CloseLayer.d.ts +1 -1
- package/lib/esm/components/Composer/Layer/LocationLayer/LocationLayer.d.ts +1 -1
- package/lib/esm/components/ComposerIconButton/ComposerIconButton.d.ts +1 -1
- package/lib/esm/components/CreateEventButton/CreateEventButton.d.ts +38 -0
- package/lib/esm/components/CreateEventButton/CreateEventButton.js +76 -0
- package/lib/esm/components/CreateEventButton/index.d.ts +3 -0
- package/lib/esm/components/CreateEventButton/index.js +2 -0
- package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +1 -1
- package/lib/esm/components/Event/Event.d.ts +57 -0
- package/lib/esm/components/Event/Event.js +87 -0
- package/lib/esm/components/Event/Skeleton.d.ts +22 -0
- package/lib/esm/components/Event/Skeleton.js +40 -0
- package/lib/esm/components/Event/constants.d.ts +1 -0
- package/lib/esm/components/Event/constants.js +1 -0
- package/lib/esm/components/Event/index.d.ts +4 -0
- package/lib/esm/components/Event/index.js +4 -0
- package/lib/esm/components/EventForm/EventAddress.d.ts +12 -0
- package/lib/esm/components/EventForm/EventAddress.js +126 -0
- package/lib/esm/components/EventForm/EventForm.d.ts +59 -0
- package/lib/esm/components/EventForm/EventForm.js +320 -0
- package/lib/esm/components/EventForm/UploadEventCover.d.ts +40 -0
- package/lib/esm/components/EventForm/UploadEventCover.js +95 -0
- package/lib/esm/components/EventForm/constants.d.ts +1 -0
- package/lib/esm/components/EventForm/constants.js +1 -0
- package/lib/esm/components/EventForm/index.d.ts +3 -0
- package/lib/esm/components/EventForm/index.js +2 -0
- package/lib/esm/components/EventLocationWidget/EventLocationWidget.d.ts +55 -0
- package/lib/esm/components/EventLocationWidget/EventLocationWidget.js +100 -0
- package/lib/esm/components/EventLocationWidget/Skeleton.d.ts +22 -0
- package/lib/esm/components/EventLocationWidget/Skeleton.js +43 -0
- package/lib/esm/components/EventLocationWidget/constants.d.ts +1 -0
- package/lib/esm/components/EventLocationWidget/constants.js +1 -0
- package/lib/esm/components/EventLocationWidget/index.d.ts +4 -0
- package/lib/esm/components/EventLocationWidget/index.js +4 -0
- package/lib/esm/components/Feed/Feed.js +2 -2
- package/lib/esm/components/FeedObject/Actions/Share/Share.js +5 -5
- package/lib/esm/components/GroupForm/GroupForm.js +3 -3
- package/lib/esm/components/GroupHeader/GroupHeader.js +4 -4
- package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +2 -2
- package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +4 -4
- package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.js +2 -2
- package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.js +2 -2
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +2 -2
- package/lib/esm/components/IncubatorListWidget/IncubatorListWidget.js +1 -1
- package/lib/esm/components/NavigationMenuIconButton/DefaultDrawerContent.d.ts +3 -2
- package/lib/esm/components/NavigationMenuIconButton/DefaultDrawerContent.js +21 -4
- package/lib/esm/components/NavigationMenuIconButton/DefaultHeaderContent.d.ts +3 -1
- package/lib/esm/components/NavigationMenuIconButton/DefaultHeaderContent.js +23 -3
- package/lib/esm/components/NavigationMenuIconButton/index.d.ts +2 -1
- package/lib/esm/components/NavigationMenuIconButton/index.js +2 -1
- package/lib/esm/components/Notification/Notification.js +1 -1
- package/lib/esm/components/PlatformWidget/PlatformWidget.d.ts +24 -2
- package/lib/esm/components/PlatformWidget/PlatformWidget.js +260 -22
- package/lib/esm/components/PlatformWidget/constants.d.ts +4 -0
- package/lib/esm/components/PlatformWidget/constants.js +4 -0
- package/lib/esm/components/PrivateMessageEditor/MessageMediaUploader/index.js +1 -1
- package/lib/esm/components/PrivateMessageSettingsIconButton/PrivateMessageSettingsIconButton.js +6 -6
- package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.js +1 -1
- package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.js +1 -1
- package/lib/esm/constants/Event.d.ts +2 -0
- package/lib/esm/constants/Event.js +2 -0
- package/lib/esm/constants/PubSub.d.ts +1 -1
- package/lib/esm/constants/PubSub.js +9 -9
- package/lib/esm/index.d.ts +12 -4
- package/lib/esm/index.js +13 -3
- package/lib/esm/shared/BaseDialog/BaseDialog.js +3 -2
- package/lib/esm/shared/EmojiPicker/EmojiPicker.js +4 -2
- package/lib/esm/shared/Media/File/PreviewComponent.d.ts +1 -1
- package/lib/esm/shared/Media/Link/LayerComponent.d.ts +1 -1
- package/lib/esm/shared/Media/Link/PreviewComponent.d.ts +1 -1
- package/lib/esm/shared/MetadataField/index.d.ts +2 -1
- package/lib/esm/types/index.d.ts +2 -1
- package/lib/esm/types/platformWidget.d.ts +15 -0
- package/lib/esm/types/platformWidget.js +1 -0
- package/lib/esm/utils/string.d.ts +1 -0
- package/lib/esm/utils/string.js +7 -0
- package/lib/umd/204.js +2 -0
- package/lib/umd/204.js.LICENSE.txt +22 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +24 -7
- package/lib/umd/311.js +0 -2
- package/lib/umd/311.js.LICENSE.txt +0 -7
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const system_1 = require("@mui/system");
|
|
6
|
+
const styles_1 = require("@mui/material/styles");
|
|
7
|
+
const material_1 = require("@mui/material");
|
|
8
|
+
const react_intl_1 = require("react-intl");
|
|
9
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
10
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
11
|
+
const constants_1 = require("./constants");
|
|
12
|
+
const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"));
|
|
13
|
+
const lab_1 = require("@mui/lab");
|
|
14
|
+
const Event_1 = require("../../constants/Event");
|
|
15
|
+
const types_1 = require("@selfcommunity/types");
|
|
16
|
+
const Errors_1 = require("../../constants/Errors");
|
|
17
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
18
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
19
|
+
const UploadEventCover_1 = tslib_1.__importDefault(require("./UploadEventCover"));
|
|
20
|
+
const x_date_pickers_1 = require("@mui/x-date-pickers");
|
|
21
|
+
const AdapterDateFns_1 = require("@mui/x-date-pickers/AdapterDateFns");
|
|
22
|
+
const EventAddress_1 = tslib_1.__importDefault(require("./EventAddress"));
|
|
23
|
+
const it_1 = tslib_1.__importDefault(require("date-fns/locale/it"));
|
|
24
|
+
const en_US_1 = tslib_1.__importDefault(require("date-fns/locale/en-US"));
|
|
25
|
+
const messages = (0, react_intl_1.defineMessages)({
|
|
26
|
+
name: {
|
|
27
|
+
id: 'ui.eventForm.name.placeholder',
|
|
28
|
+
defaultMessage: 'ui.eventForm.name.placeholder'
|
|
29
|
+
},
|
|
30
|
+
description: {
|
|
31
|
+
id: 'ui.eventForm.description.placeholder',
|
|
32
|
+
defaultMessage: 'ui.eventForm.description.placeholder'
|
|
33
|
+
},
|
|
34
|
+
startDate: {
|
|
35
|
+
id: 'ui.eventForm.date.placeholder',
|
|
36
|
+
defaultMessage: 'ui.eventForm.date.placeholder'
|
|
37
|
+
},
|
|
38
|
+
startTime: {
|
|
39
|
+
id: 'ui.eventForm.time.placeholder',
|
|
40
|
+
defaultMessage: 'ui.eventForm.time.placeholder'
|
|
41
|
+
},
|
|
42
|
+
frequency: {
|
|
43
|
+
id: 'ui.eventForm.frequency.label',
|
|
44
|
+
defaultMessage: 'ui.eventForm.frequency.label'
|
|
45
|
+
},
|
|
46
|
+
frequencyPlaceholder: {
|
|
47
|
+
id: 'ui.eventForm.frequency.none.placeholder',
|
|
48
|
+
defaultMessage: 'ui.eventForm.frequency.none.placeholder'
|
|
49
|
+
},
|
|
50
|
+
endDate: {
|
|
51
|
+
id: 'ui.eventForm.date.end.placeholder',
|
|
52
|
+
defaultMessage: 'ui.eventForm.date.end.placeholder'
|
|
53
|
+
},
|
|
54
|
+
endTime: {
|
|
55
|
+
id: 'ui.eventForm.time.end.placeholder',
|
|
56
|
+
defaultMessage: 'ui.eventForm.time.end.placeholder'
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const classes = {
|
|
60
|
+
root: `${constants_1.PREFIX}-root`,
|
|
61
|
+
active: `${constants_1.PREFIX}-active`,
|
|
62
|
+
title: `${constants_1.PREFIX}-title`,
|
|
63
|
+
cover: `${constants_1.PREFIX}-cover`,
|
|
64
|
+
picker: `${constants_1.PREFIX}-picker`,
|
|
65
|
+
dateTime: `${constants_1.PREFIX}-date-time`,
|
|
66
|
+
frequency: `${constants_1.PREFIX}-frequency`,
|
|
67
|
+
form: `${constants_1.PREFIX}-form`,
|
|
68
|
+
switch: `${constants_1.PREFIX}-switch`,
|
|
69
|
+
switchLabel: `${constants_1.PREFIX}-switch-label`,
|
|
70
|
+
name: `${constants_1.PREFIX}-name`,
|
|
71
|
+
description: `${constants_1.PREFIX}-description`,
|
|
72
|
+
content: `${constants_1.PREFIX}-content`,
|
|
73
|
+
privacySection: `${constants_1.PREFIX}-privacy-section`,
|
|
74
|
+
privacySectionInfo: `${constants_1.PREFIX}-privacy-section-info`,
|
|
75
|
+
error: `${constants_1.PREFIX}-error`
|
|
76
|
+
};
|
|
77
|
+
const Root = (0, styles_1.styled)(BaseDialog_1.default, {
|
|
78
|
+
name: constants_1.PREFIX,
|
|
79
|
+
slot: 'Root'
|
|
80
|
+
})(() => ({}));
|
|
81
|
+
/**
|
|
82
|
+
*> API documentation for the Community-JS Event Form component. Learn about the available props and the CSS API.
|
|
83
|
+
*
|
|
84
|
+
#### Import
|
|
85
|
+
```jsx
|
|
86
|
+
import {EventForm} from '@selfcommunity/react-ui';
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### Component Name
|
|
90
|
+
The name `SCEventForm` can be used when providing style overrides in the theme.
|
|
91
|
+
|
|
92
|
+
#### CSS
|
|
93
|
+
|
|
94
|
+
|Rule Name|Global class|Description|
|
|
95
|
+
|---|---|---|
|
|
96
|
+
|root|.SCEventForm-root|Styles applied to the root element.|
|
|
97
|
+
|active|.SCEventForm-active|Styles applied to the active element.|
|
|
98
|
+
|title|.SCEventForm-title|Styles applied to the title element.|
|
|
99
|
+
|cover|.SCEventForm-cover|Styles applied to the cover field.|
|
|
100
|
+
|form|.SCEventForm-form|Styles applied to the form element.|
|
|
101
|
+
|switch|.SCEventForm-switch|Styles applied to the switch element.|
|
|
102
|
+
|switchLabel|.SCEventForm-switch-label|Styles applied to the switchLabel element.|
|
|
103
|
+
|name|.SCEventForm-name|Styles applied to the name field.|
|
|
104
|
+
|description|.SCEventForm-description|Styles applied to the description field.|
|
|
105
|
+
|content|.SCEventForm-content|Styles applied to the element.|
|
|
106
|
+
|privacySection|.SCEventForm-privacy-section|Styles applied to the privacy section.|
|
|
107
|
+
|privacySectionInfo|.SCEventForm-privacy-section-info|Styles applied to the privacy info section.|
|
|
108
|
+
|error|.SCEventForm-error|Styles applied to the error elements.|
|
|
109
|
+
|
|
110
|
+
* @param inProps
|
|
111
|
+
*/
|
|
112
|
+
function EventForm(inProps) {
|
|
113
|
+
var _a, _b, _c, _d, _e;
|
|
114
|
+
//PROPS
|
|
115
|
+
const props = (0, system_1.useThemeProps)({
|
|
116
|
+
props: inProps,
|
|
117
|
+
name: constants_1.PREFIX
|
|
118
|
+
});
|
|
119
|
+
const { className, open = true, onClose, onSuccess } = props, rest = tslib_1.__rest(props, ["className", "open", "onClose", "onSuccess"]);
|
|
120
|
+
// CONTEXT
|
|
121
|
+
const scContext = (0, react_core_1.useSCContext)();
|
|
122
|
+
// INTL
|
|
123
|
+
const intl = (0, react_intl_1.useIntl)();
|
|
124
|
+
const initialFieldState = {
|
|
125
|
+
emotionalImageOriginal: '',
|
|
126
|
+
emotionalImageOriginalFile: '',
|
|
127
|
+
startDate: null,
|
|
128
|
+
startTime: null,
|
|
129
|
+
endDate: null,
|
|
130
|
+
endTime: null,
|
|
131
|
+
location: '',
|
|
132
|
+
geolocation: '',
|
|
133
|
+
lat: null,
|
|
134
|
+
lng: null,
|
|
135
|
+
link: '',
|
|
136
|
+
recurring: types_1.SCEventRecurrenceType.NEVER,
|
|
137
|
+
name: '',
|
|
138
|
+
description: '',
|
|
139
|
+
isPublic: true,
|
|
140
|
+
isSubmitting: false,
|
|
141
|
+
showEndDateTime: false
|
|
142
|
+
};
|
|
143
|
+
// STATE
|
|
144
|
+
const [field, setField] = (0, react_1.useState)(initialFieldState);
|
|
145
|
+
const [error, setError] = (0, react_1.useState)({});
|
|
146
|
+
// PREFERENCES
|
|
147
|
+
const scPreferences = (0, react_core_1.useSCPreferences)();
|
|
148
|
+
const privateEnabled = (0, react_1.useMemo)(() => scPreferences.preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_PRIVATE_ENABLED].value, [scPreferences.preferences]);
|
|
149
|
+
const _backgroundCover = Object.assign({}, (field.emotionalImageOriginal
|
|
150
|
+
? { background: `url('${field.emotionalImageOriginal}') center / cover` }
|
|
151
|
+
: { background: `url('${scPreferences.preferences[react_core_1.SCPreferences.IMAGES_USER_DEFAULT_COVER].value}') center / cover` }));
|
|
152
|
+
const combineDateAndTime = (date, time) => {
|
|
153
|
+
if (date && time) {
|
|
154
|
+
const combined = new Date(date);
|
|
155
|
+
combined.setHours(time.getHours());
|
|
156
|
+
combined.setMinutes(time.getMinutes());
|
|
157
|
+
combined.setSeconds(time.getSeconds());
|
|
158
|
+
combined.setMilliseconds(time.getMilliseconds());
|
|
159
|
+
return combined.toISOString();
|
|
160
|
+
}
|
|
161
|
+
return null;
|
|
162
|
+
};
|
|
163
|
+
function handleChangeCover(cover) {
|
|
164
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['emotionalImageOriginalFile']: cover })));
|
|
165
|
+
const reader = new FileReader();
|
|
166
|
+
reader.onloadend = () => {
|
|
167
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['emotionalImageOriginal']: reader.result })));
|
|
168
|
+
};
|
|
169
|
+
reader.readAsDataURL(cover);
|
|
170
|
+
if (error.emotionalImageOriginalError) {
|
|
171
|
+
delete error.emotionalImageOriginalError;
|
|
172
|
+
setError(error);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const handleGeoData = (data) => {
|
|
176
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), data)));
|
|
177
|
+
};
|
|
178
|
+
const handleSubmit = () => {
|
|
179
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: true })));
|
|
180
|
+
const formData = new FormData();
|
|
181
|
+
if (field.emotionalImageOriginalFile) {
|
|
182
|
+
formData.append('emotional_image_original', field.emotionalImageOriginalFile);
|
|
183
|
+
}
|
|
184
|
+
formData.append('name', field.name);
|
|
185
|
+
formData.append('start_date', combineDateAndTime(field.startDate, field.startTime));
|
|
186
|
+
formData.append('recurring', field.recurring);
|
|
187
|
+
if (field.endDate) {
|
|
188
|
+
formData.append('end_date', combineDateAndTime(field.endDate, field.endTime));
|
|
189
|
+
}
|
|
190
|
+
formData.append('location', field.location);
|
|
191
|
+
if (field.location === types_1.SCEventLocationType.ONLINE) {
|
|
192
|
+
formData.append('link', field.link);
|
|
193
|
+
}
|
|
194
|
+
if (field.location === types_1.SCEventLocationType.PERSON) {
|
|
195
|
+
formData.append('geolocation', field.geolocation);
|
|
196
|
+
formData.append('geolocation_lat', field.lat);
|
|
197
|
+
formData.append('geolocation_lng', field.lng);
|
|
198
|
+
}
|
|
199
|
+
if (privateEnabled) {
|
|
200
|
+
formData.append('privacy', field.isPublic ? types_1.SCEventPrivacyType.PUBLIC : types_1.SCEventPrivacyType.PRIVATE);
|
|
201
|
+
}
|
|
202
|
+
formData.append('description', field.description);
|
|
203
|
+
api_services_1.EventService.createEvent(formData, { headers: { 'Content-Type': 'multipart/form-data' } })
|
|
204
|
+
.then((data) => {
|
|
205
|
+
onSuccess && onSuccess(data);
|
|
206
|
+
onClose && onClose();
|
|
207
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
208
|
+
})
|
|
209
|
+
.catch((e) => {
|
|
210
|
+
setError(Object.assign(Object.assign({}, error), (0, api_services_1.formatHttpErrorCode)(e)));
|
|
211
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
212
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, e);
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
const handleChange = (event) => {
|
|
216
|
+
const { name, value } = event.target;
|
|
217
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
|
|
218
|
+
if (error[`${name}Error`]) {
|
|
219
|
+
delete error[`${name}Error`];
|
|
220
|
+
setError(error);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const handleChangeDateTime = (value, name) => {
|
|
224
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
|
|
225
|
+
if (error[`${name}Error`]) {
|
|
226
|
+
delete error[`${name}Error`];
|
|
227
|
+
setError(error);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Renders root object
|
|
232
|
+
*/
|
|
233
|
+
return (react_1.default.createElement(Root, Object.assign({ DialogContentProps: { dividers: false }, title: react_1.default.createElement(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: react_1.default.createElement(lab_1.LoadingButton, { loading: field.isSubmitting, disabled: !field.name ||
|
|
234
|
+
(!field.startDate && !field.startTime) ||
|
|
235
|
+
(types_1.SCEventLocationType.ONLINE && !field.link) ||
|
|
236
|
+
((field.recurring !== types_1.SCEventRecurrenceType.NEVER) && (!field.endDate && !field.endTime)) ||
|
|
237
|
+
Object.keys(error).length !== 0 ||
|
|
238
|
+
field.name.length > Event_1.EVENT_TITLE_MAX_LENGTH ||
|
|
239
|
+
field.description.length > Event_1.EVENT_DESCRIPTION_MAX_LENGTH, variant: "contained", onClick: handleSubmit, color: "secondary" }, react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventForm.button.create", defaultMessage: "ui.eventForm.button.create" })) }, rest),
|
|
240
|
+
react_1.default.createElement(react_1.default.Fragment, null,
|
|
241
|
+
react_1.default.createElement(material_1.Paper, { style: _backgroundCover, classes: { root: classes.cover } },
|
|
242
|
+
react_1.default.createElement(UploadEventCover_1.default, { onChange: handleChangeCover })),
|
|
243
|
+
react_1.default.createElement(material_1.FormGroup, { className: classes.form },
|
|
244
|
+
react_1.default.createElement(material_1.TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
|
|
245
|
+
endAdornment: react_1.default.createElement(material_1.Typography, { variant: "body2" }, Event_1.EVENT_TITLE_MAX_LENGTH - field.name.length)
|
|
246
|
+
}, error: Boolean(((_a = field === null || field === void 0 ? void 0 : field.name) === null || _a === void 0 ? void 0 : _a.length) > Event_1.EVENT_TITLE_MAX_LENGTH), helperText: ((_b = field === null || field === void 0 ? void 0 : field.name) === null || _b === void 0 ? void 0 : _b.length) > Event_1.EVENT_TITLE_MAX_LENGTH ? (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventForm.name.error.maxLength", defaultMessage: "ui.eventForm.name.error.maxLength" })) : null }),
|
|
247
|
+
react_1.default.createElement(material_1.Box, { className: classes.dateTime },
|
|
248
|
+
react_1.default.createElement(x_date_pickers_1.LocalizationProvider, { dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.default : en_US_1.default },
|
|
249
|
+
react_1.default.createElement(x_date_pickers_1.MobileDatePicker, { className: classes.picker, disablePast: true, label: field.startDate && react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.placeholder", defaultMessage: "ui.eventForm.date.placeholder" }), value: field.startDate, slots: {
|
|
250
|
+
textField: (params) => (react_1.default.createElement(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.startDate)}`, startAdornment: (react_1.default.createElement(material_1.InputAdornment, { position: "start" },
|
|
251
|
+
react_1.default.createElement(material_1.IconButton, null,
|
|
252
|
+
react_1.default.createElement(material_1.Icon, null, "calendar_off")))) }) })))
|
|
253
|
+
}, slotProps: {
|
|
254
|
+
toolbar: {
|
|
255
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
|
|
256
|
+
// @ts-ignore
|
|
257
|
+
toolbarTitle: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.title", defaultMessage: "ui.eventForm.date.title" })
|
|
258
|
+
}
|
|
259
|
+
}, onChange: (value) => handleChangeDateTime(value, 'startDate') }),
|
|
260
|
+
react_1.default.createElement(x_date_pickers_1.MobileTimePicker, { className: classes.picker, label: field.startTime && react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.placeholder", defaultMessage: "ui.eventForm.time.placeholder" }), value: field.startTime, slots: {
|
|
261
|
+
textField: (params) => (react_1.default.createElement(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.startTime)}`, startAdornment: (react_1.default.createElement(material_1.InputAdornment, { position: "start" },
|
|
262
|
+
react_1.default.createElement(material_1.IconButton, null,
|
|
263
|
+
react_1.default.createElement(material_1.Icon, null, "access_time")))) }) })))
|
|
264
|
+
}, slotProps: {
|
|
265
|
+
toolbar: {
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
|
|
267
|
+
// @ts-ignore
|
|
268
|
+
toolbarTitle: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.title", defaultMessage: "ui.eventForm.time.title" })
|
|
269
|
+
}
|
|
270
|
+
}, onChange: (value) => handleChangeDateTime(value, 'startTime') }))),
|
|
271
|
+
react_1.default.createElement(material_1.FormControl, { className: classes.frequency },
|
|
272
|
+
field.recurring !== types_1.SCEventRecurrenceType.NEVER && react_1.default.createElement(material_1.InputLabel, { id: "frequency" }, `${intl.formatMessage(messages.frequency)}`),
|
|
273
|
+
react_1.default.createElement(material_1.Select, { name: "recurring", label: field.recurring !== types_1.SCEventRecurrenceType.NEVER && `${intl.formatMessage(messages.frequency)}`, labelId: "recurring", value: field.recurring, onChange: handleChange, displayEmpty: true, renderValue: (selected) => {
|
|
274
|
+
if (!selected) {
|
|
275
|
+
return react_1.default.createElement("em", null, `${intl.formatMessage(messages.frequencyPlaceholder)}`);
|
|
276
|
+
}
|
|
277
|
+
return (react_1.default.createElement(react_intl_1.FormattedMessage, { id: `ui.eventForm.frequency.${selected}.placeholder`, defaultMessage: `ui.eventForm.frequency.${selected}.placeholder` }));
|
|
278
|
+
}, startAdornment: react_1.default.createElement(material_1.InputAdornment, { position: "start" },
|
|
279
|
+
react_1.default.createElement(material_1.IconButton, null,
|
|
280
|
+
react_1.default.createElement(material_1.Icon, null, "frequency"))) }, Object.values(types_1.SCEventRecurrenceType).map((f) => (react_1.default.createElement(material_1.MenuItem, { value: f, key: f },
|
|
281
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: `ui.eventForm.frequency.${f}.placeholder`, defaultMessage: `ui.eventForm.frequency.${f}.placeholder` })))))),
|
|
282
|
+
(field.showEndDateTime || field.recurring !== types_1.SCEventRecurrenceType.NEVER) && (react_1.default.createElement(material_1.Box, { className: classes.dateTime },
|
|
283
|
+
react_1.default.createElement(x_date_pickers_1.LocalizationProvider, { dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.default : en_US_1.default },
|
|
284
|
+
react_1.default.createElement(x_date_pickers_1.MobileDatePicker, { className: classes.picker, disablePast: true, label: field.endDate && react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.end.placeholder", defaultMessage: "ui.eventForm.date.end.placeholder" }), value: field.endDate, slots: {
|
|
285
|
+
textField: (params) => (react_1.default.createElement(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endDate)}`, startAdornment: (react_1.default.createElement(material_1.InputAdornment, { position: "start" },
|
|
286
|
+
react_1.default.createElement(material_1.IconButton, null,
|
|
287
|
+
react_1.default.createElement(material_1.Icon, null, "calendar_off")))) }) })))
|
|
288
|
+
}, onChange: (value) => handleChangeDateTime(value, 'endDate') }),
|
|
289
|
+
react_1.default.createElement(x_date_pickers_1.MobileTimePicker, { className: classes.picker, label: field.endTime && react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.end.placeholder", defaultMessage: "ui.eventForm.time.end.placeholder" }), value: field.endTime, slots: {
|
|
290
|
+
textField: (params) => (react_1.default.createElement(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endTime)}`, startAdornment: (react_1.default.createElement(material_1.InputAdornment, { position: "start" },
|
|
291
|
+
react_1.default.createElement(material_1.IconButton, null,
|
|
292
|
+
react_1.default.createElement(material_1.Icon, null, "access_time")))) }) })))
|
|
293
|
+
}, onChange: (value) => handleChangeDateTime(value, 'endTime') })))),
|
|
294
|
+
react_1.default.createElement(material_1.Button, { variant: "text", color: "secondary", onClick: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['showEndDateTime']: !field.showEndDateTime }))) },
|
|
295
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventForm.dateTime.placeholder", defaultMessage: "ui.eventForm.dateTime.placeholder", values: { symbol: field.showEndDateTime ? '-' : '+' } })),
|
|
296
|
+
react_1.default.createElement(EventAddress_1.default, { forwardGeolocationData: handleGeoData }),
|
|
297
|
+
privateEnabled && (react_1.default.createElement(material_1.Box, { className: classes.privacySection },
|
|
298
|
+
react_1.default.createElement(material_1.Stack, { direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" },
|
|
299
|
+
react_1.default.createElement(material_1.Typography, { className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: !field.isPublic }) },
|
|
300
|
+
react_1.default.createElement(material_1.Icon, null, "private"),
|
|
301
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })),
|
|
302
|
+
react_1.default.createElement(material_1.Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))) }),
|
|
303
|
+
react_1.default.createElement(material_1.Typography, { className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: field.isPublic }) },
|
|
304
|
+
react_1.default.createElement(material_1.Icon, null, "public"),
|
|
305
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" }))),
|
|
306
|
+
react_1.default.createElement(material_1.Typography, { variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, field.isPublic ? (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
|
|
307
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
308
|
+
// @ts-ignore
|
|
309
|
+
b: (chunks) => react_1.default.createElement("strong", null, chunks)
|
|
310
|
+
} })) : (react_1.default.createElement(react_1.default.Fragment, null, field.privacy === true ? (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private.info.edit", defaultMessage: "ui.eventForm.private.public.info.edit", values: {
|
|
311
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
312
|
+
// @ts-ignore
|
|
313
|
+
b: (chunks) => react_1.default.createElement("strong", null, chunks)
|
|
314
|
+
} })) : (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private.info", defaultMessage: "ui.eventForm.private.public.info", values: {
|
|
315
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
316
|
+
// @ts-ignore
|
|
317
|
+
b: (chunks) => react_1.default.createElement("strong", null, chunks)
|
|
318
|
+
} }))))))),
|
|
319
|
+
react_1.default.createElement(material_1.TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
|
|
320
|
+
endAdornment: (react_1.default.createElement(material_1.Typography, { variant: "body2" }, ((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) ? Event_1.EVENT_DESCRIPTION_MAX_LENGTH - field.description.length : Event_1.EVENT_DESCRIPTION_MAX_LENGTH))
|
|
321
|
+
}, error: Boolean(((_d = field.description) === null || _d === void 0 ? void 0 : _d.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH), helperText: ((_e = field.description) === null || _e === void 0 ? void 0 : _e.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH ? (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventForm.description.error.maxLength", defaultMessage: "ui.eventForm.description.error.maxLength" })) : null })))));
|
|
322
|
+
}
|
|
323
|
+
exports.default = EventForm;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface UploadEventCoverProps {
|
|
2
|
+
/**
|
|
3
|
+
* On change function.
|
|
4
|
+
* @default null
|
|
5
|
+
*/
|
|
6
|
+
onChange?: (cover: any) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Overrides or extends the styles applied to the component.
|
|
9
|
+
* @default null
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Any other properties
|
|
14
|
+
*/
|
|
15
|
+
[p: string]: any;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* > API documentation for the Community-JS Change Group Cover component. Learn about the available props and the CSS API.
|
|
19
|
+
*
|
|
20
|
+
*
|
|
21
|
+
* This component renders a button that allows admins to edit the group cover and a popover that specifies format and sizes allowed.
|
|
22
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/UploadEventCover)
|
|
23
|
+
|
|
24
|
+
#### Import
|
|
25
|
+
```jsx
|
|
26
|
+
import {UploadEventCover} from '@selfcommunity/react-ui';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
#### Component Name
|
|
30
|
+
The name `SCUploadEventCover` can be used when providing style overrides in the theme.
|
|
31
|
+
|
|
32
|
+
#### CSS
|
|
33
|
+
|
|
34
|
+
|Rule Name|Global class|Description|
|
|
35
|
+
|---|---|---|
|
|
36
|
+
|root|.SCUploadEventCover-root|Styles applied to the root element.|
|
|
37
|
+
|
|
38
|
+
* @param inProps
|
|
39
|
+
*/
|
|
40
|
+
export default function UploadEventCover(inProps: UploadEventCoverProps): JSX.Element;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const styles_1 = require("@mui/material/styles");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
8
|
+
const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon"));
|
|
9
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
10
|
+
const system_1 = require("@mui/system");
|
|
11
|
+
const constants_1 = require("./constants");
|
|
12
|
+
const lab_1 = require("@mui/lab");
|
|
13
|
+
const classes = {
|
|
14
|
+
root: `${constants_1.PREFIX}-upload-event-cover-root`
|
|
15
|
+
};
|
|
16
|
+
const Root = (0, styles_1.styled)(lab_1.LoadingButton, {
|
|
17
|
+
name: constants_1.PREFIX,
|
|
18
|
+
slot: 'UploadEventCoverRoot'
|
|
19
|
+
})(() => ({}));
|
|
20
|
+
/**
|
|
21
|
+
* > API documentation for the Community-JS Change Group Cover component. Learn about the available props and the CSS API.
|
|
22
|
+
*
|
|
23
|
+
*
|
|
24
|
+
* This component renders a button that allows admins to edit the group cover and a popover that specifies format and sizes allowed.
|
|
25
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/UploadEventCover)
|
|
26
|
+
|
|
27
|
+
#### Import
|
|
28
|
+
```jsx
|
|
29
|
+
import {UploadEventCover} from '@selfcommunity/react-ui';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
#### Component Name
|
|
33
|
+
The name `SCUploadEventCover` can be used when providing style overrides in the theme.
|
|
34
|
+
|
|
35
|
+
#### CSS
|
|
36
|
+
|
|
37
|
+
|Rule Name|Global class|Description|
|
|
38
|
+
|---|---|---|
|
|
39
|
+
|root|.SCUploadEventCover-root|Styles applied to the root element.|
|
|
40
|
+
|
|
41
|
+
* @param inProps
|
|
42
|
+
*/
|
|
43
|
+
function UploadEventCover(inProps) {
|
|
44
|
+
//PROPS
|
|
45
|
+
const props = (0, system_1.useThemeProps)({
|
|
46
|
+
props: inProps,
|
|
47
|
+
name: constants_1.PREFIX
|
|
48
|
+
});
|
|
49
|
+
const { onChange, className = false } = props, rest = tslib_1.__rest(props, ["onChange", "className"]);
|
|
50
|
+
//CONTEXT
|
|
51
|
+
const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
|
|
52
|
+
//STATE
|
|
53
|
+
let fileInput = (0, react_1.useRef)(null);
|
|
54
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
55
|
+
const [alert, setAlert] = (0, react_1.useState)(null);
|
|
56
|
+
// Anonymous
|
|
57
|
+
if (!scUserContext.user) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Handles file upload
|
|
62
|
+
* @param event
|
|
63
|
+
*/
|
|
64
|
+
const handleUpload = (event) => {
|
|
65
|
+
fileInput = event.target.files[0];
|
|
66
|
+
if (fileInput) {
|
|
67
|
+
const reader = new FileReader();
|
|
68
|
+
reader.onload = (e) => {
|
|
69
|
+
const img = new Image();
|
|
70
|
+
img.onload = () => {
|
|
71
|
+
onChange && onChange(fileInput);
|
|
72
|
+
// if (img.width < 1920) {
|
|
73
|
+
// setAlert(intl.formatMessage(messages.errorImageSize));
|
|
74
|
+
// } else {
|
|
75
|
+
// isCreationMode ? onChange && onChange(fileInput) : handleSave();
|
|
76
|
+
// }
|
|
77
|
+
};
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
79
|
+
// @ts-ignore
|
|
80
|
+
img.src = e.target.result;
|
|
81
|
+
};
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
reader.readAsDataURL(fileInput);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* If there is an error
|
|
89
|
+
*/
|
|
90
|
+
if (alert) {
|
|
91
|
+
return (react_1.default.createElement(material_1.Alert, { color: "error", onClose: () => setAlert(null) }, alert));
|
|
92
|
+
}
|
|
93
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
94
|
+
react_1.default.createElement("input", { type: "file", onChange: handleUpload, ref: fileInput, hidden: true, accept: ".gif,.png,.jpg,.jpeg" }),
|
|
95
|
+
react_1.default.createElement(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), size: "medium", variant: "contained", disabled: loading, onClick: () => fileInput.current.click(), loading: loading }, rest),
|
|
96
|
+
react_1.default.createElement(Icon_1.default, null, "image"))));
|
|
97
|
+
}
|
|
98
|
+
exports.default = UploadEventCover;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCEventForm";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { VirtualScrollerItemProps } from '../../types/virtualScroller';
|
|
2
|
+
import { SCEventType } from '@selfcommunity/types';
|
|
3
|
+
export interface EventLocationWidgetProps extends VirtualScrollerItemProps {
|
|
4
|
+
/**
|
|
5
|
+
* Event Object
|
|
6
|
+
* @default null
|
|
7
|
+
*/
|
|
8
|
+
event?: SCEventType;
|
|
9
|
+
/**
|
|
10
|
+
* Id of the event
|
|
11
|
+
* @default null
|
|
12
|
+
*/
|
|
13
|
+
eventId?: number | string;
|
|
14
|
+
/**
|
|
15
|
+
* Overrides or extends the styles applied to the component.
|
|
16
|
+
* @default null
|
|
17
|
+
*/
|
|
18
|
+
className?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Other props
|
|
21
|
+
*/
|
|
22
|
+
[p: string]: any;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* > API documentation for the Community-JS Group Info Widget component. Learn about the available props and the CSS API.
|
|
26
|
+
*
|
|
27
|
+
*
|
|
28
|
+
* This component renders a widget containing the event info.
|
|
29
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/EventLocationWidget)
|
|
30
|
+
|
|
31
|
+
#### Import
|
|
32
|
+
|
|
33
|
+
```jsx
|
|
34
|
+
import {EventLocationWidget} from '@selfcommunity/react-ui';
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
#### Component Name
|
|
38
|
+
|
|
39
|
+
The name `SCEventLocationWidget` can be used when providing style overrides in the theme.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
#### CSS
|
|
43
|
+
|
|
44
|
+
|Rule Name|Global class|Description|
|
|
45
|
+
|---|---|---|
|
|
46
|
+
|root|.SCEventLocationWidget-root|Styles applied to the root element.|
|
|
47
|
+
|title|.SCEventLocationWidget-title|Styles applied to the title element.|
|
|
48
|
+
|map|.SCEventLocationWidget-map|Styles applied to the map element.|
|
|
49
|
+
|locationTitle|.SCEventLocationWidget-location-title|Styles applied to the location title element.|
|
|
50
|
+
|address|.SCEventLocationWidget-address|Styles applied to the address element.|
|
|
51
|
+
|
|
52
|
+
*
|
|
53
|
+
* @param inProps
|
|
54
|
+
*/
|
|
55
|
+
export default function EventLocationWidget(inProps: EventLocationWidgetProps): JSX.Element;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
const styles_1 = require("@mui/material/styles");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
8
|
+
const Widget_1 = tslib_1.__importDefault(require("../Widget"));
|
|
9
|
+
const system_1 = require("@mui/system");
|
|
10
|
+
const constants_1 = require("./constants");
|
|
11
|
+
const react_intl_1 = require("react-intl");
|
|
12
|
+
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
13
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
14
|
+
const types_1 = require("@selfcommunity/types");
|
|
15
|
+
const api_1 = require("@react-google-maps/api");
|
|
16
|
+
const HiddenPlaceholder_1 = tslib_1.__importDefault(require("../../shared/HiddenPlaceholder"));
|
|
17
|
+
const string_1 = require("../../utils/string");
|
|
18
|
+
const classes = {
|
|
19
|
+
root: `${constants_1.PREFIX}-root`,
|
|
20
|
+
title: `${constants_1.PREFIX}-title`,
|
|
21
|
+
map: `${constants_1.PREFIX}-map`,
|
|
22
|
+
locationTitle: `${constants_1.PREFIX}-location-title`,
|
|
23
|
+
address: `${constants_1.PREFIX}-address`
|
|
24
|
+
};
|
|
25
|
+
const Root = (0, styles_1.styled)(Widget_1.default, {
|
|
26
|
+
name: constants_1.PREFIX,
|
|
27
|
+
slot: 'Root'
|
|
28
|
+
})(() => ({}));
|
|
29
|
+
/**
|
|
30
|
+
* > API documentation for the Community-JS Group Info Widget component. Learn about the available props and the CSS API.
|
|
31
|
+
*
|
|
32
|
+
*
|
|
33
|
+
* This component renders a widget containing the event info.
|
|
34
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/EventLocationWidget)
|
|
35
|
+
|
|
36
|
+
#### Import
|
|
37
|
+
|
|
38
|
+
```jsx
|
|
39
|
+
import {EventLocationWidget} from '@selfcommunity/react-ui';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### Component Name
|
|
43
|
+
|
|
44
|
+
The name `SCEventLocationWidget` can be used when providing style overrides in the theme.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
#### CSS
|
|
48
|
+
|
|
49
|
+
|Rule Name|Global class|Description|
|
|
50
|
+
|---|---|---|
|
|
51
|
+
|root|.SCEventLocationWidget-root|Styles applied to the root element.|
|
|
52
|
+
|title|.SCEventLocationWidget-title|Styles applied to the title element.|
|
|
53
|
+
|map|.SCEventLocationWidget-map|Styles applied to the map element.|
|
|
54
|
+
|locationTitle|.SCEventLocationWidget-location-title|Styles applied to the location title element.|
|
|
55
|
+
|address|.SCEventLocationWidget-address|Styles applied to the address element.|
|
|
56
|
+
|
|
57
|
+
*
|
|
58
|
+
* @param inProps
|
|
59
|
+
*/
|
|
60
|
+
function EventLocationWidget(inProps) {
|
|
61
|
+
var _a, _b, _c;
|
|
62
|
+
// PROPS
|
|
63
|
+
const props = (0, system_1.useThemeProps)({
|
|
64
|
+
props: inProps,
|
|
65
|
+
name: constants_1.PREFIX
|
|
66
|
+
});
|
|
67
|
+
const { className, event, eventId } = props, rest = tslib_1.__rest(props, ["className", "event", "eventId"]);
|
|
68
|
+
// STATE
|
|
69
|
+
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
70
|
+
const scContext = (0, react_core_1.useSCContext)();
|
|
71
|
+
const { isLoaded } = (0, api_1.useLoadScript)({
|
|
72
|
+
googleMapsApiKey: scContext.settings.integrations.geocoding.apiKey,
|
|
73
|
+
libraries: ['maps']
|
|
74
|
+
});
|
|
75
|
+
if (!((_c = (_b = (_a = scContext === null || scContext === void 0 ? void 0 : scContext.settings) === null || _a === void 0 ? void 0 : _a.integrations) === null || _b === void 0 ? void 0 : _b.geocoding) === null || _c === void 0 ? void 0 : _c.apiKey) || (scEvent && (scEvent === null || scEvent === void 0 ? void 0 : scEvent.location) === types_1.SCEventLocationType.ONLINE)) {
|
|
76
|
+
return react_1.default.createElement(HiddenPlaceholder_1.default, null);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Loading event
|
|
80
|
+
*/
|
|
81
|
+
if (!isLoaded || !scEvent) {
|
|
82
|
+
return react_1.default.createElement(Skeleton_1.default, null);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Renders root object
|
|
86
|
+
*/
|
|
87
|
+
return (react_1.default.createElement(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest),
|
|
88
|
+
react_1.default.createElement(material_1.CardContent, null,
|
|
89
|
+
react_1.default.createElement(material_1.Typography, { variant: "h4", className: classes.title },
|
|
90
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.eventLocationWidget.title", defaultMessage: "ui.eventLocationWidget.title" })),
|
|
91
|
+
react_1.default.createElement(material_1.Box, { className: classes.map },
|
|
92
|
+
react_1.default.createElement(api_1.GoogleMap, { mapContainerClassName: classes.map, center: {
|
|
93
|
+
lat: scEvent === null || scEvent === void 0 ? void 0 : scEvent.geolocation_lat,
|
|
94
|
+
lng: scEvent === null || scEvent === void 0 ? void 0 : scEvent.geolocation_lng
|
|
95
|
+
}, zoom: 15 },
|
|
96
|
+
react_1.default.createElement(api_1.MarkerF, { position: {
|
|
97
|
+
lat: scEvent === null || scEvent === void 0 ? void 0 : scEvent.geolocation_lat,
|
|
98
|
+
lng: scEvent === null || scEvent === void 0 ? void 0 : scEvent.geolocation_lng
|
|
99
|
+
} }))),
|
|
100
|
+
react_1.default.createElement(material_1.Typography, { variant: "h4", className: classes.locationTitle }, (0, string_1.formatEventLocationGeolocation)(scEvent === null || scEvent === void 0 ? void 0 : scEvent.geolocation, true)),
|
|
101
|
+
react_1.default.createElement(material_1.Typography, { variant: "body1", className: classes.address }, (0, string_1.formatEventLocationGeolocation)(scEvent === null || scEvent === void 0 ? void 0 : scEvent.geolocation)))));
|
|
102
|
+
}
|
|
103
|
+
exports.default = EventLocationWidget;
|