summit-registration-lite 5.0.24 → 5.0.25

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.
package/dist/index.js CHANGED
@@ -514,12 +514,44 @@ const actions_namespaceObject = require("openstack-uicore-foundation/lib/utils/a
514
514
  ;// CONCATENATED MODULE: external "sweetalert2"
515
515
  const external_sweetalert2_namespaceObject = require("sweetalert2");
516
516
  var external_sweetalert2_default = /*#__PURE__*/__webpack_require__.n(external_sweetalert2_namespaceObject);
517
+ ;// CONCATENATED MODULE: ./src/utils/constants.js
518
+ /**
519
+ * Copyright 2022 OpenStack Foundation
520
+ * Licensed under the Apache License, Version 2.0 (the "License");
521
+ * you may not use this file except in compliance with the License.
522
+ * You may obtain a copy of the License at
523
+ * http://www.apache.org/licenses/LICENSE-2.0
524
+ * Unless required by applicable law or agreed to in writing, software
525
+ * distributed under the License is distributed on an "AS IS" BASIS,
526
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
527
+ * See the License for the specific language governing permissions and
528
+ * limitations under the License.
529
+ **/
530
+ const AUTH_ERROR_MESSAGE = 'Missing Auth info';
531
+ const AUTH_ERROR_MISSING_REFRESH_TOKEN = "missing Refresh Token";
532
+ const AUTH_ERROR_REQUEST_FAILED = 'Request failed';
533
+ const VirtualAccessLevel = 'VIRTUAL';
534
+ const DefaultBGColor = '#000000';
535
+ const DefaultTextColor = '#FFFFFF';
536
+ const DefaultHintColor = 'rgb(58, 63, 65)';
537
+ const EMAIL_REGEXP = /(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
538
+ const TICKET_OWNER_MYSELF = 'myself';
539
+ const TICKET_OWNER_SOMEONE = 'someoneElse';
540
+ const TICKET_OWNER_UNASSIGNED = 'unassigned';
541
+ const TICKET_TYPE_SUBTYPE_PREPAID = 'PrePaid';
542
+ const ORDER_STATUS_PAID = 'Paid';
543
+ const ORDER_PAYMENT_METHOD_OFFLINE = 'Offline';
544
+ const STEP_SELECT_TICKET_TYPE = 0;
545
+ const STEP_PERSONAL_INFO = 1;
546
+ const STEP_PAYMENT = 2;
547
+ const STEP_COMPLETE = 3;
517
548
  ;// CONCATENATED MODULE: ./src/utils/payment-providers/lawpay-provider.js
518
549
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
519
550
 
520
551
 
521
552
 
522
553
 
554
+
523
555
  class LawPayProvider {
524
556
  constructor({
525
557
  reservation,
@@ -579,11 +611,11 @@ class LawPayProvider {
579
611
  )(params)(this.dispatch).then(payload => {
580
612
  this.dispatch(stopWidgetLoading());
581
613
  this.dispatch((0,actions_namespaceObject.createAction)(CLEAR_RESERVATION)({}));
582
- this.dispatch(changeStep(3));
614
+ this.dispatch(changeStep(STEP_COMPLETE));
583
615
  return payload;
584
616
  }).catch(e => {
585
617
  this.dispatch(removeReservedTicket());
586
- this.dispatch(changeStep(1));
618
+ this.dispatch(changeStep(STEP_PERSONAL_INFO));
587
619
  this.dispatch(stopWidgetLoading());
588
620
  return e;
589
621
  }); // The payment has succeeded. Display a success message.
@@ -647,37 +679,6 @@ const getTicketMaxQuantity = ticket => {
647
679
 
648
680
 
649
681
 
650
- ;// CONCATENATED MODULE: ./src/utils/constants.js
651
- /**
652
- * Copyright 2022 OpenStack Foundation
653
- * Licensed under the Apache License, Version 2.0 (the "License");
654
- * you may not use this file except in compliance with the License.
655
- * You may obtain a copy of the License at
656
- * http://www.apache.org/licenses/LICENSE-2.0
657
- * Unless required by applicable law or agreed to in writing, software
658
- * distributed under the License is distributed on an "AS IS" BASIS,
659
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
660
- * See the License for the specific language governing permissions and
661
- * limitations under the License.
662
- **/
663
- const AUTH_ERROR_MESSAGE = 'Missing Auth info';
664
- const AUTH_ERROR_MISSING_REFRESH_TOKEN = "missing Refresh Token";
665
- const AUTH_ERROR_REQUEST_FAILED = 'Request failed';
666
- const VirtualAccessLevel = 'VIRTUAL';
667
- const DefaultBGColor = '#000000';
668
- const DefaultTextColor = '#FFFFFF';
669
- const DefaultHintColor = 'rgb(58, 63, 65)';
670
- const EMAIL_REGEXP = /(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
671
- const TICKET_OWNER_MYSELF = 'myself';
672
- const TICKET_OWNER_SOMEONE = 'someoneElse';
673
- const TICKET_OWNER_UNASSIGNED = 'unassigned';
674
- const TICKET_TYPE_SUBTYPE_PREPAID = 'PrePaid';
675
- const ORDER_STATUS_PAID = 'Paid';
676
- const ORDER_PAYMENT_METHOD_OFFLINE = 'Offline';
677
- const STEP_SELECT_TICKET_TYPE = 0;
678
- const STEP_PERSONAL_INFO = 1;
679
- const STEP_PAYMENT = 2;
680
- const STEP_COMPLETE = 3;
681
682
  ;// CONCATENATED MODULE: ./src/utils/utils.js
682
683
 
683
684
 
@@ -1426,6 +1427,9 @@ const updateClock = timestamp => dispatch => {
1426
1427
  };
1427
1428
  ;// CONCATENATED MODULE: external "openstack-uicore-foundation/lib/security/actions"
1428
1429
  const security_actions_namespaceObject = require("openstack-uicore-foundation/lib/security/actions");
1430
+ ;// CONCATENATED MODULE: external "moment"
1431
+ const external_moment_namespaceObject = require("moment");
1432
+ var external_moment_default = /*#__PURE__*/__webpack_require__.n(external_moment_namespaceObject);
1429
1433
  ;// CONCATENATED MODULE: ./src/reducer.js
1430
1434
  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; }
1431
1435
 
@@ -1447,11 +1451,13 @@ function reducer_defineProperty(obj, key, value) { if (key in obj) { Object.defi
1447
1451
  **/
1448
1452
 
1449
1453
 
1450
- const localNowUtc = Date.now();
1454
+
1455
+
1456
+ const localNowUtc = external_moment_default()().unix();
1451
1457
  const DEFAULT_STATE = {
1452
1458
  reservation: null,
1453
1459
  checkout: null,
1454
- step: 0,
1460
+ step: STEP_SELECT_TICKET_TYPE,
1455
1461
  widgetLoading: false,
1456
1462
  passwordless: {
1457
1463
  email: null,
@@ -2188,7 +2194,7 @@ const StripeForm = ({
2188
2194
  }
2189
2195
  }, stripeOptions?.style);
2190
2196
 
2191
- const onSubmit = async data => {
2197
+ const onSubmit = async (data, ev) => {
2192
2198
  setStripeErrors({});
2193
2199
 
2194
2200
  if (!stripe) {
@@ -2197,6 +2203,8 @@ const StripeForm = ({
2197
2203
  return;
2198
2204
  }
2199
2205
 
2206
+ const btn = document.getElementById('payment-form-btn');
2207
+ if (btn) btn.disabled = true;
2200
2208
  const cardElement = elements.getElement(react_stripe_js_namespaceObject.CardNumberElement); // @see https://stripe.com/docs/js/tokens_sources/create_token?type=cardElement
2201
2209
 
2202
2210
  const {
@@ -2222,14 +2230,20 @@ const StripeForm = ({
2222
2230
  stripe,
2223
2231
  zipCode: data.zipCode
2224
2232
  });
2225
- } else if (error) {
2233
+ return;
2234
+ }
2235
+
2236
+ if (error) {
2237
+ if (btn) btn.disabled = false;
2238
+
2226
2239
  if (stripeErrorCodeMap[error.code]) {
2227
2240
  setStripeErrors({
2228
2241
  [stripeErrorCodeMap[error.code].field]: stripeErrorCodeMap[error.code].message || error.message
2229
2242
  });
2230
- } else {
2231
- external_sweetalert2_default().fire("Payment error", error.message, "warning");
2243
+ return;
2232
2244
  }
2245
+
2246
+ external_sweetalert2_default().fire("Payment error", error.message, "warning");
2233
2247
  }
2234
2248
  };
2235
2249
 
@@ -3001,6 +3015,7 @@ const TicketTypeComponent = ({
3001
3015
  (0,external_react_.useEffect)(() => {
3002
3016
  if (reservation && reservation.tickets?.length > 0) {
3003
3017
  setTicket(allowedTicketTypes.find(t => t.id === reservation.tickets[0].ticket_type_id));
3018
+ setQuantity(reservation.tickets.length);
3004
3019
  }
3005
3020
  }, []);
3006
3021
  (0,external_react_.useEffect)(() => {
@@ -3178,11 +3193,11 @@ const ButtonBarComponent = ({
3178
3193
  const nextButtonText = inPersonDisclaimer && ticketType && isInPersonTicketType(ticketType) ? 'Accept' : 'Next';
3179
3194
  return /*#__PURE__*/external_react_default().createElement("div", {
3180
3195
  className: `${button_bar_index_module.outerWrapper}`
3181
- }, step !== 3 && /*#__PURE__*/external_react_default().createElement((external_react_default()).Fragment, null, /*#__PURE__*/external_react_default().createElement("div", {
3196
+ }, step !== STEP_COMPLETE && /*#__PURE__*/external_react_default().createElement((external_react_default()).Fragment, null, /*#__PURE__*/external_react_default().createElement("div", {
3182
3197
  className: `${button_bar_index_module.innerWrapper}`
3183
3198
  }, /*#__PURE__*/external_react_default().createElement("div", {
3184
3199
  className: button_bar_index_module.required
3185
- }, step !== 0 && /*#__PURE__*/external_react_default().createElement("span", null, "* Required fields ", /*#__PURE__*/external_react_default().createElement("br", null), " ")), /*#__PURE__*/external_react_default().createElement("div", {
3200
+ }, step !== STEP_SELECT_TICKET_TYPE && /*#__PURE__*/external_react_default().createElement("span", null, "* Required fields ", /*#__PURE__*/external_react_default().createElement("br", null), " ")), /*#__PURE__*/external_react_default().createElement("div", {
3186
3201
  className: button_bar_index_module.actions
3187
3202
  }, step !== STEP_SELECT_TICKET_TYPE && step !== STEP_PAYMENT && /*#__PURE__*/external_react_default().createElement("button", {
3188
3203
  className: `${button_bar_index_module.button} button`,
@@ -3206,6 +3221,7 @@ const ButtonBarComponent = ({
3206
3221
  form: "personal-info-form"
3207
3222
  }, "Next"), step === STEP_PAYMENT && /*#__PURE__*/external_react_default().createElement("button", {
3208
3223
  className: `${button_bar_index_module.button} button`,
3224
+ id: "payment-form-btn",
3209
3225
  type: "submit",
3210
3226
  form: "payment-form"
3211
3227
  }, "Pay Now")))));
@@ -3607,6 +3623,7 @@ const RegistrationLite = _ref => {
3607
3623
  errors: []
3608
3624
  });
3609
3625
  const [ticketTaxesError, setTicketTaxesError] = (0,external_react_.useState)(false);
3626
+ const [ticketTaxesLoaded, setTicketTaxesLoaded] = (0,external_react_.useState)(false);
3610
3627
  const {
3611
3628
  values: formValues,
3612
3629
  errors: formErrors
@@ -3635,7 +3652,7 @@ const RegistrationLite = _ref => {
3635
3652
  }));
3636
3653
 
3637
3654
  if (!profileData) {
3638
- changeStep(0);
3655
+ changeStep(STEP_SELECT_TICKET_TYPE);
3639
3656
  }
3640
3657
  }, []);
3641
3658
  (0,external_react_.useEffect)(() => {
@@ -3645,8 +3662,8 @@ const RegistrationLite = _ref => {
3645
3662
  }, [summitData, profileData]);
3646
3663
  (0,external_react_.useEffect)(() => {
3647
3664
  // check if there's personal information data and no ticket data to reset widget
3648
- if (step > 0 && !registrationForm.values?.ticketType) {
3649
- changeStep(0);
3665
+ if (step > STEP_SELECT_TICKET_TYPE && !registrationForm.values?.ticketType && !reservation) {
3666
+ changeStep(STEP_SELECT_TICKET_TYPE);
3650
3667
  }
3651
3668
  }, [registrationForm.values, step]);
3652
3669
  (0,external_react_.useEffect)(() => {
@@ -3669,7 +3686,7 @@ const RegistrationLite = _ref => {
3669
3686
  // Reset the step when closed to avoid unexpected behavior from `useEffect`s w/in other steps.
3670
3687
  // (i.e., recalling `onPurchaseComplete` after a user completes one order, closes the window, and then reopens the registration widget)
3671
3688
  const closeAndClearState = () => {
3672
- changeStep(0);
3689
+ changeStep(STEP_SELECT_TICKET_TYPE);
3673
3690
  clearWidgetState();
3674
3691
 
3675
3692
  if (closeWidget) {
@@ -3689,6 +3706,7 @@ const RegistrationLite = _ref => {
3689
3706
 
3690
3707
  const handleGetTicketTypesAndTaxes = summitId => {
3691
3708
  setTicketTaxesError(false);
3709
+ setTicketTaxesLoaded(false);
3692
3710
  getTicketTypesAndTaxes(summitId).then().catch(error => {
3693
3711
  let {
3694
3712
  message
@@ -3701,13 +3719,15 @@ const RegistrationLite = _ref => {
3701
3719
  }
3702
3720
 
3703
3721
  setTicketTaxesError(true);
3722
+ }).finally(() => {
3723
+ setTicketTaxesLoaded(true);
3704
3724
  });
3705
3725
  }; // if we dont have yet ticket types and we didnt requested so far for them but we are already logged in
3706
3726
  // just dont render
3707
3727
 
3708
3728
 
3709
3729
  if (ticketTypes.length === 0 && !requestedTicketTypes && profileData) return null;
3710
- const allowedTicketTypes = ticketTypes.filter(tt => tt.sales_start_date === null && tt.sales_end_date === null || nowUtc >= tt.sales_start_date && nowUtc <= tt.sales_end_date);
3730
+ const allowedTicketTypes = ticketTaxesLoaded ? ticketTypes.filter(tt => tt.sales_start_date === null && tt.sales_end_date === null || nowUtc >= tt.sales_start_date && nowUtc <= tt.sales_end_date) : [];
3711
3731
  return /*#__PURE__*/external_react_default().createElement("div", {
3712
3732
  id: `${general_module.modal}`,
3713
3733
  className: "modal is-active"
@@ -3733,10 +3753,10 @@ const RegistrationLite = _ref => {
3733
3753
  className: "fa fa-close",
3734
3754
  "aria-label": "close",
3735
3755
  onClick: handleCloseClick
3736
- })), ticketTaxesError && profileData && /*#__PURE__*/external_react_default().createElement(ticket_taxes_error, {
3756
+ })), profileData && ticketTaxesError && /*#__PURE__*/external_react_default().createElement(ticket_taxes_error, {
3737
3757
  ticketTaxesErrorMessage: ticketTaxesErrorMessage,
3738
3758
  retryTicketTaxes: () => handleGetTicketTypesAndTaxes(summitData?.id)
3739
- }), !ticketTaxesError && profileData && allowedTicketTypes.length === 0 && requestedTicketTypes && step !== 3 && /*#__PURE__*/external_react_default().createElement(no_allowed_tickets, {
3759
+ }), profileData && ticketTaxesLoaded && !ticketTaxesError && allowedTicketTypes.length === 0 && step !== STEP_COMPLETE && /*#__PURE__*/external_react_default().createElement(no_allowed_tickets, {
3740
3760
  noAllowedTicketsMessage: noAllowedTicketsMessage
3741
3761
  }), !ticketTaxesError && /*#__PURE__*/external_react_default().createElement("div", {
3742
3762
  className: general_module.stepsWrapper
@@ -3760,7 +3780,7 @@ const RegistrationLite = _ref => {
3760
3780
  getPasswordlessCode: getPasswordlessCode,
3761
3781
  logoLight: logoLight,
3762
3782
  logoDark: logoDark
3763
- }), profileData && step !== 3 && allowedTicketTypes.length > 0 && /*#__PURE__*/external_react_default().createElement((external_react_default()).Fragment, null, ownedTickets.length > 0 && /*#__PURE__*/external_react_default().createElement(ticket_owned, {
3783
+ }), profileData && step !== STEP_COMPLETE && /*#__PURE__*/external_react_default().createElement((external_react_default()).Fragment, null, ownedTickets.length > 0 && /*#__PURE__*/external_react_default().createElement(ticket_owned, {
3764
3784
  ownedTickets: ownedTickets
3765
3785
  }), /*#__PURE__*/external_react_default().createElement(ticket_type, {
3766
3786
  allowedTicketTypes: allowedTicketTypes,
@@ -3849,7 +3869,7 @@ const RegistrationLite = _ref => {
3849
3869
  orderComplete1stParagraph: rest.orderComplete1stParagraph,
3850
3870
  orderComplete2ndParagraph: rest.orderComplete2ndParagraph,
3851
3871
  orderCompleteButton: rest.orderCompleteButton
3852
- })), !ticketTaxesError && profileData && step !== 3 && allowedTicketTypes.length > 0 && /*#__PURE__*/external_react_default().createElement(button_bar, {
3872
+ })), !ticketTaxesError && profileData && step !== STEP_COMPLETE && /*#__PURE__*/external_react_default().createElement(button_bar, {
3853
3873
  step: step,
3854
3874
  inPersonDisclaimer: inPersonDisclaimer,
3855
3875
  formValues: formValues,