summit-registration-lite 3.0.0 → 3.0.3

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 (2) hide show
  1. package/dist/index.js +155 -65
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -90,7 +90,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
90
90
 
91
91
 
92
92
 
93
-
94
93
  class LawPayProvider {
95
94
  constructor({
96
95
  reservation,
@@ -101,9 +100,9 @@ class LawPayProvider {
101
100
  dispatch: _dispatch
102
101
  }) {
103
102
  _defineProperty(this, "payTicket", ({
104
- token
103
+ token = null
105
104
  }) => async dispatch => {
106
- var _this$userProfile, _this$userProfile2, _this$userProfile3, _this$userProfile4;
105
+ var _this$userProfile, _this$userProfile2, _this$userProfile3, _this$userProfile4, _this$userProfile5, _this$userProfile6;
107
106
 
108
107
  // Pay using affinity lawpay
109
108
  const errorHandler = (err, res) => (dispatch, state) => {
@@ -135,44 +134,31 @@ class LawPayProvider {
135
134
  expand: 'tickets,' + 'tickets.owner,' + 'tickets.owner.extra_questions,' + 'tickets.badge,' + 'tickets.badge.type,' + 'tickets.badge.type.access_levels,' + 'tickets.badge.type.features,' + 'tickets.ticket_type,' + 'tickets.ticket_type.taxes'
136
135
  };
137
136
  let normalizedEntity = {
138
- billing_address_1: token.address1 || '',
139
- billing_address_2: ((_this$userProfile = this.userProfile) === null || _this$userProfile === void 0 ? void 0 : _this$userProfile.address2) || '',
140
- billing_address_zip_code: token.postal_code,
141
- billing_address_city: ((_this$userProfile2 = this.userProfile) === null || _this$userProfile2 === void 0 ? void 0 : _this$userProfile2.locality) || '',
142
- billing_address_state: ((_this$userProfile3 = this.userProfile) === null || _this$userProfile3 === void 0 ? void 0 : _this$userProfile3.region) || '',
143
- billing_address_country: ((_this$userProfile4 = this.userProfile) === null || _this$userProfile4 === void 0 ? void 0 : _this$userProfile4.country) || '',
144
- payment_method_id: token.id
137
+ billing_address_1: token ? token.address1 : ((_this$userProfile = this.userProfile) === null || _this$userProfile === void 0 ? void 0 : _this$userProfile.address1) || '',
138
+ billing_address_2: ((_this$userProfile2 = this.userProfile) === null || _this$userProfile2 === void 0 ? void 0 : _this$userProfile2.address2) || '',
139
+ billing_address_zip_code: token ? token.postal_code : ((_this$userProfile3 = this.userProfile) === null || _this$userProfile3 === void 0 ? void 0 : _this$userProfile3.postal_code) || '',
140
+ billing_address_city: ((_this$userProfile4 = this.userProfile) === null || _this$userProfile4 === void 0 ? void 0 : _this$userProfile4.locality) || '',
141
+ billing_address_state: ((_this$userProfile5 = this.userProfile) === null || _this$userProfile5 === void 0 ? void 0 : _this$userProfile5.region) || '',
142
+ billing_address_country: ((_this$userProfile6 = this.userProfile) === null || _this$userProfile6 === void 0 ? void 0 : _this$userProfile6.country) || ''
145
143
  };
146
- this.dispatch(startWidgetLoading());
147
144
 
148
- if (this.reservation.amount > 0) {
149
- return (0,actions_namespaceObject.putRequest)(null, (0,actions_namespaceObject.createAction)(PAY_RESERVATION), `${this.apiBaseUrl}/api/v1/summits/${this.summitId}/orders/${this.reservation.hash}/checkout`, normalizedEntity, errorHandler // entity
150
- )(params)(this.dispatch).then(payload => {
151
- this.dispatch(stopWidgetLoading());
152
- this.dispatch((0,actions_namespaceObject.createAction)(CLEAR_RESERVATION)({}));
153
- this.dispatch(changeStep(3));
154
- return payload;
155
- }).catch(e => {
156
- this.dispatch(removeReservedTicket());
157
- this.dispatch(changeStep(1));
158
- this.dispatch(stopWidgetLoading());
159
- return e;
160
- }); // The payment has succeeded. Display a success message.
161
- } else {
162
- // FREE TICKET
163
- return (0,actions_namespaceObject.putRequest)(null, (0,actions_namespaceObject.createAction)(PAY_RESERVATION), `${this.apiBaseUrl}/api/v1/summits/${this.summitId}/orders/${this.reservation.hash}/checkout`, normalizedEntity, errorHandler // entity
164
- )(params)(this.dispatch).then(payload => {
165
- this.dispatch(stopWidgetLoading());
166
- this.dispatch((0,actions_namespaceObject.createAction)(CLEAR_RESERVATION)({}));
167
- this.dispatch(changeStep(3));
168
- return payload;
169
- }).catch(e => {
170
- this.dispatch(removeReservedTicket());
171
- this.dispatch(changeStep(1));
172
- this.dispatch(stopWidgetLoading());
173
- return e;
174
- }); // The payment has succeeded. Display a success message.
145
+ if (token) {
146
+ normalizedEntity['payment_method_id'] = token.id;
175
147
  }
148
+
149
+ this.dispatch(startWidgetLoading());
150
+ return (0,actions_namespaceObject.putRequest)(null, (0,actions_namespaceObject.createAction)(PAY_RESERVATION), `${this.apiBaseUrl}/api/v1/summits/${this.summitId}/orders/${this.reservation.hash}/checkout`, normalizedEntity, errorHandler // entity
151
+ )(params)(this.dispatch).then(payload => {
152
+ this.dispatch(stopWidgetLoading());
153
+ this.dispatch((0,actions_namespaceObject.createAction)(CLEAR_RESERVATION)({}));
154
+ this.dispatch(changeStep(3));
155
+ return payload;
156
+ }).catch(e => {
157
+ this.dispatch(removeReservedTicket());
158
+ this.dispatch(changeStep(1));
159
+ this.dispatch(stopWidgetLoading());
160
+ return e;
161
+ }); // The payment has succeeded. Display a success message.
176
162
  });
177
163
 
178
164
  this.reservation = reservation;
@@ -377,6 +363,8 @@ const SET_PASSWORDLESS_LOGIN = 'SET_PASSWORDLESS_LOGIN';
377
363
  const SET_PASSWORDLESS_LENGTH = 'SET_PASSWORDLESS_LENGTH';
378
364
  const SET_PASSWORDLESS_ERROR = 'SET_PASSWORDLESS_ERROR';
379
365
  const GO_TO_LOGIN = 'GO_TO_LOGIN';
366
+ const GET_MY_INVITATION = 'GET_MY_INVITATION';
367
+ const CLEAR_MY_INVITATION = 'CLEAR_MY_INVITATION';
380
368
  const startWidgetLoading = (0,actions_namespaceObject.createAction)(START_WIDGET_LOADING);
381
369
  const stopWidgetLoading = (0,actions_namespaceObject.createAction)(STOP_WIDGET_LOADING);
382
370
  const loadSession = settings => dispatch => {
@@ -426,6 +414,7 @@ const getTaxesTypes = summitId => async (dispatch, getState, {
426
414
  }
427
415
  };
428
416
  const reserveTicket = ({
417
+ provider,
429
418
  personalInformation,
430
419
  ticket,
431
420
  ticketQuantity
@@ -495,12 +484,12 @@ const reserveTicket = ({
495
484
  payload.response.promo_code = promoCode || null;
496
485
 
497
486
  if (!payload.response.amount) {
498
- dispatch(payTicket(null, null, getAccessToken));
499
- return payload;
500
- } else {
501
- dispatch(changeStep(2));
487
+ dispatch(payTicketWithProvider(provider));
502
488
  return payload;
503
489
  }
490
+
491
+ dispatch(changeStep(2));
492
+ return payload;
504
493
  }).catch(e => {
505
494
  dispatch((0,actions_namespaceObject.createAction)(CREATE_RESERVATION_ERROR)(e));
506
495
  dispatch(stopWidgetLoading());
@@ -627,6 +616,45 @@ const normalizeReservation = entity => {
627
616
 
628
617
  return normalizedEntity;
629
618
  };
619
+ /**
620
+ *
621
+ * @param summitId
622
+ * @returns {(function(*=, *, {apiBaseUrl: *, getAccessToken: *}): Promise<*|undefined>)|*}
623
+ */
624
+
625
+
626
+ const getMyInvitation = summitId => async (dispatch, getState, {
627
+ apiBaseUrl,
628
+ getAccessToken
629
+ }) => {
630
+ const errorHandler = (err, res) => (dispatch, state) => {
631
+ if (res && res.statusCode === 404) {
632
+ // bypass
633
+ return;
634
+ }
635
+
636
+ if (res && res.statusCode === 500) {
637
+ const msg = res.body.message;
638
+ external_sweetalert2_default().fire("Server Error", msg, "error");
639
+ return;
640
+ }
641
+
642
+ return (0,actions_namespaceObject.authErrorHandler)(err, res)(dispatch, state);
643
+ };
644
+
645
+ try {
646
+ const accessToken = await getAccessToken();
647
+ let params = {
648
+ access_token: accessToken
649
+ };
650
+ dispatch(startWidgetLoading());
651
+ return (0,actions_namespaceObject.getRequest)((0,actions_namespaceObject.createAction)(CLEAR_MY_INVITATION), (0,actions_namespaceObject.createAction)(GET_MY_INVITATION), `${apiBaseUrl}/api/v1/summits/${summitId}/registration-invitations/me`, errorHandler)(params)(dispatch).then(() => {
652
+ dispatch(stopWidgetLoading());
653
+ });
654
+ } catch (e) {
655
+ return Promise.reject();
656
+ }
657
+ };
630
658
  ;// CONCATENATED MODULE: ./src/reducer.js
631
659
  function reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
632
660
 
@@ -660,6 +688,7 @@ const DEFAULT_STATE = {
660
688
  },
661
689
  ticketTypes: [],
662
690
  taxTypes: [],
691
+ invitation: null,
663
692
  settings: {
664
693
  apiBaseUrl: null,
665
694
  summitId: null,
@@ -705,6 +734,7 @@ const RegistrationLiteReducer = (state = DEFAULT_STATE, action) => {
705
734
  return reducer_objectSpread(reducer_objectSpread({}, state), {}, {
706
735
  reservation: null,
707
736
  checkout: null,
737
+ invitation: null,
708
738
  passwordless: reducer_objectSpread({}, DEFAULT_STATE.passwordless),
709
739
  settings: reducer_objectSpread(reducer_objectSpread({}, DEFAULT_STATE.settings), {}, {
710
740
  marketingData: marketingData,
@@ -803,7 +833,22 @@ const RegistrationLiteReducer = (state = DEFAULT_STATE, action) => {
803
833
  return reducer_objectSpread(reducer_objectSpread({}, state), {}, {
804
834
  checkout: payload.response,
805
835
  reservation: null,
806
- userProfile: null
836
+ userProfile: null,
837
+ invitation: null
838
+ });
839
+ }
840
+
841
+ case GET_MY_INVITATION:
842
+ {
843
+ return reducer_objectSpread(reducer_objectSpread({}, state), {}, {
844
+ invitation: payload.response
845
+ });
846
+ }
847
+
848
+ case CLEAR_MY_INVITATION:
849
+ {
850
+ return reducer_objectSpread(reducer_objectSpread({}, state), {}, {
851
+ invitation: null
807
852
  });
808
853
  }
809
854
 
@@ -863,6 +908,9 @@ const getPersistor = () => {
863
908
  };
864
909
  ;// CONCATENATED MODULE: external "redux-persist/integration/react"
865
910
  const react_namespaceObject = require("redux-persist/integration/react");
911
+ ;// CONCATENATED MODULE: external "prop-types"
912
+ const external_prop_types_namespaceObject = require("prop-types");
913
+ var external_prop_types_default = /*#__PURE__*/__webpack_require__.n(external_prop_types_namespaceObject);
866
914
  ;// CONCATENATED MODULE: external "react-spring"
867
915
  const external_react_spring_namespaceObject = require("react-spring");
868
916
  ;// CONCATENATED MODULE: external "react-use"
@@ -898,9 +946,10 @@ const LoginComponent = ({
898
946
  allowsNativeAuth,
899
947
  allowsOtpAuthlogin,
900
948
  getLoginCode,
901
- getPasswordlessCode
949
+ getPasswordlessCode,
950
+ initialEmailValue = ''
902
951
  }) => {
903
- const [email, setEmail] = (0,external_react_namespaceObject.useState)('');
952
+ const [email, setEmail] = (0,external_react_namespaceObject.useState)(initialEmailValue);
904
953
  const [emailError, setEmailError] = (0,external_react_namespaceObject.useState)();
905
954
 
906
955
  const isValidEmail = email => {
@@ -981,8 +1030,6 @@ const LoginComponent = ({
981
1030
  };
982
1031
 
983
1032
  /* harmony default export */ const login = (LoginComponent);
984
- ;// CONCATENATED MODULE: external "prop-types"
985
- const external_prop_types_namespaceObject = require("prop-types");
986
1033
  ;// CONCATENATED MODULE: ./src/components/payment/index.module.scss
987
1034
  // extracted by mini-css-extract-plugin
988
1035
  /* harmony default export */ const payment_index_module = ({"title":"title___LksVm","form":"form___v5GIx","fieldWrapper":"fieldWrapper___Eoe61"});
@@ -1662,13 +1709,14 @@ const PersonalInfoComponent = ({
1662
1709
  summitId,
1663
1710
  handleCompanyError,
1664
1711
  formValues,
1665
- formErrors
1712
+ formErrors,
1713
+ invitation
1666
1714
  }) => {
1667
1715
  var _errors$email, _errors$email2;
1668
1716
 
1669
1717
  const [personalInfo, setPersonalInfo] = (0,external_react_namespaceObject.useState)({
1670
- firstName: userProfile.given_name || '',
1671
- lastName: userProfile.family_name || '',
1718
+ firstName: userProfile.given_name || (invitation ? invitation.first_name : ''),
1719
+ lastName: userProfile.family_name || (invitation ? invitation.last_name : ''),
1672
1720
  email: userProfile.email || '',
1673
1721
  company: {
1674
1722
  id: null,
@@ -2385,8 +2433,36 @@ const TicketOwnedComponent = ({
2385
2433
  };
2386
2434
 
2387
2435
  /* harmony default export */ const ticket_owned = (TicketOwnedComponent);
2436
+ ;// CONCATENATED MODULE: ./src/utils/utils.js
2437
+ /**
2438
+ * Copyright 2022 OpenStack Foundation
2439
+ * Licensed under the Apache License, Version 2.0 (the "License");
2440
+ * you may not use this file except in compliance with the License.
2441
+ * You may obtain a copy of the License at
2442
+ * http://www.apache.org/licenses/LICENSE-2.0
2443
+ * Unless required by applicable law or agreed to in writing, software
2444
+ * distributed under the License is distributed on an "AS IS" BASIS,
2445
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2446
+ * See the License for the specific language governing permissions and
2447
+ * limitations under the License.
2448
+ **/
2449
+ const getCurrentProvider = summit => {
2450
+ for (let profile of summit.payment_profiles) {
2451
+ if (profile.application_type === 'Registration') {
2452
+ return {
2453
+ publicKey: profile.test_mode_enabled ? profile.test_publishable_key : profile.live_publishable_key,
2454
+ provider: profile.provider
2455
+ };
2456
+ }
2457
+ }
2458
+
2459
+ return {
2460
+ publicKey: null,
2461
+ provider: ''
2462
+ };
2463
+ };
2388
2464
  ;// CONCATENATED MODULE: ./src/components/registration-lite.js
2389
- const registration_lite_excluded = ["loadSession", "setMarketingSettings", "changeStep", "removeReservedTicket", "reserveTicket", "payTicketWithProvider", "onPurchaseComplete", "getTicketTypes", "getTaxesTypes", "getLoginCode", "passwordlessLogin", "goToLogin", "loginOptions", "allowsNativeAuth", "allowsOtpAuth", "reservation", "checkout", "ticketTypes", "taxTypes", "step", "passwordlessCodeSent", "passwordlessEmail", "passwordlessCode", "getPasswordlessCode", "passwordlessCodeError", "loginWithCode", "goToExtraQuestions", "goToEvent", "goToRegistration", "profileData", "summitData", "supportEmail", "ticketOwned", "ownedTickets", "widgetLoading", "loading", "inPersonDisclaimer", "userProfile", "handleCompanyError", "stripeOptions"];
2465
+ const registration_lite_excluded = ["loadSession", "setMarketingSettings", "changeStep", "removeReservedTicket", "reserveTicket", "payTicketWithProvider", "onPurchaseComplete", "getTicketTypes", "getTaxesTypes", "getLoginCode", "passwordlessLogin", "goToLogin", "loginOptions", "allowsNativeAuth", "allowsOtpAuth", "reservation", "checkout", "ticketTypes", "taxTypes", "step", "passwordlessCodeSent", "passwordlessEmail", "passwordlessCode", "getPasswordlessCode", "passwordlessCodeError", "loginWithCode", "goToExtraQuestions", "goToEvent", "goToRegistration", "profileData", "summitData", "supportEmail", "ticketOwned", "ownedTickets", "widgetLoading", "loading", "inPersonDisclaimer", "userProfile", "handleCompanyError", "stripeOptions", "invitation", "loginInitialEmailInputValue", "getMyInvitation"];
2390
2466
 
2391
2467
  function registration_lite_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2392
2468
 
@@ -2427,6 +2503,8 @@ function registration_lite_objectWithoutPropertiesLoose(source, excluded) { if (
2427
2503
 
2428
2504
 
2429
2505
 
2506
+
2507
+
2430
2508
  const RegistrationLite = _ref => {
2431
2509
  var _formValues$ticketTyp, _formValues$ticketTyp2;
2432
2510
 
@@ -2470,7 +2548,10 @@ const RegistrationLite = _ref => {
2470
2548
  inPersonDisclaimer,
2471
2549
  userProfile,
2472
2550
  handleCompanyError,
2473
- stripeOptions
2551
+ stripeOptions,
2552
+ invitation,
2553
+ loginInitialEmailInputValue,
2554
+ getMyInvitation
2474
2555
  } = _ref,
2475
2556
  rest = registration_lite_objectWithoutProperties(_ref, registration_lite_excluded);
2476
2557
 
@@ -2496,17 +2577,10 @@ const RegistrationLite = _ref => {
2496
2577
  errors
2497
2578
  }));
2498
2579
 
2499
- let publicKey = null;
2500
- let provider = '';
2501
-
2502
- for (let profile of summitData.payment_profiles) {
2503
- if (profile.application_type === 'Registration') {
2504
- publicKey = profile.test_mode_enabled ? profile.test_publishable_key : profile.live_publishable_key;
2505
- provider = profile.provider;
2506
- break;
2507
- }
2508
- }
2509
-
2580
+ const {
2581
+ publicKey,
2582
+ provider
2583
+ } = getCurrentProvider(summitData);
2510
2584
  (0,external_react_namespaceObject.useEffect)(() => {
2511
2585
  loadSession(registration_lite_objectSpread(registration_lite_objectSpread({}, rest), {}, {
2512
2586
  summitData,
@@ -2522,9 +2596,15 @@ const RegistrationLite = _ref => {
2522
2596
  getTicketTypes(summitData.id).then(() => getTaxesTypes(summitData.id));
2523
2597
  }
2524
2598
  }, [summitData, profileData]);
2599
+ (0,external_react_namespaceObject.useEffect)(() => {
2600
+ if (summitData && profileData) {
2601
+ getMyInvitation(summitData.id).catch(e => console.log(e));
2602
+ }
2603
+ }, [summitData, profileData]);
2525
2604
  (0,external_react_namespaceObject.useEffect)(() => {
2526
2605
  if (step === 1 && formValues !== null && formValues !== void 0 && formValues.ticketType && formValues !== null && formValues !== void 0 && formValues.personalInformation) {
2527
2606
  reserveTicket({
2607
+ provider,
2528
2608
  personalInformation: formValues === null || formValues === void 0 ? void 0 : formValues.personalInformation,
2529
2609
  ticket: formValues === null || formValues === void 0 ? void 0 : formValues.ticketType,
2530
2610
  ticketQuantity: formValues === null || formValues === void 0 ? void 0 : formValues.ticketQuantity
@@ -2590,7 +2670,8 @@ const RegistrationLite = _ref => {
2590
2670
  allowsOtpAuth: allowsOtpAuth,
2591
2671
  login: provider => rest.authUser(provider),
2592
2672
  getLoginCode: getLoginCode,
2593
- getPasswordlessCode: getPasswordlessCode
2673
+ getPasswordlessCode: getPasswordlessCode,
2674
+ initialEmailValue: loginInitialEmailInputValue
2594
2675
  }), !profileData && passwordlessCodeSent && /*#__PURE__*/external_react_default().createElement(login_passwordless, {
2595
2676
  codeLength: passwordlessCode,
2596
2677
  email: passwordlessEmail,
@@ -2614,6 +2695,7 @@ const RegistrationLite = _ref => {
2614
2695
  isActive: step === 1,
2615
2696
  reservation: reservation,
2616
2697
  userProfile: profileData,
2698
+ invitation: invitation,
2617
2699
  summitId: summitData.id,
2618
2700
  changeForm: personalInformation => setFormValues(registration_lite_objectSpread(registration_lite_objectSpread({}, formValues), {}, {
2619
2701
  personalInformation
@@ -2655,6 +2737,7 @@ const registration_lite_mapStateToProps = ({
2655
2737
  }) => ({
2656
2738
  widgetLoading: registrationLiteState.widgetLoading,
2657
2739
  reservation: registrationLiteState.reservation,
2740
+ invitation: registrationLiteState.invitation,
2658
2741
  userProfile: registrationLiteState.settings.userProfile,
2659
2742
  checkout: registrationLiteState.checkout,
2660
2743
  ticketTypes: registrationLiteState.ticketTypes,
@@ -2666,6 +2749,12 @@ const registration_lite_mapStateToProps = ({
2666
2749
  passwordlessCodeError: registrationLiteState.passwordless.error
2667
2750
  });
2668
2751
 
2752
+ RegistrationLite.defaultProps = {
2753
+ loginInitialEmailInputValue: ''
2754
+ };
2755
+ RegistrationLite.propTypes = {
2756
+ loginInitialEmailInputValue: (external_prop_types_default()).string
2757
+ };
2669
2758
  /* harmony default export */ const registration_lite = ((0,external_react_redux_namespaceObject.connect)(registration_lite_mapStateToProps, {
2670
2759
  loadSession: loadSession,
2671
2760
  changeStep: changeStep,
@@ -2676,7 +2765,8 @@ const registration_lite_mapStateToProps = ({
2676
2765
  getTaxesTypes: getTaxesTypes,
2677
2766
  getLoginCode: getLoginCode,
2678
2767
  passwordlessLogin: passwordlessLogin,
2679
- goToLogin: goToLogin
2768
+ goToLogin: goToLogin,
2769
+ getMyInvitation: getMyInvitation
2680
2770
  })(RegistrationLite));
2681
2771
  ;// CONCATENATED MODULE: ./src/summit-registration-lite.js
2682
2772
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "summit-registration-lite",
3
- "version": "3.0.0",
3
+ "version": "3.0.3",
4
4
  "description": "Summit Registration Lite",
5
5
  "main": "index.js",
6
6
  "scripts": {