@selfcommunity/react-ui 0.7.50-events.111 → 0.7.50-events.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/lib/cjs/components/Event/Event.d.ts +5 -0
  2. package/lib/cjs/components/Event/Event.js +10 -4
  3. package/lib/cjs/components/EventHeader/EventHeader.js +1 -1
  4. package/lib/cjs/components/EventInfoWidget/EventInfoWidget.js +1 -1
  5. package/lib/cjs/components/EventMembersWidget/EventMembersWidget.js +36 -10
  6. package/lib/cjs/components/EventMembersWidget/TabContentComponent.d.ts +3 -2
  7. package/lib/cjs/components/EventMembersWidget/TabContentComponent.js +33 -13
  8. package/lib/cjs/components/EventMembersWidget/types.d.ts +6 -0
  9. package/lib/cjs/components/EventMembersWidget/types.js +9 -0
  10. package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.d.ts +2 -2
  11. package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.js +8 -5
  12. package/lib/cjs/shared/EventInfoDetails/index.d.ts +1 -0
  13. package/lib/cjs/shared/EventInfoDetails/index.js +13 -9
  14. package/lib/esm/components/Event/Event.d.ts +5 -0
  15. package/lib/esm/components/Event/Event.js +11 -5
  16. package/lib/esm/components/EventHeader/EventHeader.js +1 -1
  17. package/lib/esm/components/EventInfoWidget/EventInfoWidget.js +1 -1
  18. package/lib/esm/components/EventMembersWidget/EventMembersWidget.js +36 -10
  19. package/lib/esm/components/EventMembersWidget/TabContentComponent.d.ts +3 -2
  20. package/lib/esm/components/EventMembersWidget/TabContentComponent.js +34 -14
  21. package/lib/esm/components/EventMembersWidget/types.d.ts +6 -0
  22. package/lib/esm/components/EventMembersWidget/types.js +6 -0
  23. package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.d.ts +2 -2
  24. package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.js +8 -5
  25. package/lib/esm/shared/EventInfoDetails/index.d.ts +1 -0
  26. package/lib/esm/shared/EventInfoDetails/index.js +14 -10
  27. package/lib/umd/react-ui.js +1 -1
  28. package/package.json +7 -7
@@ -1,11 +1,12 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { Avatar, Box, Button, CardActions, CardContent, CardMedia, Divider, Typography } from '@mui/material';
3
+ import { Avatar, Box, Button, CardActions, CardContent, CardMedia, Chip, Divider, Typography } from '@mui/material';
4
4
  import { styled } from '@mui/material/styles';
5
5
  import { useThemeProps } from '@mui/system';
6
6
  import { Link, SCRoutes, useSCFetchEvent, useSCRouting } from '@selfcommunity/react-core';
7
7
  import { SCEventLocationType } from '@selfcommunity/types';
8
8
  import classNames from 'classnames';
9
+ import { useMemo } from 'react';
9
10
  import { FormattedMessage, useIntl } from 'react-intl';
10
11
  import BaseItem from '../../shared/BaseItem';
11
12
  import Calendar from '../../shared/Calendar';
