@selfcommunity/react-ui 0.11.0-alpha.39 → 0.11.0-alpha.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.
@@ -91,7 +91,7 @@ function EventHeader(inProps) {
91
91
  // INTL
92
92
  const intl = (0, react_intl_1.useIntl)();
93
93
  // CONST
94
- const isEventAdmin = (0, react_1.useMemo)(() => scUserContext.user && scEvent && (scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id) === scUserContext.user.id, [scUserContext.user, scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by]);
94
+ const isEventAdmin = (0, react_1.useMemo)(() => { var _a; return scUserContext.user && scEvent && ((_a = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by]);
95
95
  const isEventFinished = (0, react_1.useMemo)(() => (0, events_1.checkEventFinished)(scEvent), [scEvent]);
96
96
  /**
97
97
  * Handles callback subscribe/unsubscribe event
@@ -120,8 +120,12 @@ function EventActionsMenu(inProps) {
120
120
  });
121
121
  }
122
122
  const createGoogleCalendarLink = (event) => {
123
+ var _a;
123
124
  const baseUrl = 'https://www.google.com/calendar/render?action=TEMPLATE';
124
- return `${baseUrl}&text=${encodeURIComponent(event.name)}&details=${encodeURIComponent(event.description)}&location=${encodeURIComponent(event.geolocation)}&dates=${event.start_date}/${event.end_date}`;
125
+ const startDate = (0, events_1.formatDateForGC)(event.start_date);
126
+ const endDate = (0, events_1.formatDateForGC)(event.end_date);
127
+ const details = `${event.description ? event.description + '\n\n' : ''}${event.link ? 'Link: ' + event.link : ''}`;
128
+ return `${baseUrl}&text=${encodeURIComponent(event.name)}&details=${encodeURIComponent(details)}&location=${encodeURIComponent((_a = event.geolocation) !== null && _a !== void 0 ? _a : '')}&dates=${startDate}/${endDate}`;
125
129
  };
126
130
  /**
127
131
  * Handles actions
@@ -1,2 +1,3 @@
1
1
  import { SCEventType } from '@selfcommunity/types';
2
2
  export declare function checkEventFinished(event: SCEventType | null): boolean;
3
+ export declare function formatDateForGC(eventDate: string): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkEventFinished = void 0;
3
+ exports.formatDateForGC = exports.checkEventFinished = void 0;
4
4
  function checkEventFinished(event) {
5
5
  if (event && !event.running) {
6
6
  return new Date().getTime() > new Date(event.end_date || event.start_date).getTime();
@@ -8,3 +8,8 @@ function checkEventFinished(event) {
8
8
  return false;
9
9
  }
10
10
  exports.checkEventFinished = checkEventFinished;
11
+ function formatDateForGC(eventDate) {
12
+ const date = new Date(eventDate);
13
+ return date.toISOString().replace(/[-:]/g, '').split('.')[0] + 'Z';
14
+ }
15
+ exports.formatDateForGC = formatDateForGC;
@@ -89,7 +89,7 @@ export default function EventHeader(inProps) {
89
89
  // INTL
90
90
  const intl = useIntl();
91
91
  // CONST
92
- const isEventAdmin = useMemo(() => scUserContext.user && scEvent && (scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id) === scUserContext.user.id, [scUserContext.user, scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by]);
92
+ const isEventAdmin = useMemo(() => { var _a; return scUserContext.user && scEvent && ((_a = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by]);
93
93
  const isEventFinished = useMemo(() => checkEventFinished(scEvent), [scEvent]);
94
94
  /**
95
95
  * Handles callback subscribe/unsubscribe event
@@ -16,7 +16,7 @@ import EventForm from '../../components/EventForm';
16
16
  import { ADD_EVENT_TO_CALENDAR, CANCEL_EVENT, GET_EVENT_LINK } from '../../constants/EventActionsMenu';
17
17
  import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
18
18
  import ConfirmDialog from '../../shared/ConfirmDialog/ConfirmDialog';
19
- import { checkEventFinished } from '../../utils/events';
19
+ import { checkEventFinished, formatDateForGC } from '../../utils/events';
20
20
  const PREFIX = 'SCEventActionsMenu';
21
21
  const classes = {
22
22
  root: `${PREFIX}-root`,
@@ -118,8 +118,12 @@ export default function EventActionsMenu(inProps) {
118
118
  });
119
119
  }
120
120
  const createGoogleCalendarLink = (event) => {
121
+ var _a;
121
122
  const baseUrl = 'https://www.google.com/calendar/render?action=TEMPLATE';
122
- return `${baseUrl}&text=${encodeURIComponent(event.name)}&details=${encodeURIComponent(event.description)}&location=${encodeURIComponent(event.geolocation)}&dates=${event.start_date}/${event.end_date}`;
123
+ const startDate = formatDateForGC(event.start_date);
124
+ const endDate = formatDateForGC(event.end_date);
125
+ const details = `${event.description ? event.description + '\n\n' : ''}${event.link ? 'Link: ' + event.link : ''}`;
126
+ return `${baseUrl}&text=${encodeURIComponent(event.name)}&details=${encodeURIComponent(details)}&location=${encodeURIComponent((_a = event.geolocation) !== null && _a !== void 0 ? _a : '')}&dates=${startDate}/${endDate}`;
123
127
  };
124
128
  /**
125
129
  * Handles actions
@@ -1,2 +1,3 @@
1
1
  import { SCEventType } from '@selfcommunity/types';
2
2
  export declare function checkEventFinished(event: SCEventType | null): boolean;
3
+ export declare function formatDateForGC(eventDate: string): string;
@@ -4,3 +4,7 @@ export function checkEventFinished(event) {
4
4
  }
5
5
  return false;
6
6
  }
7
+ export function formatDateForGC(eventDate) {
8
+ const date = new Date(eventDate);
9
+ return date.toISOString().replace(/[-:]/g, '').split('.')[0] + 'Z';
10
+ }