tf-checkout-react 1.0.81 → 1.0.85

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.
@@ -27,6 +27,7 @@ export interface IBillingInfoPage {
27
27
  onAuthorizeError?: (e: AxiosError) => void;
28
28
  onLogin?: () => void;
29
29
  onLoginSuccess?: () => void;
30
+ onErrorClose?: () => void;
30
31
  initialValues?: FormikValues;
31
32
  buttonName?: string;
32
33
  theme?: 'light' | 'dark';
@@ -38,4 +39,4 @@ export interface IBillingInfoPage {
38
39
  checkbox?: CSSProperties;
39
40
  };
40
41
  }
41
- export declare const BillingInfoContainer: ({ data, ticketHoldersFields, initialValues, buttonName, handleSubmit, theme, onRegisterSuccess, onRegisterError, onSubmitError, onGetCartSuccess, onGetCartError, onGetCountriesSuccess, onGetCountriesError, onGetStatesSuccess, onGetStatesError, onGetProfileDataSuccess, onGetProfileDataError, onAuthorizeSuccess, onAuthorizeError, onLogin, onLoginSuccess, isLoggedIn: pIsLoggedIn, accountInfoTitle, hideLogo, themeOptions }: IBillingInfoPage) => JSX.Element;
42
+ export declare const BillingInfoContainer: ({ data, ticketHoldersFields, initialValues, buttonName, handleSubmit, theme, onRegisterSuccess, onRegisterError, onSubmitError, onGetCartSuccess, onGetCartError, onGetCountriesSuccess, onGetCountriesError, onGetStatesSuccess, onGetStatesError, onGetProfileDataSuccess, onGetProfileDataError, onAuthorizeSuccess, onAuthorizeError, onLogin, onLoginSuccess, isLoggedIn: pIsLoggedIn, accountInfoTitle, hideLogo, themeOptions, onErrorClose }: IBillingInfoPage) => JSX.Element;
@@ -36,6 +36,7 @@ var reactStripeJs = require('@stripe/react-stripe-js');
36
36
  var stripeJs = require('@stripe/stripe-js');
37
37
  var reactShare = require('react-share');
38
38
  var _some = _interopDefault(require('lodash/some'));
39
+ var _every = _interopDefault(require('lodash/every'));
39
40
  var _find = _interopDefault(require('lodash/find'));
40
41
  var _isEmpty = _interopDefault(require('lodash/isEmpty'));
41
42
  var Button$1 = _interopDefault(require('react-bootstrap/Button'));
@@ -1258,8 +1259,14 @@ var getProfileData = function getProfileData(accessToken) {
1258
1259
  Authorization: "Bearer " + accessToken
1259
1260
  })
1260
1261
  })["catch"](function (e) {
1262
+ var _e$response, _e$response$data;
1263
+
1264
+ var errorType = e == null ? void 0 : (_e$response = e.response) == null ? void 0 : (_e$response$data = _e$response.data) == null ? void 0 : _e$response$data.error;
1265
+
1261
1266
  if (isWindowDefined) {
1262
- var event = new window.CustomEvent('auth_error', e);
1267
+ var event = new window.CustomEvent('auth_error', {
1268
+ detail: errorType
1269
+ });
1263
1270
  window.document.dispatchEvent(event);
1264
1271
  }
1265
1272
 
@@ -2101,14 +2108,6 @@ var FormikPhoneNumberField = function FormikPhoneNumberField(_ref) {
2101
2108
  }, rest));
2102
2109
  };
2103
2110
 
