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.
@@ -8,7 +8,7 @@ import _includes from 'lodash-es/includes';
8
8
  import _isEqual from 'lodash-es/isEqual';
9
9
  import axios from 'axios';
10
10
  import _forEach from 'lodash-es/forEach';
11
- import { TextField, FormControl, FormHelperText, InputLabel, CircularProgress, createTheme as createTheme$1 } from '@mui/material';
11
+ import { TextField, FormControl, FormHelperText, InputLabel, Alert, CircularProgress, createTheme as createTheme$1 } from '@mui/material';
12
12
  import Modal from '@mui/material/Modal';
13
13
  import Box from '@mui/material/Box';
14
14
  import _flatMapDeep from 'lodash-es/flatMapDeep';
@@ -24,7 +24,7 @@ import MuiPhoneNumber from 'material-ui-phone-number';
24
24
  import { createTheme, ThemeProvider } from '@mui/material/styles';
25
25
  import Container from '@mui/material/Container';
26
26
  import CircularProgress$1 from '@mui/material/CircularProgress';
27
- import Alert from '@mui/material/Alert';
27
+ import Alert$1 from '@mui/material/Alert';
28
28
  import { useStripe, useElements, CardNumberElement, CardExpiryElement, CardCvcElement, Elements } from '@stripe/react-stripe-js';
29
29
  import { loadStripe } from '@stripe/stripe-js';
30
30
  import { FacebookShareButton, FacebookIcon, FacebookMessengerShareButton, FacebookMessengerIcon, TwitterShareButton, TwitterIcon, LinkedinShareButton, LinkedinIcon, PinterestShareButton, PinterestIcon, VKShareButton, VKIcon, OKShareButton, OKIcon, TelegramShareButton, TelegramIcon, WhatsappShareButton, WhatsappIcon, RedditShareButton, RedditIcon, TumblrShareButton, TumblrIcon, MailruShareButton, MailruIcon, EmailShareButton, EmailIcon, LivejournalShareButton, LivejournalIcon, ViberShareButton, ViberIcon, WorkplaceShareButton, WorkplaceIcon, LineShareButton, LineIcon, PocketShareButton, PocketIcon, InstapaperShareButton, InstapaperIcon, WeiboShareButton, WeiboIcon, HatenaShareButton, HatenaIcon } from 'react-share';
@@ -2254,7 +2254,9 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2254
2254
  _ref3$accountInfoTitl = _ref3.accountInfoTitle,
2255
2255
  accountInfoTitle = _ref3$accountInfoTitl === void 0 ? '' : _ref3$accountInfoTitl,
2256
2256
  hideLogo = _ref3.hideLogo,
2257
- themeOptions = _ref3.themeOptions;
2257
+ themeOptions = _ref3.themeOptions,
2258
+ _ref3$onErrorClose = _ref3.onErrorClose,
2259
+ onErrorClose = _ref3$onErrorClose === void 0 ? function () {} : _ref3$onErrorClose;
2258
2260
 
2259
2261
  var themeMui = createTheme(themeOptions);
2260
2262
  var isWindowDefined = typeof window !== 'undefined';
@@ -2319,6 +2321,10 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2319
2321
  userValues = _useState11[0],
2320
2322
  setUserValues = _useState11[1];
2321
2323
 
2324
+ var _useState12 = useState(null),
2325
+ error = _useState12[0],
2326
+ setError = _useState12[1];
2327
+
2322
2328
  var emailLogged = _get(userData, 'email', '') || _get(userValues, 'email', '');
2323
2329
 
2324
2330
  var firstNameLogged = _get(userData, 'first_name', '') || _get(userValues, 'first_name', '');
@@ -2535,7 +2541,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2535
2541
  enableReinitialize: true,
