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.
@@ -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,11 +24,12 @@ 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';
31
31
  import _some from 'lodash-es/some';
32
+ import _every from 'lodash-es/every';
32
33
  import _find from 'lodash-es/find';
33
34
  import _isEmpty from 'lodash-es/isEmpty';
34
35
  import Button$1 from 'react-bootstrap/Button';
@@ -1251,8 +1252,14 @@ var getProfileData = function getProfileData(accessToken) {
1251
1252
  Authorization: "Bearer " + accessToken
1252
1253
  })
1253
1254
  })["catch"](function (e) {
1255
+ var _e$response, _e$response$data;
1256
+
1257
+ 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;
1258
+
1254
1259
  if (isWindowDefined) {
1255
- var event = new window.CustomEvent('auth_error', e);
1260
+ var event = new window.CustomEvent('auth_error', {
1261
+ detail: errorType
1262
+ });
1256
1263
  window.document.dispatchEvent(event);
1257
1264
  }
1258
1265
 
@@ -2094,14 +2101,6 @@ var FormikPhoneNumberField = function FormikPhoneNumberField(_ref) {
2094
2101
  }, rest));
2095
2102
  };
2096
2103
 
2097
- var usePrevious = function usePrevious(value) {
2098
- var ref = useRef();
2099
- useEffect(function () {
2100
- ref.current = value;
2101
- });
2102
- return ref.current;
2103
- };
2104
-
2105
2104
  var LogicRunner = function LogicRunner(_ref) {
2106
2105
  var values = _ref.values,
2107
2106
  setStates = _ref.setStates,
@@ -2254,7 +2253,9 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2254
2253
  _ref3$accountInfoTitl = _ref3.accountInfoTitle,
2255
2254
  accountInfoTitle = _ref3$accountInfoTitl === void 0 ? '' : _ref3$accountInfoTitl,
2256
2255
  hideLogo = _ref3.hideLogo,
2257
- themeOptions = _ref3.themeOptions;
2256
+ themeOptions = _ref3.themeOptions,
2257
+ _ref3$onErrorClose = _ref3.onErrorClose,
2258
+ onErrorClose = _ref3$onErrorClose === void 0 ? function () {} : _ref3$onErrorClose;
2258
2259
 
2259
2260
  var themeMui = createTheme(themeOptions);
2260
2261
  var isWindowDefined = typeof window !== 'undefined';
@@ -2319,6 +2320,10 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2319
2320
  userValues = _useState11[0],
2320
2321
  setUserValues = _useState11[1];
2321
2322
 
2323
+ var _useState12 = useState(null),
2324
+ error = _useState12[0],
2325
+ setError = _useState12[1];
2326
+
2322
2327
  var emailLogged = _get(userData, 'email', '') || _get(userValues, 'email', '');
2323
2328
 
2324
2329
  var firstNameLogged = _get(userData, 'first_name', '') || _get(userValues, 'first_name', '');
@@ -2330,16 +2335,25 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2330
2335
 
2331
2336
  var optedInFieldValue = _get(cartInfoData, 'optedIn', false);
2332
2337
 
2333
- var ttfOptIn = _get(cartInfoData, 'ttfOptIn', false);
2338
+ var ttfOptIn = Boolean(_get(cartInfoData, 'ttfOptIn', false));
2334
2339
 
2335
2340
  var hideTtfOptIn = _get(cartInfoData, 'hide_ttf_opt_in', true); // Get prevProps
2336
2341
 
2337
2342
 
2338
- var prevData = usePrevious(data);
2343
+ var prevData = useRef(data);
2344
+ useEffect(function () {
2345
+ var hasUniqueId = _get(dataWithUniqueIds, '[0].uniqueId');
2339
2346
 
2340
- if (!_get(dataWithUniqueIds, '[0].uniqueId') || !_isEqual(prevData, data)) {
2341
- setDataWithUniqueIds(assingUniqueIds(data));
2342
- }
2347
+ var isEqualData = _isEqual(prevData.current, data);
2348
+
2349
+ if (!hasUniqueId || !isEqualData) {
2350
+ setDataWithUniqueIds(assingUniqueIds(data));
2351
+
2352
+ if (!isEqualData) {
2353
+ prevData.current = data;
2354
+ }
2355
+ }
2356
+ }, [dataWithUniqueIds, data]);
2343
2357
 
2344
2358
  var getQuantity = function getQuantity(cart) {
2345
2359
  if (cart === void 0) {
@@ -2353,8 +2367,12 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2353
2367
  return qty;
2354
2368
  };
2355
2369
 
2356
- var handleAuthErrors = useCallback(function () {
2370
+ var handleAuthErrors = useCallback(function (e) {
2357
2371
  setIsLoggedIn(false);
2372
+
2373
+ if (isWindowDefined && (e == null ? void 0 : e.detail) === 'invalid_token') {
2374
+ window.location.href = '/';
2375
+ }
2358
2376
  }, []);
2359
2377
  useEffect(function () {
2360
2378
  isWindowDefined && window.document.addEventListener('auth_error', handleAuthErrors);
@@ -2535,7 +2553,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2535
2553
  enableReinitialize: true,
2536
2554
  onSubmit: function () {
2537
2555
  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;
2556
+ 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
2557
 
2540
2558
  return runtime_1.wrap(function _callee5$(_context5) {
2541
2559
  while (1) {
@@ -2544,7 +2562,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2544
2562
  _context5.prev = 0;
2545
2563
 
2546
2564
  if (!isLoggedIn) {
2547
- _context5.next = 15;
2565
+ _context5.next = 17;
2548
2566
  break;
2549
2567
  }
2550
2568
 
@@ -2576,10 +2594,14 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2576
2594
 
2577
2595
  case 12:
2578
2596
  _res = _context5.sent;
2597
+ _context5.next = 15;
2598
+ return getPaymentData(_res.data.data.attributes.hash);
2599
+
2600
+ case 15:
2579
2601
  handleSubmit(values, formikHelpers, eventId, _res);
2580
2602
  return _context5.abrupt("return");
2581
2603
 
2582
- case 15:
2604
+ case 17:
2583
2605
  checkoutBodyForRegistration = createCheckoutDataBody(ticketsQuantity.length, values, {
2584
2606
  emailLogged: emailLogged,
2585
2607
  firstNameLogged: firstNameLogged,
@@ -2587,11 +2609,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2587
2609
  }, showDOB);
2588
2610
  bodyFormData = createRegisterFormData(values, checkoutBodyForRegistration);
2589
2611
  access_token_register = null;
2590
- _context5.prev = 18;
2591
- _context5.next = 21;
2612
+ _context5.prev = 20;
2613
+ _context5.next = 23;
2592
2614
  return register(bodyFormData);
2593
2615
 
2594
- case 21:
2616
+ case 23:
2595
2617
  resRegister = _context5.sent;
2596
2618
  access_token_register = _get(resRegister, 'data.data.attributes.access_token');
2597
2619
  refreshToken = _get(resRegister, 'data.data.attributes.refresh_token');
@@ -2601,26 +2623,26 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2601
2623
  refreshToken: refreshToken
2602
2624
  };
2603
2625
  onRegisterSuccess(tokens);
2604
- _context5.next = 33;
2626
+ _context5.next = 35;
2605
2627
  break;
2606
2628
 
2607
- case 29:
2608
- _context5.prev = 29;
2609
- _context5.t0 = _context5["catch"](18);
2629
+ case 31:
2630
+ _context5.prev = 31;
2631
+ _context5.t0 = _context5["catch"](20);
2610
2632
 
2611
2633
  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;
2634
+ _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
2635
 
2614
- if (_includes(error, 'You must be aged')) {
2615
- formikHelpers.setFieldError('holderAge', error);
2636
+ if (_includes(_error, 'You must be aged')) {
2637
+ formikHelpers.setFieldError('holderAge', _error);
2616
2638
  }
2617
2639
 
2618
- if (error != null && error.password) {
2619
- formikHelpers.setFieldError('password', error.password);
2620
- formikHelpers.setFieldError('confirmPassword', error.password);
2640
+ if (_error != null && _error.password) {
2641
+ formikHelpers.setFieldError('password', _error.password);
2642
+ formikHelpers.setFieldError('confirmPassword', _error.password);
2621
2643
  }
2622
2644
 
2623
- if (error != null && error.email && !onLogin) {
2645
+ if (_error != null && _error.email && !onLogin) {
2624
2646
  // False will stand for outside controll
2625
2647
  setAlreadyHasUser(true);
2626
2648
  setShowModalLogin(true);
@@ -2631,11 +2653,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2631
2653
 
2632
2654
  return _context5.abrupt("return");
2633
2655
 
2634
- case 33:
2635
- _context5.next = 35;
2656
+ case 35:
2657
+ _context5.next = 37;
2636
2658
  return getProfileData(access_token_register);
2637
2659
 
2638
- case 35:
2660
+ case 37:
2639
2661
  profileData = _context5.sent;
2640
2662
  profileSpecifiedData = _get(profileData, 'data.data');
2641
2663
  profileDataObj = setLoggedUserData(profileSpecifiedData);
@@ -2649,17 +2671,21 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2649
2671
  firstNameLogged: firstNameLogged,
2650
2672
  lastNameLogged: lastNameLogged
2651
2673
  }, showDOB);
2652
- _context5.next = 42;
2674
+ _context5.next = 44;
2653
2675
  return postOnCheckout(checkoutBody, access_token_register);
2654
2676
 
2655
- case 42:
2677
+ case 44:
2656
2678
  res = _context5.sent;
2679
+ _context5.next = 47;
2680
+ return getPaymentData(res.data.data.attributes.hash);
2681
+
2682
+ case 47:
2657
2683
  handleSubmit(values, formikHelpers, eventId, res);
2658
- _context5.next = 49;
2684
+ _context5.next = 53;
2659
2685
  break;
2660
2686
 
2661
- case 46:
2662
- _context5.prev = 46;
2687
+ case 50:
2688
+ _context5.prev = 50;
2663
2689
  _context5.t1 = _context5["catch"](0);
2664
2690
 
2665
2691
  if (axios.isAxiosError(_context5.t1)) {
@@ -2672,15 +2698,23 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2672
2698
  }
2673
2699
  }
2674
2700
 
2701
+ if ((_e$response3 = _context5.t1.response) != null && _e$response3.data.message) {
2702
+ if (typeof document !== undefined) {
2703
+ document.body.scrollTop = document.documentElement.scrollTop = 0;
2704
+ }
2705
+
2706
+ setError(_get(_context5.t1, 'response.data.message'));
2707
+ }
2708
+
2675
2709
  onSubmitError(_context5.t1);
2676
2710
  }
2677
2711
 
2678
- case 49:
2712
+ case 53:
2679
2713
  case "end":
2680
2714
  return _context5.stop();
2681
2715
  }
2682
2716
  }
2683
- }, _callee5, null, [[0, 46], [18, 29]]);
2717
+ }, _callee5, null, [[0, 50], [20, 31]]);
2684
2718
  }));
