@selfcommunity/react-ui 0.10.2-alpha.1 → 0.10.2-alpha.10
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/components/CommentObject/CommentObject.js +5 -2
- package/lib/cjs/components/Editor/plugins/AutoLinkPlugin.js +7 -1
- package/lib/cjs/components/EventForm/EventAddress.js +2 -13
- package/lib/cjs/components/EventForm/EventForm.js +32 -25
- package/lib/cjs/components/EventForm/constants.d.ts +4 -4
- package/lib/cjs/components/EventForm/constants.js +4 -4
- package/lib/cjs/components/EventForm/utils.d.ts +3 -3
- package/lib/cjs/components/EventForm/utils.js +8 -5
- package/lib/cjs/components/EventLocationWidget/EventLocationWidget.js +2 -13
- package/lib/cjs/components/EventParticipantsButton/EventParticipantsButton.js +1 -2
- package/lib/cjs/components/Events/Events.js +2 -4
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +1 -1
- package/lib/cjs/components/OnBoardingWidget/Steps/Appearance/Appearance.js +65 -104
- package/lib/cjs/components/UserProfileEdit/UserProfileEdit.d.ts +1 -1
- package/lib/cjs/components/UserProfileEdit/UserProfileEdit.js +1 -1
- package/lib/cjs/components/UserSocialAssociation/UserSocialAssociation.js +16 -4
- package/lib/cjs/constants/SocialShare.d.ts +12 -0
- package/lib/cjs/constants/SocialShare.js +15 -2
- package/lib/cjs/index.d.ts +2 -2
- package/lib/cjs/index.js +3 -1
- package/lib/esm/components/CommentObject/CommentObject.js +6 -3
- package/lib/esm/components/Editor/plugins/AutoLinkPlugin.js +7 -1
- package/lib/esm/components/EventForm/EventAddress.js +4 -15
- package/lib/esm/components/EventForm/EventForm.js +32 -25
- package/lib/esm/components/EventForm/constants.d.ts +4 -4
- package/lib/esm/components/EventForm/constants.js +4 -4
- package/lib/esm/components/EventForm/utils.d.ts +3 -3
- package/lib/esm/components/EventForm/utils.js +8 -5
- package/lib/esm/components/EventLocationWidget/EventLocationWidget.js +4 -15
- package/lib/esm/components/EventParticipantsButton/EventParticipantsButton.js +1 -2
- package/lib/esm/components/Events/Events.js +2 -4
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +1 -1
- package/lib/esm/components/OnBoardingWidget/Steps/Appearance/Appearance.js +67 -106
- package/lib/esm/components/UserProfileEdit/UserProfileEdit.d.ts +1 -1
- package/lib/esm/components/UserProfileEdit/UserProfileEdit.js +1 -1
- package/lib/esm/components/UserSocialAssociation/UserSocialAssociation.js +18 -6
- package/lib/esm/constants/SocialShare.d.ts +12 -0
- package/lib/esm/constants/SocialShare.js +13 -0
- package/lib/esm/index.d.ts +2 -2
- package/lib/esm/index.js +2 -2
- package/lib/umd/2aa155858f48b8f3911a.eot +0 -0
- package/lib/umd/36f3af7f155d916c26ff.woff2 +0 -0
- package/lib/umd/80884d7cc0fcb1a47982.svg +1 -0
- package/lib/umd/a221d3aba0f6753cfbb7.ttf +0 -0
- package/lib/umd/assets/icons.svg +251 -0
- package/lib/umd/c3528e120c4e831db2ae.woff +0 -0
- package/lib/umd/react-ui.js +19 -1
- package/package.json +5 -5
- package/lib/cjs/components/OnBoardingWidget/Steps/Appearance/reducer.d.ts +0 -15
- package/lib/cjs/components/OnBoardingWidget/Steps/Appearance/reducer.js +0 -42
- package/lib/esm/components/OnBoardingWidget/Steps/Appearance/reducer.d.ts +0 -15
- package/lib/esm/components/OnBoardingWidget/Steps/Appearance/reducer.js +0 -37
|
@@ -4,16 +4,15 @@ import { Autocomplete, Box, InputAdornment, Tab, Tabs, TextField } from '@mui/ma
|
|
|
4
4
|
import Icon from '@mui/material/Icon';
|
|
5
5
|
import { styled } from '@mui/material/styles';
|
|
6
6
|
import { useThemeProps } from '@mui/system';
|
|
7
|
-
import { useLoadScript } from '@react-google-maps/api';
|
|
8
7
|
import { SCEventLocationType } from '@selfcommunity/types';
|
|
9
8
|
import axios from 'axios';
|
|
10
9
|
import classNames from 'classnames';
|
|
11
|
-
import { useEffect,
|
|
10
|
+
import { useEffect, useState } from 'react';
|
|
12
11
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
13
12
|
import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
|
|
14
13
|
import UrlTextField from '../../shared/UrlTextField';
|
|
15
14
|
import { PREFIX } from './constants';
|
|
16
|
-
import {
|
|
15
|
+
import { useSCGoogleApiLoader } from '@selfcommunity/react-core';
|
|
17
16
|
const messages = defineMessages({
|
|
18
17
|
virtualPlaceholder: {
|
|
19
18
|
id: 'ui.eventForm.address.online.placeholder',
|
|
@@ -46,18 +45,8 @@ export default function EventAddress(inProps) {
|
|
|
46
45
|
const [inputValue, setInputValue] = useState('');
|
|
47
46
|
const [suggestions, setSuggestions] = useState([]);
|
|
48
47
|
const [timeoutId, setTimeoutId] = useState(null);
|
|
49
|
-
//
|
|
50
|
-
const {
|
|
51
|
-
// MEMO
|
|
52
|
-
const geocodingApiKey = useMemo(() => {
|
|
53
|
-
return preferences && SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY in preferences
|
|
54
|
-
? preferences[SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY].value
|
|
55
|
-
: null;
|
|
56
|
-
}, [preferences]);
|
|
57
|
-
const { isLoaded } = useLoadScript({
|
|
58
|
-
googleMapsApiKey: geocodingApiKey,
|
|
59
|
-
libraries: ['places', 'geocoding']
|
|
60
|
-
});
|
|
48
|
+
// HOOKS
|
|
49
|
+
const { isLoaded, geocodingApiKey } = useSCGoogleApiLoader();
|
|
61
50
|
// HANDLERS
|
|
62
51
|
const handleChange = (_event, newValue) => {
|
|
63
52
|
setLocation(newValue);
|
|
@@ -112,7 +112,7 @@ const Root = styled(Box, {
|
|
|
112
112
|
* @param inProps
|
|
113
113
|
*/
|
|
114
114
|
export default function EventForm(inProps) {
|
|
115
|
-
var _a, _b, _c
|
|
115
|
+
var _a, _b, _c;
|
|
116
116
|
//PROPS
|
|
117
117
|
const props = useThemeProps({
|
|
118
118
|
props: inProps,
|
|
@@ -140,7 +140,7 @@ export default function EventForm(inProps) {
|
|
|
140
140
|
recurring: (event === null || event === void 0 ? void 0 : event.recurring) || SCEventRecurrenceType.NEVER,
|
|
141
141
|
name: (event === null || event === void 0 ? void 0 : event.name) || '',
|
|
142
142
|
description: event ? event.description : '',
|
|
143
|
-
isPublic: (
|
|
143
|
+
isPublic: (event === null || event === void 0 ? void 0 : event.privacy) === SCEventPrivacyType.PUBLIC || true,
|
|
144
144
|
isSubmitting: false
|
|
145
145
|
};
|
|
146
146
|
// STATE
|
|
@@ -225,9 +225,7 @@ export default function EventForm(inProps) {
|
|
|
225
225
|
})
|
|
226
226
|
.catch((e) => {
|
|
227
227
|
const _error = formatHttpErrorCode(e);
|
|
228
|
-
|
|
229
|
-
// @ts-ignore
|
|
230
|
-
if (Object.values(_error)[0].error === 'unique') {
|
|
228
|
+
if (Object.values(_error)[0]['error'] === 'unique') {
|
|
231
229
|
setError(Object.assign(Object.assign({}, error), { ['nameError']: _jsx(FormattedMessage, { id: "ui.eventForm.name.error.unique", defaultMessage: "ui.eventForm.name.error.unique" }) }));
|
|
232
230
|
}
|
|
233
231
|
else {
|
|
@@ -237,7 +235,7 @@ export default function EventForm(inProps) {
|
|
|
237
235
|
Logger.error(SCOPE_SC_UI, e);
|
|
238
236
|
onError === null || onError === void 0 ? void 0 : onError(e);
|
|
239
237
|
});
|
|
240
|
-
}, [field, privateEnabled, visibilityEnabled, onSuccess, onError]);
|
|
238
|
+
}, [field, privateEnabled, visibilityEnabled, onSuccess, onError, notifyChanges]);
|
|
241
239
|
const handleChange = useCallback((event) => {
|
|
242
240
|
const { name, value } = event.target;
|
|
243
241
|
setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
|
|
@@ -245,7 +243,7 @@ export default function EventForm(inProps) {
|
|
|
245
243
|
delete error[`${name}Error`];
|
|
246
244
|
setError(error);
|
|
247
245
|
}
|
|
248
|
-
}, [error]);
|
|
246
|
+
}, [setField, error]);
|
|
249
247
|
const handleChangeDateTime = useCallback((value, name) => {
|
|
250
248
|
setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
|
|
251
249
|
if (error[`${name}Error`]) {
|
|
@@ -256,29 +254,26 @@ export default function EventForm(inProps) {
|
|
|
256
254
|
delete error['endDateError'];
|
|
257
255
|
setError(error);
|
|
258
256
|
}
|
|
259
|
-
}, [error]);
|
|
260
|
-
const
|
|
257
|
+
}, [setField, error]);
|
|
258
|
+
const shouldDisableDate = useCallback((date) => {
|
|
261
259
|
let disabled = false;
|
|
262
260
|
switch (field.recurring) {
|
|
263
261
|
case SCEventRecurrenceType.DAILY:
|
|
264
|
-
disabled = date.getTime() > getLaterDaysDate(DAILY_LATER_DAYS).getTime();
|
|
262
|
+
disabled = date.getTime() > getLaterDaysDate(DAILY_LATER_DAYS, field.startDate).getTime();
|
|
265
263
|
break;
|
|
266
264
|
case SCEventRecurrenceType.WEEKLY:
|
|
267
|
-
disabled = date.getTime() > getLaterDaysDate(WEEKLY_LATER_DAYS).getTime();
|
|
265
|
+
disabled = date.getTime() > getLaterDaysDate(WEEKLY_LATER_DAYS, field.startDate).getTime();
|
|
268
266
|
break;
|
|
269
267
|
case SCEventRecurrenceType.MONTHLY:
|
|
270
|
-
disabled = date.getTime() > getLaterDaysDate(MONTHLY_LATER_DAYS).getTime();
|
|
268
|
+
disabled = date.getTime() > getLaterDaysDate(MONTHLY_LATER_DAYS, field.startDate).getTime();
|
|
271
269
|
break;
|
|
272
270
|
case SCEventRecurrenceType.NEVER:
|
|
273
271
|
default:
|
|
274
|
-
disabled = date.getTime() > getLaterDaysDate(NEVER_LATER_DAYS).getTime();
|
|
275
|
-
}
|
|
276
|
-
if (field.startDate.getDate() > date.getDate()) {
|
|
277
|
-
disabled = true;
|
|
272
|
+
disabled = date.getTime() > getLaterDaysDate(NEVER_LATER_DAYS, field.startDate).getTime();
|
|
278
273
|
}
|
|
279
274
|
return disabled;
|
|
280
275
|
}, [field]);
|
|
281
|
-
const
|
|
276
|
+
const shouldDisableTime = useCallback((date) => field.startTime.getTime() > date.getTime(), [field]);
|
|
282
277
|
/**
|
|
283
278
|
* Renders root object
|
|
284
279
|
*/
|
|
@@ -305,24 +300,36 @@ export default function EventForm(inProps) {
|
|
|
305
300
|
return _jsx("em", { children: `${intl.formatMessage(messages.frequencyPlaceholder)}` });
|
|
306
301
|
}
|
|
307
302
|
return (_jsx(FormattedMessage, { id: `ui.eventForm.frequency.${selected}.placeholder`, defaultMessage: `ui.eventForm.frequency.${selected}.placeholder` }));
|
|
308
|
-
}, startAdornment: _jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "frequency" }) }) })) }, { children: Object.values(SCEventRecurrenceType).map((f) => (_jsx(MenuItem, Object.assign({ value: f }, { children: _jsx(FormattedMessage, { id: `ui.eventForm.frequency.${f}.placeholder`, defaultMessage: `ui.eventForm.frequency.${f}.placeholder` }) }), f))) }))] })), _jsx(Box, Object.assign({ className: classes.dateTime }, { children: _jsxs(LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? itLocale : enLocale }, { children: [_jsx(MobileDatePicker, { className: classes.picker,
|
|
303
|
+
}, startAdornment: _jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "frequency" }) }) })) }, { children: Object.values(SCEventRecurrenceType).map((f) => (_jsx(MenuItem, Object.assign({ value: f }, { children: _jsx(FormattedMessage, { id: `ui.eventForm.frequency.${f}.placeholder`, defaultMessage: `ui.eventForm.frequency.${f}.placeholder` }) }), f))) }))] })), _jsx(Box, Object.assign({ className: classes.dateTime }, { children: _jsxs(LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? itLocale : enLocale }, { children: [_jsx(MobileDatePicker, { className: classes.picker, minDate: field.startDate, label: _jsx(FormattedMessage, { id: "ui.eventForm.date.end.placeholder", defaultMessage: "ui.eventForm.date.end.placeholder" }), value: field.endDate, slots: {
|
|
309
304
|
textField: (params) => (_jsx(TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endDate)}`, startAdornment: (_jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "calendar_off" }) }) }))) }) })))
|
|
310
|
-
},
|
|
305
|
+
}, slotProps: {
|
|
306
|
+
toolbar: {
|
|
307
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
|
|
308
|
+
// @ts-ignore
|
|
309
|
+
toolbarTitle: _jsx(FormattedMessage, { id: "ui.eventForm.date.title", defaultMessage: "ui.eventForm.date.title" })
|
|
310
|
+
}
|
|
311
|
+
}, onChange: (value) => handleChangeDateTime(value, 'endDate'), shouldDisableDate: shouldDisableDate }), _jsx(MobileTimePicker, { className: classes.picker, disablePast: disablePastEndTime, label: field.endTime && _jsx(FormattedMessage, { id: "ui.eventForm.time.end.placeholder", defaultMessage: "ui.eventForm.time.end.placeholder" }), value: field.endTime, slots: {
|
|
311
312
|
textField: (params) => {
|
|
312
313
|
var _a;
|
|
313
314
|
return (_jsx(TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endTime)}`, startAdornment: (_jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "access_time" }) }) }))) }), error: Boolean(error['endDateError']), helperText: ((_a = error['endDateError']) === null || _a === void 0 ? void 0 : _a.error) ? (_jsx(FormattedMessage, { id: "ui.eventForm.time.end.error.invalid", defaultMessage: "ui.eventForm.time.end.error.invalid" })) : null })));
|
|
314
315
|
}
|
|
315
|
-
},
|
|
316
|
-
|
|
317
|
-
|
|
316
|
+
}, slotProps: {
|
|
317
|
+
toolbar: {
|
|
318
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
|
|
319
|
+
// @ts-ignore
|
|
320
|
+
toolbarTitle: _jsx(FormattedMessage, { id: "ui.eventForm.time.title", defaultMessage: "ui.eventForm.time.title" })
|
|
321
|
+
}
|
|
322
|
+
}, onChange: (value) => handleChangeDateTime(value, 'endTime'), shouldDisableTime: shouldDisableTime })] })) })), _jsx(EventAddress, { forwardGeolocationData: handleGeoData, event: event !== null && event !== void 0 ? event : null }), privateEnabled && (_jsxs(Box, Object.assign({ className: classes.privacySection }, { children: [_jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [_jsxs(Typography, Object.assign({ className: classNames(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [_jsx(Icon, { children: "private" }), _jsx(FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), _jsx(Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: event && !field.isPublic }), _jsxs(Typography, Object.assign({ className: classNames(classes.switchLabel, { [classes.active]: field.isPublic }) }, { children: [_jsx(Icon, { children: "public" }), _jsx(FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" })] }))] })), _jsx(Typography, Object.assign({ variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, { children: field.isPublic ? (_jsx(FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
|
|
323
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
|
|
324
|
+
// @ts-ignores
|
|
318
325
|
b: (chunks) => _jsx("strong", { children: chunks })
|
|
319
326
|
} })) : (_jsx(FormattedMessage, { id: "ui.eventForm.privacy.private.info", defaultMessage: "ui.eventForm.private.public.info", values: {
|
|
320
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
327
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
|
|
321
328
|
// @ts-ignore
|
|
322
329
|
b: (chunks) => _jsx("strong", { children: chunks })
|
|
323
330
|
} })) }))] }))), _jsx(TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
|
|
324
|
-
endAdornment: (_jsx(Typography, Object.assign({ variant: "body2" }, { children: ((
|
|
325
|
-
}, error: Boolean(((
|
|
331
|
+
endAdornment: (_jsx(Typography, Object.assign({ variant: "body2" }, { children: ((_a = field.description) === null || _a === void 0 ? void 0 : _a.length) ? EVENT_DESCRIPTION_MAX_LENGTH - field.description.length : EVENT_DESCRIPTION_MAX_LENGTH })))
|
|
332
|
+
}, error: Boolean(((_b = field.description) === null || _b === void 0 ? void 0 : _b.length) > EVENT_DESCRIPTION_MAX_LENGTH), helperText: ((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) > EVENT_DESCRIPTION_MAX_LENGTH ? (_jsx(FormattedMessage, { id: "ui.eventForm.description.error.maxLength", defaultMessage: "ui.eventForm.description.error.maxLength" })) : null }), _jsx(Box, Object.assign({ className: classes.actions }, { children: _jsx(LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.name ||
|
|
326
333
|
!field.startDate ||
|
|
327
334
|
!field.startTime ||
|
|
328
335
|
!field.endDate ||
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const PREFIX = "SCEventForm";
|
|
2
|
-
export declare const NEVER_LATER_DAYS =
|
|
3
|
-
export declare const DAILY_LATER_DAYS =
|
|
4
|
-
export declare const WEEKLY_LATER_DAYS =
|
|
5
|
-
export declare const MONTHLY_LATER_DAYS =
|
|
2
|
+
export declare const NEVER_LATER_DAYS = 13;
|
|
3
|
+
export declare const DAILY_LATER_DAYS = 59;
|
|
4
|
+
export declare const WEEKLY_LATER_DAYS = 359;
|
|
5
|
+
export declare const MONTHLY_LATER_DAYS = 729;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const PREFIX = 'SCEventForm';
|
|
2
|
-
export const NEVER_LATER_DAYS =
|
|
3
|
-
export const DAILY_LATER_DAYS = 60
|
|
4
|
-
export const WEEKLY_LATER_DAYS = 360
|
|
5
|
-
export const MONTHLY_LATER_DAYS =
|
|
2
|
+
export const NEVER_LATER_DAYS = 13; // 2 weeks less 1 day
|
|
3
|
+
export const DAILY_LATER_DAYS = 59; // 60 days less 1 day
|
|
4
|
+
export const WEEKLY_LATER_DAYS = 359; // 360 days less 1 day
|
|
5
|
+
export const MONTHLY_LATER_DAYS = 729; // 2 years less 1 day
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function getNewDate(date?: string): Date;
|
|
2
|
-
export declare function getLaterHoursDate(
|
|
3
|
-
export declare function getLaterDaysDate(
|
|
1
|
+
export declare function getNewDate(date?: string | Date): Date;
|
|
2
|
+
export declare function getLaterHoursDate(hours: number, date?: Date): Date;
|
|
3
|
+
export declare function getLaterDaysDate(days: number, date?: Date): Date;
|
|
4
4
|
export declare const combineDateAndTime: (date: Date, time: Date) => string;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { addDays, addHours } from 'date-fns';
|
|
2
2
|
export function getNewDate(date) {
|
|
3
3
|
if (date) {
|
|
4
|
-
|
|
4
|
+
if (typeof date === 'string') {
|
|
5
|
+
return new Date(date);
|
|
6
|
+
}
|
|
7
|
+
return date;
|
|
5
8
|
}
|
|
6
9
|
return new Date();
|
|
7
10
|
}
|
|
8
|
-
export function getLaterHoursDate(
|
|
9
|
-
return addHours(getNewDate(),
|
|
11
|
+
export function getLaterHoursDate(hours, date) {
|
|
12
|
+
return addHours(getNewDate(date), hours);
|
|
10
13
|
}
|
|
11
|
-
export function getLaterDaysDate(
|
|
12
|
-
return addDays(getNewDate(),
|
|
14
|
+
export function getLaterDaysDate(days, date) {
|
|
15
|
+
return addDays(getNewDate(date), days);
|
|
13
16
|
}
|
|
14
17
|
export const combineDateAndTime = (date, time) => {
|
|
15
18
|
const combined = date;
|
|
@@ -3,8 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { Box, CardContent, Typography } from '@mui/material';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
5
|
import { useThemeProps } from '@mui/system';
|
|
6
|
-
import { GoogleMap, MarkerF
|
|
7
|
-
import {
|
|
6
|
+
import { GoogleMap, MarkerF } from '@react-google-maps/api';
|
|
7
|
+
import { useSCGoogleApiLoader, useSCFetchEvent } from '@selfcommunity/react-core';
|
|
8
8
|
import { SCEventLocationType } from '@selfcommunity/types';
|
|
9
9
|
import classNames from 'classnames';
|
|
10
10
|
import { FormattedMessage } from 'react-intl';
|
|
@@ -13,7 +13,6 @@ import { formatEventLocationGeolocation } from '../../utils/string';
|
|
|
13
13
|
import Widget from '../Widget';
|
|
14
14
|
import { PREFIX } from './constants';
|
|
15
15
|
import EventLocationWidgetSkeleton from './Skeleton';
|
|
16
|
-
import { useMemo } from 'react';
|
|
17
16
|
const classes = {
|
|
18
17
|
root: `${PREFIX}-root`,
|
|
19
18
|
title: `${PREFIX}-title`,
|
|
@@ -65,18 +64,8 @@ export default function EventLocationWidget(inProps) {
|
|
|
65
64
|
const { className, event, eventId } = props, rest = __rest(props, ["className", "event", "eventId"]);
|
|
66
65
|
// STATE
|
|
67
66
|
const { scEvent } = useSCFetchEvent({ id: eventId, event });
|
|
68
|
-
//
|
|
69
|
-
const {
|
|
70
|
-
// MEMO
|
|
71
|
-
const geocodingApiKey = useMemo(() => {
|
|
72
|
-
return preferences && SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY in preferences
|
|
73
|
-
? preferences[SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY].value
|
|
74
|
-
: null;
|
|
75
|
-
}, [preferences]);
|
|
76
|
-
const { isLoaded } = useLoadScript({
|
|
77
|
-
googleMapsApiKey: geocodingApiKey,
|
|
78
|
-
libraries: ['maps']
|
|
79
|
-
});
|
|
67
|
+
// HOOKS
|
|
68
|
+
const { isLoaded, geocodingApiKey } = useSCGoogleApiLoader();
|
|
80
69
|
const mapOptions = {
|
|
81
70
|
fullscreenControl: false,
|
|
82
71
|
mapTypeControl: false,
|
|
@@ -20,7 +20,6 @@ import User, { UserSkeleton } from '../User';
|
|
|
20
20
|
const PREFIX = 'SCEventParticipantsButton';
|
|
21
21
|
const classes = {
|
|
22
22
|
root: `${PREFIX}-root`,
|
|
23
|
-
avatar: `${PREFIX}-avatar`,
|
|
24
23
|
participants: `${PREFIX}-participants`,
|
|
25
24
|
dialogRoot: `${PREFIX}-dialog-root`,
|
|
26
25
|
infiniteScroll: `${PREFIX}-infinite-scroll`,
|
|
@@ -134,5 +133,5 @@ export default function EventParticipantsButton(inProps) {
|
|
|
134
133
|
}, [setOpen]);
|
|
135
134
|
return (_jsxs(_Fragment, { children: [_jsxs(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scEvent || scEvent.goings_counter === 0,
|
|
136
135
|
// @ts-expect-error this is needed to use followers into SCEventParticipantsButton
|
|
137
|
-
followers: followers }, rest, { children: [!hideCaption && (_jsx(Typography, Object.assign({ className: classes.participants, variant: "caption" }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.eventParticipantsButton.participants", id: "ui.eventParticipantsButton.participants" }) }))), !followers.length && (loading || !scEvent) ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest, (!participantsAvailable && { skeletonsAnimation: false })))) : (_jsx(AvatarGroup, Object.assign({ total: followers.length, renderSurplus: renderSurplus }, { children: followers.map((c) => (_jsx(Avatar, { alt: c.username, src: c.avatar
|
|
136
|
+
followers: followers }, rest, { children: [!hideCaption && (_jsx(Typography, Object.assign({ className: classes.participants, variant: "caption" }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.eventParticipantsButton.participants", id: "ui.eventParticipantsButton.participants" }) }))), !followers.length && (loading || !scEvent) ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest, (!participantsAvailable && { skeletonsAnimation: false })))) : (_jsx(AvatarGroup, Object.assign({ total: followers.length, renderSurplus: renderSurplus }, { children: followers.map((c) => (_jsx(Avatar, { alt: c.username, src: c.avatar }, c.id))) })))] })), open && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: _jsx(FormattedMessage, { defaultMessage: "ui.eventParticipantsButton.dialogTitle", id: "ui.eventParticipantsButton.dialogTitle", values: { total: scEvent.goings_counter } }), onClose: handleToggleDialogOpen, open: open }, DialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: followers.length, next: fetchFollowers, hasMoreNext: next !== null || loading, loaderNext: _jsx(UserSkeleton, { elevation: 0 }), className: classes.infiniteScroll, endMessage: _jsx(Typography, Object.assign({ className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.eventParticipantsButton.noOtherParticipants", defaultMessage: "ui.eventParticipantsButton.noOtherParticipants" }) })) }, { children: _jsx(List, { children: followers.map((follower) => (_jsx(ListItem, { children: _jsx(User, { elevation: 0, user: follower }) }, follower.id))) }) })) })))] }));
|
|
138
137
|
}
|
|
@@ -210,8 +210,7 @@ export default function Events(inProps) {
|
|
|
210
210
|
* Renders events list
|
|
211
211
|
*/
|
|
212
212
|
const c = (_jsxs(_Fragment, { children: [showFilters && (_jsx(Grid, Object.assign({ container: true, className: classes.filters, gap: 2 }, { children: filters ? (filters) : !general ? (_jsxs(_Fragment, { children: [(events.length !== 0 || (events.length === 0 && showMyEvents)) && (_jsx(Grid, Object.assign({ item: true }, { children: _jsx(EventsChipRoot, { color: showMyEvents ? 'secondary' : 'default', variant: showMyEvents ? 'filled' : 'outlined', label: _jsx(FormattedMessage, { id: "ui.events.filterByCreatedByMe", defaultMessage: "ui.events.filterByCreatedByMe" }), onClick: () => setShowMyEvents(!showMyEvents),
|
|
213
|
-
//
|
|
214
|
-
// @ts-ignore
|
|
213
|
+
// @ts-expect-error this is needed to use showFollowed into SCEvents
|
|
215
214
|
showFollowed: showMyEvents, deleteIcon: showMyEvents ? _jsx(Icon, { children: "close" }) : null, onDelete: showMyEvents ? handleDeleteClick : null, disabled: loading }) }))), _jsx(Grid, Object.assign({ item: true }, { children: _jsx(PastEventsFilter, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, disabled: loading }) })), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: _jsx(LocationEventsFilter, { value: location, autoHide: !loading && !events.length, disabled: loading || (!events.length && !location), handleOnChange: handleOnChangeLocation }) }))] })) : (_jsxs(_Fragment, { children: [_jsx(Grid, Object.assign({ item: true, xs: 12, md: 3 }, { children: _jsx(TextField, { className: classes.search, size: 'small', fullWidth: true, value: query, label: _jsx(FormattedMessage, { id: "ui.events.filterByName", defaultMessage: "ui.events.filterByName" }), variant: "outlined", onChange: handleOnChangeFilterName, disabled: loading || (!events.length && !query), onKeyUp: (e) => {
|
|
216
215
|
e.preventDefault();
|
|
217
216
|
if (e.key === 'Enter') {
|
|
@@ -220,8 +219,7 @@ export default function Events(inProps) {
|
|
|
220
219
|
}, InputProps: {
|
|
221
220
|
endAdornment: (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: isMobile ? (_jsx(IconButton, Object.assign({ onClick: () => fetchEvents(true), disabled: loading || (!events.length && !query) }, { children: _jsx(Icon, { children: "search" }) }))) : (_jsx(Button, { size: "small", variant: "contained", color: "secondary", onClick: () => fetchEvents(true), endIcon: _jsx(Icon, { children: "search" }), disabled: loading || (!events.length && !query) })) })))
|
|
222
221
|
} }) })), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: _jsxs(FormControl, Object.assign({ fullWidth: true }, { children: [_jsx(InputLabel, { children: _jsx(FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }) }), _jsx(Select, Object.assign({ disabled: showPastEvents || loading || (!events.length && dateSearch === SCEventDateFilterType.ANY), size: 'small', label: _jsx(FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }), value: dateSearch, onChange: handleOnChangeTimeFrame, renderValue: (selected) => options.find((option) => option.value === selected).label }, { children: options.map((option) => (_jsxs(MenuItem, Object.assign({ value: option.value }, { children: [_jsx(Radio, { checked: dateSearch === option.value, value: option.value, name: "radio-button-select", inputProps: { 'aria-label': option.label } }), option.label] }), option.value))) }))] })) })), _jsx(Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: _jsx(LocationEventsFilter, { value: location, disabled: loading || (!events.length && !location), handleOnChange: handleOnChangeLocation }) })), authUserId && (_jsx(Grid, Object.assign({ item: true }, { children: _jsx(EventsChipRoot, { color: showFollowed ? 'secondary' : 'default', variant: showFollowed ? 'filled' : 'outlined', label: _jsx(FormattedMessage, { id: "ui.events.filterByFollowedInterest", defaultMessage: "ui.events.filterByFollowedInterest" }), onClick: handleChipClick,
|
|
223
|
-
//
|
|
224
|
-
// @ts-ignore
|
|
222
|
+
// @ts-expect-error this is needed to use showFollowed into SCEvents
|
|
225
223
|
showFollowed: showFollowed, deleteIcon: showFollowed ? _jsx(Icon, { children: "close" }) : null, onDelete: showFollowed ? handleDeleteClick : null, disabled: loading || (!events.length && !showFollowed) }) }))), _jsx(Grid, Object.assign({ item: true }, { children: _jsx(PastEventsFilter, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, disabled: dateSearch !== SCEventDateFilterType.ANY || loading }) }))] })) }))), _jsx(_Fragment, { children: loading ? (_jsx(Skeleton, Object.assign({}, EventsSkeletonComponentProps, { EventSkeletonProps: EventSkeletonComponentProps }))) : (_jsx(_Fragment, { children: !events.length ? (_jsx(Box, Object.assign({ className: classes.noResults }, { children: general ? (_jsxs(_Fragment, { children: [_jsx(EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: (onlyStaffEnabled && UserUtils.isStaff(scUserContext.user)) || !onlyStaffEnabled ? _jsx(CreateEventButton, {}) : null })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.events.noEvents.title", defaultMessage: "ui.events.noEvents.title" }) }))] })) : (_jsxs(_Fragment, { children: [_jsx(EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: (onlyStaffEnabled && UserUtils.isStaff(scUserContext.user)) || !onlyStaffEnabled ? _jsx(CreateEventButton, {}) : null })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.events.noEvents.title.personal", defaultMessage: "ui.events.noEvents.title.personal" }) }))] })) }))) : (_jsxs(_Fragment, { children: [_jsx(Grid, Object.assign({ container: true, spacing: { xs: 2 }, className: classes.events }, GridContainerComponentProps, { children: _jsxs(_Fragment, { children: [events.map((event) => (_jsx(Grid, Object.assign({ item: true, xs: 12, sm: 12, md: 6, className: classes.item }, GridItemComponentProps, { children: _jsx(Event, Object.assign({ event: event, eventId: event.id }, EventComponentProps)) }), event.id))), authUserId && events.length % 2 !== 0 && (_jsx(Grid, Object.assign({ item: true, xs: 12, sm: 12, md: 6, className: classes.itemSkeleton }, GridItemComponentProps, { children: _jsx(EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: _jsx(CreateEventButton, Object.assign({ variant: "outlined", color: "primary", size: "small" }, { children: _jsx(FormattedMessage, { id: "ui.events.skeleton.action.add", defaultMessage: "ui.events.skeleton.action.add" }) })) })) }), 'skeleton-item'))] }) })), Boolean(next) && (_jsx(Button, Object.assign({ color: "secondary", variant: "text", onClick: handleNext, className: classes.showMore }, { children: _jsx(FormattedMessage, { id: "ui.events.button.seeMore", defaultMessage: "ui.events.button.seeMore" }) })))] })) })) })] }));
|
|
226
224
|
/**
|
|
227
225
|
* Renders root object (if content availability community option is false and user is anonymous, component is hidden)
|
|
@@ -133,5 +133,5 @@ export default function GroupMembersButton(inProps) {
|
|
|
133
133
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
134
134
|
return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleToggleDialogOpen, disabled: loading || !scGroup || scGroup.subscribers_counter === 0,
|
|
135
135
|
// @ts-expect-error this is needed to use subscribers into SCGroupMembersButton
|
|
136
|
-
subscribers: scGroup.subscribers_counter }, rest, { children: loading || !scGroup ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest))) : (_jsx(AvatarGroup, Object.assign({ total: scGroup.subscribers_counter, renderSurplus: renderSurplus }, { children: members.map((c) => (_jsx(Avatar, { alt: c.username, src: c.avatar }, c.id))) }))) })), open && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: _jsx(FormattedMessage, { defaultMessage: "ui.groupMembersButton.dialogTitle", id: "ui.groupMembersButton.dialogTitle", values: { total: scGroup.subscribers_counter } }), onClose: handleToggleDialogOpen, open: open }, DialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: members.length, next: fetchMembers, hasMoreNext: next !== null || loading, loaderNext: _jsx(UserSkeleton, { elevation: 0 }), height: isMobile ? '100%' : 400, endMessage: _jsx(Typography, Object.assign({ className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.groupMembersButton.noOtherMembers", defaultMessage: "ui.groupMembersButton.noOtherMembers" }) })) }, { children: _jsx(List, { children: members.map((member) => (_jsx(ListItem, { children: _jsx(User, { elevation: 0, user: member, onClick: handleToggleDialogOpen }) }, member.id))) }) })) })))] }));
|
|
136
|
+
subscribers: scGroup === null || scGroup === void 0 ? void 0 : scGroup.subscribers_counter }, rest, { children: loading || !scGroup ? (_jsx(AvatarGroupSkeleton, Object.assign({}, rest))) : (_jsx(AvatarGroup, Object.assign({ total: scGroup.subscribers_counter, renderSurplus: renderSurplus }, { children: members.map((c) => (_jsx(Avatar, { alt: c.username, src: c.avatar }, c.id))) }))) })), open && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: _jsx(FormattedMessage, { defaultMessage: "ui.groupMembersButton.dialogTitle", id: "ui.groupMembersButton.dialogTitle", values: { total: scGroup.subscribers_counter } }), onClose: handleToggleDialogOpen, open: open }, DialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: members.length, next: fetchMembers, hasMoreNext: next !== null || loading, loaderNext: _jsx(UserSkeleton, { elevation: 0 }), height: isMobile ? '100%' : 400, endMessage: _jsx(Typography, Object.assign({ className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.groupMembersButton.noOtherMembers", defaultMessage: "ui.groupMembersButton.noOtherMembers" }) })) }, { children: _jsx(List, { children: members.map((member) => (_jsx(ListItem, { children: _jsx(User, { elevation: 0, user: member, onClick: handleToggleDialogOpen }) }, member.id))) }) })) })))] }));
|
|
137
137
|
}
|