2536
2542
  onSubmit: function () {
2537
2543
  var _onSubmit = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(values, formikHelpers) {
2538
- 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;
2544
+ 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;
2539
2545
 
2540
2546
  return runtime_1.wrap(function _callee5$(_context5) {
2541
2547
  while (1) {
@@ -2544,7 +2550,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2544
2550
  _context5.prev = 0;
2545
2551
 
2546
2552
  if (!isLoggedIn) {
2547
- _context5.next = 15;
2553
+ _context5.next = 17;
2548
2554
  break;
2549
2555
  }
2550
2556
 
@@ -2576,10 +2582,14 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2576
2582
 
2577
2583
  case 12:
2578
2584
  _res = _context5.sent;
2585
+ _context5.next = 15;
2586
+ return getPaymentData(_res.data.data.attributes.hash);
2587
+
2588
+ case 15:
2579
2589
  handleSubmit(values, formikHelpers, eventId, _res);
2580
2590
  return _context5.abrupt("return");
2581
2591
 
2582
- case 15:
2592
+ case 17:
2583
2593
  checkoutBodyForRegistration = createCheckoutDataBody(ticketsQuantity.length, values, {
2584
2594
  emailLogged: emailLogged,
2585
2595
  firstNameLogged: firstNameLogged,
@@ -2587,11 +2597,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2587
2597
  }, showDOB);
2588
2598
  bodyFormData = createRegisterFormData(values, checkoutBodyForRegistration);
2589
2599
  access_token_register = null;
2590
- _context5.prev = 18;
2591
- _context5.next = 21;
2600
+ _context5.prev = 20;
2601
+ _context5.next = 23;
2592
2602
  return register(bodyFormData);
2593
2603
 
2594
- case 21:
2604
+ case 23:
2595
2605
  resRegister = _context5.sent;
2596
2606
  access_token_register = _get(resRegister, 'data.data.attributes.access_token');
2597
2607
  refreshToken = _get(resRegister, 'data.data.attributes.refresh_token');
@@ -2601,26 +2611,26 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2601
2611
  refreshToken: refreshToken
2602
2612
  };
2603
2613
  onRegisterSuccess(tokens);
2604
- _context5.next = 33;
2614
+ _context5.next = 35;
2605
2615
  break;
2606
2616
 
2607
- case 29:
2608
- _context5.prev = 29;
2609
- _context5.t0 = _context5["catch"](18);
2617
+ case 31:
2618
+ _context5.prev = 31;
2619
+ _context5.t0 = _context5["catch"](20);
2610
2620
 
2611
2621
  if (axios.isAxiosError(_context5.t0)) {
2612
- 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;
2622
+ _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;
2613
2623
 
2614
- if (_includes(error, 'You must be aged')) {
2615
- formikHelpers.setFieldError('holderAge', error);
2624
+ if (_includes(_error, 'You must be aged')) {
2625
+ formikHelpers.setFieldError('holderAge', _error);
2616
2626
  }
2617
2627
 
2618
- if (error != null && error.password) {
2619
- formikHelpers.setFieldError('password', error.password);
2620
- formikHelpers.setFieldError('confirmPassword', error.password);
2628
+ if (_error != null && _error.password) {
2629
+ formikHelpers.setFieldError('password', _error.password);
2630
+ formikHelpers.setFieldError('confirmPassword', _error.password);
2621
2631
  }
2622
2632
 
2623
- if (error != null && error.email && !onLogin) {
2633
+ if (_error != null && _error.email && !onLogin) {
2624
2634
  // False will stand for outside controll
2625
2635
  setAlreadyHasUser(true);
2626
2636
  setShowModalLogin(true);
@@ -2631,11 +2641,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2631
2641
 
2632
2642
  return _context5.abrupt("return");
2633
2643
 
2634
- case 33:
2635
- _context5.next = 35;
2644
+ case 35:
2645
+ _context5.next = 37;
2636
2646
  return getProfileData(access_token_register);
2637
2647
 
2638
- case 35:
2648
+ case 37:
2639
2649
  profileData = _context5.sent;
2640
2650
  profileSpecifiedData = _get(profileData, 'data.data');
2641
2651
  profileDataObj = setLoggedUserData(profileSpecifiedData);
@@ -2649,17 +2659,21 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2649
2659
  firstNameLogged: firstNameLogged,
2650
2660
  lastNameLogged: lastNameLogged
2651
2661
  }, showDOB);
2652
- _context5.next = 42;
2662
+ _context5.next = 44;
2653
2663
  return postOnCheckout(checkoutBody, access_token_register);
2654
2664
 
2655
- case 42:
2665
+ case 44:
2656
2666
  res = _context5.sent;
2667
+ _context5.next = 47;
2668
+ return getPaymentData(res.data.data.attributes.hash);
2669
+
2670
+ case 47:
2657
2671
  handleSubmit(values, formikHelpers, eventId, res);
2658
- _context5.next = 49;
2672
+ _context5.next = 53;
2659
2673
  break;
2660
2674
 
2661
- case 46:
2662
- _context5.prev = 46;
2675
+ case 50:
2676
+ _context5.prev = 50;
2663
2677
  _context5.t1 = _context5["catch"](0);
2664
2678
 
2665
2679
  if (axios.isAxiosError(_context5.t1)) {
@@ -2672,15 +2686,23 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2672
2686
  }
2673
2687
  }
2674
2688
 
2689
+ if ((_e$response3 = _context5.t1.response) != null && _e$response3.data.message) {
2690
+ if (typeof document !== undefined) {
2691
+ document.body.scrollTop = document.documentElement.scrollTop = 0;
2692
+ }
2693
+
2694
+ setError(_get(_context5.t1, 'response.data.message'));
2695
+ }
2696
+
2675
2697
  onSubmitError(_context5.t1);
2676
2698
  }
2677
2699
 
2678
- case 49:
2700
+ case 53:
2679
2701
  case "end":
2680
2702
  return _context5.stop();
2681
2703
  }
2682
2704
  }
2683
- }, _callee5, null, [[0, 46], [18, 29]]);
2705
+ }, _callee5, null, [[0, 50], [20, 31]]);
2684
2706
  }));
2685
2707
 
2686
2708
  function onSubmit(_x2, _x3) {
@@ -2702,7 +2724,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2702
2724
  onGetStatesError: onGetStatesError
2703
2725
  }), React.createElement("div", {
2704
2726
  className: "billing-info-container " + theme
2705
- }, !isLoggedIn && React.createElement("div", {
2727
+ }, error && React.createElement(Alert, {
2728
+ severity: "error",
2729
+ onClose: onErrorClose,
2730
+ variant: "filled"
2731
+ }, error), !isLoggedIn && React.createElement("div", {
2706
2732
  className: "account-actions-block"
2707
2733
  }, React.createElement("div", null, accountInfoTitle), React.createElement("div", null, "Login & skip ahead:"), React.createElement("div", {
2708
2734
  className: "login-block"
@@ -3353,7 +3379,7 @@ var PaymentContainer = function PaymentContainer(_ref) {
3353
3379
  theme: themeMui
3354
3380
  }, React.createElement("div", {
3355
3381
  className: "payment_page"
3356
- }, error && React.createElement(Alert, {
3382
+ }, error && React.createElement(Alert$1, {
3357
3383
  severity: "error",
3358
3384
  onClose: onErrorClose,
3359
3385
  variant: "filled"