tf-checkout-react 1.0.81 → 1.0.82

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;
@@ -2261,7 +2261,9 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2261
2261
  _ref3$accountInfoTitl = _ref3.accountInfoTitle,
2262
2262
  accountInfoTitle = _ref3$accountInfoTitl === void 0 ? '' : _ref3$accountInfoTitl,
2263
2263
  hideLogo = _ref3.hideLogo,
2264
- themeOptions = _ref3.themeOptions;
2264
+ themeOptions = _ref3.themeOptions,
2265
+ _ref3$onErrorClose = _ref3.onErrorClose,
2266
+ onErrorClose = _ref3$onErrorClose === void 0 ? function () {} : _ref3$onErrorClose;
2265
2267
 
2266
2268
  var themeMui = styles$1.createTheme(themeOptions);
2267
2269
  var isWindowDefined = typeof window !== 'undefined';
@@ -2326,6 +2328,10 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2326
2328
  userValues = _useState11[0],
2327
2329
  setUserValues = _useState11[1];
2328
2330
 
2331
+ var _useState12 = React.useState(null),
2332
+ error = _useState12[0],
2333
+ setError = _useState12[1];
2334
+
2329
2335
  var emailLogged = _get(userData, 'email', '') || _get(userValues, 'email', '');
2330
2336
 
2331
2337
  var firstNameLogged = _get(userData, 'first_name', '') || _get(userValues, 'first_name', '');
@@ -2542,7 +2548,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2542
2548
  enableReinitialize: true,