@@ -23,6 +24,7 @@ const classes = {
23
24
  snippetRoot: `${PREFIX}-snippet-root`,
24
25
  detailImageWrapper: `${PREFIX}-detail-image-wrapper`,
25
26
  detailImage: `${PREFIX}-detail-image`,
27
+ detailInProgress: `${PREFIX}-detail-in-progress`,
26
28
  detailNameWrapper: `${PREFIX}-detail-name-wrapper`,
27
29
  detailName: `${PREFIX}-detail-name`,
28
30
  detailContent: `${PREFIX}-detail-content`,
@@ -32,11 +34,14 @@ const classes = {
32
34
  detailActions: `${PREFIX}-detail-actions`,
33
35
  previewImageWrapper: `${PREFIX}-preview-image-wrapper`,
34
36
  previewImage: `${PREFIX}-preview-image`,
37
+ previewInProgress: `${PREFIX}-preview-in-progress`,
35
38
  previewNameWrapper: `${PREFIX}-preview-name-wrapper`,
36
39
  previewName: `${PREFIX}-preview-name`,
37
40
  previewContent: `${PREFIX}-preview-content`,
38
41
  previewActions: `${PREFIX}-preview-actions`,
42
+ snippetImage: `${PREFIX}-snippet-image`,
39
43
  snippetAvatar: `${PREFIX}-snippet-avatar`,
44
+ snippetInProgress: `${PREFIX}-snippet-in-progress`,
40
45
  snippetPrimary: `${PREFIX}-snippet-primary`,
41
46
  snippetSecondary: `${PREFIX}-snippet-secondary`,
42
47
  snippetActions: `${PREFIX}-snippet-actions`
@@ -99,9 +104,10 @@ export default function Event(inProps) {
99
104
  props: inProps,
100
105
  name: PREFIX
101
106
  });
102
- const { id = `event_object_${props.eventId ? props.eventId : props.event ? props.event.id : ''}`, eventId = null, event = null, className = null, template = SCEventTemplateType.SNIPPET, hideEventParticipants = false, hideEventPlanner = false, actions, EventParticipantsButtonComponentProps = {}, EventSkeletonComponentProps = {} } = props, rest = __rest(props, ["id", "eventId", "event", "className", "template", "hideEventParticipants", "hideEventPlanner", "actions", "EventParticipantsButtonComponentProps", "EventSkeletonComponentProps"]);
107
+ const { id = `event_object_${props.eventId ? props.eventId : props.event ? props.event.id : ''}`, eventId = null, event = null, className = null, template = SCEventTemplateType.SNIPPET, hideInProgress = false, hideEventParticipants = false, hideEventPlanner = false, actions, EventParticipantsButtonComponentProps = {}, EventSkeletonComponentProps = {} } = props, rest = __rest(props, ["id", "eventId", "event", "className", "template", "hideInProgress", "hideEventParticipants", "hideEventPlanner", "actions", "EventParticipantsButtonComponentProps", "EventSkeletonComponentProps"]);
103
108
  // STATE
104
109
  const { scEvent } = useSCFetchEvent({ id: eventId, event });
110
+ const inProgress = useMemo(() => scEvent && scEvent.active && scEvent.running, [scEvent]);
105
111
  // CONTEXT
106
112
  const scRoutingContext = useSCRouting();
107
113
  // HOOKS
@@ -117,13 +123,13 @@ export default function Event(inProps) {
117
123
  */
118
124
  let contentObj;
119
125
  if (template === SCEventTemplateType.DETAIL) {
120
- contentObj = (_jsxs(DetailRoot, Object.assign({ className: classes.detailRoot }, { children: [_jsxs(Box, Object.assign({ className: classes.detailImageWrapper }, { children: [_jsx(CardMedia, { component: "img", image: scEvent.image_medium, alt: scEvent.name, className: classes.detailImage }), _jsx(Calendar, { day: new Date(scEvent.start_date).getDate() })] })), _jsxs(CardContent, Object.assign({ className: classes.detailContent }, { children: [scEvent.active ? (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.detailNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h3", className: classes.detailName }, { children: scEvent.name })) }))) : (_jsx(Box, Object.assign({ className: classes.detailNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h3", className: classes.detailName }, { children: scEvent.name })) }))), _jsx(EventInfoDetails, { event: scEvent }), !hideEventPlanner && (_jsx(User, { user: scEvent.managed_by, elevation: 0, secondary: _jsx(Typography, Object.assign({ variant: "caption" }, { children: _jsx(FormattedMessage, { id: "ui.myEventsWidget.planner", defaultMessage: "ui.myEventsWidget.planner" }) })), actions: _jsx(_Fragment, {}), className: classes.detailUser })), !hideEventParticipants && (_jsxs(_Fragment, { children: [_jsx(Divider, { className: classes.detailFirstDivider }), _jsx(EventParticipantsButton, Object.assign({ event: scEvent }, EventParticipantsButtonComponentProps))] })), _jsx(Divider, { className: classes.detailSecondDivider })] })), actions !== null && actions !== void 0 ? actions : (_jsx(CardActions, Object.assign({ className: classes.detailActions }, { children: _jsx(Button, Object.assign({ size: "small", variant: "outlined", component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })))] })));
126
+ contentObj = (_jsxs(DetailRoot, Object.assign({ className: classes.detailRoot }, { children: [_jsxs(Box, Object.assign({ className: classes.detailImageWrapper }, { children: [_jsx(CardMedia, { component: "img", image: scEvent.image_medium, alt: scEvent.name, className: classes.detailImage }), !hideInProgress && inProgress && (_jsx(Chip, { size: "small", component: "div", label: _jsx(FormattedMessage, { id: "ui.event.inProgress", defaultMessage: "ui.event.inProgress" }), className: classes.detailInProgress })), _jsx(Calendar, { day: new Date(scEvent.start_date).getDate() })] })), _jsxs(CardContent, Object.assign({ className: classes.detailContent }, { children: [scEvent.active ? (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.detailNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h3", className: classes.detailName }, { children: scEvent.name })) }))) : (_jsx(Box, Object.assign({ className: classes.detailNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h3", className: classes.detailName }, { children: scEvent.name })) }))), _jsx(EventInfoDetails, { event: scEvent }), !hideEventPlanner && (_jsx(User, { user: scEvent.managed_by, elevation: 0, secondary: _jsx(Typography, Object.assign({ variant: "caption" }, { children: _jsx(FormattedMessage, { id: "ui.myEventsWidget.planner", defaultMessage: "ui.myEventsWidget.planner" }) })), actions: _jsx(_Fragment, {}), className: classes.detailUser })), !hideEventParticipants && (_jsxs(_Fragment, { children: [_jsx(Divider, { className: classes.detailFirstDivider }), _jsx(EventParticipantsButton, Object.assign({ event: scEvent }, EventParticipantsButtonComponentProps))] })), _jsx(Divider, { className: classes.detailSecondDivider })] })), actions !== null && actions !== void 0 ? actions : (_jsx(CardActions, Object.assign({ className: classes.detailActions }, { children: _jsx(Button, Object.assign({ size: "small", variant: "outlined", component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })))] })));
121
127
  }