2685
2719
 
2686
2720
  function onSubmit(_x2, _x3) {
@@ -2702,7 +2736,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2702
2736
  onGetStatesError: onGetStatesError
2703
2737
  }), React.createElement("div", {
2704
2738
  className: "billing-info-container " + theme
2705
- }, !isLoggedIn && React.createElement("div", {
2739
+ }, error && React.createElement(Alert, {
2740
+ severity: "error",
2741
+ onClose: onErrorClose,
2742
+ variant: "filled"
2743
+ }, error), !isLoggedIn && React.createElement("div", {
2706
2744
  className: "account-actions-block"
2707
2745
  }, React.createElement("div", null, accountInfoTitle), React.createElement("div", null, "Login & skip ahead:"), React.createElement("div", {
2708
2746
  className: "login-block"
@@ -3353,7 +3391,7 @@ var PaymentContainer = function PaymentContainer(_ref) {
3353
3391
  theme: themeMui
3354
3392
  }, React.createElement("div", {
3355
3393
  className: "payment_page"
3356
- }, error && React.createElement(Alert, {
3394
+ }, error && React.createElement(Alert$1, {
3357
3395
  severity: "error",
3358
3396
  onClose: onErrorClose,
3359
3397
  variant: "filled"
@@ -3984,7 +4022,7 @@ var WaitingList = function WaitingList(_ref) {
3984
4022
  className: "field-item"
3985
4023
  }, React.createElement(Field, {
3986
4024
  name: "ticketTypeId",
3987
- label: "Ticket types",
4025
+ label: "Type of Ticket",
3988
4026
  type: "select",
3989
4027
  component: CustomField,
3990
4028
  selectOptions: [{
@@ -3996,7 +4034,7 @@ var WaitingList = function WaitingList(_ref) {
3996
4034
  className: "field-item"
3997
4035
  }, React.createElement(Field, {
3998
4036
  name: "quantity",
3999
- label: "Quantity",
4037
+ label: "Quantity Requested",
4000
4038
  type: "select",
4001
4039
  component: CustomField,
4002
4040
  selectOptions: [{
@@ -4518,9 +4556,14 @@ var TicketsContainer = function TicketsContainer(_ref) {
4518
4556
  getTicketsApi();
4519
4557
  };
4520
4558
 
4521
- var isAllTicketsSoldOut = !_some(tickets, function (item) {
4522
- return !(item.sold_out || item.soldOut);
4559
+ var isAllTicketsSoldOut = _every(tickets, function (item) {
4560
+ return item.sold_out || item.soldOut;
4561
+ });
4562
+
4563
+ var isTicketOnSale = _some(tickets, function (item) {
4564
+ return item.salesStarted && !item.salesEnded && !item.soldOut;
4523
4565
  });
4566
+
4524
4567
  var themeMui = createTheme$1(themeOptions);
4525
4568
  useEffect(function () {
4526
4569
  isWindowDefined && window.document.addEventListener('custom-logout', handleLogout);
@@ -4544,7 +4587,9 @@ var TicketsContainer = function TicketsContainer(_ref) {
4544
4587
  selectedTickets: selectedTickets,
4545
4588
  handleTicketSelect: handleTicketSelect,
4546
4589
  promoCodeIsApplied: promoCodeIsApplied
4547
- }), event != null && event.salesEnded ? React.createElement("p", null, "Sales for this event are closed.") : event != null && event.salesStart ? React.createElement(Countdown, {
4590
+ }), event != null && event.salesEnded ? React.createElement("p", {
4591
+ className: 'event-closed-message'
4592
+ }, "Sales for this event are closed.") : !(event != null && event.salesStarted) && event != null && event.salesStart ? React.createElement(Countdown, {
4548
4593
  startDate: event.salesStart,
4549
4594
  timezone: event.timezone,
4550
4595
  title: "Sales start in:",
@@ -4563,7 +4608,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
4563
4608
  isPromotionsEnabled: isPromotionsEnabled,
4564
4609
  isAccessCodeEnabled: isAccessCodeEnabled,
4565
4610
  isAllTicketsSoldOut: isAllTicketsSoldOut
4566
- }), !isAllTicketsSoldOut && React.createElement(Button$1, {
4611
+ }), isTicketOnSale && React.createElement(Button$1, {
4567
4612
  "aria-hidden": true,
4568
4613
  className: "book-button " + (handleBookIsLoading || _isEmpty(selectedTickets) || Object.values(selectedTickets)[0] === 0 ? 'disabled' : ''),
4569
4614
  onClick: !handleBookIsLoading && !_isEmpty(selectedTickets) && Object.values(selectedTickets)[0] > 0 ? handleBook : function () {}