2543
2549
  onSubmit: function () {
2544
2550
  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;
2551
+ 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
2552
 
2547
2553
  return runtime_1.wrap(function _callee5$(_context5) {
2548
2554
  while (1) {
@@ -2551,7 +2557,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2551
2557
  _context5.prev = 0;
2552
2558
 
2553
2559
  if (!isLoggedIn) {
2554
- _context5.next = 15;
2560
+ _context5.next = 17;
2555
2561
  break;
2556
2562
  }
2557
2563
 
@@ -2583,10 +2589,14 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2583
2589
 
2584
2590
  case 12:
2585
2591
  _res = _context5.sent;
2592
+ _context5.next = 15;
2593
+ return getPaymentData(_res.data.data.attributes.hash);
2594
+
2595
+ case 15:
2586
2596
  handleSubmit(values, formikHelpers, eventId, _res);
2587
2597
  return _context5.abrupt("return");
2588
2598
 
2589
- case 15:
2599
+ case 17:
2590
2600
  checkoutBodyForRegistration = createCheckoutDataBody(ticketsQuantity.length, values, {
2591
2601
  emailLogged: emailLogged,
2592
2602
  firstNameLogged: firstNameLogged,
@@ -2594,11 +2604,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2594
2604
  }, showDOB);
2595
2605
  bodyFormData = createRegisterFormData(values, checkoutBodyForRegistration);
2596
2606
  access_token_register = null;
2597
- _context5.prev = 18;
2598
- _context5.next = 21;
2607
+ _context5.prev = 20;
2608
+ _context5.next = 23;
2599
2609
  return register(bodyFormData);
2600
2610
 
2601
- case 21:
2611
+ case 23:
2602
2612
  resRegister = _context5.sent;
2603
2613
  access_token_register = _get(resRegister, 'data.data.attributes.access_token');
2604
2614
  refreshToken = _get(resRegister, 'data.data.attributes.refresh_token');
@@ -2608,26 +2618,26 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2608
2618
  refreshToken: refreshToken
2609
2619
  };
2610
2620
  onRegisterSuccess(tokens);
2611
- _context5.next = 33;
2621
+ _context5.next = 35;
2612
2622
  break;
2613
2623
 
2614
- case 29:
2615
- _context5.prev = 29;
2616
- _context5.t0 = _context5["catch"](18);
2624
+ case 31:
2625
+ _context5.prev = 31;
2626
+ _context5.t0 = _context5["catch"](20);
2617
2627
 
2618
2628
  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;
2629
+ _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
2630
 
2621
- if (_includes(error, 'You must be aged')) {
2622
- formikHelpers.setFieldError('holderAge', error);
2631
+ if (_includes(_error, 'You must be aged')) {
2632
+ formikHelpers.setFieldError('holderAge', _error);
2623
2633
  }
2624
2634
 
2625
- if (error != null && error.password) {
2626
- formikHelpers.setFieldError('password', error.password);
2627
- formikHelpers.setFieldError('confirmPassword', error.password);
2635
+ if (_error != null && _error.password) {
2636
+ formikHelpers.setFieldError('password', _error.password);
2637
+ formikHelpers.setFieldError('confirmPassword', _error.password);
2628
2638
  }
2629
2639
 
2630
- if (error != null && error.email && !onLogin) {
2640
+ if (_error != null && _error.email && !onLogin) {
2631
2641
  // False will stand for outside controll
2632
2642
  setAlreadyHasUser(true);
2633
2643
  setShowModalLogin(true);
@@ -2638,11 +2648,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2638
2648
 
2639
2649
  return _context5.abrupt("return");
2640
2650
 
2641
- case 33:
2642
- _context5.next = 35;
2651
+ case 35:
2652
+ _context5.next = 37;
2643
2653
  return getProfileData(access_token_register);
2644
2654
 
2645
- case 35:
2655
+ case 37:
2646
2656
  profileData = _context5.sent;
2647
2657
  profileSpecifiedData = _get(profileData, 'data.data');
2648
2658
  profileDataObj = setLoggedUserData(profileSpecifiedData);
@@ -2656,17 +2666,21 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2656
2666
  firstNameLogged: firstNameLogged,
2657
2667
  lastNameLogged: lastNameLogged
2658
2668
  }, showDOB);
2659
- _context5.next = 42;
2669
+ _context5.next = 44;
2660
2670
  return postOnCheckout(checkoutBody, access_token_register);
2661
2671
 
2662
- case 42:
2672
+ case 44:
2663
2673
  res = _context5.sent;
2674
+ _context5.next = 47;
2675
+ return getPaymentData(res.data.data.attributes.hash);
2676
+
2677
+ case 47:
2664
2678
  handleSubmit(values, formikHelpers, eventId, res);
2665
- _context5.next = 49;
2679
+ _context5.next = 53;
2666
2680
  break;
2667
2681
 
2668
- case 46:
2669
- _context5.prev = 46;
2682
+ case 50:
2683
+ _context5.prev = 50;
2670
2684
  _context5.t1 = _context5["catch"](0);
2671
2685
 
2672
2686
  if (axios.isAxiosError(_context5.t1)) {
@@ -2679,15 +2693,23 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2679
2693
  }
2680
2694
  }
2681
2695
 
2696
+ if ((_e$response3 = _context5.t1.response) != null && _e$response3.data.message) {
2697
+ if (typeof document !== undefined) {
2698
+ document.body.scrollTop = document.documentElement.scrollTop = 0;
2699
+ }
2700
+
2701
+ setError(_get(_context5.t1, 'response.data.message'));
2702
+ }
2703
+
2682
2704
  onSubmitError(_context5.t1);
2683
2705
  }
2684
2706
 
2685
- case 49:
2707
+ case 53:
2686
2708
  case "end":
2687
2709
  return _context5.stop();
2688
2710
  }
2689
2711
  }
2690
- }, _callee5, null, [[0, 46], [18, 29]]);
2712
+ }, _callee5, null, [[0, 50], [20, 31]]);
2691
2713
  }));
2692
2714
 
2693
2715
  function onSubmit(_x2, _x3) {
@@ -2709,7 +2731,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2709
2731
  onGetStatesError: onGetStatesError
2710
2732
  }), React__default.createElement("div", {
2711
2733
  className: "billing-info-container " + theme
2712
- }, !isLoggedIn && React__default.createElement("div", {
2734
+ }, error && React__default.createElement(material.Alert, {
2735
+ severity: "error",
2736
+ onClose: onErrorClose,
2737
+ variant: "filled"
2738
+ }, error), !isLoggedIn && React__default.createElement("div", {
2713
2739
  className: "account-actions-block"
2714
2740
  }, React__default.createElement("div", null, accountInfoTitle), React__default.createElement("div", null, "Login & skip ahead:"), React__default.createElement("div", {
2715
2741
  className: "login-block"