@openeventkit/event-site 2.1.18 → 2.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/.github/workflows/jest.yml +1 -1
  2. package/babel.config.json +9 -9
  3. package/gatsby-node.js +67 -125
  4. package/jest.setup.js +2 -0
  5. package/netlify.toml +1 -1
  6. package/package.json +25 -16
  7. package/src/__mocks__/@mdx-js/mdx.js +32 -0
  8. package/src/__mocks__/@mdx-js/react.js +15 -0
  9. package/src/__mocks__/rehype-external-links.js +3 -0
  10. package/src/__mocks__/remark-gfm.js +3 -0
  11. package/src/actions/fetch-entities-actions.js +45 -87
  12. package/src/actions/update-data-actions.js +2 -2
  13. package/src/actions/user-actions.js +578 -430
  14. package/src/cms/config/collections/configurationsCollection/siteSettings/index.js +2 -0
  15. package/src/cms/config/collections/configurationsCollection/siteSettings/typeDefs.js +10 -0
  16. package/src/cms/preview-templates/ContentPagePreview.js +27 -29
  17. package/src/components/AvatarEditorModal/index.js +10 -0
  18. package/src/components/CertificatePDF.js +313 -0
  19. package/src/components/CertificateSection.js +139 -0
  20. package/src/components/FullSchedule.js +83 -66
  21. package/src/components/Mdx.js +39 -0
  22. package/src/components/__tests__/Mdx.test.jsx +70 -0
  23. package/src/content/site-settings/index.json +1 -1
  24. package/src/content/sponsors.json +1 -1
  25. package/src/i18n/locales/en.json +9 -1
  26. package/src/pages/a/[...].js +3 -0
  27. package/src/reducers/user-reducer.js +89 -27
  28. package/src/routes/authorization-callback-route.js +20 -2
  29. package/src/styles/rsvp-page.module.scss +63 -0
  30. package/src/templates/full-profile-page.js +61 -2
  31. package/src/templates/marketing-page-template/MainColumn.js +40 -42
  32. package/src/templates/rsvp-page.js +144 -0
  33. package/src/utils/alerts.js +1 -1
  34. package/src/utils/build-json/BaseAPIRequest.js +25 -0
  35. package/src/utils/build-json/EventsAPIRequest.js +171 -0
  36. package/src/utils/build-json/SpeakersAPIRequest.js +62 -0
  37. package/src/utils/build-json/SummitAPIRequest.js +115 -0
  38. package/src/utils/build-json/constants.js +5 -0
  39. package/src/utils/certificateSettings.js +45 -0
  40. package/src/utils/customErrorHandler.js +40 -1
  41. package/src/utils/rsvpConstants.js +7 -0
  42. package/src/utils/useMarketingSettings.js +48 -1
  43. package/src/utils/useSiteSettings.js +11 -0
  44. package/src/workers/feeds.worker.js +85 -90
  45. package/src/workers/sync_strategies/activity_synch_strategy.js +147 -102
  46. package/src/workers/sync_strategies/speaker_synch_strategy.js +3 -3
  47. package/src/workers/sync_strategies/track_synch_strategy.js +149 -48
  48. package/src/workers/synch.worker.js +123 -88
  49. package/static/fonts/fonts.css +120 -20
  50. package/static/fonts/nunito-sans/nunito-sans-v18-latin-200.woff2 +0 -0
  51. package/static/fonts/nunito-sans/nunito-sans-v18-latin-200italic.ttf +0 -0
  52. package/static/fonts/nunito-sans/nunito-sans-v18-latin-200italic.woff2 +0 -0
  53. package/static/fonts/nunito-sans/nunito-sans-v18-latin-300.woff2 +0 -0
  54. package/static/fonts/nunito-sans/nunito-sans-v18-latin-300italic.ttf +0 -0
  55. package/static/fonts/nunito-sans/nunito-sans-v18-latin-300italic.woff2 +0 -0
  56. package/static/fonts/nunito-sans/nunito-sans-v18-latin-400.ttf +0 -0
  57. package/static/fonts/nunito-sans/nunito-sans-v18-latin-400.woff2 +0 -0
  58. package/static/fonts/nunito-sans/nunito-sans-v18-latin-400italic.ttf +0 -0
  59. package/static/fonts/nunito-sans/nunito-sans-v18-latin-400italic.woff2 +0 -0
  60. package/static/fonts/nunito-sans/nunito-sans-v18-latin-500.ttf +0 -0
  61. package/static/fonts/nunito-sans/nunito-sans-v18-latin-500.woff2 +0 -0
  62. package/static/fonts/nunito-sans/nunito-sans-v18-latin-500italic.ttf +0 -0
  63. package/static/fonts/nunito-sans/nunito-sans-v18-latin-500italic.woff2 +0 -0
  64. package/static/fonts/nunito-sans/nunito-sans-v18-latin-600.woff2 +0 -0
  65. package/static/fonts/nunito-sans/nunito-sans-v18-latin-600italic.woff2 +0 -0
  66. package/static/fonts/nunito-sans/nunito-sans-v18-latin-700.ttf +0 -0
  67. package/static/fonts/nunito-sans/nunito-sans-v18-latin-700.woff2 +0 -0
  68. package/static/fonts/nunito-sans/nunito-sans-v18-latin-700italic.woff2 +0 -0
  69. package/static/fonts/nunito-sans/nunito-sans-v18-latin-800.ttf +0 -0
  70. package/static/fonts/nunito-sans/nunito-sans-v18-latin-800.woff2 +0 -0
  71. package/static/fonts/nunito-sans/nunito-sans-v18-latin-800italic.woff2 +0 -0
  72. package/static/fonts/nunito-sans/nunito-sans-v18-latin-900.ttf +0 -0
  73. package/static/fonts/nunito-sans/nunito-sans-v18-latin-900.woff2 +0 -0
  74. package/static/fonts/nunito-sans/nunito-sans-v18-latin-900italic.woff2 +0 -0
  75. package/static/fonts/nunito-sans/nunito-sans-v12-latin-300.woff +0 -0
  76. package/static/fonts/nunito-sans/nunito-sans-v12-latin-300.woff2 +0 -0
  77. package/static/fonts/nunito-sans/nunito-sans-v12-latin-300italic.woff +0 -0
  78. package/static/fonts/nunito-sans/nunito-sans-v12-latin-300italic.woff2 +0 -0
  79. package/static/fonts/nunito-sans/nunito-sans-v12-latin-600.woff +0 -0
  80. package/static/fonts/nunito-sans/nunito-sans-v12-latin-600.woff2 +0 -0
  81. package/static/fonts/nunito-sans/nunito-sans-v12-latin-600italic.woff +0 -0
  82. package/static/fonts/nunito-sans/nunito-sans-v12-latin-600italic.woff2 +0 -0
  83. package/static/fonts/nunito-sans/nunito-sans-v12-latin-700.woff +0 -0
  84. package/static/fonts/nunito-sans/nunito-sans-v12-latin-700.woff2 +0 -0
  85. package/static/fonts/nunito-sans/nunito-sans-v12-latin-700italic.woff +0 -0
  86. package/static/fonts/nunito-sans/nunito-sans-v12-latin-700italic.woff2 +0 -0