2104
- var usePrevious = function usePrevious(value) {
2105
- var ref = React.useRef();
2106
- React.useEffect(function () {
2107
- ref.current = value;
2108
- });
2109
- return ref.current;
2110
- };
2111
-
2112
2111
  var LogicRunner = function LogicRunner(_ref) {
2113
2112
  var values = _ref.values,
2114
2113
  setStates = _ref.setStates,
@@ -2261,7 +2260,9 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2261
2260
  _ref3$accountInfoTitl = _ref3.accountInfoTitle,
2262
2261
  accountInfoTitle = _ref3$accountInfoTitl === void 0 ? '' : _ref3$accountInfoTitl,
2263
2262
  hideLogo = _ref3.hideLogo,
2264
- themeOptions = _ref3.themeOptions;
2263
+ themeOptions = _ref3.themeOptions,
2264
+ _ref3$onErrorClose = _ref3.onErrorClose,
2265
+ onErrorClose = _ref3$onErrorClose === void 0 ? function () {} : _ref3$onErrorClose;
2265
2266
 
2266
2267
  var themeMui = styles$1.createTheme(themeOptions);
2267
2268
  var isWindowDefined = typeof window !== 'undefined';
@@ -2326,6 +2327,10 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2326
2327
  userValues = _useState11[0],
2327
2328
  setUserValues = _useState11[1];
2328
2329
 
2330
+ var _useState12 = React.useState(null),
2331
+ error = _useState12[0],
2332
+ setError = _useState12[1];
2333
+
2329
2334
  var emailLogged = _get(userData, 'email', '') || _get(userValues, 'email', '');
2330
2335
 
2331
2336
  var firstNameLogged = _get(userData, 'first_name', '') || _get(userValues, 'first_name', '');
@@ -2337,16 +2342,25 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2337
2342
 
2338
2343
  var optedInFieldValue = _get(cartInfoData, 'optedIn', false);
2339
2344
 
2340
- var ttfOptIn = _get(cartInfoData, 'ttfOptIn', false);
2345
+ var ttfOptIn = Boolean(_get(cartInfoData, 'ttfOptIn', false));
2341
2346
 
2342
2347
  var hideTtfOptIn = _get(cartInfoData, 'hide_ttf_opt_in', true); // Get prevProps
2343
2348
 
2344
2349
 
2345
- var prevData = usePrevious(data);
2350
+ var prevData = React.useRef(data);
2351
+ React.useEffect(function () {
2352
+ var hasUniqueId = _get(dataWithUniqueIds, '[0].uniqueId');
2346
2353
 
2347
- if (!_get(dataWithUniqueIds, '[0].uniqueId') || !_isEqual(prevData, data)) {
2348
- setDataWithUniqueIds(assingUniqueIds(data));
2349
- }
2354
+ var isEqualData = _isEqual(prevData.current, data);
2355
+
2356
+ if (!hasUniqueId || !isEqualData) {
2357
+ setDataWithUniqueIds(assingUniqueIds(data));
2358
+
2359
+ if (!isEqualData) {
2360
+ prevData.current = data;
2361
+ }
2362
+ }
2363
+ }, [dataWithUniqueIds, data]);
2350
2364
 
2351
2365
  var getQuantity = function getQuantity(cart) {
2352
2366
  if (cart === void 0) {
@@ -2360,8 +2374,12 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2360
2374
  return qty;
2361
2375
  };
2362
2376
 
2363
- var handleAuthErrors = React.useCallback(function () {
2377
+ var handleAuthErrors = React.useCallback(function (e) {
2364
2378
  setIsLoggedIn(false);
2379
+
2380
+ if (isWindowDefined && (e == null ? void 0 : e.detail) === 'invalid_token') {
2381
+ window.location.href = '/';
2382
+ }
2365
2383
  }, []);
2366
2384
  React.useEffect(function () {
2367
2385
  isWindowDefined && window.document.addEventListener('auth_error', handleAuthErrors);
@@ -2542,7 +2560,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2542
2560
  enableReinitialize: true,
2543
2561
  onSubmit: function () {
2544
2562
  var _onSubmit = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(values, formikHelpers) {
2545
- var updatedUserData, _profileSpecifiedData, _profileDataObj, _checkoutBody, _res, checkoutBodyForRegistration, bodyFormData, access_token_register, resRegister, refreshToken, tokens, _e$response, _e$response$data, error, profileData, profileSpecifiedData, profileDataObj, checkoutBody, res, _e$response2;
2563
+ var updatedUserData, _profileSpecifiedData, _profileDataObj, _checkoutBody, _res, checkoutBodyForRegistration, bodyFormData, access_token_register, resRegister, refreshToken, tokens, _e$response, _e$response$data, _error, profileData, profileSpecifiedData, profileDataObj, checkoutBody, res, _e$response2, _e$response3;
2546
2564
 
2547
2565
  return runtime_1.wrap(function _callee5$(_context5) {
2548
2566
  while (1) {
@@ -2551,7 +2569,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2551
2569
  _context5.prev = 0;
2552
2570
 
2553
2571
  if (!isLoggedIn) {
2554
- _context5.next = 15;
2572
+ _context5.next = 17;
2555
2573
  break;
2556
2574
  }
2557
2575
 
@@ -2583,10 +2601,14 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2583
2601
 
2584
2602
  case 12:
2585
2603
  _res = _context5.sent;
2604
+ _context5.next = 15;
2605
+ return getPaymentData(_res.data.data.attributes.hash);
2606
+
2607
+ case 15:
2586
2608
  handleSubmit(values, formikHelpers, eventId, _res);
2587
2609
  return _context5.abrupt("return");
2588
2610
 
2589
- case 15:
2611
+ case 17:
2590
2612
  checkoutBodyForRegistration = createCheckoutDataBody(ticketsQuantity.length, values, {
2591
2613
  emailLogged: emailLogged,
2592
2614
  firstNameLogged: firstNameLogged,
@@ -2594,11 +2616,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2594
2616
  }, showDOB);
2595
2617
  bodyFormData = createRegisterFormData(values, checkoutBodyForRegistration);
2596
2618
  access_token_register = null;
2597
- _context5.prev = 18;
2598
- _context5.next = 21;
2619
+ _context5.prev = 20;
2620
+ _context5.next = 23;
2599
2621
  return register(bodyFormData);
2600
2622
 
2601
- case 21:
2623
+ case 23:
2602
2624
  resRegister = _context5.sent;
2603
2625
  access_token_register = _get(resRegister, 'data.data.attributes.access_token');
2604
2626
  refreshToken = _get(resRegister, 'data.data.attributes.refresh_token');
@@ -2608,26 +2630,26 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2608
2630
  refreshToken: refreshToken
2609
2631
  };
2610
2632
  onRegisterSuccess(tokens);
2611
- _context5.next = 33;
2633
+ _context5.next = 35;
2612
2634
  break;
2613
2635
 
2614
- case 29:
2615
- _context5.prev = 29;
2616
- _context5.t0 = _context5["catch"](18);
2636
+ case 31:
2637
+ _context5.prev = 31;
2638
+ _context5.t0 = _context5["catch"](20);
2617
2639
 
2618
2640
  if (axios.isAxiosError(_context5.t0)) {
2619
- error = _context5.t0 == null ? void 0 : (_e$response = _context5.t0.response) == null ? void 0 : (_e$response$data = _e$response.data) == null ? void 0 : _e$response$data.message;
2641
+ _error = _context5.t0 == null ? void 0 : (_e$response = _context5.t0.response) == null ? void 0 : (_e$response$data = _e$response.data) == null ? void 0 : _e$response$data.message;
2620
2642
 
2621
- if (_includes(error, 'You must be aged')) {
2622
- formikHelpers.setFieldError('holderAge', error);
2643
+ if (_includes(_error, 'You must be aged')) {
2644
+ formikHelpers.setFieldError('holderAge', _error);
2623
2645
  }
2624
2646
 
2625
- if (error != null && error.password) {
2626
- formikHelpers.setFieldError('password', error.password);
2627
- formikHelpers.setFieldError('confirmPassword', error.password);
2647
+ if (_error != null && _error.password) {
2648
+ formikHelpers.setFieldError('password', _error.password);
2649
+ formikHelpers.setFieldError('confirmPassword', _error.password);
2628
2650
  }
2629
2651
 
2630
- if (error != null && error.email && !onLogin) {
2652
+ if (_error != null && _error.email && !onLogin) {
2631
2653
  // False will stand for outside controll
2632
2654
  setAlreadyHasUser(true);
2633
2655
  setShowModalLogin(true);
@@ -2638,11 +2660,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2638
2660
 
2639
2661
  return _context5.abrupt("return");
2640
2662
 
2641
- case 33:
2642
- _context5.next = 35;
2663
+ case 35:
2664
+ _context5.next = 37;
2643
2665
  return getProfileData(access_token_register);
2644
2666
 
2645
- case 35:
2667
+ case 37:
2646
2668
  profileData = _context5.sent;
2647
2669
  profileSpecifiedData = _get(profileData, 'data.data');
2648
2670
  profileDataObj = setLoggedUserData(profileSpecifiedData);
@@ -2656,17 +2678,21 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2656
2678
  firstNameLogged: firstNameLogged,
2657
2679
  lastNameLogged: lastNameLogged
2658
2680
  }, showDOB);
2659
- _context5.next = 42;
2681
+ _context5.next = 44;
2660
2682
  return postOnCheckout(checkoutBody, access_token_register);
2661
2683
 
2662
- case 42:
2684
+ case 44:
2663
2685
  res = _context5.sent;
2686
+ _context5.next = 47;
2687
+ return getPaymentData(res.data.data.attributes.hash);
2688
+
2689
+ case 47:
2664
2690
  handleSubmit(values, formikHelpers, eventId, res);
2665
- _context5.next = 49;
2691
+ _context5.next = 53;
2666
2692
  break;
2667
2693
 
2668
- case 46:
2669
- _context5.prev = 46;
2694
+ case 50:
2695
+ _context5.prev = 50;
2670
2696
  _context5.t1 = _context5["catch"](0);
2671
2697
 
2672
2698
  if (axios.isAxiosError(_context5.t1)) {
@@ -2679,15 +2705,23 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2679
2705
  }
2680
2706
  }
2681
2707
 
2708
+ if ((_e$response3 = _context5.t1.response) != null && _e$response3.data.message) {
2709
+ if (typeof document !== undefined) {
2710
+ document.body.scrollTop = document.documentElement.scrollTop = 0;
2711
+ }
2712
+
2713
+ setError(_get(_context5.t1, 'response.data.message'));
2714
+ }
2715
+
2682
2716
  onSubmitError(_context5.t1);
2683
2717
  }
2684
2718
 
2685
- case 49:
2719
+ case 53:
2686
2720
  case "end":
2687
2721
  return _context5.stop();
2688
2722
  }
2689
2723
  }
2690
- }, _callee5, null, [[0, 46], [18, 29]]);
2724
+ }, _callee5, null, [[0, 50], [20, 31]]);
2691
2725
  }));
2692
2726
 
2693
2727
  function onSubmit(_x2, _x3) {
@@ -2709,7 +2743,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2709
2743
  onGetStatesError: onGetStatesError
2710
2744
  }), React__default.createElement("div", {
2711
2745
  className: "billing-info-container " + theme
2712
- }, !isLoggedIn && React__default.createElement("div", {
2746
+ }, error && React__default.createElement(material.Alert, {
2747
+ severity: "error",
2748
+ onClose: onErrorClose,
2749
+ variant: "filled"
2750
+ }, error), !isLoggedIn && React__default.createElement("div", {
2713
2751
  className: "account-actions-block"
2714
2752
  }, React__default.createElement("div", null, accountInfoTitle), React__default.createElement("div", null, "Login & skip ahead:"), React__default.createElement("div", {
2715
2753
  className: "login-block"
@@ -3991,7 +4029,7 @@ var WaitingList = function WaitingList(_ref) {
3991
4029
  className: "field-item"
3992
4030
  }, React__default.createElement(formik.Field, {
3993
4031
  name: "ticketTypeId",
3994
- label: "Ticket types",
4032
+ label: "Type of Ticket",
3995
4033
  type: "select",
3996
4034
  component: CustomField,
3997
4035
  selectOptions: [{
@@ -4003,7 +4041,7 @@ var WaitingList = function WaitingList(_ref) {
4003
4041
  className: "field-item"
4004
4042
  }, React__default.createElement(formik.Field, {
4005
4043
  name: "quantity",
4006
- label: "Quantity",
4044
+ label: "Quantity Requested",
4007
4045
  type: "select",
4008
4046
  component: CustomField,
4009
4047
  selectOptions: [{
@@ -4520,9 +4558,14 @@ var TicketsContainer = function TicketsContainer(_ref) {
4520
4558
  getTicketsApi();
4521
4559
  };
4522
4560
 
4523
- var isAllTicketsSoldOut = !_some(tickets, function (item) {
4524
- return !(item.sold_out || item.soldOut);
4561
+ var isAllTicketsSoldOut = _every(tickets, function (item) {
4562
+ return item.sold_out || item.soldOut;
4563
+ });
4564
+
4565
+ var isTicketOnSale = _some(tickets, function (item) {
4566
+ return item.salesStarted && !item.salesEnded && !item.soldOut;
4525
4567
  });
4568
+
4526
4569
  var themeMui = material.createTheme(themeOptions);
4527
4570
  React.useEffect(function () {
4528
4571
  isWindowDefined && window.document.addEventListener('custom-logout', handleLogout);
@@ -4546,7 +4589,9 @@ var TicketsContainer = function TicketsContainer(_ref) {
4546
4589
  selectedTickets: selectedTickets,
4547
4590
  handleTicketSelect: handleTicketSelect,
4548
4591
  promoCodeIsApplied: promoCodeIsApplied
4549
- }), event != null && event.salesEnded ? React__default.createElement("p", null, "Sales for this event are closed.") : event != null && event.salesStart ? React__default.createElement(Countdown, {
4592
+ }), event != null && event.salesEnded ? React__default.createElement("p", {
4593
+ className: 'event-closed-message'
4594
+ }, "Sales for this event are closed.") : !(event != null && event.salesStarted) && event != null && event.salesStart ? React__default.createElement(Countdown, {
4550
4595
  startDate: event.salesStart,
4551
4596
  timezone: event.timezone,
4552
4597
  title: "Sales start in:",
@@ -4565,7 +4610,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
4565
4610
  isPromotionsEnabled: isPromotionsEnabled,
4566
4611
  isAccessCodeEnabled: isAccessCodeEnabled,
4567
4612
  isAllTicketsSoldOut: isAllTicketsSoldOut
4568
- }), !isAllTicketsSoldOut && React__default.createElement(Button$1, {
4613
+ }), isTicketOnSale && React__default.createElement(Button$1, {
4569
4614
  "aria-hidden": true,
4570
4615
  className: "book-button " + (handleBookIsLoading || _isEmpty(selectedTickets) || Object.values(selectedTickets)[0] === 0 ? 'disabled' : ''),
4571
4616
  onClick: !handleBookIsLoading && !_isEmpty(selectedTickets) && Object.values(selectedTickets)[0] > 0 ? handleBook : function () {}