122
128
  else if (template === SCEventTemplateType.PREVIEW) {
123
- contentObj = (_jsxs(PreviewRoot, Object.assign({ className: classes.previewRoot }, { children: [_jsx(Box, Object.assign({ position: "relative", className: classes.previewImageWrapper }, { children: _jsx(CardMedia, { component: "img", height: "100px", image: scEvent.image_medium, alt: scEvent.name, className: classes.previewImage }) })), _jsxs(CardContent, Object.assign({ className: classes.previewContent }, { children: [_jsx(EventInfoDetails, { event: scEvent, hidePrivacyIcon: true, hasLocationInfo: false, beforePrivacyInfo: _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.previewNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h5", className: classes.previewName }, { children: scEvent.name })) })) }), !hideEventParticipants && _jsx(EventParticipantsButton, Object.assign({ event: scEvent, hideCaption: true }, EventParticipantsButtonComponentProps))] })), actions !== null && actions !== void 0 ? actions : (_jsx(CardActions, Object.assign({ className: classes.previewActions }, { children: _jsx(Button, Object.assign({ size: "small", variant: "outlined", component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })))] })));
129
+ contentObj = (_jsxs(PreviewRoot, Object.assign({ className: classes.previewRoot }, { children: [_jsxs(Box, Object.assign({ position: "relative", className: classes.previewImageWrapper }, { children: [_jsx(CardMedia, { component: "img", image: scEvent.image_medium, alt: scEvent.name, className: classes.previewImage }), !hideInProgress && inProgress && (_jsx(Chip, { size: "small", component: "div", label: _jsx(FormattedMessage, { id: "ui.event.inProgress", defaultMessage: "ui.event.inProgress" }), className: classes.previewInProgress }))] })), _jsxs(CardContent, Object.assign({ className: classes.previewContent }, { children: [_jsx(EventInfoDetails, { event: scEvent, hidePrivacyIcon: true, hasLocationInfo: false, beforePrivacyInfo: _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.previewNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h5", className: classes.previewName }, { children: scEvent.name })) })) }), !hideEventParticipants && _jsx(EventParticipantsButton, Object.assign({ event: scEvent, hideCaption: true }, EventParticipantsButtonComponentProps))] })), actions !== null && actions !== void 0 ? actions : (_jsx(CardActions, Object.assign({ className: classes.previewActions }, { children: _jsx(Button, Object.assign({ size: "small", variant: "outlined", component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.event.see", id: "ui.event.see" }) })) })))] })));
124
130
  }
125
131
  else {
126
- contentObj = (_jsx(SnippetRoot, { elevation: 0, square: true, disableTypography: true, className: classes.snippetRoot, image: _jsx(Avatar, { variant: "square", alt: scEvent.name, src: scEvent.image_medium, className: classes.snippetAvatar }), primary: _jsxs(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.snippetPrimary }, { children: [_jsx(Typography, Object.assign({ component: "span" }, { children: `${intl.formatDate(scEvent.start_date, {
132
+ contentObj = (_jsx(SnippetRoot, { elevation: 0, square: true, disableTypography: true, className: classes.snippetRoot, image: _jsxs(Box, Object.assign({ className: classes.snippetImage }, { children: [_jsx(Avatar, { variant: "square", alt: scEvent.name, src: scEvent.image_medium, className: classes.snippetAvatar }), ' ', !hideInProgress && inProgress && (_jsx(Chip, { size: "small", component: "div", label: _jsx(FormattedMessage, { id: "ui.event.inProgress", defaultMessage: "ui.event.inProgress" }), className: classes.snippetInProgress }))] })), primary: _jsxs(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, scEvent), className: classes.snippetPrimary }, { children: [_jsx(Typography, Object.assign({ component: "span" }, { children: `${intl.formatDate(scEvent.start_date, {
127
133
  weekday: 'long',
128
134
  month: 'long',
129
135
  day: 'numeric'
@@ -118,7 +118,7 @@ export default function EventHeader(inProps) {
118
118
  /**
119
119
  * Handles callback subscribe/unsubscribe event
120
120
  */
121
- const handleSubscribe = (event, status) => {
121
+ const handleSubscribe = (_event, status) => {
122
122
  setSCEvent(Object.assign({}, scEvent, { subscription_status: status }));
123
123
  };
124
124
  /**
@@ -72,5 +72,5 @@ export default function EventInfoWidget(inProps) {
72
72
  if (!scEvent) {
73
73
  return _jsx(HiddenPlaceholder, {});
74
74
  }
75
- return (_jsx(Root, Object.assign({ className: classes.root }, rest, { children: _jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsxs(Stack, Object.assign({ className: classes.titleWrapper }, { children: [_jsx(Icon, Object.assign({ fontSize: "small" }, { children: "info" })), _jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.title", defaultMessage: "ui.infoEventWidget.title" }) }))] })), _jsx(Box, Object.assign({ className: classes.textWrapper }, { children: _jsxs(Typography, Object.assign({ component: "span", variant: "body1" }, { children: [description, showButton && !expanded && (_jsx(Button, Object.assign({ size: "small", variant: "text", className: classes.showMore, onClick: handleToggleSummary }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.showMore", defaultMessage: "ui.infoEventWidget.showMore" }) })))] })) })), _jsx(EventInfoDetails, { event: scEvent, hasRecurringInfo: true, hasCreatedInfo: true, hasLocationInfo: showInfo, hasInProgress: false })] })) })));
75
+ return (_jsx(Root, Object.assign({ className: classes.root }, rest, { children: _jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsxs(Stack, Object.assign({ className: classes.titleWrapper }, { children: [_jsx(Icon, Object.assign({ fontSize: "small" }, { children: "info" })), _jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.title", defaultMessage: "ui.infoEventWidget.title" }) }))] })), _jsx(Box, Object.assign({ className: classes.textWrapper }, { children: _jsxs(Typography, Object.assign({ component: "span", variant: "body1" }, { children: [description, showButton && !expanded && (_jsx(Button, Object.assign({ size: "small", variant: "text", className: classes.showMore, onClick: handleToggleSummary }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.showMore", defaultMessage: "ui.infoEventWidget.showMore" }) })))] })) })), _jsx(EventInfoDetails, { event: scEvent, hasRecurringInfo: true, hasCreatedInfo: true, hasLocationInfo: showInfo })] })) })));
76
76
  }
@@ -17,6 +17,7 @@ import Widget from '../Widget';
17
17
  import { PREFIX } from './constants';
18
18
  import Skeleton from './Skeleton';
19
19
  import TabContentComponent from './TabContentComponent';
20
+ import { TabValueEnum } from './types';
20
21
  const classes = {
21
22
  root: `${PREFIX}-root`,
22
23
  content: `${PREFIX}-content`,
@@ -59,18 +60,29 @@ export default function EventMembersWidget(inProps) {
59
60
  cacheStrategy,
60
61
  visibleItems: limit
61
62
  }, stateWidgetInitializer);
63
+ const [participantsCount, setParticipantsCount] = useState(0);
62
64
  const [invitedCount, setInvitedCount] = useState(0);
63
65
  const [requestsCount, setRequestsCount] = useState(0);
64
66
  const [requestsUsers, setRequestsUsers] = useState([]);
65
67
  const [tabValue, setTabValue] = useState('1');
66
- const [refresh, setRefresh] = useState(false);
68
+ const [refresh, setRefresh] = useState(null);
67
69
  // CONTEXT
68
70
  const scUserContext = useSCUser();
69
71
  // HOOKS
70
72
  const { scEvent } = useSCFetchEvent({ id: eventId, event });
71
73
  // CONSTS
72
74
  const hasAllow = useMemo(() => { var _a; return ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) === (scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id); }, [scUserContext, scEvent]);
73
- const title = useMemo(() => (tabValue === '1' ? 'ui.eventMembersWidget.participants' : 'ui.eventMembersWidget.invited'), [tabValue]);
75
+ const title = useMemo(() => {
76
+ switch (tabValue) {
77
+ case TabValueEnum.THREE:
78
+ return 'ui.eventMembersWidget.requests';
79
+ case TabValueEnum.TWO:
80
+ return 'ui.eventMembersWidget.invited';
81
+ case TabValueEnum.ONE:
82
+ default:
83
+ return 'ui.eventMembersWidget.participants';
84
+ }
85
+ }, [tabValue]);
74
86
  // CALLBACKS
75
87
  const _initParticipants = useCallback(() => {
76
88
  if (!participants.initialized && !participants.isLoadingNext) {
@@ -78,13 +90,14 @@ export default function EventMembersWidget(inProps) {
78
90
  EventService.getUsersGoingToEvent(scEvent.id, Object.assign({}, endpointQueryParams))
79
91
  .then((payload) => {
80
92
  dispatchParticipants({ type: actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: Object.assign(Object.assign({}, payload), { initialized: true }) });
93
+ setParticipantsCount(payload.count);
81
94
  })
82
95
  .catch((error) => {
83
96
  dispatchParticipants({ type: actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
84
97
  Logger.error(SCOPE_SC_UI, error);
85
98
  });
86
99
  }
87
- }, [participants.isLoadingNext, participants.initialized, dispatchParticipants, scEvent]);
100
+ }, [participants.isLoadingNext, participants.initialized, scEvent]);
88
101
  const _initInvited = useCallback(() => {
89
102
  if (!invited.initialized && !invited.isLoadingNext && hasAllow) {
90
103
  dispatchInvited({ type: actionWidgetTypes.LOADING_NEXT });
@@ -98,7 +111,7 @@ export default function EventMembersWidget(inProps) {
98
111
  Logger.error(SCOPE_SC_UI, error);
99
112
  });
100
113
  }
101
- }, [invited.isLoadingNext, invited.initialized, dispatchInvited, scUserContext.user, scEvent]);
114
+ }, [invited.isLoadingNext, invited.initialized, scUserContext.user, scEvent]);
102
115
  const _initRequests = useCallback(() => {
103
116
  if (!requests.initialized && !requests.isLoadingNext && hasAllow) {
104
117
  dispatchRequests({ type: actionWidgetTypes.LOADING_NEXT });
@@ -113,15 +126,19 @@ export default function EventMembersWidget(inProps) {
113
126
  Logger.error(SCOPE_SC_UI, error);
114
127
  });
115
128
  }
116
- }, [requests.isLoadingNext, requests.initialized, dispatchRequests, scUserContext.user, scEvent]);
129
+ }, [requests.isLoadingNext, requests.initialized, scUserContext.user, scEvent]);
117
130
  // EFFECTS
118
131
  useEffect(() => {
119
132
  let _t;
120
133
  if (scUserContext.user && scEvent) {
121
134
  _t = setTimeout(() => {
122
- if (refresh) {
135
+ if (refresh === TabValueEnum.ONE) {
136
+ _initParticipants();
137
+ setRefresh(null);
138
+ }
139
+ else if (refresh === TabValueEnum.TWO) {
123
140
  _initInvited();
124
- setRefresh(false);
141
+ setRefresh(null);
125
142
  }
126
143
  else {
127
144
  _initParticipants();
@@ -138,6 +155,15 @@ export default function EventMembersWidget(inProps) {
138
155
  const handleTabChange = useCallback((_evt, newTabValue) => {
139
156
  setTabValue(newTabValue);
140
157
  }, []);
158
+ const handleRefresh = useCallback((_tabValue) => {
159
+ if (_tabValue === TabValueEnum.ONE) {
160
+ dispatchParticipants({ type: actionWidgetTypes.RESET });
161
+ }
162
+ else if (_tabValue === TabValueEnum.TWO) {
163
+ dispatchInvited({ type: actionWidgetTypes.RESET });
164
+ }
165
+ setRefresh(_tabValue);
166
+ }, []);
141
167
  if (!scEvent && !participants.initialized) {
142
168
  return _jsx(Skeleton, {});
143
169
  }
@@ -145,14 +171,14 @@ export default function EventMembersWidget(inProps) {
145
171
  if (!scEvent) {
146
172
  return _jsx(HiddenPlaceholder, {});
147
173
  }
148
- return (_jsx(Root, Object.assign({ className: classes.root }, rest, { children: _jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsx(Typography, Object.assign({ variant: "h5", className: classes.title }, { children: _jsx(FormattedMessage, { id: title, defaultMessage: title }) })), _jsxs(TabContext, Object.assign({ value: tabValue }, { children: [_jsxs(TabList, Object.assign({ className: classes.tabsWrapper, onChange: handleTabChange, textColor: "primary", indicatorColor: "primary", variant: "fullWidth" }, { children: [_jsx(Tab, { label: _jsxs(Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "h3" }, { children: participants.count })), _jsx(Typography, Object.assign({ variant: "subtitle2" }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.participants", defaultMessage: "ui.eventMembersWidget.participants" }) }))] })), value: "1" }), hasAllow && (_jsx(Tab, { label: _jsxs(Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "h3" }, { children: invitedCount })), _jsx(Typography, Object.assign({ variant: "subtitle2" }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.invited", defaultMessage: "ui.eventMembersWidget.invited" }) }))] })), value: "2" })), hasAllow && (_jsx(Tab, { label: _jsxs(Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "h3" }, { children: requestsCount })), _jsx(Typography, Object.assign({ variant: "subtitle2" }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.requests", defaultMessage: "ui.eventMembersWidget.requests" }) }))] })), value: "3" }))] })), _jsx(TabPanel, Object.assign({ value: "1", className: classes.tabPanel }, { children: _jsx(TabContentComponent, { tabValue: "1", state: participants, dispatch: dispatchParticipants, userProps: userProps, dialogProps: dialogProps }) })), hasAllow && (_jsx(TabPanel, Object.assign({ value: "2", className: classes.tabPanel }, { children: _jsx(TabContentComponent, { tabValue: "2", state: invited, dispatch: dispatchInvited, userProps: userProps, dialogProps: dialogProps, actionProps: {
174
+ return (_jsx(Root, Object.assign({ className: classes.root }, rest, { children: _jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsx(Typography, Object.assign({ variant: "h5", className: classes.title }, { children: _jsx(FormattedMessage, { id: title, defaultMessage: title }) })), _jsxs(TabContext, Object.assign({ value: tabValue }, { children: [_jsxs(TabList, Object.assign({ className: classes.tabsWrapper, onChange: handleTabChange, textColor: "primary", indicatorColor: "primary", variant: "fullWidth" }, { children: [_jsx(Tab, { label: _jsxs(Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "h3" }, { children: participantsCount })), _jsx(Typography, Object.assign({ variant: "subtitle2" }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.participants", defaultMessage: "ui.eventMembersWidget.participants" }) }))] })), value: TabValueEnum.ONE }), hasAllow && (_jsx(Tab, { label: _jsxs(Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "h3" }, { children: invitedCount })), _jsx(Typography, Object.assign({ variant: "subtitle2" }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.invited", defaultMessage: "ui.eventMembersWidget.invited" }) }))] })), value: TabValueEnum.TWO })), hasAllow && (_jsx(Tab, { label: _jsxs(Stack, Object.assign({ className: classes.tabLabelWrapper }, { children: [_jsx(Typography, Object.assign({ variant: "h3" }, { children: requestsCount })), _jsx(Typography, Object.assign({ variant: "subtitle2" }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.requests", defaultMessage: "ui.eventMembersWidget.requests" }) }))] })), value: TabValueEnum.THREE }))] })), _jsx(TabPanel, Object.assign({ value: TabValueEnum.ONE, className: classes.tabPanel }, { children: _jsx(TabContentComponent, { tabValue: TabValueEnum.ONE, state: participants, dispatch: dispatchParticipants, userProps: userProps, dialogProps: dialogProps, handleRefresh: handleRefresh }) })), hasAllow && (_jsx(TabPanel, Object.assign({ value: TabValueEnum.TWO, className: classes.tabPanel }, { children: _jsx(TabContentComponent, { tabValue: TabValueEnum.TWO, state: invited, dispatch: dispatchInvited, userProps: userProps, dialogProps: dialogProps, actionProps: {
149
175
  scEvent,
150
176
  setCount: setInvitedCount
151
- }, setRefresh: setRefresh }) }))), hasAllow && (_jsx(TabPanel, Object.assign({ value: "3", className: classes.tabPanel }, { children: _jsx(TabContentComponent, { tabValue: "3", state: requests, dispatch: dispatchRequests, userProps: userProps, dialogProps: dialogProps, actionProps: {
177
+ }, handleRefresh: handleRefresh }) }))), hasAllow && (_jsx(TabPanel, Object.assign({ value: TabValueEnum.THREE, className: classes.tabPanel }, { children: _jsx(TabContentComponent, { tabValue: TabValueEnum.THREE, state: requests, dispatch: dispatchRequests, userProps: userProps, dialogProps: dialogProps, actionProps: {
152
178
  scEvent,
153
179
  count: requestsCount,
154
180
  setCount: setRequestsCount,
155
181
  users: requestsUsers,
156
182
  setUsers: setRequestsUsers
157
- } }) })))] }))] })) })));
183
+ }, handleRefresh: handleRefresh }) })))] }))] })) })));
158
184
  }
@@ -2,8 +2,9 @@ import { SCEventType, SCUserType } from '@selfcommunity/types';
2
2
  import { Dispatch, SetStateAction } from 'react';
3
3
  import { BaseDialogProps } from '../../shared/BaseDialog';
4
4
  import { UserProps } from '../User';
5
+ import { TabValueType } from './types';
5
6
  interface TabComponentProps {
6
- tabValue: '1' | '2' | '3';
7
+ tabValue: TabValueType;
7
8
  state: any;
8
9
  dispatch: Dispatch<any>;
9
10
  /**
@@ -23,7 +24,7 @@ interface TabComponentProps {
23
24
  users?: SCUserType[];
24
25
  setUsers?: Dispatch<SetStateAction<SCUserType[]>>;
25
26
  };
26
- setRefresh?: Dispatch<SetStateAction<boolean>>;
27
+ handleRefresh?: (tabValue: TabValueType) => void;
27
28
  }
28
29
  export default function TabContentComponent(props: TabComponentProps): JSX.Element;
29
30
  export {};
@@ -3,9 +3,11 @@ import { Button, List, ListItem, styled, Typography } from '@mui/material';
3
3
  import { Endpoints, http } from '@selfcommunity/api-services';
4
4
  import { Logger } from '@selfcommunity/utils';
5
5
  import { useSnackbar } from 'notistack';
6
- import { useCallback, useMemo, useState } from 'react';
6
+ import PubSub from 'pubsub-js';
7
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
7
8
  import { FormattedMessage } from 'react-intl';
8
9
  import { SCOPE_SC_UI } from '../../constants/Errors';
10
+ import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
9
11
  import BaseDialog from '../../shared/BaseDialog';
10
12
  import InfiniteScroll from '../../shared/InfiniteScroll';
11
13
  import { actionWidgetTypes } from '../../utils/widget';
@@ -14,6 +16,7 @@ import EventInviteButton from '../EventInviteButton';
14
16
  import InviteUserEventButton from '../InviteUserEventButton';
15
17
  import User, { UserSkeleton } from '../User';
16
18
  import { PREFIX } from './constants';
19
+ import { TabValueEnum } from './types';
17
20
  const classes = {
18
21
  actionButton: `${PREFIX}-action-button`,
19
22
  eventButton: `${PREFIX}-event-button`,
@@ -28,13 +31,25 @@ const DialogRoot = styled(BaseDialog, {
28
31
  })(() => ({}));
29
32
  export default function TabContentComponent(props) {
30
33
  // PROPS
31
- const { state, dispatch, userProps, dialogProps, actionProps, setRefresh, tabValue } = props;
34
+ const { tabValue, state, dispatch, userProps, dialogProps, actionProps, handleRefresh } = props;
32
35
  // STATE
33
36
  const [openDialog, setOpenDialog] = useState(false);
37
+ // REFS
38
+ const updatesInvited = useRef(null);
39
+ const updatesParticipants = useRef(null);
34
40
  // HOOKS
35
41
  const { enqueueSnackbar } = useSnackbar();
36
42
  // CONSTS
37
- const users = useMemo(() => (tabValue === '3' ? actionProps === null || actionProps === void 0 ? void 0 : actionProps.users : state.results), [tabValue, actionProps, state]);
43
+ const users = useMemo(() => (tabValue === TabValueEnum.THREE ? actionProps === null || actionProps === void 0 ? void 0 : actionProps.users : state.results), [tabValue, actionProps, state]);
44
+ // EFFECTS
45
+ useEffect(() => {
46
+ updatesInvited.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.INVITE_MEMBER}`, handleInviteMember);
47
+ updatesParticipants.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.ADD_MEMBER}`, handleToggleMember);
48
+ return () => {
49
+ updatesInvited.current && PubSub.unsubscribe(updatesInvited.current);
50
+ updatesParticipants.current && PubSub.unsubscribe(updatesParticipants.current);
51
+ };
52
+ }, []);
38
53
  // HANDLERS
39
54
  /**
40
55
  * Handles pagination
@@ -52,13 +67,19 @@ export default function TabContentComponent(props) {
52
67
  .catch((error) => {
53
68
  Logger.error(SCOPE_SC_UI, error);
54
69
  });
55
- }, [dispatch, state.next, state.isLoadingNext, state.initialized]);
70
+ }, [state.next, state.isLoadingNext, state.initialized]);
56
71
  const handleToggleDialogOpen = useCallback(() => {
57
72
  setOpenDialog((prev) => !prev);
58
73
  }, []);
74
+ const handleToggleMember = useCallback(() => {
75
+ handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(TabValueEnum.ONE);
76
+ }, []);
77
+ const handleInviteMember = useCallback(() => {
78
+ handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(TabValueEnum.TWO);
79
+ }, []);
59
80
  const getActionsComponent = useCallback((userId) => {
60
- if (tabValue === '2' && actionProps) {
61
- const handleInvitations = (invited) => {
81
+ if (tabValue === TabValueEnum.TWO && actionProps) {
82
+ const _handleInvitations = (invited) => {
62
83
  var _a, _b;
63
84
  if (invited) {
64
85
  (_a = actionProps.setCount) === null || _a === void 0 ? void 0 : _a.call(actionProps, (prev) => prev - 1);
@@ -67,9 +88,9 @@ export default function TabContentComponent(props) {
67
88
  (_b = actionProps.setCount) === null || _b === void 0 ? void 0 : _b.call(actionProps, (prev) => prev + 1);
68
89
  }
69
90
  };
70
- return _jsx(InviteUserEventButton, { event: actionProps.scEvent, userId: userId, handleInvitations: handleInvitations });
91
+ return _jsx(InviteUserEventButton, { event: actionProps.scEvent, userId: userId, handleInvitations: _handleInvitations });
71
92
  }
72
- else if (tabValue === '3' && actionProps) {
93
+ else if (tabValue === TabValueEnum.THREE && actionProps) {
73
94
  const handleConfirm = (id) => {
74
95
  if (id) {
75
96
  actionProps.setCount((prev) => prev - 1);
@@ -89,22 +110,21 @@ export default function TabContentComponent(props) {
89
110
  return _jsx(AcceptRequestUserEventButton, { event: actionProps.scEvent, userId: userId, handleConfirm: handleConfirm });
90
111
  }
91
112
  return undefined;
92
- }, [tabValue, actionProps, dispatch, setRefresh]);
93
- if (tabValue === '1' && (actionProps === null || actionProps === void 0 ? void 0 : actionProps.count) === 0) {
113
+ }, [tabValue, actionProps]);
114
+ if (tabValue === TabValueEnum.ONE && (actionProps === null || actionProps === void 0 ? void 0 : actionProps.count) === 0) {
94
115
  return (_jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.noParticipants", defaultMessage: "ui.eventMembersWidget.noParticipants" }) })));
95
116
  }
96
- if (tabValue === '2' && state.count === 0 && actionProps) {
117
+ else if (tabValue === TabValueEnum.TWO && state.count === 0 && actionProps) {
97
118
  const date = actionProps.scEvent.end_date || actionProps.scEvent.start_date;
98
119
  const disabled = new Date(date).getTime() < new Date().getTime();
99
120
  const handleInvitations = (invited) => {
100
121
  if (invited) {
101
- dispatch({ type: actionWidgetTypes.RESET });
102
- setRefresh(true);
122
+ handleRefresh === null || handleRefresh === void 0 ? void 0 : handleRefresh(tabValue);
103
123
  }
104
124
  };
105
125
  return (_jsx(EventInviteButton, { event: actionProps.scEvent, className: classes.eventButton, handleInvitations: handleInvitations, disabled: disabled }));
106
126
  }
107
- if (tabValue === '3' && (actionProps === null || actionProps === void 0 ? void 0 : actionProps.count) === 0) {
127
+ else if (tabValue === TabValueEnum.THREE && (actionProps === null || actionProps === void 0 ? void 0 : actionProps.count) === 0) {
108
128
  return (_jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.noOtherRequests", defaultMessage: "ui.eventMembersWidget.noOtherRequests" }) })));
109
129
  }
110
130
  return (_jsxs(_Fragment, { children: [_jsx(List, { children: users === null || users === void 0 ? void 0 : users.map((user) => (_jsx(ListItem, { children: _jsx(User, Object.assign({ elevation: 0, user: user }, userProps, { actions: getActionsComponent(user.id) })) }, user.id))) }), state.count > state.visibleItems && (_jsx(Button, Object.assign({ onClick: handleToggleDialogOpen, className: classes.actionButton }, { children: _jsx(Typography, Object.assign({ variant: "caption" }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.showAll", defaultMessage: "ui.eventMembersWidget.showAll" }) })) }))), openDialog && (_jsx(DialogRoot, Object.assign({ className: classes.dialogRoot, title: _jsx(FormattedMessage, { defaultMessage: "ui.eventMembersWidget.title", id: "ui.eventMembersWidget.title" }), onClose: handleToggleDialogOpen, open: openDialog }, dialogProps, { children: _jsx(InfiniteScroll, Object.assign({ dataLength: state.results.length, next: handleNext, hasMoreNext: Boolean(state.next), loaderNext: _jsx(UserSkeleton, Object.assign({ elevation: 0 }, userProps)), className: classes.infiniteScroll, endMessage: _jsx(Typography, Object.assign({ className: classes.endMessage }, { children: _jsx(FormattedMessage, { id: "ui.eventMembersWidget.noMoreResults", defaultMessage: "ui.eventMembersWidget.noMoreResults" }) })) }, { children: _jsx(List, { children: state.results.map((user) => (_jsx(ListItem, { children: _jsx(User, Object.assign({ elevation: 0, user: user }, userProps)) }, user.id))) }) })) })))] }));
@@ -0,0 +1,6 @@
1
+ export declare type TabValueType = '1' | '2' | '3';
2
+ export declare enum TabValueEnum {
3
+ ONE = "1",
4
+ TWO = "2",
5
+ THREE = "3"
6
+ }
@@ -0,0 +1,6 @@
1
+ export var TabValueEnum;
2
+ (function (TabValueEnum) {
3
+ TabValueEnum["ONE"] = "1";
4
+ TabValueEnum["TWO"] = "2";
5
+ TabValueEnum["THREE"] = "3";
6
+ })(TabValueEnum || (TabValueEnum = {}));
@@ -1,4 +1,4 @@
1
- import { SCEventType, SCUserType } from '@selfcommunity/types';
1
+ import { SCEventSubscriptionStatusType, SCEventType, SCUserType } from '@selfcommunity/types';
2
2
  export interface EventSubscribeButtonProps {
3
3
  /**
4
4
  * Overrides or extends the styles applied to the component.
@@ -25,7 +25,7 @@ export interface EventSubscribeButtonProps {
25
25
  * @param user
26
26
  * @param joined
27
27
  */
28
- onSubscribe?: (event: SCEventType, status: string | null) => any;
28
+ onSubscribe?: (event: SCEventType, status: SCEventSubscriptionStatusType | null) => any;
29
29
  /**
30
30
  * Others properties
31
31
  */
@@ -8,9 +8,11 @@ import { getEventStatus, useSCContext, useSCFetchEvent, useSCUser } from '@selfc
8
8
  import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
9
9
  import { CacheStrategies, Logger } from '@selfcommunity/utils';
10
10
  import classNames from 'classnames';
11
- import React, { useEffect, useMemo, useState } from 'react';
11
+ import PubSub from 'pubsub-js';
12
+ import { useEffect, useMemo, useState } from 'react';
12
13
  import { FormattedMessage } from 'react-intl';
13
14
  import { SCOPE_SC_UI } from '../../constants/Errors';
15
+ import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
14
16
  const PREFIX = 'SCEventSubscribeButton';
15
17
  const classes = {
16
18
  requestRoot: `${PREFIX}-request-root`,
@@ -81,7 +83,7 @@ export default function EventSubscribeButton(inProps) {
81
83
  // STATE
82
84
  const [status, setStatus] = useState(undefined);
83
85
  const [loading, setLoading] = useState(false);
84
- const [anchorEl, setAnchorEl] = React.useState(null);
86
+ const [anchorEl, setAnchorEl] = useState(null);
85
87
  const open = Boolean(anchorEl);
86
88
  // CONTEXT
87
89
  const scContext = useSCContext();
@@ -116,15 +118,16 @@ export default function EventSubscribeButton(inProps) {
116
118
  const toggleEventAttendance = (eventStatus) => {
117
119
  setLoading(true);
118
120
  const isGoing = eventStatus === SCEventSubscriptionStatusType.GOING ||
119
- !scEvent.subscription_status ||
121
+ !(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) ||
120
122
  (scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) === SCEventSubscriptionStatusType.INVITED;
121
123
  const toggleAction = isGoing
122
- ? scEventsManager.toggleEventAttendance(scEvent, user ? user === null || user === void 0 ? void 0 : user.id : null)
124
+ ? scEventsManager.toggleEventAttendance(scEvent, (user === null || user === void 0 ? void 0 : user.id) || null)
123
125
  : scEventsManager.toggleEventNonattendance(scEvent);
124
126
  toggleAction
125
127
  .then(() => {
126
- onSubscribe && onSubscribe(scEvent, getEventStatus(scEvent, isGoing));
128
+ onSubscribe === null || onSubscribe === void 0 ? void 0 : onSubscribe(scEvent, getEventStatus(scEvent, isGoing));
127
129
  setLoading(false);
130
+ PubSub.publish(`${SCTopicType.EVENT}.${SCGroupEventType.ADD_MEMBER}`, scUserContext.user);
128
131
  })
129
132
  .catch((e) => {
130
133
  Logger.error(SCOPE_SC_UI, e);
@@ -2,6 +2,7 @@ import { SCEventType } from '@selfcommunity/types';
2
2
  import { ReactNode } from 'react';
3
3
  export interface EventInfoDetailsProps {
4
4
  event: SCEventType;
5
+ eventId?: number;
5
6
  hideDateIcon?: boolean;
6
7
  hideRecurringIcon?: boolean;
7
8
  hidePrivacyIcon?: boolean;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Icon, Stack, styled, Tooltip, Typography, useThemeProps } from '@mui/material';
3
- import { Link } from '@selfcommunity/react-core';
3
+ import { Link, useSCFetchEvent } from '@selfcommunity/react-core';
4
4
  import { SCEventLocationType, SCEventPrivacyType, SCEventRecurrenceType } from '@selfcommunity/types';
5
5
  import { useMemo } from 'react';
6
6
  import { FormattedMessage, useIntl } from 'react-intl';
@@ -8,7 +8,7 @@ const PREFIX = 'SCEventInfoDetails';
8
8
  const classes = {
9
9
  root: `${PREFIX}-root`,
10
10
  iconTextWrapper: `${PREFIX}-icon-text-wrapper`,
11
- live: `${PREFIX}-live`,
11
+ inProgress: `${PREFIX}-in-progress`,
12
12
  link: `${PREFIX}-link`,
13
13
  url: `${PREFIX}-url`,
14
14
  creationWrapper: `${PREFIX}-creation-wrapper`
@@ -24,21 +24,25 @@ export default function EventInfoDetails(inProps) {
24
24
  props: inProps,
25
25
  name: PREFIX
26
26
  });
27
- const { event, hideDateIcon = false, hideRecurringIcon = false, hidePrivacyIcon = false, hideLocationIcon = false, hideCreatedIcon = false, hasDateInfo = true, hasRecurringInfo = false, hasPrivacyInfo = true, hasLocationInfo = true, hasCreatedInfo = false, hasInProgress = true, beforeDateInfo, beforeRecurringInfo, beforePrivacyInfo, beforeLocationInfo, beforeCreatedInfo } = props;
27
+ const { event, eventId, hideDateIcon = false, hideRecurringIcon = false, hidePrivacyIcon = false, hideLocationIcon = false, hideCreatedIcon = false, hasDateInfo = true, hasRecurringInfo = false, hasPrivacyInfo = true, hasLocationInfo = true, hasCreatedInfo = false, hasInProgress = false, beforeDateInfo, beforeRecurringInfo, beforePrivacyInfo, beforeLocationInfo, beforeCreatedInfo } = props;
28
28
  // HOOKS
29
29
  const intl = useIntl();
30
- const privacy = useMemo(() => (event.privacy === SCEventPrivacyType.PUBLIC ? 'ui.eventInfoDetails.privacy.public' : 'ui.eventInfoDetails.privacy.private'), [event]);
31
- const location = useMemo(() => (event.location === SCEventLocationType.ONLINE ? 'ui.eventInfoDetails.location.virtual' : 'ui.eventInfoDetails.location.inPerson'), [event]);
32
- return (_jsxs(Root, Object.assign({ className: classes.root }, { children: [beforeDateInfo, hasDateInfo && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideDateIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: event.active ? 'CalendarIcon' : 'calendar_off' })), _jsx(Tooltip, Object.assign({ title: !event.active ? (_jsx(FormattedMessage, { id: "ui.eventInfoDetails.deleted.tooltip", defaultMessage: "ui.eventInfoDetails.deleted.tooltip" })) : null }, { children: _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.eventInfoDetails.date.startEndTime", defaultMessage: "ui.eventInfoDetails.date.startEndTime", values: {
33
- date: intl.formatDate(event.running ? event.running_start_date : event.next_start_date, {
30
+ const { scEvent } = useSCFetchEvent({ id: eventId, event });
31
+ const privacy = useMemo(() => (scEvent && scEvent.privacy === SCEventPrivacyType.PUBLIC ? 'ui.eventInfoDetails.privacy.public' : 'ui.eventInfoDetails.privacy.private'), [scEvent]);
32
+ const location = useMemo(() => (scEvent && scEvent.location === SCEventLocationType.ONLINE ? 'ui.eventInfoDetails.location.virtual' : 'ui.eventInfoDetails.location.inPerson'), [scEvent]);
33
+ if (!scEvent) {
34
+ return null;
35
+ }
36
+ return (_jsxs(Root, Object.assign({ className: classes.root }, { children: [beforeDateInfo, hasDateInfo && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideDateIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: scEvent.active ? 'CalendarIcon' : 'calendar_off' })), _jsx(Tooltip, Object.assign({ title: !scEvent.active ? (_jsx(FormattedMessage, { id: "ui.eventInfoDetails.deleted.tooltip", defaultMessage: "ui.eventInfoDetails.deleted.tooltip" })) : null }, { children: _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.eventInfoDetails.date.startEndTime", defaultMessage: "ui.eventInfoDetails.date.startEndTime", values: {
37
+ date: intl.formatDate(scEvent.running ? scEvent.running_start_date : scEvent.next_start_date, {
34
38
  weekday: 'long',
35
39
  day: 'numeric',
36
40
  year: 'numeric',
37
41
  month: 'long'
38
42
  }),
39
- start: intl.formatDate(event.running ? event.running_start_date : event.next_start_date, { hour: 'numeric', minute: 'numeric' })
40
- } }) })) })), hasInProgress && event.active && (_jsx(Tooltip, Object.assign({ title: _jsx(FormattedMessage, { id: "ui.eventInfoDetails.inProgress", defaultMessage: "ui.eventInfoDetails.inProgress" }) }, { children: _jsx(Box, { className: classes.live }) })))] }))), beforeRecurringInfo, hasRecurringInfo && event.recurring !== SCEventRecurrenceType.NEVER && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideRecurringIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: "frequency" })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: `ui.eventInfoDetails.frequency.${event.recurring}.placeholder`, defaultMessage: `ui.eventInfoDetails.frequency.${event.recurring}.placeholder` }) }))] }))), beforePrivacyInfo, hasPrivacyInfo && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hidePrivacyIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: event.privacy === SCEventPrivacyType.PUBLIC ? 'public' : 'private' })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: privacy, defaultMessage: privacy }) })), "-", _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: location, defaultMessage: location }) }))] }))), beforeLocationInfo, hasLocationInfo && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideLocationIcon && (_jsx(Icon, Object.assign({ fontSize: "small" }, { children: event.location === SCEventLocationType.ONLINE ? 'play_circle_outline' : 'add_location_alt' }))), event.location === SCEventLocationType.ONLINE ? (_jsx(Link, Object.assign({ to: event.link, target: "_blank", className: classes.link }, { children: _jsx(Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.link })) }))) : (_jsx(Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.geolocation })))] }))), beforeCreatedInfo, hasCreatedInfo && (_jsxs(Stack, Object.assign({ className: classes.creationWrapper }, { children: [!hideCreatedIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: "create" })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.eventInfoDetails.date.create", defaultMessage: "ui.eventInfoDetails.date.create", values: {
41
- date: intl.formatDate(event.created_at, {
43
+ start: intl.formatDate(scEvent.running ? scEvent.running_start_date : scEvent.next_start_date, { hour: 'numeric', minute: 'numeric' })
44
+ } }) })) })), hasInProgress && scEvent.active && scEvent.running && (_jsx(Tooltip, Object.assign({ title: _jsx(FormattedMessage, { id: "ui.eventInfoDetails.inProgress", defaultMessage: "ui.eventInfoDetails.inProgress" }) }, { children: _jsx(Box, { className: classes.inProgress }) })))] }))), beforeRecurringInfo, hasRecurringInfo && scEvent.recurring !== SCEventRecurrenceType.NEVER && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideRecurringIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: "frequency" })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: `ui.eventInfoDetails.frequency.${scEvent.recurring}.placeholder`, defaultMessage: `ui.eventInfoDetails.frequency.${scEvent.recurring}.placeholder` }) }))] }))), beforePrivacyInfo, hasPrivacyInfo && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hidePrivacyIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: scEvent.privacy === SCEventPrivacyType.PUBLIC ? 'public' : 'private' })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: privacy, defaultMessage: privacy }) })), "-", _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: location, defaultMessage: location }) }))] }))), beforeLocationInfo, hasLocationInfo && (_jsxs(Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideLocationIcon && (_jsx(Icon, Object.assign({ fontSize: "small" }, { children: scEvent.location === SCEventLocationType.ONLINE ? 'play_circle_outline' : 'add_location_alt' }))), scEvent.location === SCEventLocationType.ONLINE ? (_jsx(Link, Object.assign({ to: scEvent.link, target: "_blank", className: classes.link }, { children: _jsx(Typography, Object.assign({ variant: "body1", className: classes.url }, { children: scEvent.link })) }))) : (_jsx(Typography, Object.assign({ variant: "body1", className: classes.url }, { children: scEvent.geolocation })))] }))), beforeCreatedInfo, hasCreatedInfo && (_jsxs(Stack, Object.assign({ className: classes.creationWrapper }, { children: [!hideCreatedIcon && _jsx(Icon, Object.assign({ fontSize: "small" }, { children: "create" })), _jsx(Typography, Object.assign({ variant: "body1" }, { children: _jsx(FormattedMessage, { id: "ui.eventInfoDetails.date.create", defaultMessage: "ui.eventInfoDetails.date.create", values: {
45
+ date: intl.formatDate(scEvent.created_at, {
42
46
  weekday: 'long',
43
47
  day: 'numeric',
44
48
  year: 'numeric',