@@ -1,31 +1,31 @@
1
1
  import {
2
- getRequest,
3
- postRequest,
4
- putRequest,
5
- deleteRequest,
6
- putFile,
7
- createAction,
8
- startLoading,
9
- stopLoading,
2
+ getRequest,
3
+ postRequest,
4
+ putRequest,
5
+ deleteRequest,
6
+ putFile,
7
+ createAction,
8
+ startLoading,
9
+ stopLoading,
10
10
  } from 'openstack-uicore-foundation/lib/utils/actions';
11
11
 
12
- import {putOnLocalStorage, getFromLocalStorage} from 'openstack-uicore-foundation/lib/utils/methods';
12
+ import { putOnLocalStorage, getFromLocalStorage } from 'openstack-uicore-foundation/lib/utils/methods';
13
13
 
14
14
  import {
15
- getAccessToken,
16
- clearAccessToken,
17
- passwordlessLogin
15
+ clearAccessToken,
16
+ passwordlessLogin,
17
+ initLogOut
18
18
  } from 'openstack-uicore-foundation/lib/security/methods';
19
19
 
20
20
  import QuestionsSet from 'openstack-uicore-foundation/lib/utils/questions-set'
21
-
22
21
  import Swal from 'sweetalert2';
23
22
  import axios from "axios";
24
- import { navigate } from 'gatsby';
25
- import { customErrorHandler, customBadgeHandler, voidErrorHandler } from '../utils/customErrorHandler';
26
- import { getEnvVariable, SUMMIT_API_BASE_URL, SUMMIT_ID } from "../utils/envVariables";
23
+ import {navigate} from 'gatsby';
24
+ import {customErrorHandler, customBadgeHandler, voidErrorHandler, customRSVPHandler} from '../utils/customErrorHandler';
25
+ import {getEnvVariable, SUMMIT_API_BASE_URL, SUMMIT_ID} from "../utils/envVariables";
27
26
  import expiredToken from "../utils/expiredToken";
28
- import {getAccessTokenSafely} from "../utils/loginUtils";
27
+ import { getAccessTokenSafely } from "../utils/loginUtils";
28
+
29
29
  import * as Sentry from "@sentry/react";
30
30
 
31
31
  export const GET_DISQUS_SSO = 'GET_DISQUS_SSO';
@@ -58,425 +58,494 @@ export const TICKET_OWNER_CHANGED = 'TICKET_OWNER_CHANGED';
58
58
  export const REQUEST_INVITATION = 'REQUEST_INVITATION';
59
59
  export const RECEIVE_INVITATION = 'RECEIVE_INVITATION';
60
60
  export const REJECT_INVITATION = 'REJECT_INVITATION';
61
-
61
+ export const RSVP_CONFIRMED = 'RSVP_CONFIRMED';
62
+ export const RSVP_CANCELLED = 'RSVP_CANCELLED';
63
+ export const REQUEST_RSVP_INVITATION = 'REQUEST_RSVP_INVITATION';
64
+ export const RECEIVE_RSVP_INVITATION = 'RECEIVE_RSVP_INVITATION';
65
+ export const RSVP_INVITATION_ERROR = 'RSVP_INVITATION_ERROR';
66
+ export const RSVP_INVITATION_ACCEPTED = 'RSVP_INVITATION_ACCEPTED';
67
+ export const RSVP_INVITATION_REJECTED = 'RSVP_INVITATION_REJECTED';
62
68
  const DISQUS_SSO_EXPIRATION = "DISQUS_SSO_EXPIRATION";
63
69
 
64
70
  // shortName is the unique identifier assigned to a Disqus site.
65
71
  export const getDisqusSSO = (shortName) => async (dispatch, getState) => {
66
- const { userState: { disqusSSO } } = getState();
67
- const almostTwoHours = 1000 * 60 * 60 * 1.9;
68
- const disqusSsoExpiration = parseInt(getFromLocalStorage(DISQUS_SSO_EXPIRATION)) || 0;
69
-
70
- if (disqusSSO && disqusSsoExpiration > Date.now()) return;
71
-
72
- const accessToken = await getAccessTokenSafely()
73
- .catch(() => {
74
- dispatch(stopLoading());
75
- return Promise.reject();
76
- });
77
-
78
- return getRequest(
79
- null,
80
- createAction(GET_DISQUS_SSO),
81
- `${window.IDP_BASE_URL}/api/v1/sso/disqus/${shortName}/profile?access_token=${accessToken}`,
82
- customErrorHandler
83
- )({})(dispatch)
84
- .then(() => {
85
- putOnLocalStorage(DISQUS_SSO_EXPIRATION, Date.now() + almostTwoHours)
86
- })
87
- .catch(e => {
88
- console.log('ERROR: ', e);
89
- Sentry.captureException(e)
90
- clearAccessToken();
91
-
92
- return Promise.reject(e);
93
- });
72
+ const {userState: {disqusSSO}} = getState();
73
+ const almostTwoHours = 1000 * 60 * 60 * 1.9;
74
+ const disqusSsoExpiration = parseInt(getFromLocalStorage(DISQUS_SSO_EXPIRATION)) || 0;
75
+
76
+ if (disqusSSO && disqusSsoExpiration > Date.now()) return;
77
+
78
+ const accessToken = await getAccessTokenSafely()
79
+ .catch(() => {
80
+ dispatch(stopLoading());
81
+ return Promise.reject();
82
+ });
83
+
84
+ return getRequest(
85
+ null,
86
+ createAction(GET_DISQUS_SSO),
87
+ `${window.IDP_BASE_URL}/api/v1/sso/disqus/${shortName}/profile?access_token=${accessToken}`,
88
+ customErrorHandler
89
+ )({})(dispatch)
90
+ .then(() => {
91
+ putOnLocalStorage(DISQUS_SSO_EXPIRATION, Date.now() + almostTwoHours)
92
+ })
93
+ .catch(e => {
94
+ console.log('ERROR: ', e);
95
+ Sentry.captureException(e)
96
+ clearAccessToken();
97
+ return Promise.reject(e);
98
+ });
94
99
  }
95
100
 
