summit-registration-lite 3.0.0 → 3.0.1

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 +119 -24
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -377,6 +377,7 @@ const SET_PASSWORDLESS_LOGIN = 'SET_PASSWORDLESS_LOGIN';
377
377
  const SET_PASSWORDLESS_LENGTH = 'SET_PASSWORDLESS_LENGTH';
378
378
  const SET_PASSWORDLESS_ERROR = 'SET_PASSWORDLESS_ERROR';
379
379
  const GO_TO_LOGIN = 'GO_TO_LOGIN';
380
+ const GET_MY_INVITATION = 'GET_MY_INVITATION';
380
381
  const startWidgetLoading = (0,actions_namespaceObject.createAction)(START_WIDGET_LOADING);
381
382
  const stopWidgetLoading = (0,actions_namespaceObject.createAction)(STOP_WIDGET_LOADING);
382
383
  const loadSession = settings => dispatch => {
@@ -426,6 +427,7 @@ const getTaxesTypes = summitId => async (dispatch, getState, {
426
427
  }
427
428
  };
428
429
  const reserveTicket = ({
430
+ provider,
429
431
  personalInformation,
430
432
  ticket,
431
433
  ticketQuantity
@@ -495,7 +497,7 @@ const reserveTicket = ({
495
497
  payload.response.promo_code = promoCode || null;
496
498
 
497
499
  if (!payload.response.amount) {
498
- dispatch(payTicket(null, null, getAccessToken));
500
+ dispatch(payTicketWithProvider(provider));
499
501
  return payload;
500
502
  } else {
501
503
  dispatch(changeStep(2));
@@ -627,6 +629,45 @@ const normalizeReservation = entity => {
627
629
 
628
630
  return normalizedEntity;
629
631
  };
632
+ /**
633
+ *
634
+ * @param summitId
635
+ * @returns {(function(*=, *, {apiBaseUrl: *, getAccessToken: *}): Promise<*|undefined>)|*}
636
+ */
637
+
638
+
639
+ const getMyInvitation = summitId => async (dispatch, getState, {
640
+ apiBaseUrl,
641
+ getAccessToken
642
+ }) => {
643
+ const errorHandler = (err, res) => (dispatch, state) => {
644
+ if (res && res.statusCode === 404) {
645
+ // bypass
646
+ return;
647
+ }
648
+
649
+ if (res && res.statusCode === 500) {
650
+ const msg = res.body.message;
651
+ external_sweetalert2_default().fire("Server Error", msg, "error");
652
+ return;
653
+ }
654
+
655
+ return (0,actions_namespaceObject.authErrorHandler)(err, res)(dispatch, state);
656
+ };
657
+
658
+ try {
659
+ const accessToken = await getAccessToken();
660
+ let params = {
661
+ access_token: accessToken
662
+ };
663
+ dispatch(startWidgetLoading());
664
+ return (0,actions_namespaceObject.getRequest)(null, (0,actions_namespaceObject.createAction)(GET_MY_INVITATION), `${apiBaseUrl}/api/v1/summits/${summitId}/registration-invitations/me`, errorHandler)(params)(dispatch).then(() => {
665
+ dispatch(stopWidgetLoading());
666
+ });
667
+ } catch (e) {
668
+ return Promise.reject();
669
+ }
670
+ };
630
671
  ;// CONCATENATED MODULE: ./src/reducer.js
631
672
  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
673
 
@@ -660,6 +701,7 @@ const DEFAULT_STATE = {
660
701
  },
661
702
  ticketTypes: [],
662
703
  taxTypes: [],
704
+ invitation: null,
663
705
  settings: {
664
706
  apiBaseUrl: null,
665
707
  summitId: null,
@@ -803,7 +845,15 @@ const RegistrationLiteReducer = (state = DEFAULT_STATE, action) => {
803
845
  return reducer_objectSpread(reducer_objectSpread({}, state), {}, {
804
846
  checkout: payload.response,
805
847
  reservation: null,
806
- userProfile: null
848
+ userProfile: null,
849
+ invitation: null
850
+ });
851
+ }
852
+
853
+ case GET_MY_INVITATION:
854
+ {
855
+ return reducer_objectSpread(reducer_objectSpread({}, state), {}, {
856
+ invitation: payload.response
807
857
  });
808
858
  }
809
859
 
@@ -863,6 +913,9 @@ const getPersistor = () => {
863
913
  };
864
914
  ;// CONCATENATED MODULE: external "redux-persist/integration/react"
865
915
  const react_namespaceObject = require("redux-persist/integration/react");
916
+ ;// CONCATENATED MODULE: external "prop-types"
917
+ const external_prop_types_namespaceObject = require("prop-types");
918
+ var external_prop_types_default = /*#__PURE__*/__webpack_require__.n(external_prop_types_namespaceObject);
866
919
  ;// CONCATENATED MODULE: external "react-spring"
867
920
  const external_react_spring_namespaceObject = require("react-spring");
868
921
  ;// CONCATENATED MODULE: external "react-use"
@@ -898,9 +951,10 @@ const LoginComponent = ({
898
951
  allowsNativeAuth,
899
952
  allowsOtpAuthlogin,
900
953
  getLoginCode,
901
- getPasswordlessCode
954
+ getPasswordlessCode,
955
+ initialEmailValue = ''
902
956
  }) => {
903
- const [email, setEmail] = (0,external_react_namespaceObject.useState)('');
957
+ const [email, setEmail] = (0,external_react_namespaceObject.useState)(initialEmailValue);
904
958
  const [emailError, setEmailError] = (0,external_react_namespaceObject.useState)();
905
959
 
906
960
  const isValidEmail = email => {
@@ -981,8 +1035,6 @@ const LoginComponent = ({
981
1035
  };
982
1036
 
983
1037
  /* harmony default export */ const login = (LoginComponent);
984
- ;// CONCATENATED MODULE: external "prop-types"
985
- const external_prop_types_namespaceObject = require("prop-types");
986
1038
  ;// CONCATENATED MODULE: ./src/components/payment/index.module.scss
987
1039
  // extracted by mini-css-extract-plugin
988
1040
  /* harmony default export */ const payment_index_module = ({"title":"title___LksVm","form":"form___v5GIx","fieldWrapper":"fieldWrapper___Eoe61"});
@@ -1662,13 +1714,14 @@ const PersonalInfoComponent = ({
1662
1714
  summitId,
1663
1715
  handleCompanyError,
1664
1716
  formValues,
1665
- formErrors
1717
+ formErrors,
1718
+ invitation
1666
1719
  }) => {
1667
1720
  var _errors$email, _errors$email2;
1668
1721
 
1669
1722
  const [personalInfo, setPersonalInfo] = (0,external_react_namespaceObject.useState)({
1670
- firstName: userProfile.given_name || '',
1671
- lastName: userProfile.family_name || '',
1723
+ firstName: userProfile.given_name || (invitation ? invitation.first_name : ''),
1724
+ lastName: userProfile.family_name || (invitation ? invitation.last_name : ''),
1672
1725
  email: userProfile.email || '',
1673
1726
  company: {
1674
1727
  id: null,
@@ -2385,8 +2438,36 @@ const TicketOwnedComponent = ({
2385
2438
  };
2386
2439
 
2387
2440
  /* harmony default export */ const ticket_owned = (TicketOwnedComponent);
2441
+ ;// CONCATENATED MODULE: ./src/utils/utils.js
2442
+ /**
2443
+ * Copyright 2022 OpenStack Foundation
2444
+ * Licensed under the Apache License, Version 2.0 (the "License");
2445
+ * you may not use this file except in compliance with the License.
2446
+ * You may obtain a copy of the License at
2447
+ * http://www.apache.org/licenses/LICENSE-2.0
2448
+ * Unless required by applicable law or agreed to in writing, software
2449
+ * distributed under the License is distributed on an "AS IS" BASIS,
2450
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2451
+ * See the License for the specific language governing permissions and
2452
+ * limitations under the License.
2453
+ **/
2454
+ const getCurrentProvider = summit => {
2455
+ for (let profile of summit.payment_profiles) {
2456
+ if (profile.application_type === 'Registration') {
2457
+ return {
2458
+ publicKey: profile.test_mode_enabled ? profile.test_publishable_key : profile.live_publishable_key,
2459
+ provider: profile.provider
2460
+ };
2461
+ }
2462
+ }
2463
+
2464
+ return {
2465
+ publicKey: null,
2466
+ provider: ''
2467
+ };
2468
+ };
2388
2469
  ;// 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"];
2470
+ 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
2471
 
2391
2472
  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
2473
 
@@ -2427,6 +2508,8 @@ function registration_lite_objectWithoutPropertiesLoose(source, excluded) { if (
2427
2508
 
2428
2509
 
2429
2510
 
2511
+
2512
+
2430
2513
  const RegistrationLite = _ref => {
2431
2514
  var _formValues$ticketTyp, _formValues$ticketTyp2;
2432
2515
 
@@ -2470,7 +2553,10 @@ const RegistrationLite = _ref => {
2470
2553
  inPersonDisclaimer,
2471
2554
  userProfile,
2472
2555
  handleCompanyError,
2473
- stripeOptions
2556
+ stripeOptions,
2557
+ invitation,
2558
+ loginInitialEmailInputValue,
2559
+ getMyInvitation
2474
2560
  } = _ref,
2475
2561
  rest = registration_lite_objectWithoutProperties(_ref, registration_lite_excluded);
2476
2562
 
@@ -2496,17 +2582,10 @@ const RegistrationLite = _ref => {
2496
2582
  errors
2497
2583
  }));
2498
2584
 
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
-
2585
+ const {
2586
+ publicKey,
2587
+ provider
2588
+ } = getCurrentProvider(summitData);
2510
2589
  (0,external_react_namespaceObject.useEffect)(() => {
2511
2590
  loadSession(registration_lite_objectSpread(registration_lite_objectSpread({}, rest), {}, {
2512
2591
  summitData,
@@ -2522,9 +2601,15 @@ const RegistrationLite = _ref => {
2522
2601
  getTicketTypes(summitData.id).then(() => getTaxesTypes(summitData.id));
2523
2602
  }
2524
2603
  }, [summitData, profileData]);
2604
+ (0,external_react_namespaceObject.useEffect)(() => {
2605
+ if (summitData && profileData) {
2606
+ getMyInvitation(summitData.id).catch(e => console.log(e));
2607
+ }
2608
+ }, [summitData, profileData]);
2525
2609
  (0,external_react_namespaceObject.useEffect)(() => {
2526
2610
  if (step === 1 && formValues !== null && formValues !== void 0 && formValues.ticketType && formValues !== null && formValues !== void 0 && formValues.personalInformation) {
2527
2611
  reserveTicket({
2612
+ provider,
2528
2613
  personalInformation: formValues === null || formValues === void 0 ? void 0 : formValues.personalInformation,
2529
2614
  ticket: formValues === null || formValues === void 0 ? void 0 : formValues.ticketType,
2530
2615
  ticketQuantity: formValues === null || formValues === void 0 ? void 0 : formValues.ticketQuantity
@@ -2590,7 +2675,8 @@ const RegistrationLite = _ref => {
2590
2675
  allowsOtpAuth: allowsOtpAuth,
2591
2676
  login: provider => rest.authUser(provider),
2592
2677
  getLoginCode: getLoginCode,
2593
- getPasswordlessCode: getPasswordlessCode
2678
+ getPasswordlessCode: getPasswordlessCode,
2679
+ initialEmailValue: loginInitialEmailInputValue
2594
2680
  }), !profileData && passwordlessCodeSent && /*#__PURE__*/external_react_default().createElement(login_passwordless, {
2595
2681
  codeLength: passwordlessCode,
2596
2682
  email: passwordlessEmail,
@@ -2614,6 +2700,7 @@ const RegistrationLite = _ref => {
2614
2700
  isActive: step === 1,
2615
2701
  reservation: reservation,
2616
2702
  userProfile: profileData,
2703
+ invitation: invitation,
2617
2704
  summitId: summitData.id,
2618
2705
  changeForm: personalInformation => setFormValues(registration_lite_objectSpread(registration_lite_objectSpread({}, formValues), {}, {
2619
2706
  personalInformation
@@ -2655,6 +2742,7 @@ const registration_lite_mapStateToProps = ({
2655
2742
  }) => ({
2656
2743
  widgetLoading: registrationLiteState.widgetLoading,
2657
2744
  reservation: registrationLiteState.reservation,
2745
+ invitation: registrationLiteState.invitation,
2658
2746
  userProfile: registrationLiteState.settings.userProfile,
2659
2747
  checkout: registrationLiteState.checkout,
2660
2748
  ticketTypes: registrationLiteState.ticketTypes,
@@ -2666,6 +2754,12 @@ const registration_lite_mapStateToProps = ({
2666
2754
  passwordlessCodeError: registrationLiteState.passwordless.error
2667
2755
  });
2668
2756
 
2757
+ RegistrationLite.defaultProps = {
2758
+ loginInitialEmailInputValue: ''
2759
+ };
2760
+ RegistrationLite.propTypes = {
2761
+ loginInitialEmailInputValue: (external_prop_types_default()).string
2762
+ };
2669
2763
  /* harmony default export */ const registration_lite = ((0,external_react_redux_namespaceObject.connect)(registration_lite_mapStateToProps, {
2670
2764
  loadSession: loadSession,
2671
2765
  changeStep: changeStep,
@@ -2676,7 +2770,8 @@ const registration_lite_mapStateToProps = ({
2676
2770
  getTaxesTypes: getTaxesTypes,
2677
2771
  getLoginCode: getLoginCode,
2678
2772
  passwordlessLogin: passwordlessLogin,
2679
- goToLogin: goToLogin
2773
+ goToLogin: goToLogin,
2774
+ getMyInvitation: getMyInvitation
2680
2775
  })(RegistrationLite));
2681
2776
  ;// CONCATENATED MODULE: ./src/summit-registration-lite.js
2682
2777
  /**
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.1",
4
4
  "description": "Summit Registration Lite",
5
5
  "main": "index.js",
6
6
  "scripts": {