@selfcommunity/react-ui 0.7.50-events.38 → 0.7.50-events.40
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/BottomNavigation/BottomNavigation.js +14 -5
- package/lib/cjs/components/CreateEventButton/CreateEventButton.js +6 -7
- package/lib/cjs/components/EditEventButton/EditEventButton.d.ts +43 -0
- package/lib/cjs/components/EditEventButton/EditEventButton.js +61 -0
- package/lib/cjs/components/EditEventButton/index.d.ts +3 -0
- package/lib/cjs/components/EditEventButton/index.js +5 -0
- package/lib/cjs/components/EventForm/EventAddress.d.ts +2 -1
- package/lib/cjs/components/EventForm/EventAddress.js +4 -4
- package/lib/cjs/components/EventForm/EventForm.d.ts +6 -0
- package/lib/cjs/components/EventForm/EventForm.js +51 -25
- package/lib/cjs/components/EventForm/UploadEventCover.d.ts +10 -0
- package/lib/cjs/components/EventForm/UploadEventCover.js +34 -7
- package/lib/cjs/components/EventHeader/EventHeader.d.ts +67 -0
- package/lib/cjs/components/EventHeader/EventHeader.js +175 -0
- package/lib/cjs/components/EventHeader/Skeleton.d.ts +25 -0
- package/lib/cjs/components/EventHeader/Skeleton.js +56 -0
- package/lib/cjs/components/EventHeader/constants.d.ts +1 -0
- package/lib/cjs/components/EventHeader/constants.js +4 -0
- package/lib/cjs/components/EventHeader/index.d.ts +4 -0
- package/lib/cjs/components/EventHeader/index.js +8 -0
- package/lib/cjs/components/EventInfoWidget/EventInfoWidget.d.ts +24 -0
- package/lib/cjs/components/EventInfoWidget/EventInfoWidget.js +74 -0
- package/lib/cjs/components/EventInfoWidget/constants.d.ts +1 -0
- package/lib/cjs/components/EventInfoWidget/constants.js +4 -0
- package/lib/cjs/components/EventInfoWidget/index.d.ts +3 -0
- package/lib/cjs/components/EventInfoWidget/index.js +6 -0
- package/lib/cjs/components/EventInviteButton/EventInviteButton.js +11 -11
- package/lib/cjs/components/EventLocationWidget/EventLocationWidget.js +1 -0
- package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.d.ts +56 -0
- package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.js +193 -0
- package/lib/cjs/components/EventSubscribeButton/index.d.ts +3 -0
- package/lib/cjs/components/EventSubscribeButton/index.js +5 -0
- package/lib/cjs/components/Events/Events.js +12 -11
- package/lib/cjs/components/FeedObject/FeedObject.js +1 -1
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.d.ts +2 -0
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +9 -1
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +12 -2
- package/lib/cjs/components/User/User.d.ts +2 -1
- package/lib/cjs/components/User/User.js +9 -9
- package/lib/cjs/constants/PubSub.d.ts +5 -1
- package/lib/cjs/index.d.ts +104 -100
- package/lib/cjs/index.js +270 -260
- package/lib/cjs/shared/Bullet/index.js +1 -2
- package/lib/cjs/shared/Calendar/index.d.ts +1 -2
- package/lib/cjs/shared/Calendar/index.js +3 -5
- package/lib/cjs/shared/EventInfoDetails/index.d.ts +6 -0
- package/lib/cjs/shared/EventInfoDetails/index.js +67 -0
- package/lib/esm/components/BottomNavigation/BottomNavigation.js +14 -5
- package/lib/esm/components/CreateEventButton/CreateEventButton.js +6 -7
- package/lib/esm/components/EditEventButton/EditEventButton.d.ts +43 -0
- package/lib/esm/components/EditEventButton/EditEventButton.js +58 -0
- package/lib/esm/components/EditEventButton/index.d.ts +3 -0
- package/lib/esm/components/EditEventButton/index.js +2 -0
- package/lib/esm/components/EventForm/EventAddress.d.ts +2 -1
- package/lib/esm/components/EventForm/EventAddress.js +4 -4
- package/lib/esm/components/EventForm/EventForm.d.ts +6 -0
- package/lib/esm/components/EventForm/EventForm.js +51 -25
- package/lib/esm/components/EventForm/UploadEventCover.d.ts +10 -0
- package/lib/esm/components/EventForm/UploadEventCover.js +34 -7
- package/lib/esm/components/EventHeader/EventHeader.d.ts +67 -0
- package/lib/esm/components/EventHeader/EventHeader.js +172 -0
- package/lib/esm/components/EventHeader/Skeleton.d.ts +25 -0
- package/lib/esm/components/EventHeader/Skeleton.js +53 -0
- package/lib/esm/components/EventHeader/constants.d.ts +1 -0
- package/lib/esm/components/EventHeader/constants.js +1 -0
- package/lib/esm/components/EventHeader/index.d.ts +4 -0
- package/lib/esm/components/EventHeader/index.js +4 -0
- package/lib/esm/components/EventInfoWidget/EventInfoWidget.d.ts +24 -0
- package/lib/esm/components/EventInfoWidget/EventInfoWidget.js +71 -0
- package/lib/esm/components/EventInfoWidget/constants.d.ts +1 -0
- package/lib/esm/components/EventInfoWidget/constants.js +1 -0
- package/lib/esm/components/EventInfoWidget/index.d.ts +3 -0
- package/lib/esm/components/EventInfoWidget/index.js +3 -0
- package/lib/esm/components/EventInviteButton/EventInviteButton.js +11 -11
- package/lib/esm/components/EventLocationWidget/EventLocationWidget.js +1 -0
- package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.d.ts +56 -0
- package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.js +190 -0
- package/lib/esm/components/EventSubscribeButton/index.d.ts +3 -0
- package/lib/esm/components/EventSubscribeButton/index.js +2 -0
- package/lib/esm/components/Events/Events.js +12 -11
- package/lib/esm/components/FeedObject/FeedObject.js +1 -1
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.d.ts +2 -0
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +9 -1
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +13 -3
- package/lib/esm/components/User/User.d.ts +2 -1
- package/lib/esm/components/User/User.js +9 -9
- package/lib/esm/constants/PubSub.d.ts +5 -1
- package/lib/esm/index.d.ts +104 -100
- package/lib/esm/index.js +109 -105
- package/lib/esm/shared/Bullet/index.js +0 -1
- package/lib/esm/shared/Calendar/index.d.ts +1 -2
- package/lib/esm/shared/Calendar/index.js +0 -1
- package/lib/esm/shared/EventInfoDetails/index.d.ts +6 -0
- package/lib/esm/shared/EventInfoDetails/index.js +64 -0
- package/lib/umd/84.js +2 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +8 -7
- package/lib/umd/204.js +0 -2
- /package/lib/umd/{204.js.LICENSE.txt → 84.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
import { CacheStrategies, Logger } from '@selfcommunity/utils';
|
|
5
|
+
import { useSCContext, useSCFetchEvent, useSCUser } from '@selfcommunity/react-core';
|
|
6
|
+
import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
|
|
7
|
+
import { FormattedMessage } from 'react-intl';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import { useThemeProps } from '@mui/system';
|
|
10
|
+
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
11
|
+
import { Box, Button, Checkbox, Icon, Menu, MenuItem, SwipeableDrawer, useMediaQuery, useTheme } from '@mui/material';
|
|
12
|
+
import { LoadingButton } from '@mui/lab';
|
|
13
|
+
const PREFIX = 'SCEventSubscribeButton';
|
|
14
|
+
const classes = {
|
|
15
|
+
requestRoot: `${PREFIX}-request-root`,
|
|
16
|
+
selectRoot: `${PREFIX}-select-root`,
|
|
17
|
+
drawerRoot: `${PREFIX}-drawer-root`,
|
|
18
|
+
menuRoot: `${PREFIX}-menu-root`,
|
|
19
|
+
paper: `${PREFIX}-paper`,
|
|
20
|
+
item: `${PREFIX}-item`,
|
|
21
|
+
going: `${PREFIX}-going`,
|
|
22
|
+
notGoing: `${PREFIX}-not-going`
|
|
23
|
+
};
|
|
24
|
+
const options = [
|
|
25
|
+
{
|
|
26
|
+
value: SCEventSubscriptionStatusType.GOING,
|
|
27
|
+
label: React.createElement(FormattedMessage, { id: "ui.eventSubscribeButton.going", defaultMessage: "ui.eventSubscribeButton.going" })
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
value: SCEventSubscriptionStatusType.NOT_GOING,
|
|
31
|
+
label: React.createElement(FormattedMessage, { id: "ui.eventSubscribeButton.notGoing", defaultMessage: "ui.eventSubscribeButton.notGoing" })
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
const RequestRoot = styled(LoadingButton, {
|
|
35
|
+
name: PREFIX,
|
|
36
|
+
slot: 'RequestRoot'
|
|
37
|
+
})(() => ({}));
|
|
38
|
+
const SelectRoot = styled(Button, {
|
|
39
|
+
name: PREFIX,
|
|
40
|
+
slot: 'SelectRoot'
|
|
41
|
+
})(() => ({}));
|
|
42
|
+
const SwipeableDrawerRoot = styled(SwipeableDrawer, {
|
|
43
|
+
name: PREFIX,
|
|
44
|
+
slot: 'DrawerRoot'
|
|
45
|
+
})(() => ({}));
|
|
46
|
+
const MenuRoot = styled(Menu, {
|
|
47
|
+
name: PREFIX,
|
|
48
|
+
slot: 'MenuRoot'
|
|
49
|
+
})(() => ({}));
|
|
50
|
+
/**
|
|
51
|
+
* > API documentation for the Community-JS Event Subscribe Button component. Learn about the available props and the CSS API.
|
|
52
|
+
|
|
53
|
+
#### Import
|
|
54
|
+
|
|
55
|
+
```jsx
|
|
56
|
+
import {EventSubscribeButton} from '@selfcommunity/react-ui';
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
#### Component Name
|
|
60
|
+
|
|
61
|
+
The name `SCEventSubscribeButton` can be used when providing style overrides in the theme.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
#### CSS
|
|
65
|
+
|
|
66
|
+
|Rule Name|Global class|Description|
|
|
67
|
+
|---|---|---|
|
|
68
|
+
|root|.SCEventSubscribeButton-root|Styles applied to the root element.|
|
|
69
|
+
|
|
70
|
+
* @param inProps
|
|
71
|
+
*/
|
|
72
|
+
export default function EventSubscribeButton(inProps) {
|
|
73
|
+
var _a;
|
|
74
|
+
// PROPS
|
|
75
|
+
const props = useThemeProps({
|
|
76
|
+
props: inProps,
|
|
77
|
+
name: PREFIX
|
|
78
|
+
});
|
|
79
|
+
const { className, eventId, event, user, onSubscribe } = props, rest = __rest(props, ["className", "eventId", "event", "user", "onSubscribe"]);
|
|
80
|
+
// STATE
|
|
81
|
+
const [status, setStatus] = useState(null);
|
|
82
|
+
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
83
|
+
const open = Boolean(anchorEl);
|
|
84
|
+
// CONTEXT
|
|
85
|
+
const scContext = useSCContext();
|
|
86
|
+
const scUserContext = useSCUser();
|
|
87
|
+
const scEventsManager = scUserContext.managers.events;
|
|
88
|
+
const theme = useTheme();
|
|
89
|
+
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
90
|
+
// CONST
|
|
91
|
+
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
92
|
+
const { scEvent } = useSCFetchEvent({
|
|
93
|
+
id: eventId,
|
|
94
|
+
event,
|
|
95
|
+
cacheStrategy: authUserId ? CacheStrategies.CACHE_FIRST : CacheStrategies.STALE_WHILE_REVALIDATE
|
|
96
|
+
});
|
|
97
|
+
const isEventAdmin = useMemo(() => { var _a; return scUserContext.user && ((_a = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
|
|
98
|
+
// HANDLERS
|
|
99
|
+
const handleOpen = (event) => {
|
|
100
|
+
setAnchorEl(event.currentTarget);
|
|
101
|
+
};
|
|
102
|
+
const handleClose = () => {
|
|
103
|
+
setAnchorEl(null);
|
|
104
|
+
};
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
/**
|
|
107
|
+
* Call scEventsManager.subscriptionStatus inside an effect
|
|
108
|
+
* to avoid warning rendering child during update parent state
|
|
109
|
+
*/
|
|
110
|
+
if (authUserId) {
|
|
111
|
+
setStatus(scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus(scEvent));
|
|
112
|
+
}
|
|
113
|
+
}, [authUserId, scEventsManager === null || scEventsManager === void 0 ? void 0 : scEventsManager.subscriptionStatus, scEvent]);
|
|
114
|
+
const toggleGoingToEvent = (user) => {
|
|
115
|
+
scEventsManager
|
|
116
|
+
.toggleEventAttendance(scEvent, user === null || user === void 0 ? void 0 : user.id)
|
|
117
|
+
.then(() => {
|
|
118
|
+
const _status = scEvent.privacy === SCEventPrivacyType.PRIVATE && scEvent.subscription_status !== SCEventSubscriptionStatusType.INVITED
|
|
119
|
+
? SCEventSubscriptionStatusType.REQUESTED
|
|
120
|
+
: scEvent.subscription_status === SCEventSubscriptionStatusType.GOING
|
|
121
|
+
? SCEventSubscriptionStatusType.SUBSCRIBED
|
|
122
|
+
: SCEventSubscriptionStatusType.GOING;
|
|
123
|
+
onSubscribe && onSubscribe(scEvent, _status);
|
|
124
|
+
})
|
|
125
|
+
.catch((e) => {
|
|
126
|
+
Logger.error(SCOPE_SC_UI, e);
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
const toggleNotGoingToEvent = () => {
|
|
130
|
+
scEventsManager
|
|
131
|
+
.toggleEventNonattendance(scEvent)
|
|
132
|
+
.then(() => {
|
|
133
|
+
const _status = scEvent.subscription_status === SCEventSubscriptionStatusType.NOT_GOING
|
|
134
|
+
? SCEventSubscriptionStatusType.SUBSCRIBED
|
|
135
|
+
: SCEventSubscriptionStatusType.NOT_GOING;
|
|
136
|
+
onSubscribe && onSubscribe(scEvent, _status);
|
|
137
|
+
})
|
|
138
|
+
.catch((e) => {
|
|
139
|
+
Logger.error(SCOPE_SC_UI, e);
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
const handleToggleAction = (event) => {
|
|
143
|
+
const _status = event.target.value;
|
|
144
|
+
setAnchorEl(null);
|
|
145
|
+
if (!scUserContext.user) {
|
|
146
|
+
scContext.settings.handleAnonymousAction();
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
(_status === SCEventSubscriptionStatusType.NOT_GOING && !(user === null || user === void 0 ? void 0 : user.id)) || (!_status && (user === null || user === void 0 ? void 0 : user.id)) ? toggleNotGoingToEvent() : toggleGoingToEvent();
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
function renderMenuItems() {
|
|
153
|
+
return (React.createElement(Box, null, options.map((option) => (React.createElement(MenuItem, { key: option.value, className: classes.item },
|
|
154
|
+
option.label,
|
|
155
|
+
React.createElement(Checkbox, { size: "small", checked: status === option.value, value: option.value, onChange: handleToggleAction, name: `${option.value}-option`, inputProps: { 'aria-label': `${option.label}` } }))))));
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Get current translated status
|
|
159
|
+
*/
|
|
160
|
+
const getStatus = useMemo(() => {
|
|
161
|
+
let _status;
|
|
162
|
+
switch (status) {
|
|
163
|
+
case SCEventSubscriptionStatusType.REQUESTED:
|
|
164
|
+
_status = React.createElement(FormattedMessage, { defaultMessage: "ui.eventSubscribeButton.waitingApproval", id: "ui.eventSubscribeButton.waitingApproval" });
|
|
165
|
+
break;
|
|
166
|
+
case SCEventSubscriptionStatusType.GOING:
|
|
167
|
+
_status = React.createElement(FormattedMessage, { defaultMessage: "ui.eventSubscribeButton.going", id: "ui.eventSubscribeButton.going" });
|
|
168
|
+
break;
|
|
169
|
+
case SCEventSubscriptionStatusType.INVITED:
|
|
170
|
+
_status = React.createElement(FormattedMessage, { defaultMessage: "ui.eventSubscribeButton.accept", id: "ui.eventSubscribeButton.accept" });
|
|
171
|
+
break;
|
|
172
|
+
case SCEventSubscriptionStatusType.NOT_GOING:
|
|
173
|
+
_status = React.createElement(FormattedMessage, { defaultMessage: "ui.eventSubscribeButton.notGoing", id: "ui.eventSubscribeButton.notGoing" });
|
|
174
|
+
break;
|
|
175
|
+
default:
|
|
176
|
+
(scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) === SCEventPrivacyType.PUBLIC
|
|
177
|
+
? (_status = React.createElement(FormattedMessage, { defaultMessage: "ui.eventSubscribeButton.label", id: "ui.eventSubscribeButton.label" }))
|
|
178
|
+
: (_status = (React.createElement(FormattedMessage, { defaultMessage: "ui.eventSubscribeButton.requestParticipation", id: "ui.eventSubscribeButton.requestParticipation" })));
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
return _status;
|
|
182
|
+
}, [status, scEvent]);
|
|
183
|
+
if (!scEvent || (isEventAdmin && (user === null || user === void 0 ? void 0 : user.id) === scUserContext.user.id) || (isEventAdmin && !(user === null || user === void 0 ? void 0 : user.id))) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
return (React.createElement(React.Fragment, null, (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) !== SCEventPrivacyType.PRIVATE ? (React.createElement(React.Fragment, null,
|
|
187
|
+
React.createElement(SelectRoot, Object.assign({ className: classNames(classes.selectRoot, className, { [classes.going]: status && status === SCEventSubscriptionStatusType.GOING }, { [classes.notGoing]: status && status === SCEventSubscriptionStatusType.NOT_GOING }), onClick: handleOpen, endIcon: React.createElement(Icon, null, open ? 'expand_less' : 'expand_more'), startIcon: status &&
|
|
188
|
+
status !== SCEventSubscriptionStatusType.SUBSCRIBED && (React.createElement(Icon, null, status === SCEventSubscriptionStatusType.GOING ? 'circle_checked' : 'circle_closed')) }, rest), getStatus),
|
|
189
|
+
isMobile ? (React.createElement(SwipeableDrawerRoot, { className: classes.drawerRoot, PaperProps: { className: classes.paper }, open: open, onClose: handleClose, onOpen: handleOpen, anchor: "bottom", disableSwipeToOpen: true }, renderMenuItems())) : (React.createElement(MenuRoot, { className: classes.menuRoot, anchorEl: anchorEl, open: open, onClose: handleClose }, renderMenuItems())))) : (React.createElement(RequestRoot, Object.assign({ className: classNames(classes.requestRoot, className), variant: "outlined", size: "small", loading: scUserContext.user ? scEventsManager.isLoading(scEvent) : null, disabled: status === SCEventSubscriptionStatusType.REQUESTED }, rest), getStatus))));
|
|
190
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
3
|
-
import { styled } from '@mui/material/styles';
|
|
4
2
|
import { Box, Button, Chip, FormControl, Grid, Icon, InputLabel, MenuItem, Radio, Select, TextField, Typography } from '@mui/material';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
import { useThemeProps } from '@mui/system';
|
|
5
5
|
import { Endpoints, EventService, http } from '@selfcommunity/api-services';
|
|
6
6
|
import { SCPreferences, SCPreferencesContext, SCUserContext, UserUtils } from '@selfcommunity/react-core';
|
|
7
7
|
import { SCEventDateFilterType } from '@selfcommunity/types';
|
|
8
|
-
import
|
|
9
|
-
import { FormattedMessage } from 'react-intl';
|
|
8
|
+
import { Logger, sortByAttr } from '@selfcommunity/utils';
|
|
10
9
|
import classNames from 'classnames';
|
|
11
|
-
import {
|
|
10
|
+
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
11
|
+
import { FormattedMessage } from 'react-intl';
|
|
12
12
|
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
13
|
-
import { Logger, sortByAttr } from '@selfcommunity/utils';
|
|
14
|
-
import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
|
|
15
|
-
import { PREFIX } from './constants';
|
|
16
|
-
import Skeleton from '../Events/Skeleton';
|
|
17
13
|
import { DEFAULT_PAGINATION_OFFSET } from '../../constants/Pagination';
|
|
14
|
+
import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
|
|
18
15
|
import CreateEventButton from '../CreateEventButton';
|
|
16
|
+
import Event, { EventSkeleton } from '../Event';
|
|
17
|
+
import Skeleton from '../Events/Skeleton';
|
|
18
|
+
import { PREFIX } from './constants';
|
|
19
19
|
const classes = {
|
|
20
20
|
root: `${PREFIX}-root`,
|
|
21
21
|
filters: `${PREFIX}-filters`,
|
|
@@ -74,7 +74,7 @@ export default function Events(inProps) {
|
|
|
74
74
|
props: inProps,
|
|
75
75
|
name: PREFIX
|
|
76
76
|
});
|
|
77
|
-
const { endpointQueryParams = { limit: 8, offset: DEFAULT_PAGINATION_OFFSET }, className, EventComponentProps = {}, showFilters = false, filters, general =
|
|
77
|
+
const { endpointQueryParams = { limit: 8, offset: DEFAULT_PAGINATION_OFFSET }, className, EventComponentProps = {}, showFilters = false, filters, general = false } = props, rest = __rest(props, ["endpointQueryParams", "className", "EventComponentProps", "showFilters", "filters", "general"]);
|
|
78
78
|
// STATE
|
|
79
79
|
const [events, setEvents] = useState([]);
|
|
80
80
|
const [loading, setLoading] = useState(true);
|
|
@@ -211,7 +211,8 @@ export default function Events(inProps) {
|
|
|
211
211
|
filteredEvents.map((event) => (React.createElement(Grid, { item: true, xs: 12, sm: 8, md: 6, key: event.id, className: classes.item },
|
|
212
212
|
React.createElement(Event, Object.assign({ event: event, eventId: event.id }, EventComponentProps))))),
|
|
213
213
|
filteredEvents.length <= 3 && (React.createElement(Grid, { item: true, xs: 12, sm: 8, md: 6, key: 'skeleton-item', className: classes.itemSkeleton },
|
|
214
|
-
React.createElement(EventSkeleton, { action: React.createElement(CreateEventButton,
|
|
214
|
+
React.createElement(EventSkeleton, { action: React.createElement(CreateEventButton, { variant: "outlined", color: "primary", size: "small" },
|
|
215
|
+
React.createElement(FormattedMessage, { id: "ui.events.skeleton.action.add", defaultMessage: "ui.events.skeleton.action.add" })) }))))),
|
|
215
216
|
Boolean(next) && (React.createElement(Button, { color: "secondary", variant: "text", onClick: handleNext, className: classes.showMore },
|
|
216
217
|
React.createElement(FormattedMessage, { id: "ui.events.button.seeMore", defaultMessage: "ui.events.button.seeMore" }))))))));
|
|
217
218
|
/**
|
|
@@ -438,7 +438,7 @@ export default function FeedObject(inProps) {
|
|
|
438
438
|
obj.group && (React.createElement("div", { className: classes.group },
|
|
439
439
|
React.createElement(Chip, { color: "secondary", size: "small", key: obj.group.id, icon: React.createElement(Icon, null, "groups"), component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }))),
|
|
440
440
|
obj.event && (React.createElement("div", { className: classes.event },
|
|
441
|
-
React.createElement(Chip, { color: "secondary", size: "small", key: obj.event.id, icon: React.createElement(Icon, null, "CalendarIcon"), component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true })))),
|
|
441
|
+
React.createElement(Chip, { color: "secondary", size: "small", key: obj.event.id, label: obj.event.name, icon: React.createElement(Icon, null, "CalendarIcon"), component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true })))),
|
|
442
442
|
obj.categories.map((c) => (React.createElement(Link, { to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, c), key: c.id },
|
|
443
443
|
React.createElement(Typography, { variant: "overline" }, c.name)))))),
|
|
444
444
|
obj.group && !obj.categories.length && (React.createElement("div", { className: classes.group },
|
|
@@ -85,6 +85,8 @@ export interface NavigationToolbarProps extends ToolbarProps {
|
|
|
85
85
|
|navigation|.SCNavigationToolbar-navigation|Styles applied to the navigation container element|
|
|
86
86
|
|home|.SCNavigationToolbar-home|Styles applied to the home button|
|
|
87
87
|
|explore|.SCNavigationToolbar-explore|Styles applied to the explore button|
|
|
88
|
+
|groups|.SCNavigationToolbar-groups|Styles applied to the group button|
|
|
89
|
+
|events|.SCNavigationToolbar-events|Styles applied to the event button|
|
|
88
90
|
|search|.SCNavigationToolbar-search|Styles applied to the search component|
|
|
89
91
|
|composer|.SCNavigationToolbar-composer|Styles applied to the composer component|
|
|
90
92
|
|profile|.SCNavigationToolbar-profile|Styles applied to the profile button|
|
|
@@ -22,6 +22,7 @@ const classes = {
|
|
|
22
22
|
navigation: `${PREFIX}-navigation`,
|
|
23
23
|
home: `${PREFIX}-home`,
|
|
24
24
|
explore: `${PREFIX}-explore`,
|
|
25
|
+
events: `${PREFIX}-events`,
|
|
25
26
|
groups: `${PREFIX}-groups`,
|
|
26
27
|
search: `${PREFIX}-search`,
|
|
27
28
|
composer: `${PREFIX}-composer`,
|
|
@@ -74,6 +75,8 @@ const PREFERENCES = [
|
|
|
74
75
|
|navigation|.SCNavigationToolbar-navigation|Styles applied to the navigation container element|
|
|
75
76
|
|home|.SCNavigationToolbar-home|Styles applied to the home button|
|
|
76
77
|
|explore|.SCNavigationToolbar-explore|Styles applied to the explore button|
|
|
78
|
+
|groups|.SCNavigationToolbar-groups|Styles applied to the group button|
|
|
79
|
+
|events|.SCNavigationToolbar-events|Styles applied to the event button|
|
|
77
80
|
|search|.SCNavigationToolbar-search|Styles applied to the search component|
|
|
78
81
|
|composer|.SCNavigationToolbar-composer|Styles applied to the composer component|
|
|
79
82
|
|profile|.SCNavigationToolbar-profile|Styles applied to the profile button|
|
|
@@ -105,6 +108,7 @@ export default function NavigationToolbar(inProps) {
|
|
|
105
108
|
}, [scPreferences.preferences]);
|
|
106
109
|
const privateMessagingEnabled = useMemo(() => scPreferences.features.includes(SCFeatureName.PRIVATE_MESSAGING), [scPreferences.features]);
|
|
107
110
|
const groupsEnabled = useMemo(() => scPreferences.features && scPreferences.features.includes(SCFeatureName.GROUPING) && scPreferences.features.includes(SCFeatureName.TAGGING), [scPreferences.features]);
|
|
111
|
+
const eventsEnabled = useMemo(() => scPreferences.features && scPreferences.features.includes(SCFeatureName.EVENT) && scPreferences.features.includes(SCFeatureName.TAGGING), [scPreferences.features]);
|
|
108
112
|
const showComposer = useMemo(() => {
|
|
109
113
|
return (!disableComposer &&
|
|
110
114
|
(!scPreferences.preferences[SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value || UserUtils.isStaff(scUserContext.user)));
|
|
@@ -134,7 +138,11 @@ export default function NavigationToolbar(inProps) {
|
|
|
134
138
|
[classes.active]: value.startsWith(scRoutingContext.url(SCRoutes.GROUPS_SUBSCRIBED_ROUTE_NAME, {})) ||
|
|
135
139
|
value.startsWith(scRoutingContext.url(SCRoutes.GROUPS_ROUTE_NAME, {}))
|
|
136
140
|
}), "aria-label": "Groups", to: scRoutingContext.url(SCRoutes.GROUPS_SUBSCRIBED_ROUTE_NAME, {}), component: Link },
|
|
137
|
-
React.createElement(Icon, null, "groups")))
|
|
141
|
+
React.createElement(Icon, null, "groups"))),
|
|
142
|
+
eventsEnabled && scUserContext.user && (React.createElement(IconButton, { className: classNames(classes.events, {
|
|
143
|
+
[classes.active]: value.startsWith(scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, {}))
|
|
144
|
+
}), "aria-label": "Groups", to: scRoutingContext.url(SCRoutes.EVENTS_ROUTE_NAME, {}), component: Link },
|
|
145
|
+
React.createElement(Icon, null, "CalendarIcon")))));
|
|
138
146
|
return (React.createElement(Root, Object.assign({ className: classNames(className, classes.root) }, rest),
|
|
139
147
|
React.createElement(NavigationMenuIconButtonComponent, null),
|
|
140
148
|
React.createElement(Link, { to: scRoutingContext.url(SCRoutes.HOME_ROUTE_NAME, {}), className: classes.logo },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { Badge, Button, IconButton, styled, Toolbar } from '@mui/material';
|
|
3
3
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
4
|
-
import { Link, SCPreferences, SCRoutes, useSCPreferences, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
4
|
+
import { Link, SCPreferences, SCRoutes, UserUtils, useSCPreferences, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
5
5
|
import Icon from '@mui/material/Icon';
|
|
6
6
|
import { useThemeProps } from '@mui/system';
|
|
7
7
|
import classNames from 'classnames';
|
|
@@ -12,6 +12,7 @@ import NavigationSettingsIconButton from '../NavigationSettingsIconButton';
|
|
|
12
12
|
import NavigationMenuIconButton from '../NavigationMenuIconButton';
|
|
13
13
|
import { PREFIX } from './constants';
|
|
14
14
|
import { SCFeatureName } from '@selfcommunity/types';
|
|
15
|
+
import ComposerIconButton from '../ComposerIconButton';
|
|
15
16
|
const classes = {
|
|
16
17
|
root: `${PREFIX}-root`,
|
|
17
18
|
logo: `${PREFIX}-logo`,
|
|
@@ -77,6 +78,10 @@ export default function NavigationToolbarMobile(inProps) {
|
|
|
77
78
|
const [searchOpen, setSearchOpen] = useState(false);
|
|
78
79
|
// MEMO
|
|
79
80
|
const groupsEnabled = useMemo(() => features && features.includes(SCFeatureName.GROUPING) && features.includes(SCFeatureName.TAGGING), [features]);
|
|
81
|
+
const eventsEnabled = useMemo(() => features && features.includes(SCFeatureName.EVENT) && features.includes(SCFeatureName.TAGGING), [features]);
|
|
82
|
+
const exploreStreamEnabled = preferences[SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value;
|
|
83
|
+
const postOnlyStaffEnabled = preferences[SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value;
|
|
84
|
+
const contentAvailable = preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value;
|
|
80
85
|
// HANDLERS
|
|
81
86
|
const handleOpenSearch = useCallback(() => {
|
|
82
87
|
setSearchOpen(true);
|
|
@@ -98,12 +103,17 @@ export default function NavigationToolbarMobile(inProps) {
|
|
|
98
103
|
return (React.createElement(Root, Object.assign({ className: classNames(className, classes.root) }, rest),
|
|
99
104
|
_children,
|
|
100
105
|
startActions,
|
|
101
|
-
(
|
|
106
|
+
(contentAvailable || scUserContext.user) && !disableSearch && (React.createElement(React.Fragment, null,
|
|
102
107
|
React.createElement(IconButton, { className: classes.search, onClick: handleOpenSearch },
|
|
103
108
|
React.createElement(Icon, null, "search")),
|
|
104
109
|
React.createElement(SearchDialog, { className: classes.searchDialog, fullScreen: true, open: searchOpen, SearchAutocompleteProps: Object.assign(Object.assign({}, SearchAutocompleteProps), { onClear: handleCloseSearch }) }))),
|
|
105
110
|
endActions,
|
|
106
|
-
|
|
111
|
+
(!postOnlyStaffEnabled || (UserUtils.isStaff(scUserContext.user) && postOnlyStaffEnabled)) &&
|
|
112
|
+
groupsEnabled &&
|
|
113
|
+
eventsEnabled &&
|
|
114
|
+
(scUserContext.user || contentAvailable) &&
|
|
115
|
+
exploreStreamEnabled && React.createElement(ComposerIconButton, null),
|
|
116
|
+
scUserContext.user && (groupsEnabled || eventsEnabled) && (React.createElement(IconButton, { className: classes.notifications, component: Link, to: scRoutingContext.url(SCRoutes.USER_NOTIFICATIONS_ROUTE_NAME, {}) },
|
|
107
117
|
React.createElement(Badge, { badgeContent: scUserContext.user.unseen_notification_banners_counter + scUserContext.user.unseen_interactions_counter, color: "secondary" },
|
|
108
118
|
React.createElement(Icon, null, "notifications_active")))),
|
|
109
119
|
scUserContext.user ? (React.createElement(NavigationSettingsIconButtonComponent, { className: classes.settings })) : (React.createElement(Button, { className: classes.login, color: "inherit", component: Link, to: scRoutingContext.url(SCRoutes.SIGNIN_ROUTE_NAME, {}) },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { ButtonBaseProps } from '@mui/material';
|
|
3
2
|
import { SCUserType } from '@selfcommunity/types';
|
|
3
|
+
import React, { ReactNode } from 'react';
|
|
4
4
|
import { FollowUserButtonProps } from '../FollowUserButton/FollowUserButton';
|
|
5
5
|
import { FriendshipButtonProps } from '../FriendshipUserButton/FriendshipUserButton';
|
|
6
6
|
import { WidgetProps } from '../Widget';
|
|
@@ -49,6 +49,7 @@ export interface UserProps extends WidgetProps {
|
|
|
49
49
|
* @default {}
|
|
50
50
|
*/
|
|
51
51
|
buttonProps?: ButtonBaseProps | null;
|
|
52
|
+
secondary?: ReactNode | null;
|
|
52
53
|
/**
|
|
53
54
|
* Any other properties
|
|
54
55
|
*/
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import React, { useMemo, useState } from 'react';
|
|
3
|
-
import { styled } from '@mui/material/styles';
|
|
4
|
-
import UserSkeleton from './Skeleton';
|
|
5
2
|
import { Avatar, Badge, Button, Chip } from '@mui/material';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
import { useThemeProps } from '@mui/system';
|
|
6
5
|
import { Link, SCPreferences, SCRoutes, useSCFetchUser, useSCPreferences, useSCRouting } from '@selfcommunity/react-core';
|
|
7
|
-
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
8
6
|
import classNames from 'classnames';
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
7
|
+
import React, { useMemo, useState } from 'react';
|
|
8
|
+
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
11
9
|
import BaseItemButton from '../../shared/BaseItemButton';
|
|
12
|
-
import UserDeletedSnackBar from '../../shared/UserDeletedSnackBar';
|
|
13
10
|
import UserAvatar from '../../shared/UserAvatar';
|
|
11
|
+
import UserDeletedSnackBar from '../../shared/UserDeletedSnackBar';
|
|
12
|
+
import ConnectionUserButton from '../ConnectionUserButton';
|
|
14
13
|
import { PREFIX } from './constants';
|
|
14
|
+
import UserSkeleton from './Skeleton';
|
|
15
15
|
const messages = defineMessages({
|
|
16
16
|
userFollowers: {
|
|
17
17
|
id: 'ui.user.userFollowers',
|
|
@@ -65,7 +65,7 @@ export default function User(inProps) {
|
|
|
65
65
|
props: inProps,
|
|
66
66
|
name: PREFIX
|
|
67
67
|
});
|
|
68
|
-
const { userId = null, user = null, handleIgnoreAction, className = null, followConnectUserButtonProps = {}, showFollowers = false, elevation, badgeContent = null, actions = null, isGroupAdmin = false, buttonProps = null } = props, rest = __rest(props, ["userId", "user", "handleIgnoreAction", "className", "followConnectUserButtonProps", "showFollowers", "elevation", "badgeContent", "actions", "isGroupAdmin", "buttonProps"]);
|
|
68
|
+
const { userId = null, user = null, handleIgnoreAction, className = null, followConnectUserButtonProps = {}, showFollowers = false, elevation, badgeContent = null, actions = null, isGroupAdmin = false, buttonProps = null, secondary = null } = props, rest = __rest(props, ["userId", "user", "handleIgnoreAction", "className", "followConnectUserButtonProps", "showFollowers", "elevation", "badgeContent", "actions", "isGroupAdmin", "buttonProps", "secondary"]);
|
|
69
69
|
// STATE
|
|
70
70
|
const { scUser, setSCUser } = useSCFetchUser({ id: userId, user });
|
|
71
71
|
// CONTEXT
|
|
@@ -107,6 +107,6 @@ export default function User(inProps) {
|
|
|
107
107
|
React.createElement(Avatar, { alt: scUser.username, src: scUser.avatar, className: classes.avatar }))) : (React.createElement(UserAvatar, { hide: !hasBadge },
|
|
108
108
|
React.createElement(Avatar, { alt: scUser.username, src: scUser.avatar, className: classes.avatar }))), primary: (hasBadge && preferences) || isGroupAdmin ? (React.createElement(React.Fragment, null,
|
|
109
109
|
scUser.username,
|
|
110
|
-
React.createElement(Chip, { component: "span", className: isGroupAdmin ? classes.groupAdminBadgeLabel : classes.staffBadgeLabel, size: "small", label: isGroupAdmin ? (React.createElement(FormattedMessage, { defaultMessage: "ui.user.group.admin", id: "ui.user.group.admin" })) : (preferences[SCPreferences.STAFF_STAFF_BADGE_LABEL]) }))) : (scUser.username), secondary: showFollowers ? `${intl.formatMessage(messages.userFollowers, { total: scUser.followers_counter })}` : scUser.description, actions: actions !== null && actions !== void 0 ? actions : renderAuthenticatedActions() })),
|
|
110
|
+
React.createElement(Chip, { component: "span", className: isGroupAdmin ? classes.groupAdminBadgeLabel : classes.staffBadgeLabel, size: "small", label: isGroupAdmin ? (React.createElement(FormattedMessage, { defaultMessage: "ui.user.group.admin", id: "ui.user.group.admin" })) : (preferences[SCPreferences.STAFF_STAFF_BADGE_LABEL]) }))) : (scUser.username), secondary: secondary || (showFollowers ? `${intl.formatMessage(messages.userFollowers, { total: scUser.followers_counter })}` : scUser.description), actions: actions !== null && actions !== void 0 ? actions : renderAuthenticatedActions() })),
|
|
111
111
|
openAlert && React.createElement(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })));
|
|
112
112
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SCUserType, SCGroupType } from '@selfcommunity/types';
|
|
1
|
+
import { SCUserType, SCGroupType, SCEventType } from '@selfcommunity/types';
|
|
2
2
|
/**
|
|
3
3
|
* Define topics for pubsub
|
|
4
4
|
*/
|
|
@@ -21,3 +21,7 @@ export interface SCGroupMembersEventType {
|
|
|
21
21
|
group: SCGroupType;
|
|
22
22
|
user?: SCUserType;
|
|
23
23
|
}
|
|
24
|
+
export interface SCEventMembersEventType {
|
|
25
|
+
event: SCEventType;
|
|
26
|
+
user?: SCUserType;
|
|
27
|
+
}
|