96
101
  export const getUserProfile = () => async (dispatch) => {
97
102
 
98
- const accessToken = await getAccessTokenSafely()
99
- .catch(() => {
100
- dispatch(stopLoading());
101
- return Promise.reject();
102
- });
103
-
104
- let params = {
105
- access_token: accessToken,
106
- expand:
107
- 'groups,summit_tickets,summit_tickets.ticket_type,summit_tickets.owner,summit_tickets.owner.presentation_votes,' +
108
- 'summit_tickets.owner.extra_questions,summit_tickets.badge,summit_tickets.badge.features,summit_tickets.badge.type,' +
109
- 'summit_tickets.badge.type.access_levels,summit_tickets.badge.type.features,favorite_summit_events,feedback,' +
110
- 'schedule_summit_events,rsvp,rsvp.answers'
111
- };
103
+ const accessToken = await getAccessTokenSafely()
104
+ .catch(() => {
105
+ dispatch(stopLoading());
106
+ return Promise.reject();
107
+ });
108
+
109
+ let params = {
110
+ access_token: accessToken,
111
+ fields: 'rsvp.event_id,rsvp.seat_type,rsvp_invitations.event_id,rsvp_invitations.status',
112
+ expand:
113
+ 'groups,summit_tickets,summit_tickets.ticket_type,summit_tickets.owner,summit_tickets.owner.presentation_votes,' +
114
+ 'summit_tickets.owner.extra_questions,summit_tickets.badge,summit_tickets.badge.features,summit_tickets.badge.type,' +
115
+ 'summit_tickets.badge.type.access_levels,summit_tickets.badge.type.features,favorite_summit_events,feedback,' +
116
+ 'schedule_summit_events,rsvp,rsvp.answers,rsvp_invitations'
117
+ };
112
118
 
113
- return getRequest(
114
- createAction(START_LOADING_PROFILE),
115
- createAction(GET_USER_PROFILE),
116
- `${window.SUMMIT_API_BASE_URL}/api/v1/summits/${window.SUMMIT_ID}/members/me`,
117
- customErrorHandler
118
- )(params)(dispatch).then(() => {
119
- dispatch(createAction(STOP_LOADING_PROFILE)());
120
- return dispatch(getIDPProfile()).then(() => dispatch(getScheduleSyncLink()));
121
- }).catch((e) => {
122
- console.log('ERROR: ', e);
123
- dispatch(createAction(STOP_LOADING_PROFILE)());
124
- clearAccessToken();
125
- return (e);
126
- });
119
+ return getRequest(
120
+ createAction(START_LOADING_PROFILE),
121
+ createAction(GET_USER_PROFILE),
122
+ `${window.SUMMIT_API_BASE_URL}/api/v1/summits/${window.SUMMIT_ID}/members/me`,
123
+ customErrorHandler
124
+ )(params)(dispatch).then(() => {
125
+ dispatch(createAction(STOP_LOADING_PROFILE)());
126
+ return dispatch(getIDPProfile()).then(() => dispatch(getScheduleSyncLink()));
127
+ }).catch((e) => {
128
+ console.log('ERROR: ', e);
129
+ dispatch(createAction(STOP_LOADING_PROFILE)());
130
+ clearAccessToken();
131
+ Swal.fire('Error', "There was an error at Login Flow. Please retry.", "warning");
132
+ initLogOut();
133
+ return (e);
134
+ });
127
135
  }
128
136
 
129
137
  export const getIDPProfile = () => async (dispatch) => {
130
138
 
131
- const accessToken = await getAccessTokenSafely()
132
- .catch(() => {
133
- dispatch(stopLoading());
134
- return Promise.reject();
135
- });
139
+ const accessToken = await getAccessTokenSafely()
140
+ .catch(() => {
141
+ dispatch(stopLoading());
142
+ return Promise.reject();
143
+ });
136
144
 
137
- let params = {
138
- access_token: accessToken,
139
- expand: 'groups'
140
- };
145
+ let params = {
146
+ access_token: accessToken,
147
+ expand: 'groups'
148
+ };
141
149
 
142
- return getRequest(
143
- createAction(START_LOADING_IDP_PROFILE),
144
- createAction(GET_IDP_PROFILE),
145
- `${window.IDP_BASE_URL}/api/v1/users/me`,
146
- customErrorHandler
147
- )(params)(dispatch)
148
- .then(() => dispatch(createAction(STOP_LOADING_IDP_PROFILE)()))
149
- .catch((e) => {
150
- console.log('ERROR: ', e);
151
- dispatch(createAction(STOP_LOADING_IDP_PROFILE)())
152
- clearAccessToken();
153
- return (e);
154
- });
150
+ return getRequest(
151
+ createAction(START_LOADING_IDP_PROFILE),
152
+ createAction(GET_IDP_PROFILE),
153
+ `${window.IDP_BASE_URL}/api/v1/users/me`,
154
+ customErrorHandler
155
+ )(params)(dispatch)
156
+ .then(() => dispatch(createAction(STOP_LOADING_IDP_PROFILE)()))
157
+ .catch((e) => {
158
+ console.log('ERROR: ', e);
159
+ dispatch(createAction(STOP_LOADING_IDP_PROFILE)())
160
+ clearAccessToken();
161
+ return (e);
162
+ });
155
163
  }
156
164
 
157
165
  export const requireExtraQuestions = () => (dispatch, getState) => {
158
- const { userState: { userProfile } } = getState();
166
+ const {userState: {userProfile}} = getState();
159
167
 
160
- const owner = userProfile?.summit_tickets[0]?.owner || null;
161
- // if user does not have an attendee then we dont require extra questions
162
- if (!owner) return false;
163
- return dispatch(checkRequireExtraQuestionsByAttendee(owner));
168
+ const owner = userProfile?.summit_tickets[0]?.owner || null;
169
+ // if user does not have an attendee then we dont require extra questions
170
+ if (!owner) return false;
171
+ return dispatch(checkRequireExtraQuestionsByAttendee(owner));
164
172
  }
165
173
 
166
174
  export const checkRequireExtraQuestionsByAttendee = (attendee) => (dispatch, getState) => {
167
- const { summitState : { summit, extra_questions }} = getState();
168
- if (!attendee.first_name || !attendee.last_name || !attendee.company || !attendee.email) return true;
169
- const disclaimer = summit.registration_disclaimer_mandatory ? attendee.disclaimer_accepted : true;
170
- if (!disclaimer) return true;
171
- if (extra_questions?.length > 0) {
172
- const qs = new QuestionsSet(extra_questions, attendee.extra_questions || []);
173
- return !qs.completed();
174
- }
175
- return false;
175
+
176
+ const {summitState: {summit, extra_questions}} = getState();
177
+ if (!attendee.first_name || !attendee.last_name || !attendee.company || !attendee.email) return true;
178
+ const disclaimer = summit.registration_disclaimer_mandatory ? attendee.disclaimer_accepted : true;
179
+ if (!disclaimer) return true;
180
+ if (extra_questions?.length > 0) {
181
+ const qs = new QuestionsSet(extra_questions, attendee.extra_questions || []);
182
+ return !qs.completed();
183
+ }
184
+ return false;
176
185
  }
177
186
 
