@selfcommunity/react-ui 0.10.2-alpha.2 → 0.10.2-alpha.21
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 +6 -3
- package/lib/cjs/components/EditEventButton/EditEventButton.js +2 -2
- package/lib/cjs/components/Editor/plugins/AutoLinkPlugin.js +7 -1
- package/lib/cjs/components/Event/Event.js +4 -4
- 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/EventInviteButton/EventInviteButton.js +5 -5
- package/lib/cjs/components/EventLocationWidget/EventLocationWidget.js +2 -13
- package/lib/cjs/components/Events/Events.js +2 -4
- package/lib/cjs/components/FeedObject/FeedObject.js +2 -2
- package/lib/cjs/components/NavigationMenuIconButton/DefaultDrawerContent.js +24 -2
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +1 -1
- package/lib/cjs/components/Notification/Comment/Comment.js +2 -2
- package/lib/cjs/components/Notification/Notification.js +1 -1
- package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.js +3 -6
- 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/cjs/utils/contribution.d.ts +7 -0
- package/lib/cjs/utils/contribution.js +13 -1
- package/lib/esm/components/CommentObject/CommentObject.js +8 -5
- package/lib/esm/components/EditEventButton/EditEventButton.js +2 -2
- package/lib/esm/components/Editor/plugins/AutoLinkPlugin.js +7 -1
- package/lib/esm/components/Event/Event.js +4 -4
- 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/EventInviteButton/EventInviteButton.js +5 -5
- package/lib/esm/components/EventLocationWidget/EventLocationWidget.js +4 -15
- package/lib/esm/components/Events/Events.js +2 -4
- package/lib/esm/components/FeedObject/FeedObject.js +2 -2
- package/lib/esm/components/NavigationMenuIconButton/DefaultDrawerContent.js +27 -5
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +1 -1
- package/lib/esm/components/Notification/Comment/Comment.js +2 -2
- package/lib/esm/components/Notification/Notification.js +1 -1
- package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.js +3 -6
- 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/esm/utils/contribution.d.ts +7 -0
- package/lib/esm/utils/contribution.js +11 -0
- 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 +4 -4
|
@@ -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;
|
|
@@ -38,13 +38,13 @@ const classes = {
|
|
|
38
38
|
const Root = styled(Button, {
|
|
39
39
|
name: PREFIX,
|
|
40
40
|
slot: 'Root',
|
|
41
|
-
overridesResolver: (
|
|
42
|
-
})((
|
|
41
|
+
overridesResolver: (_props, styles) => styles.root
|
|
42
|
+
})(() => ({}));
|
|
43
43
|
const DialogRoot = styled(BaseDialog, {
|
|
44
44
|
name: PREFIX,
|
|
45
45
|
slot: 'Root',
|
|
46
|
-
overridesResolver: (
|
|
47
|
-
})((
|
|
46
|
+
overridesResolver: (_props, styles) => styles.dialogRoot
|
|
47
|
+
})(() => ({}));
|
|
48
48
|
/**
|
|
49
49
|
*> API documentation for the Community-JS Event Invite Button component. Learn about the available props and the CSS API.
|
|
50
50
|
*
|
|
@@ -194,7 +194,7 @@ export default function EventInviteButton(inProps) {
|
|
|
194
194
|
});
|
|
195
195
|
};
|
|
196
196
|
// Autocomplete Handlers
|
|
197
|
-
const handleInputChange = (
|
|
197
|
+
const handleInputChange = (_event, value, reason) => {
|
|
198
198
|
switch (reason) {
|
|
199
199
|
case 'input':
|
|
200
200
|
setValue(value);
|
|
@@ -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,
|
|
@@ -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)
|
|
@@ -429,7 +429,7 @@ export default function FeedObject(inProps) {
|
|
|
429
429
|
else if (template === SCFeedObjectTemplateType.PREVIEW ||
|
|
430
430
|
template === SCFeedObjectTemplateType.DETAIL ||
|
|
431
431
|
template === SCFeedObjectTemplateType.SEARCH) {
|
|
432
|
-
objElement = (_jsx(React.Fragment, { children: obj ? (_jsxs(Box, Object.assign({ className: classNames({ [classes.deleted]: obj && obj.deleted }) }, { children: [obj.categories.length > 0 && (_jsxs("div", Object.assign({ className: classes.category }, { children: [_jsxs(_Fragment, { children: [obj.group && (_jsx(
|
|
432
|
+
objElement = (_jsx(React.Fragment, { children: obj ? (_jsxs(Box, Object.assign({ className: classNames({ [classes.deleted]: obj && obj.deleted }) }, { children: [obj.categories.length > 0 && (_jsxs("div", Object.assign({ className: classes.category }, { children: [_jsxs(_Fragment, { children: [obj.group && (_jsx(Chip, { className: classes.group, color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id)), obj.event && (_jsx(Chip, { className: classes.event, color: "secondary", size: "small", label: obj.event.name, icon: _jsx(Icon, { children: "CalendarIcon" }), component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id))] }), obj.categories.map((c) => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, c) }, { children: _jsx(Typography, Object.assign({ variant: "overline" }, { children: c.name })) }), c.id)))] }))), obj.group && !obj.categories.length && (_jsx("div", Object.assign({ className: classes.group }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), label: obj.group.name, component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && !obj.categories.length && (_jsx(Chip, { className: classes.event, color: "secondary", size: "small", icon: _jsx(Icon, { children: "CalendarIcon" }), label: obj.event.name, component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id)), _jsx(CardHeader, { className: classes.header, avatar: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !obj.author.community_badge }, { children: _jsx(Avatar, Object.assign({ "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, { children: obj.author.username })) })) })), title: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: obj.author.username })), subheader: _jsxs(_Fragment, { children: [_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)), className: classes.activityAt }, { children: _jsx(DateTimeAgo, { component: 'span', date: obj.added_at }) })), obj.location && (_jsxs(_Fragment, { children: [_jsx(Bullet, {}), _jsxs(Box, Object.assign({ className: classes.location }, { children: [_jsx(Icon, { children: "add_location_alt" }), (_a = obj.location) === null || _a === void 0 ? void 0 : _a.location] }))] })), _jsx(Bullet, {}), _jsx(Box, Object.assign({ className: classes.tag }, { children: obj.addressing.length > 0 ? (_jsx(Tags, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : obj.group ? (_jsx(Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToGroup, { group: obj.group.name })}` }, { children: _jsx(Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "groups" })) }))) : (_jsx(Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToAll)}` }, { children: _jsx(Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "public" })) }))) }))] }), action: renderHeaderAction() }), _jsxs(CardContent, Object.assign({ classes: { root: classes.content } }, { children: [_jsx(Box, Object.assign({ className: classes.titleSection }, { children: 'title' in obj && (_jsx(_Fragment, { children: template === SCFeedObjectTemplateType.DETAIL ? (_jsx(Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title }))) : (_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)) }, { children: _jsx(Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title })) }))) })) })), _jsx(Box, Object.assign({ className: classes.textSection }, { children: getContributionSummary(obj, template) })), _jsx(Box, Object.assign({ className: classes.mediasSection }, { children: _jsx(FeedObjectMediaPreview, Object.assign({ medias: obj.medias }, FeedObjectMediaPreviewProps)) })), _jsx(Box, Object.assign({ className: classes.pollsSection }, { children: obj['poll'] && (_jsx(PollObject, Object.assign({ visible: pollVisible ||
|
|
433
433
|
template === SCFeedObjectTemplateType.DETAIL ||
|
|
434
434
|
Boolean(obj.type !== SCContributionType.DISCUSSION && !obj.html && !obj.medias.length), feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, onToggleVisibility: handleTogglePollVisibility }, PollObjectProps))) })), _jsx(Box, Object.assign({ className: classes.infoSection }, { children: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [!hideParticipantsPreview && (_jsx(ContributorsFeedObject, Object.assign({ feedObject: obj, feedObjectType: obj.type }, ContributorsFeedObjectProps, { cacheStrategy: cacheStrategy }))), !_hideFollowAction && _jsx(Follow, Object.assign({ feedObject: obj, feedObjectType: obj.type, handleFollow: handleFollow }, FollowButtonProps))] })) }))] })), _jsxs(CardActions, Object.assign({ className: classes.actionsSection }, { children: [_jsx(Actions, Object.assign({ feedObjectId: feedObjectId, feedObjectType: feedObjectType, feedObject: obj, hideCommentAction: template === SCFeedObjectTemplateType.DETAIL || (hasEvent && !((_c = (_b = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.active)), handleExpandActivities: template === SCFeedObjectTemplateType.PREVIEW ? handleExpandActivities : null, VoteActionProps: { onVoteAction: handleVoteSuccess } }, ActionsProps)), ((template === SCFeedObjectTemplateType.DETAIL && (!hasEvent || ((_h = (_g = (_f = (_d = obj === null || obj === void 0 ? void 0 : obj.medias) === null || _d === void 0 ? void 0 : _d[0]) === null || _f === void 0 ? void 0 : _f.embed) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.active))) || expandedActivities) && (_jsx(Box, Object.assign({ className: classes.replyContent }, { children: _jsx(CommentObjectReplyComponent, Object.assign({ id: `reply-feedObject-${obj.id}`, onReply: handleReply, editable: !isReplying || Boolean(obj) }, CommentObjectReplyComponentProps), Number(isReplying)) })))] })), template === SCFeedObjectTemplateType.PREVIEW && (obj.comment_count > 0 || (feedObjectActivities && feedObjectActivities.length > 0)) && (_jsx(Collapse, Object.assign({ in: expandedActivities, timeout: "auto", classes: { root: classes.activitiesSection } }, { children: _jsx(CardContent, Object.assign({ className: classes.activitiesContent }, { children: _jsx(Activities, Object.assign({ feedObject: obj, feedObjectActivities: feedObjectActivities, activitiesType: selectedActivities, onSetSelectedActivities: handleSelectedActivities, comments: comments, CommentsObjectProps: {
|
|
435
435
|
CommentComponentProps: Object.assign({ onDelete: handleDeleteComment, truncateContent: true, CommentsObjectComponentProps: { inPlaceLoadMoreContents: false } }, CommentComponentProps),
|
|
@@ -437,7 +437,7 @@ export default function FeedObject(inProps) {
|
|
|
437
437
|
}, cacheStrategy: cacheStrategy }, ActivitiesProps), selectedActivities) })) }))), composerOpen && (_jsx(Composer, { open: composerOpen, feedObject: obj, onClose: handleToggleEdit, onSuccess: handleEditSuccess, maxWidth: "sm", fullWidth: true }))] }))) : (_jsx(FeedObjectSkeleton, Object.assign({ template: template }, FeedObjectSkeletonProps))) }));
|
|
438
438
|
}
|
|
439
439
|
else if (template === SCFeedObjectTemplateType.SHARE) {
|
|
440
|
-
objElement = (_jsx(React.Fragment, { children: obj ? (_jsxs(React.Fragment, { children: [obj.categories.length > 0 && (_jsxs("div", Object.assign({ className: classes.category }, { children: [_jsxs(_Fragment, { children: [obj.group && (_jsx("div", Object.assign({ className: classes.group }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && (_jsx(
|
|
440
|
+
objElement = (_jsx(React.Fragment, { children: obj ? (_jsxs(React.Fragment, { children: [obj.categories.length > 0 && (_jsxs("div", Object.assign({ className: classes.category }, { children: [_jsxs(_Fragment, { children: [obj.group && (_jsx("div", Object.assign({ className: classes.group }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && (_jsx(Chip, { className: classes.event, color: "secondary", size: "small", icon: _jsx(Icon, { children: "CalendarIcon" }), component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id))] }), obj.categories.map((c) => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, c) }, { children: _jsx(Typography, Object.assign({ variant: "overline" }, { children: c.name })) }), c.id)))] }))), obj.group && !obj.categories.length && (_jsx("div", Object.assign({ className: classes.group }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), label: obj.group.name, component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && !obj.categories.length && (_jsx("div", Object.assign({ className: classes.event }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), label: obj.event.name, component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id) }))), _jsx(CardHeader, { classes: { root: classes.header }, avatar: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: _jsx(UserAvatar, Object.assign({ hide: !obj.author.community_badge }, { children: _jsx(Avatar, Object.assign({ "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, { children: obj.author.username })) })) })), title: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: obj.author.username })), subheader: _jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)), className: classes.activityAt }, { children: _jsx(DateTimeAgo, { date: obj.added_at }) })) }), _jsxs(CardContent, Object.assign({ classes: { root: classes.content } }, { children: [_jsx(Box, Object.assign({ className: classes.titleSection }, { children: 'title' in obj && (_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)) }, { children: _jsx(Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title })) }))) })), _jsx(Box, Object.assign({ className: classes.textSection }, { children: getContributionSummary(obj, template) })), _jsx(Box, Object.assign({ className: classes.mediasSection }, { children: _jsx(FeedObjectMediaPreview, Object.assign({ medias: obj.medias }, FeedObjectMediaPreviewProps)) })), _jsx(Box, Object.assign({ className: classes.pollsSection }, { children: obj['poll'] && (_jsx(PollObject, Object.assign({ feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, visible: Boolean(obj.type !== SCContributionType.DISCUSSION && !obj.html && !obj.medias.length) }, PollObjectProps))) }))] }))] })) : (_jsx(FeedObjectSkeleton, Object.assign({ template: template }, FeedObjectSkeletonProps))) }));
|
|
441
441
|
}
|
|
442
442
|
else {
|
|
443
443
|
objElement = (_jsx(React.Fragment, { children: obj ? (_jsx(BaseItem, { elevation: 0, className: classes.snippet, image: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !obj.author.community_badge }, { children: _jsx(Avatar, { alt: obj.author.username, variant: "circular", src: obj.author.avatar, className: classes.avatar }) })) })), primary: _jsxs(Box, { children: [_jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: obj.author.username })), _jsx(Typography, Object.assign({ variant: "body2", className: classes.snippetContent }, { children: _jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)) }, { children: getContributionSnippet(obj) })) }))] }), disableTypography: true, secondary: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", spacing: 2, alignItems: "center" }, { children: [_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)), className: classes.activityAt }, { children: _jsx(DateTimeAgo, { component: "span", date: obj.added_at }) })), _jsx(Button, Object.assign({ component: Link, to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)), variant: "text", color: "secondary", size: "small" }, { children: _jsx(FormattedMessage, { id: "ui.feedObject.comment", defaultMessage: "ui.feedObject.comment" }) }))] })) })) : (_jsx(FeedObjectSkeleton, Object.assign({}, FeedObjectSkeletonProps))) }));
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Box,
|
|
4
|
-
import { Link, SCRoutes, useSCFetchCategories, useSCRouting } from '@selfcommunity/react-core';
|
|
5
|
-
import { useEffect, useState } from 'react';
|
|
3
|
+
import { Box, Divider, Icon, List, ListItem, ListItemButton, ListItemIcon, ListItemText, Typography, Zoom } from '@mui/material';
|
|
4
|
+
import { Link, SCPreferences, SCRoutes, useSCFetchCategories, useSCPreferences, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
5
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
6
6
|
import Category from '../Category';
|
|
7
7
|
import { FormattedMessage } from 'react-intl';
|
|
8
8
|
import { sortByAttr } from '@selfcommunity/utils';
|
|
9
|
+
import { SCFeatureName } from '@selfcommunity/types';
|
|
9
10
|
import { styled } from '@mui/material/styles';
|
|
10
11
|
import classNames from 'classnames';
|
|
11
12
|
import { useThemeProps } from '@mui/system';
|
|
12
13
|
const PREFIX = 'SCDefaultDrawerContent';
|
|
13
14
|
const classes = {
|
|
14
|
-
root: `${PREFIX}-root
|
|
15
|
+
root: `${PREFIX}-root`,
|
|
16
|
+
navigation: `${PREFIX}-navigation`,
|
|
17
|
+
noResults: `${PREFIX}-no-results`,
|
|
18
|
+
title: `${PREFIX}-title`
|
|
15
19
|
};
|
|
16
20
|
const Root = styled(Box, {
|
|
17
21
|
name: PREFIX,
|
|
@@ -29,8 +33,26 @@ export default function DefaultDrawerContent(inProps) {
|
|
|
29
33
|
const [categoriesOrdered, setCategoriesOrdered] = useState([]);
|
|
30
34
|
// ROUTING
|
|
31
35
|
const scRoutingContext = useSCRouting();
|
|
36
|
+
// CONTEXT
|
|
37
|
+
const scUserContext = useSCUser();
|
|
38
|
+
// PREFERENCES
|
|
39
|
+
const { preferences, features } = useSCPreferences();
|
|
32
40
|
//STATE
|
|
33
41
|
const [isHovered, setIsHovered] = useState({});
|
|
42
|
+
// MEMO
|
|
43
|
+
const groupsEnabled = useMemo(() => preferences &&
|
|
44
|
+
features &&
|
|
45
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
46
|
+
features.includes(SCFeatureName.GROUPING) &&
|
|
47
|
+
SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
|
|
48
|
+
preferences[SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
|
|
49
|
+
const eventsEnabled = useMemo(() => preferences &&
|
|
50
|
+
features &&
|
|
51
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
52
|
+
SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
53
|
+
preferences[SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
54
|
+
const exploreStreamEnabled = preferences[SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value;
|
|
55
|
+
const contentAvailable = preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value;
|
|
34
56
|
// HANDLERS
|
|
35
57
|
const handleMouseEnter = (index) => {
|
|
36
58
|
setIsHovered((prevState) => {
|
|
@@ -53,5 +75,5 @@ export default function DefaultDrawerContent(inProps) {
|
|
|
53
75
|
onTouchMove: mouseLeave
|
|
54
76
|
});
|
|
55
77
|
//order
|
|
56
|
-
return (_jsxs(Root, Object.assign({ className: classNames(className, classes.root) }, rest, { children: [_jsxs(
|
|
78
|
+
return (_jsxs(Root, Object.assign({ className: classNames(className, classes.root) }, rest, { children: [_jsxs(List, Object.assign({ className: classes.navigation }, { children: [_jsx(ListItem, Object.assign({ disablePadding: true }, { children: _jsxs(ListItemButton, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.HOME_ROUTE_NAME, {}) }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "home" }) }), _jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.navigationMenuIconButton.defaultDrawerContent.navigation.home", defaultMessage: "ui.navigationMenuIconButton.defaultDrawerContent.navigation.home" }) })] })) })), groupsEnabled && scUserContext.user && (_jsx(ListItem, Object.assign({ disablePadding: true }, { children: _jsxs(ListItemButton, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.GROUPS_ROUTE_NAME, {}) }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "groups" }) }), _jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.navigationMenuIconButton.defaultDrawerContent.navigation.groups", defaultMessage: "ui.navigationMenuIconButton.defaultDrawerContent.navigation.groups" }) })] })) }))), eventsEnabled && (scUserContext.user || contentAvailable) && (_jsx(ListItem, Object.assign({ disablePadding: true }, { children: _jsxs(ListItemButton, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.EVENTS_ROUTE_NAME, {}) }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "CalendarIcon" }) }), _jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.navigationMenuIconButton.defaultDrawerContent.navigation.events", defaultMessage: "ui.navigationMenuIconButton.defaultDrawerContent.navigation.events" }) })] })) }))), exploreStreamEnabled && (contentAvailable || scUserContext.user) && (_jsx(ListItem, Object.assign({ disablePadding: true }, { children: _jsxs(ListItemButton, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.EXPLORE_ROUTE_NAME, {}) }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "explore" }) }), _jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.navigationMenuIconButton.defaultDrawerContent.navigation.explore", defaultMessage: "ui.navigationMenuIconButton.defaultDrawerContent.navigation.explore" }) })] })) })))] })), _jsx(Divider, {}), _jsx(Typography, Object.assign({ variant: "subtitle1", className: classes.title }, { children: _jsx(FormattedMessage, { id: "ui.navigationMenuIconButton.defaultDrawerContent.category.title", defaultMessage: "ui.navigationMenuIconButton.defaultDrawerContent.category.title" }) })), !categoriesOrdered.length && (_jsx(Typography, Object.assign({ variant: "body1", className: classes.noResults }, { children: _jsx(FormattedMessage, { id: "ui.navigationMenuIconButton.defaultDrawerContent.category.noResults", defaultMessage: "ui.navigationMenuIconButton.defaultDrawerContent.category.noResults" }) }))), categoriesOrdered.map((c, index) => (_jsx(Zoom, Object.assign({ in: true, style: { transform: isHovered[c.id] && 'scale(1.05)' } }, { children: _jsx(ListItem, { children: _jsx(Category, Object.assign({ ButtonBaseProps: { component: Link, to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, c) }, elevation: 0, category: c, actions: null }, CategoryItemProps, getMouseEvents(() => handleMouseEnter(c.id), () => handleMouseLeave(c.id)))) }, c.id) }), index)))] })));
|
|
57
79
|
}
|
|
@@ -144,7 +144,7 @@ export default function NavigationToolbar(inProps) {
|
|
|
144
144
|
value.startsWith(scRoutingContext.url(SCRoutes.GROUPS_ROUTE_NAME, {}))
|
|
145
145
|
}), "aria-label": "Groups", to: scRoutingContext.url(SCRoutes.GROUPS_SUBSCRIBED_ROUTE_NAME, {}), component: Link }, { children: _jsx(Icon, { children: "groups" }) }))), eventsEnabled && (scUserContext.user || preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY]) && (_jsx(IconButton, Object.assign({ className: classNames(classes.events, {
|
|
146
146
|
[classes.active]: value.startsWith(scRoutingContext.url(SCRoutes.EVENTS_ROUTE_NAME, {}))
|
|
147
|
-
}), "aria-label": "
|
|
147
|
+
}), "aria-label": "Events", to: scRoutingContext.url(SCRoutes.EVENTS_ROUTE_NAME, {}), component: Link }, { children: _jsx(Icon, { children: "CalendarIcon" }) })))] })));
|
|
148
148
|
return (_jsxs(Root, Object.assign({ className: classNames(className, classes.root) }, rest, { children: [_jsx(NavigationMenuIconButtonComponent, Object.assign({}, NavigationMenuIconButtonComponentProps)), _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.HOME_ROUTE_NAME, {}), className: classes.logo }, { children: _jsx("img", { src: preferences[SCPreferences.LOGO_NAVBAR_LOGO], alt: "logo" }) })), !scUserContext.user && !preferences[SCPreferences.ADDONS_CLOSED_COMMUNITY] && (_jsx(Button, Object.assign({ color: "inherit", component: Link, to: scRoutingContext.url(SCRoutes.SIGNUP_ROUTE_NAME, {}), className: classes.register }, { children: _jsx(FormattedMessage, { id: "ui.appBar.navigation.register", defaultMessage: "ui.appBar.navigation.register" }) }))), preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_ENABLED] && (_jsx(_Fragment, { children: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT] ? (_jsx(Tooltip, Object.assign({ title: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT] }, { children: _jsx(Link, Object.assign({ target: "blank", to: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL], className: classes.customItem }, { children: _jsx("img", { src: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE], alt: "custom_item" }) })) }))) : (_jsx(Link, Object.assign({ target: "blank", to: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL], className: classes.customItem }, { children: _jsx("img", { src: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE], alt: "custom_item" }) }))) })), _children, (preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY] || scUserContext.user) && !disableSearch ? (_jsx(SearchAutocomplete, Object.assign({ className: classes.search, blurOnSelect: true }, SearchAutocompleteProps))) : (_jsx(Box, { className: classes.search })), startActions, scUserContext.user ? (_jsxs(_Fragment, { children: [showComposer && _jsx(ComposerIconButton, Object.assign({ className: classes.composer }, ComposerIconButtonProps)), _jsx(Tooltip, Object.assign({ title: scUserContext.user.username }, { children: _jsx(IconButton, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, scUserContext.user), "aria-label": "Profile", className: classes.profile }, { children: _jsx(Avatar, { alt: scUserContext.user.username, src: scUserContext.user.avatar }) })) })), _jsxs(_Fragment, { children: [_jsx(IconButton, Object.assign({ className: classNames(classes.notification, {
|
|
149
149
|
[classes.active]: value.startsWith(scRoutingContext.url(SCRoutes.USER_NOTIFICATIONS_ROUTE_NAME, {}))
|
|
150
150
|
}), "aria-label": "Notification", onClick: handleOpenNotificationMenu }, { children: _jsx(Badge, Object.assign({ badgeContent: scUserContext.user.unseen_notification_banners_counter + scUserContext.user.unseen_interactions_counter, color: "secondary" }, { children: _jsx(Icon, { children: "notifications_active" }) })) })), _jsx(NotificationMenu, Object.assign({ className: classes.notificationsMenu, id: "notification-menu", anchorEl: anchorNotification, open: Boolean(anchorNotification), onClose: handleCloseNotificationMenu, onClick: handleCloseNotificationMenu, transformOrigin: { horizontal: 'right', vertical: 'top' }, anchorOrigin: { horizontal: 'right', vertical: 'bottom' } }, NotificationMenuProps))] }), privateMessagingEnabled && (_jsx(IconButton, Object.assign({ className: classNames(classes.messages, {
|
|
@@ -65,10 +65,10 @@ export default function CommentNotification(props) {
|
|
|
65
65
|
}), { onClick: notificationObject.comment.author.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !notificationObject.comment.author.community_badge, smaller: true }, { children: _jsx(Avatar, { alt: notificationObject.comment.author.username, variant: "circular", src: notificationObject.comment.author.avatar, classes: { root: classes.avatar } }) })) })), primary: _jsxs(_Fragment, { children: [_jsx(Link, Object.assign({}, (!notificationObject.comment.author.deleted && {
|
|
66
66
|
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.comment.author)
|
|
67
67
|
}), { onClick: notificationObject.comment.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.comment.author.username })), ' ', notificationObject.type === SCNotificationTypologyType.NESTED_COMMENT
|
|
68
|
-
? intl.formatMessage(messages.
|
|
68
|
+
? intl.formatMessage(messages.nestedComment, {
|
|
69
69
|
b: (...chunks) => _jsx("strong", { children: chunks })
|
|
70
70
|
})
|
|
71
|
-
: intl.formatMessage(messages.
|
|
71
|
+
: intl.formatMessage(messages.comment, {
|
|
72
72
|
b: (...chunks) => _jsx("strong", { children: chunks })
|
|
73
73
|
})] }), secondary: _jsxs(React.Fragment, { children: [_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.COMMENT_ROUTE_NAME, getRouteData(notificationObject.comment)) }, { children: _jsx(Typography, Object.assign({ variant: "body2", className: classes.contributionText }, { children: getContributionSnippet(notificationObject.comment) })) })), (template === SCNotificationObjectTemplateType.DETAIL || template === SCNotificationObjectTemplateType.SNIPPET) && (_jsxs(Stack, Object.assign({ direction: "row", justifyContent: "flex-start", alignItems: "center", spacing: 1 }, { children: [_jsx(DateTimeAgo, { date: notificationObject.active_at, className: classes.activeAt }), _jsx(Bullet, { className: classes.bullet }), _jsx(VoteButton, { className: classes.voteButton, variant: "text", size: "small", contributionId: notificationObject.comment.id, contributionType: SCContributionType.COMMENT, contribution: notificationObject.comment, onVote: handleVote })] })))] }), footer: template === SCNotificationObjectTemplateType.TOAST && (_jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [_jsx(DateTimeAgo, { date: notificationObject.active_at }), _jsx(Typography, Object.assign({ color: "primary", component: 'div' }, { children: _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.COMMENT_ROUTE_NAME, getRouteData(notificationObject.comment)) }, { children: _jsx(FormattedMessage, { id: "ui.userToastNotifications.viewContribution", defaultMessage: 'ui.userToastNotifications.viewContribution' }) })) }))] }))) }, rest)), openAlert && _jsx(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })] }));
|
|
74
74
|
}
|
|
@@ -224,7 +224,7 @@ export default function UserNotification(inProps) {
|
|
|
224
224
|
notificationObject.aggregated[0].type === SCNotificationTypologyType.VOTE_UP ||
|
|
225
225
|
notificationObject.aggregated[0].type === SCNotificationTypologyType.CONTRIBUTION)) {
|
|
226
226
|
const contribution = getContribution(notificationObject);
|
|
227
|
-
return (_jsx(CardHeader, { className: classes.header, titleTypographyProps: { className: classes.title, variant: 'subtitle1' }, title: _jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(contribution), getRouteData(notificationObject[contribution.type])) }, { children: getContributionSnippet(contribution) })), action: contribution && (_jsx(Tooltip, Object.assign({ title: contribution.suspended ? (_jsx(FormattedMessage, { id: 'ui.notification.notificationSuspended', defaultMessage: 'ui.notification.notificationSuspended' })) : (_jsx(FormattedMessage, { id: 'ui.notification.notificationSuspend', defaultMessage: 'ui.notification.notificationSuspend' })) }, { children: _jsx(LoadingButton, Object.assign({ variant: "text", size: "small", loading: loadingSuspendNotification, color: 'inherit', classes: { root: classes.stopButton }, onClick: () => handleStopContentNotification(contribution) }, { children: contribution.suspended ? _jsx(Icon, Object.assign({ color: 'primary' }, { children: "notifications_off" })) : _jsx(Icon, Object.assign({ color: 'inherit' }, { children: "
|
|
227
|
+
return (_jsx(CardHeader, { className: classes.header, titleTypographyProps: { className: classes.title, variant: 'subtitle1' }, title: _jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(contribution), getRouteData(notificationObject[contribution.type])) }, { children: getContributionSnippet(contribution) })), action: contribution && (_jsx(Tooltip, Object.assign({ title: contribution.suspended ? (_jsx(FormattedMessage, { id: 'ui.notification.notificationSuspended', defaultMessage: 'ui.notification.notificationSuspended' })) : (_jsx(FormattedMessage, { id: 'ui.notification.notificationSuspend', defaultMessage: 'ui.notification.notificationSuspend' })) }, { children: _jsx(LoadingButton, Object.assign({ variant: "text", size: "small", loading: loadingSuspendNotification, color: 'inherit', classes: { root: classes.stopButton }, onClick: () => handleStopContentNotification(contribution) }, { children: contribution.suspended ? _jsx(Icon, Object.assign({ color: 'primary' }, { children: "notifications_off" })) : _jsx(Icon, Object.assign({ color: 'inherit' }, { children: "notifications_active" })) })) }))) }));
|
|
228
228
|
}
|
|
229
229
|
return null;
|
|
230
230
|
}
|
|
@@ -175,12 +175,9 @@ export default function PrivateMessageThread(inProps) {
|
|
|
175
175
|
* Memoized message recipients ids
|
|
176
176
|
*/
|
|
177
177
|
const ids = useMemo(() => {
|
|
178
|
-
if (recipients
|
|
179
|
-
return
|
|
180
|
-
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
return [parseInt(recipients === null || recipients === void 0 ? void 0 : recipients.id, 10) || recipients];
|
|
178
|
+
if (!recipients)
|
|
179
|
+
return [];
|
|
180
|
+
return Array.isArray(recipients) ? recipients.map((u) => parseInt(u.id, 10)) : [parseInt(recipients.id || recipients, 10)];
|
|
184
181
|
}, [recipients, openNewMessage]);
|
|
185
182
|
function fetchResults() {
|
|
186
183
|
setLoading(true);
|
|
@@ -67,5 +67,5 @@ export default function UserProfileEdit(inProps) {
|
|
|
67
67
|
setTab(newValue);
|
|
68
68
|
};
|
|
69
69
|
// RENDER
|
|
70
|
-
return (_jsxs(Root, Object.assign({
|
|
70
|
+
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: [_jsxs(Tabs, Object.assign({ className: classes.tabs, value: tab, onChange: handleChange, variant: "scrollable", scrollButtons: "auto", allowScrollButtonsMobile: true }, { children: [_jsx(Tab, { label: _jsx(FormattedMessage, { id: "ui.userProfileEdit.info", defaultMessage: "ui.userProfileEdit.info" }) }), _jsx(Tab, { label: _jsx(FormattedMessage, { id: "ui.userProfileEdit.account", defaultMessage: "ui.userProfileEdit.account" }) }), _jsx(Tab, { label: _jsx(FormattedMessage, { id: "ui.userProfileEdit.notification", defaultMessage: "ui.userProfileEdit.notification" }) })] })), _jsxs(Box, Object.assign({ className: classes.tabContent }, { children: [tab === 0 && _jsx(PublicInfo, Object.assign({ className: classes.publicInfo, fields: fields }, UserProfileEditSectionPublicInfoProps)), tab === 1 && _jsx(Account, Object.assign({ className: classes.account }, UserProfileEditSectionAccountProps)), tab === 2 && _jsx(Settings, Object.assign({ settings: settings, className: classes.settings }, UserProfileEditSectionSettingsProps))] }))] })));
|
|
71
71
|
}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import { jsxs as _jsxs,
|
|
3
|
-
import
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useMemo } from 'react';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
|
-
import {
|
|
5
|
+
import { Button, Paper, Stack, Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from '@mui/material';
|
|
6
6
|
import { defineMessages, useIntl } from 'react-intl';
|
|
7
7
|
import { SCPreferences, useSCFetchUser, useSCFetchUserProviders, useSCPreferences } from '@selfcommunity/react-core';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import { useThemeProps } from '@mui/system';
|
|
10
|
-
import Icon from '@mui/material/Icon';
|
|
11
10
|
import { SCUserSocialAssociations } from '../../types';
|
|
11
|
+
import { PROVIDER_ICONS_CONTAINED } from '../../constants/SocialShare';
|
|
12
12
|
const messages = defineMessages({
|
|
13
|
+
provider: {
|
|
14
|
+
id: 'ui.userSocialAssociation.provider',
|
|
15
|
+
defaultMessage: 'ui.userSocialAssociation.provider'
|
|
16
|
+
},
|
|
17
|
+
actions: {
|
|
18
|
+
id: 'ui.userSocialAssociation.actions',
|
|
19
|
+
defaultMessage: 'ui.userSocialAssociation.actions'
|
|
20
|
+
},
|
|
13
21
|
socialAdd: {
|
|
14
22
|
id: 'ui.userSocialAssociation.add',
|
|
15
23
|
defaultMessage: 'ui.userSocialAssociation.add'
|
|
@@ -22,7 +30,11 @@ const messages = defineMessages({
|
|
|
22
30
|
const PREFIX = 'SCUserSocialAssociation';
|
|
23
31
|
const classes = {
|
|
24
32
|
root: `${PREFIX}-root`,
|
|
25
|
-
field: `${PREFIX}-field
|
|
33
|
+
field: `${PREFIX}-field`,
|
|
34
|
+
providerTable: `${PREFIX}-provider-table`,
|
|
35
|
+
providerIcon: `${PREFIX}-provider-icon`,
|
|
36
|
+
providerName: `${PREFIX}-provider-name`,
|
|
37
|
+
providerAction: `${PREFIX}-provider-action`
|
|
26
38
|
};
|
|
27
39
|
const Root = styled(Stack, {
|
|
28
40
|
name: PREFIX,
|
|
@@ -101,5 +113,5 @@ export default function UserSocialAssociation(inProps) {
|
|
|
101
113
|
if (!providersEnabled) {
|
|
102
114
|
return null;
|
|
103
115
|
}
|
|
104
|
-
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { direction: "column" }, { children: [providersLinked.length !== 0 || (providersToLink.length !== 0 && onCreateAssociation) ? children : null,
|
|
116
|
+
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { direction: "column" }, { children: [providersLinked.length !== 0 || (providersToLink.length !== 0 && onCreateAssociation) ? children : null, _jsx(TableContainer, Object.assign({ component: Paper, className: classes.providerTable }, { children: _jsxs(Table, { children: [_jsx(TableHead, { children: _jsxs(TableRow, { children: [_jsx(TableCell, Object.assign({ sx: { width: '60%' } }, { children: intl.formatMessage(messages.provider) })), _jsx(TableCell, Object.assign({ align: "left" }, { children: intl.formatMessage(messages.actions) }))] }) }), _jsxs(TableBody, { children: [providersToLink.length !== 0 && onCreateAssociation && (_jsx(_Fragment, { children: providersToLink.map((p, index) => (_jsxs(TableRow, { children: [_jsxs(TableCell, Object.assign({ scope: "row" }, { children: [_jsx("img", { src: PROVIDER_ICONS_CONTAINED[`${p}`], width: "30", height: "30", className: classes.providerIcon, alt: p }), _jsx("span", Object.assign({ className: classes.providerName }, { children: p }))] })), _jsx(TableCell, Object.assign({ align: "left" }, { children: _jsx(Button, Object.assign({ variant: "contained", className: classes.providerAction, color: "primary", onClick: onCreateAssociation ? () => onCreateAssociation(p) : null, size: "small" }, { children: intl.formatMessage(messages.socialAdd) })) }))] }, index))) })), providersLinked.length !== 0 && (_jsx(_Fragment, { children: providersLinked.map((p, index) => (_jsxs(TableRow, Object.assign({ sx: { '&:last-child td, &:last-child th': { border: 0 } } }, { children: [_jsxs(TableCell, Object.assign({ scope: "row" }, { children: [_jsx("img", { src: PROVIDER_ICONS_CONTAINED[`${p.provider}`], width: "30", height: "30", className: classes.providerIcon, alt: p.provider }), _jsx("span", Object.assign({ className: classes.providerName }, { children: p.provider }))] })), _jsx(TableCell, Object.assign({ align: "left" }, { children: _jsx(Button, Object.assign({ variant: "outlined", className: classes.providerAction, onClick: () => onDeleteAssociation(p), size: "small" }, { children: intl.formatMessage(messages.socialRemove) })) }))] }), index))) }))] })] }) }))] })));
|
|
105
117
|
}
|