178
187
  export const scanBadge = (sponsorId) => async (dispatch) => {
179
188
 
180
- const accessToken = await getAccessTokenSafely()
181
- .catch(() => {
182
- dispatch(stopLoading());
183
- return Promise.reject();
184
- });
189
+ const accessToken = await getAccessTokenSafely()
190
+ .catch(() => {
191
+ dispatch(stopLoading());
192
+ return Promise.reject();
193
+ });
185
194
 
186
- let params = {
187
- access_token: accessToken,
188
- };
195
+ let params = {
196
+ access_token: accessToken,
197
+ };
189
198
 
190
- return postRequest(
191
- createAction(SCAN_BADGE),
192
- createAction(SCAN_BADGE_SUCCESS),
193
- `${window.SUMMIT_API_BASE_URL}/api/v1/summits/${window.SUMMIT_ID}/sponsors/${sponsorId}/user-info-grants/me`,
194
- null,
195
- customBadgeHandler,
196
- // entity
197
- )(params)(dispatch)
198
- .then((payload) => {
199
- let msg = 'Thanks for sharing your info!';
200
- Swal.fire("Success", msg, "success");
201
- return (payload)
202
- })
203
- .catch(e => {
204
- console.log('ERROR: ', e);
205
- dispatch(createAction(SCAN_BADGE_ERROR)(e));
206
- clearAccessToken();
207
- return (e);
208
- });
199
+ return postRequest(
200
+ createAction(SCAN_BADGE),
201
+ createAction(SCAN_BADGE_SUCCESS),
202
+ `${window.SUMMIT_API_BASE_URL}/api/v1/summits/${window.SUMMIT_ID}/sponsors/${sponsorId}/user-info-grants/me`,
203
+ null,
204
+ customBadgeHandler,
205
+ // entity
206
+ )(params)(dispatch)
207
+ .then((payload) => {
208
+ let msg = 'Thanks for sharing your info!';
209
+ Swal.fire("Success", msg, "success");
210
+ return (payload)
211
+ })
212
+ .catch(e => {
213
+ console.log('ERROR: ', e);
214
+ dispatch(createAction(SCAN_BADGE_ERROR)(e));
215
+ clearAccessToken();
216
+ return (e);
217
+ });
209
218
  }
210
219
 
211
220
  export const addToSchedule = (event) => async (dispatch, getState) => {
212
221
 
213
- const accessToken = await getAccessTokenSafely()
214
- .catch(() => {
215
- dispatch(stopLoading());
216
- return Promise.reject();
222
+ const accessToken = await getAccessTokenSafely()
223
+ .catch(() => {
224
+ dispatch(stopLoading());
225
+ return Promise.reject();
226
+ });
227
+
228
+ const url = `${getEnvVariable(SUMMIT_API_BASE_URL)}/api/v1/summits/${getEnvVariable(SUMMIT_ID)}/members/me/schedule/${event.id}`;
229
+
230
+ return axios.post(
231
+ url, {access_token: accessToken}
232
+ ).then(() => {
233
+ dispatch(createAction(ADD_TO_SCHEDULE)(event));
234
+ return event;
235
+ }).catch(e => {
236
+ console.log('ERROR: ', e);
237
+ Sentry.captureException(e)
238
+ return e;
217
239
  });
218
-
219
- const url = `${getEnvVariable(SUMMIT_API_BASE_URL)}/api/v1/summits/${getEnvVariable(SUMMIT_ID)}/members/me/schedule/${event.id}`;
220
-
221
- return axios.post(
222
- url, { access_token: accessToken }
223
- ).then(() => {
224
- dispatch(createAction(ADD_TO_SCHEDULE)(event));
225
- return event;
226
- }).catch(e => {
227
- console.log('ERROR: ', e);
228
- clearAccessToken();
229
- return e;
230
- });
231
240
  };
232
241
 
233
242
  export const removeFromSchedule = (event) => async (dispatch, getState) => {
234
243
 
235
- const accessToken = await getAccessTokenSafely()
236
- .catch(() => {
237
- dispatch(stopLoading());
238
- return Promise.reject();
244
+ const accessToken = await getAccessTokenSafely()
245
+ .catch(() => {
246
+ dispatch(stopLoading());
247
+ return Promise.reject();
248
+ });
249
+
250
+ const url = `${getEnvVariable(SUMMIT_API_BASE_URL)}/api/v1/summits/${getEnvVariable(SUMMIT_ID)}/members/me/schedule/${event.id}`;
251
+
252
+ return axios.delete(
253
+ url, {data: {access_token: accessToken}}
254
+ ).then(() => {
255
+ dispatch(createAction(REMOVE_FROM_SCHEDULE)(event));
256
+ return event;
257
+ }).catch(e => {
258
+ console.log('ERROR: ', e);
259
+ Sentry.captureException(e)
260
+ return e;
239
261
  });
262
+ };
240
263
 
241
- const url = `${getEnvVariable(SUMMIT_API_BASE_URL)}/api/v1/summits/${getEnvVariable(SUMMIT_ID)}/members/me/schedule/${event.id}`;
242
-
243
- return axios.delete(
244
- url, { data: { access_token: accessToken } }
245
- ).then(() => {
246
- dispatch(createAction(REMOVE_FROM_SCHEDULE)(event));
247
- return event;
248
- }).catch(e => {
249
- console.log('ERROR: ', e);
250
- clearAccessToken();
251
- return e;
252
- });
264
+ /************************************** RSVP **************************************************************************/
265
+
266
+ export const rsvpToEvent = (event) => async (dispatch, getState) => {
267
+
268
+ const accessToken = await getAccessTokenSafely()
269
+ .catch(() => {
270
+ dispatch(stopLoading());
271
+ return Promise.reject();
272
+ });
273
+
274
+ const url = `${getEnvVariable(SUMMIT_API_BASE_URL)}/api/v1/summits/${getEnvVariable(SUMMIT_ID)}/events/${event.id}/rsvp`;
275
+
276
+ return axios.post(
277
+ url, {
278
+ access_token: accessToken,
279
+ fields: 'event_id,seat_type',
280
+ relations: 'none',
281
+ }
282
+ ).then((payload) => {
283
+ const {data: rsvp} = payload;
284
+ dispatch(createAction(RSVP_CONFIRMED)(rsvp));
285
+ dispatch(createAction(ADD_TO_SCHEDULE)(event));
286
+ return rsvp;
287
+ }).catch(e => {
288
+ console.log('ERROR: ', e);
289
+ Swal.fire('Error', "There was an error at RSVP. Please retry.", "warning");
290
+ Sentry.captureException(e)
291
+ return e;
292
+ });
293
+ };
294
+
295
+ export const cancelRSVP = (event) => async (dispatch, getState) => {
296
+
297
+ const accessToken = await getAccessTokenSafely()
298
+ .catch(() => {
299
+ dispatch(stopLoading());
300
+ return Promise.reject();
301
+ });
302
+
303
+ const url = `${getEnvVariable(SUMMIT_API_BASE_URL)}/api/v1/summits/${getEnvVariable(SUMMIT_ID)}/events/${event.id}/unrsvp`;
304
+
305
+ return axios.delete(
306
+ url, {data: {
307
+ access_token: accessToken,
308
+ relations: 'none',
309
+ fields: 'id',
310
+ }}
311
+ ).then(() => {
312
+ dispatch(createAction(RSVP_CANCELLED)(event));
313
+ dispatch(createAction(REMOVE_FROM_SCHEDULE)(event));
314
+ return event;
315
+ }).catch(e => {
316
+ console.log('ERROR: ', e);
317
+ Swal.fire('Error', "There was an error at UnRSVP. Please retry.", "warning");
318
+ Sentry.captureException(e)
319
+ return e;
320
+ });
253
321
  };
254
322
 
323
+
255
324
  export const castPresentationVote = (presentation) => async (dispatch, getState) => {
256
325
 
257
- const accessToken = await getAccessTokenSafely()
258
- .catch(() => {
259
- dispatch(stopLoading());
260
- return Promise.reject();
261
- });
326
+ const accessToken = await getAccessTokenSafely()
327
+ .catch(() => {
328
+ dispatch(stopLoading());
329
+ return Promise.reject();
330
+ });
262
331
 
263
- const params = {
264
- access_token: accessToken,
265
- };
332
+ const params = {
333
+ access_token: accessToken,
334
+ };
266
335
 
267
- const errorHandler = (err) => (dispatch, state) => {
268
- const { status, response: { text } } = err;
269
- if (status === 412) {
270
- if (text.includes('already vote')) {
271
- // 'confirm' as local vote
272
- dispatch(createAction(TOGGLE_PRESENTATION_VOTE)({ presentation, isVoted: true }));
273
- } else if (text.includes('Max. allowed votes') ||
274
- text.includes('Member is not an attendee') ||
275
- // Voting Period for track group is closed
276
- text.includes('is closed')) {
336
+ const errorHandler = (err) => (dispatch, state) => {
337
+ const {status, response: {text}} = err;
338
+ if (status === 412) {
339
+ if (text.includes('already vote')) {
340
+ // 'confirm' as local vote
341
+ dispatch(createAction(TOGGLE_PRESENTATION_VOTE)({presentation, isVoted: true}));
342
+ } else if (text.includes('Max. allowed votes') ||
343
+ text.includes('Member is not an attendee') ||
344
+ // Voting Period for track group is closed
345
+ text.includes('is closed')) {
346
+ // need to revert button state
347
+ // first 'confirm' as local vote
348
+ dispatch(createAction(TOGGLE_PRESENTATION_VOTE)({presentation, isVoted: true}));
349
+ // inmediately remove vote
350
+ dispatch(createAction(TOGGLE_PRESENTATION_VOTE)({presentation, isVoted: false, reverting: true}));
351
+ }
352
+ } else {
353
+ console.log('castPresentationVote error code: ', status, text);
354
+ }
355
+ };
356
+
357
+ return postRequest(
358
+ createAction(CAST_PRESENTATION_VOTE_REQUEST),
359
+ createAction(CAST_PRESENTATION_VOTE_RESPONSE),
360
+ `${getEnvVariable('SUMMIT_API_BASE_URL')}/api/v1/summits/${getEnvVariable(SUMMIT_ID)}/presentations/${presentation.id}/attendee-votes`,
361
+ {},
362
+ errorHandler,
363
+ {presentation}
364
+ )(params)(dispatch).catch((e) => {
365
+ console.log('ERROR: ', e);
366
+ clearAccessToken();
277
367
  // need to revert button state
278
368
  // first 'confirm' as local vote
279
- dispatch(createAction(TOGGLE_PRESENTATION_VOTE)({ presentation, isVoted: true }));
369
+ dispatch(createAction(TOGGLE_PRESENTATION_VOTE)({presentation, isVoted: true}));
280
370
  // inmediately remove vote
281
- dispatch(createAction(TOGGLE_PRESENTATION_VOTE)({ presentation, isVoted: false, reverting: true }));
282
- }
283
- } else {
284
- console.log('castPresentationVote error code: ', status, text);
285
- }
286
- };
287
-
288
- return postRequest(
289
- createAction(CAST_PRESENTATION_VOTE_REQUEST),
290
- createAction(CAST_PRESENTATION_VOTE_RESPONSE),
291
- `${getEnvVariable('SUMMIT_API_BASE_URL')}/api/v1/summits/${getEnvVariable(SUMMIT_ID)}/presentations/${presentation.id}/attendee-votes`,
292
- {},
293
- errorHandler,
294
- { presentation }
295
- )(params)(dispatch).catch((e) => {
296
- console.log('ERROR: ', e);
297
- clearAccessToken();
298
- // need to revert button state
299
- // first 'confirm' as local vote
300
- dispatch(createAction(TOGGLE_PRESENTATION_VOTE)({ presentation, isVoted: true }));
301
- // inmediately remove vote
302
- dispatch(createAction(TOGGLE_PRESENTATION_VOTE)({ presentation, isVoted: false, reverting: true }));
303
- return e;
304
- });
371
+ dispatch(createAction(TOGGLE_PRESENTATION_VOTE)({presentation, isVoted: false, reverting: true}));
372
+ return e;
373
+ });
305
374
  };
306
375
 
307
376
  export const uncastPresentationVote = (presentation) => async (dispatch, getState) => {
308
377
 
309
- const accessToken = await getAccessTokenSafely()
310
- .catch(() => {
311
- dispatch(stopLoading());
312
- return Promise.reject();
313
- });
378
+ const accessToken = await getAccessTokenSafely()
379
+ .catch(() => {
380
+ dispatch(stopLoading());
381
+ return Promise.reject();
382
+ });
314
383
 
315
- const params = {
316
- access_token: accessToken,
317
- };
384
+ const params = {
385
+ access_token: accessToken,
386
+ };
318
387
 
319
- const errorHandler = (err) => (dispatch, state) => {
320
- const { status, response: { text } } = err;
321
- if (status === 412 && text.includes('Vote not found')) {
322
- // tried removing a vote not longer present in api
323
- // confirming removal
324
- dispatch(createAction(TOGGLE_PRESENTATION_VOTE)({ presentation, isVoted: false }));
325
- } else {
326
- console.log('uncastPresentationVote error code: ', status, text);
327
- }
328
- };
388
+ const errorHandler = (err) => (dispatch, state) => {
389
+ const {status, response: {text}} = err;
390
+ if (status === 412 && text.includes('Vote not found')) {
391
+ // tried removing a vote not longer present in api
392
+ // confirming removal
393
+ dispatch(createAction(TOGGLE_PRESENTATION_VOTE)({presentation, isVoted: false}));
394
+ } else {
395
+ console.log('uncastPresentationVote error code: ', status, text);
396
+ }
397
+ };
329
398
 
330
- return deleteRequest(
331
- createAction(UNCAST_PRESENTATION_VOTE_REQUEST),
332
- createAction(UNCAST_PRESENTATION_VOTE_RESPONSE)({ presentation }),
333
- `${getEnvVariable('SUMMIT_API_BASE_URL')}/api/v1/summits/${getEnvVariable(SUMMIT_ID)}/presentations/${presentation.id}/attendee-votes`,
334
- {},
335
- errorHandler,
336
- { presentation }
337
- )(params)(dispatch).catch((e) => {
338
- console.log('ERROR: ', e);
339
- clearAccessToken();
340
- return e;
341
- });
399
+ return deleteRequest(
400
+ createAction(UNCAST_PRESENTATION_VOTE_REQUEST),
401
+ createAction(UNCAST_PRESENTATION_VOTE_RESPONSE)({presentation}),
402
+ `${getEnvVariable('SUMMIT_API_BASE_URL')}/api/v1/summits/${getEnvVariable(SUMMIT_ID)}/presentations/${presentation.id}/attendee-votes`,
403
+ {},
404
+ errorHandler,
405
+ {presentation}
406
+ )(params)(dispatch).catch((e) => {
407
+ console.log('ERROR: ', e);
408
+ clearAccessToken();
409
+ return e;
410
+ });
342
411
  };
343
412
 
344
413
  export const updateProfilePicture = (pic) => async (dispatch) => {
345
414
 
346
- const accessToken = await getAccessTokenSafely()
347
- .catch(() => {
348
- dispatch(stopLoading());
349
- return Promise.reject();
350
- });
351
-
352
- let params = {
353
- access_token: accessToken,
354
- };
415
+ const accessToken = await getAccessTokenSafely()
416
+ .catch(() => {
417
+ dispatch(stopLoading());
418
+ return Promise.reject();
419
+ });
355
420
 
356
- dispatch(createAction(START_LOADING_IDP_PROFILE)());
421
+ let params = {
422
+ access_token: accessToken,
423
+ };
357
424
 
358
- putFile(
359
- null,
360
- createAction(UPDATE_PROFILE_PIC),
361
- `${window.IDP_BASE_URL}/api/v1/users/me/pic`,
362
- pic,
363
- {},
364
- customErrorHandler,
365
- )(params)(dispatch)
366
- .then(() => dispatch(getIDPProfile()))
367
- .catch((e) => {
368
- console.log('ERROR: ', e);
369
- dispatch(createAction(STOP_LOADING_IDP_PROFILE)())
370
- clearAccessToken();
371
- return e;
372
- });
425
+ dispatch(createAction(START_LOADING_IDP_PROFILE)());
426
+
427
+ putFile(
428
+ null,
429
+ createAction(UPDATE_PROFILE_PIC),
430
+ `${window.IDP_BASE_URL}/api/v1/users/me/pic`,
431
+ pic,
432
+ {},
433
+ customErrorHandler,
434
+ )(params)(dispatch)
435
+ .then(() => dispatch(getIDPProfile()))
436
+ .catch((e) => {
437
+ console.log('ERROR: ', e);
438
+ dispatch(createAction(STOP_LOADING_IDP_PROFILE)())
439
+ clearAccessToken();
440
+ return e;
441
+ });
373
442
  }
374
443
 
375
444
  export const updateProfile = (profile) => async (dispatch) => {
376
445
 
377
- const accessToken = await getAccessTokenSafely()
378
- .catch(() => {
379
- dispatch(stopLoading());
380
- return Promise.reject();
381
- });
382
-
383
- let params = {
384
- access_token: accessToken,
385
- };
446
+ const accessToken = await getAccessTokenSafely()
447
+ .catch(() => {
448
+ dispatch(stopLoading());
449
+ return Promise.reject();
450
+ });
386
451
 
387
- dispatch(createAction(START_LOADING_IDP_PROFILE)());
452
+ let params = {
453
+ access_token: accessToken,
454
+ };
388
455
 
389
- putRequest(
390
- null,
391
- createAction(UPDATE_IDP_PROFILE),
392
- `${window.IDP_BASE_URL}/api/v1/users/me`,
393
- profile,
394
- customErrorHandler
395
- )(params)(dispatch)
396
- .then(() => dispatch(getIDPProfile()))
397
- .catch((e) => {
398
- console.log('ERROR: ', e);
399
- dispatch(createAction(STOP_LOADING_IDP_PROFILE)());
400
- clearAccessToken();
401
- return e;
402
- });
456
+ dispatch(createAction(START_LOADING_IDP_PROFILE)());
457
+
458
+ putRequest(
459
+ null,
460
+ createAction(UPDATE_IDP_PROFILE),
461
+ `${window.IDP_BASE_URL}/api/v1/users/me`,
462
+ profile,
463
+ customErrorHandler
464
+ )(params)(dispatch)
465
+ .then(() => dispatch(getIDPProfile()))
466
+ .catch((e) => {
467
+ console.log('ERROR: ', e);
468
+ dispatch(createAction(STOP_LOADING_IDP_PROFILE)());
469
+ clearAccessToken();
470
+ return e;
471
+ });
403
472
  }
404
473
 
405
474
  export const updatePassword = (password) => async (dispatch) => {
406
475
 
407
- const accessToken = await getAccessTokenSafely()
408
- .catch(() => {
409
- dispatch(stopLoading());
410
- return Promise.reject();
411
- });
476
+ const accessToken = await getAccessTokenSafely()
477
+ .catch(() => {
478
+ dispatch(stopLoading());
479
+ return Promise.reject();
480
+ });
412
481
 
413
- let params = {
414
- access_token: accessToken,
415
- };
482
+ let params = {
483
+ access_token: accessToken,
484
+ };
416
485
 
417
- return putRequest(
418
- createAction(START_LOADING_IDP_PROFILE),
419
- createAction(UPDATE_PASSWORD),
420
- `${window.IDP_BASE_URL}/api/v1/users/me`,
421
- password,
422
- customErrorHandler
423
- )(params)(dispatch)
424
- .then(() => {
425
- dispatch(createAction(STOP_LOADING_IDP_PROFILE)());
426
- let msg = 'Password Updated';
427
- Swal.fire("Success", msg, "success");
428
- })
429
- .catch((e) => {
430
- console.log('ERROR: ', e);
431
- dispatch(createAction(STOP_LOADING_IDP_PROFILE)())
432
- clearAccessToken();
433
- return e;
434
- });
486
+ return putRequest(
487
+ createAction(START_LOADING_IDP_PROFILE),
488
+ createAction(UPDATE_PASSWORD),
489
+ `${window.IDP_BASE_URL}/api/v1/users/me`,
490
+ password,
491
+ customErrorHandler
492
+ )(params)(dispatch)
493
+ .then(() => {
494
+ dispatch(createAction(STOP_LOADING_IDP_PROFILE)());
495
+ let msg = 'Password Updated';
496
+ Swal.fire("Success", msg, "success");
497
+ })
498
+ .catch((e) => {
499
+ console.log('ERROR: ', e);
500
+ dispatch(createAction(STOP_LOADING_IDP_PROFILE)())
501
+ clearAccessToken();
502
+ return e;
503
+ });
435
504
  }
436
505
 
437
506
  export const saveAttendeeQuestions = (values, ticketId = null) => async (dispatch, getState) => {
438
507
 
439
- const { userState: { userProfile: { summit_tickets } } } = getState();
508
+ const {userState: {userProfile: {summit_tickets}}} = getState();
440
509
 
441
- const normalizedEntity = {...values};
510
+ const normalizedEntity = {...values};
442
511
 
443
- if (!values.attendee_company.id) {
444
- normalizedEntity['attendee_company'] = values.attendee_company.name;
445
- } else {
446
- delete(normalizedEntity['attendee_company']);
447
- normalizedEntity['attendee_company_id'] = values.attendee_company.id;
448
- }
449
-
450
- const accessToken = await getAccessTokenSafely()
451
- .catch(() => {
452
- dispatch(stopLoading());
453
- return Promise.reject();
454
- });
512
+ if (!values.attendee_company.id) {
513
+ normalizedEntity['attendee_company'] = values.attendee_company.name;
514
+ } else {
515
+ delete (normalizedEntity['attendee_company']);
516
+ normalizedEntity['attendee_company_id'] = values.attendee_company.id;
517
+ }
455
518
 
456
- let params = {
457
- access_token: accessToken,
458
- expand: 'owner, owner.extra_questions'
459
- };
519
+ const accessToken = await getAccessTokenSafely()
520
+ .catch(() => {
521
+ dispatch(stopLoading());
522
+ return Promise.reject();
523
+ });
460
524
 
461
- dispatch(startLoading());
525
+ let params = {
526
+ access_token: accessToken,
527
+ expand: 'owner, owner.extra_questions'
528
+ };
462
529
 
463
- return putRequest(
464
- null,
465
- createAction(UPDATE_EXTRA_QUESTIONS),
466
- `${window.API_BASE_URL}/api/v1/summits/all/orders/all/tickets/${ticketId ? ticketId : summit_tickets[0].id}`,
467
- normalizedEntity,
468
- customErrorHandler
469
- )(params)(dispatch).then(() => {
470
- dispatch(stopLoading());
471
- Swal.fire('Success', "Thank you, information saved", "success");
472
- dispatch(getUserProfile());
473
- navigate('/')
474
- }).catch(e => {
475
- dispatch(stopLoading());
476
- Swal.fire('Error', "Error saving your Attendee info. Please retry.", "warning");
477
- clearAccessToken();
478
- return e;
479
- });
530
+ dispatch(startLoading());
531
+
532
+ return putRequest(
533
+ null,
534
+ createAction(UPDATE_EXTRA_QUESTIONS),
535
+ `${window.API_BASE_URL}/api/v1/summits/all/orders/all/tickets/${ticketId ? ticketId : summit_tickets[0].id}`,
536
+ normalizedEntity,
537
+ customErrorHandler
538
+ )(params)(dispatch).then(() => {
539
+ dispatch(stopLoading());
540
+ Swal.fire('Success', "Thank you, information saved", "success");
541
+ dispatch(getUserProfile());
542
+ navigate('/')
543
+ }).catch(e => {
544
+ dispatch(stopLoading());
545
+ Swal.fire('Error', "Error saving your Attendee info. Please retry.", "warning");
546
+ clearAccessToken();
547
+ return e;
548
+ });
480
549
  };
481
550
 
482
551
  /**
@@ -484,63 +553,63 @@ export const saveAttendeeQuestions = (values, ticketId = null) => async (dispatc
484
553
  * @returns {function(*, *): *}
485
554
  */
486
555
  export const setPasswordlessLogin = (params) => (dispatch, getState) => {
487
- return dispatch(passwordlessLogin(params))
488
- .then((res) => {
489
- return dispatch(getUserProfile()).then(() => res);
490
- }).catch((e) => {
491
- console.log(e);
492
- return Promise.reject(e);
493
- })
556
+ return dispatch(passwordlessLogin(params))
557
+ .then((res) => {
558
+ return dispatch(getUserProfile()).then(() => res);
559
+ }).catch((e) => {
560
+ console.log(e);
561
+ return Promise.reject(e);
562
+ })
494
563
  }
495
564
 
496
565
  export const getScheduleSyncLink = () => async (dispatch) => {
497
566
 
498
- const accessToken = await getAccessTokenSafely()
499
- .catch(() => {
500
- dispatch(stopLoading());
501
- return Promise.reject();
502
- });
567
+ const accessToken = await getAccessTokenSafely()
568
+ .catch(() => {
569
+ dispatch(stopLoading());
570
+ return Promise.reject();
571
+ });
503
572
 
504
- let params = {
505
- access_token: accessToken,
506
- };
573
+ let params = {
574
+ access_token: accessToken,
575
+ };
507
576
 
508
- return postRequest(
509
- null,
510
- createAction(SCHEDULE_SYNC_LINK_RECEIVED),
511
- `${window.SUMMIT_API_BASE_URL}/api/v1/summits/${window.SUMMIT_ID}/members/me/schedule/shareable-link`,
512
- null,
513
- customErrorHandler,
514
- )(params)(dispatch).catch((e) => {
515
- console.log('ERROR: ', e);
516
- clearAccessToken();
517
- return e;
518
- });
577
+ return postRequest(
578
+ null,
579
+ createAction(SCHEDULE_SYNC_LINK_RECEIVED),
580
+ `${window.SUMMIT_API_BASE_URL}/api/v1/summits/${window.SUMMIT_ID}/members/me/schedule/shareable-link`,
581
+ null,
582
+ customErrorHandler,
583
+ )(params)(dispatch).catch((e) => {
584
+ console.log('ERROR: ', e);
585
+ clearAccessToken();
586
+ return e;
587
+ });
519
588
  };
520
589
 
521
590
  export const setUserOrder = (order) => (dispatch) => Promise.resolve().then(() => {
522
- return dispatch(createAction(SET_USER_ORDER)(order));
591
+ return dispatch(createAction(SET_USER_ORDER)(order));
523
592
  })
524
593
 
525
594
  export const checkOrderData = (order) => (dispatch, getState) => {
526
- if (!order) return;
527
-
528
- const { userState: { idpProfile: { company, given_name, family_name, email } } } = getState();
529
- const { owner_company, owner_first_name, owner_last_name, owner_email } = order || {};
530
-
531
- // only change data if I am the order owner
532
- if (owner_email === email && (owner_company !== company || owner_first_name !== given_name || owner_last_name !== family_name)) {
533
- const newProfile = {
534
- first_name: owner_first_name,
535
- last_name: owner_last_name,
536
- company: owner_company
537
- };
538
- dispatch(updateProfile(newProfile));
539
- }
595
+ if (!order) return;
596
+
597
+ const {userState: {idpProfile: {company, given_name, family_name, email}}} = getState();
598
+ const {owner_company, owner_first_name, owner_last_name, owner_email} = order || {};
599
+
600
+ // only change data if I am the order owner
601
+ if (owner_email === email && (owner_company !== company || owner_first_name !== given_name || owner_last_name !== family_name)) {
602
+ const newProfile = {
603
+ first_name: owner_first_name,
604
+ last_name: owner_last_name,
605
+ company: owner_company
606
+ };
607
+ dispatch(updateProfile(newProfile));
608
+ }
540
609
  }
541
610
 
542
611
  export const ticketOwnerChange = (ticket) => async (dispatch) => {
543
- return dispatch(createAction(TICKET_OWNER_CHANGED)(ticket));
612
+ return dispatch(createAction(TICKET_OWNER_CHANGED)(ticket));
544
613
  }
545
614
 
546
615
  /**
@@ -550,27 +619,27 @@ export const ticketOwnerChange = (ticket) => async (dispatch) => {
550
619
  */
551
620
  export const doVirtualCheckIn = (attendee) => async (dispatch, getState) => {
552
621
 
553
- const accessToken = await getAccessTokenSafely()
554
- .catch(() => {
555
- dispatch(stopLoading());
556
- return Promise.reject();
557
- });
622
+ const accessToken = await getAccessTokenSafely()
623
+ .catch(() => {
624
+ dispatch(stopLoading());
625
+ return Promise.reject();
626
+ });
558
627
 
559
- let params = {
560
- access_token: accessToken,
561
- };
628
+ let params = {
629
+ access_token: accessToken,
630
+ };
562
631
 
563
- return putRequest(
564
- null,
565
- createAction(UPDATE_EXTRA_QUESTIONS),
566
- `${window.API_BASE_URL}/api/v1/summits/${attendee.summit_id}/attendees/${attendee.id}/virtual-check-in`,
567
- {},
568
- voidErrorHandler
569
- )(params)(dispatch).catch((e) => {
570
- console.log('ERROR: ', e);
571
- clearAccessToken();
572
- return e;
573
- });
632
+ return putRequest(
633
+ null,
634
+ createAction(UPDATE_EXTRA_QUESTIONS),
635
+ `${window.API_BASE_URL}/api/v1/summits/${attendee.summit_id}/attendees/${attendee.id}/virtual-check-in`,
636
+ {},
637
+ voidErrorHandler
638
+ )(params)(dispatch).catch((e) => {
639
+ console.log('ERROR: ', e);
640
+ clearAccessToken();
641
+ return e;
642
+ });
574
643
  };
575
644
 
576
645
  /**
@@ -579,14 +648,14 @@ export const doVirtualCheckIn = (attendee) => async (dispatch, getState) => {
579
648
  * @returns {function(*=, *): *}
580
649
  */
581
650
  export const getInvitation = (token) => async (dispatch) => {
582
- dispatch(startLoading());
583
- return getRequest(
584
- createAction(REQUEST_INVITATION),
585
- createAction(RECEIVE_INVITATION),
586
- `${window.API_BASE_URL}/api/public/v1/summits/${window.SUMMIT_ID}/registration-invitations/${token}`,
587
- null
588
- )({})(dispatch)
589
- .finally(() => dispatch(stopLoading()));
651
+ dispatch(startLoading());
652
+ return getRequest(
653
+ createAction(REQUEST_INVITATION),
654
+ createAction(RECEIVE_INVITATION),
655
+ `${window.API_BASE_URL}/api/public/v1/summits/${window.SUMMIT_ID}/registration-invitations/${token}`,
656
+ null
657
+ )({})(dispatch)
658
+ .finally(() => dispatch(stopLoading()));
590
659
  }
591
660
 
592
661
  /**
@@ -595,15 +664,94 @@ export const getInvitation = (token) => async (dispatch) => {
595
664
  * @returns {function(*=, *): *}
596
665
  */
597
666
  export const rejectInvitation = (token) => async (dispatch) => {
598
- dispatch(startLoading());
599
- return deleteRequest(
667
+ dispatch(startLoading());
668
+ return deleteRequest(
669
+ null,
670
+ createAction(REJECT_INVITATION),
671
+ `${window.API_BASE_URL}/api/public/v1/summits/${window.SUMMIT_ID}/registration-invitations/${token}/reject`,
672
+ {},
673
+ null
674
+ )({})(dispatch)
675
+ .finally(() => dispatch(stopLoading()));
676
+ }
677
+
678
+
679
+ export const getRSVPInvitation = (token, eventId) => async (dispatch) => {
680
+ let params = {
681
+ fields: "status,event_id",
682
+ relations: "none"
683
+ };
684
+
685
+ return getRequest(
686
+ createAction(REQUEST_RSVP_INVITATION),
687
+ createAction(RECEIVE_RSVP_INVITATION),
688
+ `${window.API_BASE_URL}/api/public/v1/summits/${window.SUMMIT_ID}/events/${eventId}/rsvp-invitations/${token}`,
600
689
  null,
601
- createAction(REJECT_INVITATION),
602
- `${window.API_BASE_URL}/api/public/v1/summits/${window.SUMMIT_ID}/registration-invitations/${token}/reject`,
603
- {},
604
- null
605
- )({})(dispatch)
690
+ )(params)(dispatch)
691
+ .catch(({ err }) => {
692
+ let code = err.status;
693
+ let msg = '';
694
+ switch (code) {
695
+ case 401:
696
+ console.log('authErrorHandler 401 - re login');
697
+ expiredToken(err);
698
+ break;
699
+ case 404:
700
+ msg = "";
701
+ if (err.response.body && err.response.body.message) msg = err.response.body.message;
702
+ else if (err.response.error && err.response.error.message) msg = err.response.error.message;
703
+ else msg = err.message;
704
+ dispatch(createAction(RSVP_INVITATION_ERROR)({ errorMessage: msg }))
705
+ break;
706
+ case 412:
707
+ for (var [key, value] of Object.entries(err.response.body.errors)) {
708
+ if (isNaN(key)) {
709
+ msg += key + ': ';
710
+ }
711
+ msg += value + '<br>';
712
+ }
713
+ dispatch(createAction(RSVP_INVITATION_ERROR)({ errorMessage: msg }))
714
+ break;
715
+ default:
716
+ dispatch(createAction(RSVP_INVITATION_ERROR)({ errorMessage: "Internal Error. Please contact support " }))
717
+ break;
718
+ }
719
+ })
606
720
  .finally(() => dispatch(stopLoading()));
607
721
  }
608
722
 
723
+ export const acceptRSVPInvitation = (token, eventId) => async (dispatch) => {
609
724
 
725
+ let params = {
726
+ expand: "rsvp",
727
+ fields: "status,event_id,rsvp.seat_type,rsvp.event_id",
728
+ relations: "event.none,rsvp.none"
729
+ };
730
+
731
+ return putRequest(
732
+ null,
733
+ createAction(RSVP_INVITATION_ACCEPTED),
734
+ `${window.API_BASE_URL}/api/public/v1/summits/${window.SUMMIT_ID}/events/${eventId}/rsvp-invitations/${token}/accept`,
735
+ null,
736
+ customRSVPHandler
737
+ )(params)(dispatch)
738
+ .catch((err) => console.log("ERROR: ", err))
739
+ .finally(() => dispatch(stopLoading()));
740
+ }
741
+
742
+ export const declineRSVPInvitation = (token, eventId) => async (dispatch) => {
743
+ let params = {
744
+ fields: "status,event_id",
745
+ relations: "event.none"
746
+ };
747
+
748
+ return deleteRequest(
749
+ null,
750
+ createAction(RSVP_INVITATION_REJECTED),
751
+ `${window.API_BASE_URL}/api/public/v1/summits/${window.SUMMIT_ID}/events/${eventId}/rsvp-invitations/${token}/decline`,
752
+ null,
753
+ customRSVPHandler
754
+ )(params)(dispatch)
755
+ .catch((err) => console.log("ERROR: ", err))
756
+ .finally(() => dispatch(stopLoading()));
757
+ }