tf-checkout-react 1.0.84 → 1.0.88

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.
@@ -1,4 +1,4 @@
1
- import React, { Component, useState, useRef, useEffect, useCallback, Fragment } from 'react';
1
+ import React, { Component, useState, useRef, useEffect, Fragment } from 'react';
2
2
  import { connect, Formik, Form, Field } from 'formik';
3
3
  import Button from '@mui/material/Button';
4
4
  import _identity from 'lodash-es/identity';
@@ -6,9 +6,10 @@ import _map from 'lodash-es/map';
6
6
  import _get from 'lodash-es/get';
7
7
  import _includes from 'lodash-es/includes';
8
8
  import _isEqual from 'lodash-es/isEqual';
9
+ import _isEmpty from 'lodash-es/isEmpty';
9
10
  import axios from 'axios';
10
11
  import _forEach from 'lodash-es/forEach';
11
- import { TextField, FormControl, FormHelperText, InputLabel, Alert, CircularProgress, createTheme as createTheme$1 } from '@mui/material';
12
+ import { TextField, FormControl, FormHelperText, InputLabel, CircularProgress, Alert, createTheme as createTheme$1 } from '@mui/material';
12
13
  import Modal from '@mui/material/Modal';
13
14
  import Box from '@mui/material/Box';
14
15
  import _flatMapDeep from 'lodash-es/flatMapDeep';
@@ -22,15 +23,18 @@ import Checkbox from '@mui/material/Checkbox';
22
23
  import Select from '@mui/material/Select';
23
24
  import MuiPhoneNumber from 'material-ui-phone-number';
24
25
  import { createTheme, ThemeProvider } from '@mui/material/styles';
26
+ import Backdrop from '@mui/material/Backdrop';
25
27
  import Container from '@mui/material/Container';
26
28
  import CircularProgress$1 from '@mui/material/CircularProgress';
27
29
  import Alert$1 from '@mui/material/Alert';
28
30
  import { useStripe, useElements, CardNumberElement, CardExpiryElement, CardCvcElement, Elements } from '@stripe/react-stripe-js';
29
31
  import { loadStripe } from '@stripe/stripe-js';
32
+ import Countdown$1 from 'react-countdown';
33
+ import _isNumber from 'lodash-es/isNumber';
30
34
  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
35
  import _some from 'lodash-es/some';
36
+ import _every from 'lodash-es/every';
32
37
  import _find from 'lodash-es/find';
33
- import _isEmpty from 'lodash-es/isEmpty';
34
38
  import Button$1 from 'react-bootstrap/Button';
35
39
  import jwt_decode from 'jwt-decode';
36
40
  import _sortBy from 'lodash-es/sortBy';
@@ -1102,9 +1106,16 @@ publicRequest.interceptors.response.use(function (response) {
1102
1106
 
1103
1107
  if ((error == null ? void 0 : (_error$response = error.response) == null ? void 0 : _error$response.status) === 401) {
1104
1108
  if (isWindowDefined) {
1109
+ var _error$response2, _error$response2$data;
1110
+
1105
1111
  window.localStorage.removeItem('auth_guest_token');
1106
1112
  window.localStorage.removeItem('user_data');
1107
1113
  window.localStorage.removeItem('access_token');
1114
+ var errorType = error == null ? void 0 : (_error$response2 = error.response) == null ? void 0 : (_error$response2$data = _error$response2.data) == null ? void 0 : _error$response2$data.error;
1115
+
1116
+ if (errorType === 'invalid_token') {
1117
+ window.location.href = '/';
1118
+ }
1108
1119
  }
1109
1120
  }
1110
1121
 
@@ -1251,17 +1262,6 @@ var getProfileData = function getProfileData(accessToken) {
1251
1262
  Authorization: "Bearer " + accessToken
1252
1263
  })
1253
1264
  })["catch"](function (e) {
1254
- var _e$response, _e$response$data;
1255
-
1256
- 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;
1257
-
1258
- if (isWindowDefined) {
1259
- var event = new window.CustomEvent('auth_error', {
1260
- detail: errorType
1261
- });
1262
- window.document.dispatchEvent(event);
1263
- }
1264
-
1265
1265
  return e;
1266
1266
  });
1267
1267
  };
@@ -1904,7 +1904,8 @@ var CustomField = function CustomField(_ref) {
1904
1904
  }
1905
1905
  },
1906
1906
  InputLabelProps: {
1907
- sx: customTheme == null ? void 0 : customTheme.input
1907
+ sx: customTheme == null ? void 0 : customTheme.input,
1908
+ shrink: field.name === 'holderAge' ? true : undefined
1908
1909
  },
1909
1910
  inputProps: {
1910
1911
  sx: customTheme == null ? void 0 : customTheme.input
@@ -2180,7 +2181,7 @@ var LogicRunner = function LogicRunner(_ref) {
2180
2181
  confirmEmail: (parsedData == null ? void 0 : parsedData.email) || '',
2181
2182
  state: (parsedData == null ? void 0 : parsedData.state) || '',
2182
2183
  street_address: (parsedData == null ? void 0 : parsedData.street_address) || '',
2183
- country: (parsedData == null ? void 0 : parsedData.country) || "1",
2184
+ country: (parsedData == null ? void 0 : parsedData.country) || '1',
2184
2185
  zip: (parsedData == null ? void 0 : parsedData.zip) || '',
2185
2186
  brand_opt_in: (parsedData == null ? void 0 : parsedData.brand_opt_in) || '',
2186
2187
  city: (parsedData == null ? void 0 : parsedData.city) || '',
@@ -2254,7 +2255,13 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2254
2255
  hideLogo = _ref3.hideLogo,
2255
2256
  themeOptions = _ref3.themeOptions,
2256
2257
  _ref3$onErrorClose = _ref3.onErrorClose,
2257
- onErrorClose = _ref3$onErrorClose === void 0 ? function () {} : _ref3$onErrorClose;
2258
+ onErrorClose = _ref3$onErrorClose === void 0 ? function () {} : _ref3$onErrorClose,
2259
+ _ref3$hideErrorsAlert = _ref3.hideErrorsAlertSection,
2260
+ hideErrorsAlertSection = _ref3$hideErrorsAlert === void 0 ? false : _ref3$hideErrorsAlert,
2261
+ _ref3$onSkipBillingPa = _ref3.onSkipBillingPage,
2262
+ onSkipBillingPage = _ref3$onSkipBillingPa === void 0 ? function () {} : _ref3$onSkipBillingPa,
2263
+ _ref3$skipPage = _ref3.skipPage,
2264
+ skipPage = _ref3$skipPage === void 0 ? false : _ref3$skipPage;
2258
2265
 
2259
2266
  var themeMui = createTheme(themeOptions);
2260
2267
  var isWindowDefined = typeof window !== 'undefined';
@@ -2319,9 +2326,13 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2319
2326
  userValues = _useState11[0],
2320
2327
  setUserValues = _useState11[1];
2321
2328
 
2322
- var _useState12 = useState(null),
2323
- error = _useState12[0],
2324
- setError = _useState12[1];
2329
+ var _useState12 = useState(true),
2330
+ loading = _useState12[0],
2331
+ setLoading = _useState12[1];
2332
+
2333
+ var _useState13 = useState(null),
2334
+ error = _useState13[0],
2335
+ setError = _useState13[1];
2325
2336
 
2326
2337
  var emailLogged = _get(userData, 'email', '') || _get(userValues, 'email', '');
2327
2338
 
@@ -2334,7 +2345,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2334
2345
 
2335
2346
  var optedInFieldValue = _get(cartInfoData, 'optedIn', false);
2336
2347
 
2337
- var ttfOptIn = _get(cartInfoData, 'ttfOptIn', false);
2348
+ var ttfOptIn = Boolean(_get(cartInfoData, 'ttfOptIn', false));
2338
2349
 
2339
2350
  var hideTtfOptIn = _get(cartInfoData, 'hide_ttf_opt_in', true); // Get prevProps
2340
2351
 
@@ -2366,19 +2377,6 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2366
2377
  return qty;
2367
2378
  };
2368
2379
 
2369
- var handleAuthErrors = useCallback(function (e) {
2370
- setIsLoggedIn(false);
2371
-
2372
- if (isWindowDefined && (e == null ? void 0 : e.detail) === 'invalid_token') {
2373
- window.location.href = '/';
2374
- }
2375
- }, []);
2376
- useEffect(function () {
2377
- isWindowDefined && window.document.addEventListener('auth_error', handleAuthErrors);
2378
- return function () {
2379
- isWindowDefined && window.document.removeEventListener('auth_error', handleAuthErrors);
2380
- };
2381
- }, [handleAuthErrors]);
2382
2380
  useEffect(function () {
2383
2381
  if ((pIsLoggedIn || access_token) && !isLoggedIn) {
2384
2382
  setIsLoggedIn(true);
@@ -2540,41 +2538,106 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2540
2538
  useEffect(function () {
2541
2539
  fetchUserData(access_token);
2542
2540
  }, [access_token]);
2541
+ useEffect(function () {
2542
+ var collectPaymentData = /*#__PURE__*/function () {
2543
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
2544
+ var checkoutBody, res;
2545
+ return runtime_1.wrap(function _callee5$(_context5) {
2546
+ while (1) {
2547
+ switch (_context5.prev = _context5.next) {
2548
+ case 0:
2549
+ if (!(skipPage && !_isEmpty(ticketsQuantity))) {
2550
+ _context5.next = 16;
2551
+ break;
2552
+ }
2553
+
2554
+ setLoading(true);
2555
+ checkoutBody = createCheckoutDataBodyWithDefaultHolder(ticketsQuantity.length, userData);
2556
+ _context5.prev = 3;
2557
+ _context5.next = 6;
2558
+ return postOnCheckout(checkoutBody, access_token);
2559
+
2560
+ case 6:
2561
+ res = _context5.sent;
2562
+ onSkipBillingPage(_get(res, 'data.data.attributes'));
2563
+ setLoading(false);
2564
+ _context5.next = 14;
2565
+ break;
2566
+
2567
+ case 11:
2568
+ _context5.prev = 11;
2569
+ _context5.t0 = _context5["catch"](3);
2570
+ onSubmitError(_context5.t0);
2571
+
2572
+ case 14:
2573
+ _context5.next = 17;
2574
+ break;
2575
+
2576
+ case 16:
2577
+ setLoading(false);
2578
+
2579
+ case 17:
2580
+ case "end":
2581
+ return _context5.stop();
2582
+ }
2583
+ }
2584
+ }, _callee5, null, [[3, 11]]);
2585
+ }));
2586
+
2587
+ return function collectPaymentData() {
2588
+ return _ref7.apply(this, arguments);
2589
+ };
2590
+ }();
2591
+
2592
+ collectPaymentData();
2593
+ }, [skipPage, ticketsQuantity]); // Displaying loader
2594
+
2595
+ if (loading) {
2596
+ return React.createElement(Backdrop, {
2597
+ sx: {
2598
+ color: '#fff'
2599
+ },
2600
+ open: true
2601
+ }, React.createElement(CircularProgress, {
2602
+ color: "inherit"
2603
+ }));
2604
+ }
2605
+
2543
2606
  return React.createElement(ThemeProvider, {
2544
2607
  theme: themeMui
2545
2608
  }, React.createElement(Formik, {
2546
2609
  initialValues: getInitialValues(dataWithUniqueIds, _extends({}, initialValues, {
2547
- country: _get(userData, 'country', '') || "1",
2548
- state: _get(userData, 'state', '') || "1",
2610
+ country: _get(userData, 'country', '') || '1',
2611
+ state: _get(userData, 'state', '') || '1',
2549
2612
  brand_opt_in: optedInFieldValue,
2550
2613
  ttf_opt_in: ttfOptIn
2551
2614
  }), userValues),
2552
2615
  enableReinitialize: true,
2553
2616
  onSubmit: function () {
2554
- var _onSubmit = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(values, formikHelpers) {
2617
+ var _onSubmit = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(values, formikHelpers) {
2555
2618
  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;
2556
2619
 
2557
- return runtime_1.wrap(function _callee5$(_context5) {
2620
+ return runtime_1.wrap(function _callee6$(_context6) {
2558
2621
  while (1) {
2559
- switch (_context5.prev = _context5.next) {
2622
+ switch (_context6.prev = _context6.next) {
2560
2623
  case 0:
2561
- _context5.prev = 0;
2624
+ _context6.prev = 0;
2562
2625
 
2563
2626
  if (!isLoggedIn) {
2564
- _context5.next = 17;
2627
+ _context6.next = 17;
2565
2628
  break;
2566
2629
  }
2567
2630
 
2568
2631
  if (!access_token) {
2569
- _context5.next = 9;
2632
+ _context6.next = 9;
2570
2633
  break;
2571
2634
  }
2572
2635
 
2573
- _context5.next = 5;
2636
+ _context6.next = 5;
2574
2637
  return getProfileData(access_token);
2575
2638
 
2576
2639
  case 5:
2577
- updatedUserData = _context5.sent;
2640
+ updatedUserData = _context6.sent;
2578
2641
  _profileSpecifiedData = _get(updatedUserData, 'data.data');
2579
2642
  _profileDataObj = setLoggedUserData(_profileSpecifiedData);
2580
2643
 
@@ -2588,17 +2651,17 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2588
2651
  firstNameLogged: firstNameLogged,
2589
2652
  lastNameLogged: lastNameLogged
2590
2653
  }, showDOB);
2591
- _context5.next = 12;
2654
+ _context6.next = 12;
2592
2655
  return postOnCheckout(_checkoutBody, access_token);
2593
2656
 
2594
2657
  case 12:
2595
- _res = _context5.sent;
2596
- _context5.next = 15;
2658
+ _res = _context6.sent;
2659
+ _context6.next = 15;
2597
2660
  return getPaymentData(_res.data.data.attributes.hash);
2598
2661
 
2599
2662
  case 15:
2600
2663
  handleSubmit(values, formikHelpers, eventId, _res);
2601
- return _context5.abrupt("return");
2664
+ return _context6.abrupt("return");
2602
2665
 
2603
2666
  case 17:
2604
2667
  checkoutBodyForRegistration = createCheckoutDataBody(ticketsQuantity.length, values, {
@@ -2608,12 +2671,12 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2608
2671
  }, showDOB);
2609
2672
  bodyFormData = createRegisterFormData(values, checkoutBodyForRegistration);
2610
2673
  access_token_register = null;
2611
- _context5.prev = 20;
2612
- _context5.next = 23;
2674
+ _context6.prev = 20;
2675
+ _context6.next = 23;
2613
2676
  return register(bodyFormData);
2614
2677
 
2615
2678
  case 23:
2616
- resRegister = _context5.sent;
2679
+ resRegister = _context6.sent;
2617
2680
  access_token_register = _get(resRegister, 'data.data.attributes.access_token');
2618
2681
  refreshToken = _get(resRegister, 'data.data.attributes.refresh_token');
2619
2682
  handleSetAccessToken(access_token_register);
@@ -2622,15 +2685,15 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2622
2685
  refreshToken: refreshToken
2623
2686
  };
2624
2687
  onRegisterSuccess(tokens);
2625
- _context5.next = 35;
2688
+ _context6.next = 35;
2626
2689
  break;
2627
2690
 
2628
2691
  case 31:
2629
- _context5.prev = 31;
2630
- _context5.t0 = _context5["catch"](20);
2692
+ _context6.prev = 31;
2693
+ _context6.t0 = _context6["catch"](20);
2631
2694
 
2632
- if (axios.isAxiosError(_context5.t0)) {
2633
- _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;
2695
+ if (axios.isAxiosError(_context6.t0)) {
2696
+ _error = _context6.t0 == null ? void 0 : (_e$response = _context6.t0.response) == null ? void 0 : (_e$response$data = _e$response.data) == null ? void 0 : _e$response$data.message;
2634
2697
 
2635
2698
  if (_includes(_error, 'You must be aged')) {
2636
2699
  formikHelpers.setFieldError('holderAge', _error);
@@ -2647,17 +2710,17 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2647
2710
  setShowModalLogin(true);
2648
2711
  }
2649
2712
 
2650
- onRegisterError(_context5.t0, values.email);
2713
+ onRegisterError(_context6.t0, values.email);
2651
2714
  }
2652
2715
 
2653
- return _context5.abrupt("return");
2716
+ return _context6.abrupt("return");
2654
2717
 
2655
2718
  case 35:
2656
- _context5.next = 37;
2719
+ _context6.next = 37;
2657
2720
  return getProfileData(access_token_register);
2658
2721
 
2659
2722
  case 37:
2660
- profileData = _context5.sent;
2723
+ profileData = _context6.sent;
2661
2724
  profileSpecifiedData = _get(profileData, 'data.data');
2662
2725
  profileDataObj = setLoggedUserData(profileSpecifiedData);
2663
2726
 
@@ -2670,25 +2733,25 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2670
2733
  firstNameLogged: firstNameLogged,
2671
2734
  lastNameLogged: lastNameLogged
2672
2735
  }, showDOB);
2673
- _context5.next = 44;
2736
+ _context6.next = 44;
2674
2737
  return postOnCheckout(checkoutBody, access_token_register);
2675
2738
 
2676
2739
  case 44:
2677
- res = _context5.sent;
2678
- _context5.next = 47;
2740
+ res = _context6.sent;
2741
+ _context6.next = 47;
2679
2742
  return getPaymentData(res.data.data.attributes.hash);
2680
2743
 
2681
2744
  case 47:
2682
2745
  handleSubmit(values, formikHelpers, eventId, res);
2683
- _context5.next = 53;
2746
+ _context6.next = 53;
2684
2747
  break;
2685
2748
 
2686
2749
  case 50:
2687
- _context5.prev = 50;
2688
- _context5.t1 = _context5["catch"](0);
2750
+ _context6.prev = 50;
2751
+ _context6.t1 = _context6["catch"](0);
2689
2752
 
2690
- if (axios.isAxiosError(_context5.t1)) {
2691
- if (((_e$response2 = _context5.t1.response) == null ? void 0 : _e$response2.data.error) === 'invalid_token') {
2753
+ if (axios.isAxiosError(_context6.t1)) {
2754
+ if (((_e$response2 = _context6.t1.response) == null ? void 0 : _e$response2.data.error) === 'invalid_token') {
2692
2755
  if (isWindowDefined) {
2693
2756
  window.localStorage.removeItem('user_data');
2694
2757
  window.localStorage.removeItem('access_token');
@@ -2697,23 +2760,23 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2697
2760
  }
2698
2761
  }
2699
2762
 
2700
- if ((_e$response3 = _context5.t1.response) != null && _e$response3.data.message) {
2763
+ if ((_e$response3 = _context6.t1.response) != null && _e$response3.data.message) {
2701
2764
  if (typeof document !== undefined) {
2702
2765
  document.body.scrollTop = document.documentElement.scrollTop = 0;
2703
2766
  }
2704
2767
 
2705
- setError(_get(_context5.t1, 'response.data.message'));
2768
+ setError(_get(_context6.t1, 'response.data.message'));
2706
2769
  }
2707
2770
 
2708
- onSubmitError(_context5.t1);
2771
+ onSubmitError(_context6.t1);
2709
2772
  }
2710
2773
 
2711
2774
  case 53:
2712
2775
  case "end":
2713
- return _context5.stop();
2776
+ return _context6.stop();
2714
2777
  }
2715
2778
  }
2716
- }, _callee5, null, [[0, 50], [20, 31]]);
2779
+ }, _callee6, null, [[0, 50], [20, 31]]);
2717
2780
  }));
2718
2781
 
2719
2782
  function onSubmit(_x2, _x3) {
@@ -2735,7 +2798,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2735
2798
  onGetStatesError: onGetStatesError
2736
2799
  }), React.createElement("div", {
2737
2800
  className: "billing-info-container " + theme
2738
- }, error && React.createElement(Alert, {
2801
+ }, error && !hideErrorsAlertSection && React.createElement(Alert, {
2739
2802
  severity: "error",
2740
2803
  onClose: onErrorClose,
2741
2804
  variant: "filled"
@@ -2802,7 +2865,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2802
2865
  })));
2803
2866
  })));
2804
2867
  }));
2805
- }), React.createElement("div", {
2868
+ }), !_isEmpty(ticketHoldersFields.fields) && React.createElement("div", {
2806
2869
  className: "ticket-holders-fields"
2807
2870
  }, React.createElement("p", null, ticketHoldersFields.label), _map(ticketsQuantity, function (_item, index) {
2808
2871
  return React.createElement("div", {
@@ -3141,6 +3204,63 @@ var CheckoutForm = function CheckoutForm(_ref) {
3141
3204
  }) : "Pay " + getCurrencySymbolByCurrency(currency) + total))));
3142
3205
  };
3143
3206
 
3207
+ var showZero = function showZero(value) {
3208
+ if (value === void 0) {
3209
+ value = 0;
3210
+ }
3211
+
3212
+ var intNumber = Number(value);
3213
+ return _isNumber(intNumber) ? intNumber >= 0 && intNumber < 10 ? '0' + intNumber : intNumber : null;
3214
+ };
3215
+
3216
+ var TimerWidget = function TimerWidget(_ref) {
3217
+ var expires_at = _ref.expires_at,
3218
+ buyLoading = _ref.buyLoading,
3219
+ _ref$onCountdownFinis = _ref.onCountdownFinish,
3220
+ onCountdownFinish = _ref$onCountdownFinis === void 0 ? function () {} : _ref$onCountdownFinis;
3221
+
3222
+ var _useState = useState(true),
3223
+ showTimer = _useState[0],
3224
+ setShowTimer = _useState[1];
3225
+
3226
+ var handleCountdownFinish = function handleCountdownFinish() {
3227
+ setShowTimer(false);
3228
+
3229
+ if (!buyLoading) {
3230
+ onCountdownFinish();
3231
+ }
3232
+ };
3233
+
3234
+ var _renderer = function renderer(_ref2) {
3235
+ var minutes = _ref2.minutes,
3236
+ seconds = _ref2.seconds,
3237
+ completed = _ref2.completed,
3238
+ handleCountdownFinish = _ref2.handleCountdownFinish;
3239
+
3240
+ if (completed) {
3241
+ handleCountdownFinish();
3242
+ return null;
3243
+ }
3244
+
3245
+ return React.createElement("span", null, showZero(minutes), ":", showZero(seconds));
3246
+ };
3247
+
3248
+ return showTimer && !!expires_at ? React.createElement("div", {
3249
+ className: "timer"
3250
+ }, React.createElement("div", {
3251
+ className: "toast-message"
3252
+ }, React.createElement("p", null, "Please complete your purchase before the timer reaches zero."), React.createElement("p", {
3253
+ className: "countdown"
3254
+ }, React.createElement(Countdown$1, {
3255
+ date: Date.now() + expires_at * 1000,
3256
+ renderer: function renderer(props) {
3257
+ return _renderer(_extends({}, props, {
3258
+ handleCountdownFinish: handleCountdownFinish
3259
+ }));
3260
+ }
3261
+ })))) : null;
3262
+ };
3263
+
3144
3264
  var publishableKey = CONFIGS.STRIPE_PUBLISHABLE_KEY || '';
3145
3265
 
3146
3266
  var getStripePromise = function getStripePromise(reviewData) {
@@ -3201,7 +3321,11 @@ var PaymentContainer = function PaymentContainer(_ref) {
3201
3321
  _ref$disableZipSectio = _ref.disableZipSection,
3202
3322
  disableZipSection = _ref$disableZipSectio === void 0 ? false : _ref$disableZipSectio,
3203
3323
  themeOptions = _ref.themeOptions,
3204
- elementsOptions = _ref.elementsOptions;
3324
+ elementsOptions = _ref.elementsOptions,
3325
+ _ref$onCountdownFinis = _ref.onCountdownFinish,
3326
+ onCountdownFinish = _ref$onCountdownFinis === void 0 ? function () {} : _ref$onCountdownFinis,
3327
+ _ref$enableTimer = _ref.enableTimer,
3328
+ enableTimer = _ref$enableTimer === void 0 ? false : _ref$enableTimer;
3205
3329
 
3206
3330
  var _useState = useState(initialReviewValues),
3207
3331
  reviewData = _useState[0],
@@ -3390,7 +3514,11 @@ var PaymentContainer = function PaymentContainer(_ref) {
3390
3514
  theme: themeMui
3391
3515
  }, React.createElement("div", {
3392
3516
  className: "payment_page"
3393
- }, error && React.createElement(Alert$1, {
3517
+ }, !paymentIsLoading && !error && enableTimer && React.createElement(TimerWidget, {
3518
+ expires_at: _get(reviewData, 'expires_at', 0),
3519
+ buyLoading: paymentIsLoading,
3520
+ onCountdownFinish: onCountdownFinish
3521
+ }), error && React.createElement(Alert$1, {
3394
3522
  severity: "error",
3395
3523
  onClose: onErrorClose,
3396
3524
  variant: "filled"
@@ -3934,6 +4062,8 @@ var WaitingList = function WaitingList(_ref) {
3934
4062
  var _ref$tickets = _ref.tickets,
3935
4063
  tickets = _ref$tickets === void 0 ? {} : _ref$tickets,
3936
4064
  eventId = _ref.eventId;
4065
+ var isWindowDefined = typeof window !== 'undefined';
4066
+ var userData = isWindowDefined && window.localStorage.getItem('user_data') ? JSON.parse(window.localStorage.getItem('user_data') || '') : {};
3937
4067
 
3938
4068
  var _useState = useState(false),
3939
4069
  showSuccessMessage = _useState[0],
@@ -4012,16 +4142,16 @@ var WaitingList = function WaitingList(_ref) {
4012
4142
  initialValues: {
4013
4143
  ticketTypeId: '',
4014
4144
  quantity: '',
4015
- firstName: '',
4016
- lastName: '',
4017
- email: ''
4145
+ firstName: userData.first_name || '',
4146
+ lastName: userData.last_name || '',
4147
+ email: userData.email || ''
4018
4148
  },
4019
4149
  onSubmit: handleSubmit
4020
4150
  }, React.createElement(Form, null, React.createElement(ErrorFocus, null), showTicketsField && React.createElement(React.Fragment, null, React.createElement("div", {
4021
4151
  className: "field-item"
4022
4152
  }, React.createElement(Field, {
4023
4153
  name: "ticketTypeId",
4024
- label: "Ticket types",
4154
+ label: "Type of Ticket",
4025
4155
  type: "select",
4026
4156
  component: CustomField,
4027
4157
  selectOptions: [{
@@ -4033,7 +4163,7 @@ var WaitingList = function WaitingList(_ref) {
4033
4163
  className: "field-item"
4034
4164
  }, React.createElement(Field, {
4035
4165
  name: "quantity",
4036
- label: "Quantity",
4166
+ label: "Quantity Requested",
4037
4167
  type: "select",
4038
4168
  component: CustomField,
4039
4169
  selectOptions: [{
@@ -4264,7 +4394,9 @@ var TicketsContainer = function TicketsContainer(_ref) {
4264
4394
  _ref$isAccessCodeEnab = _ref.isAccessCodeEnabled,
4265
4395
  isAccessCodeEnabled = _ref$isAccessCodeEnab === void 0 ? false : _ref$isAccessCodeEnab,
4266
4396
  _ref$hideSessionButto = _ref.hideSessionButtons,
4267
- hideSessionButtons = _ref$hideSessionButto === void 0 ? false : _ref$hideSessionButto;
4397
+ hideSessionButtons = _ref$hideSessionButto === void 0 ? false : _ref$hideSessionButto,
4398
+ _ref$hideWaitingList = _ref.hideWaitingList,
4399
+ hideWaitingList = _ref$hideWaitingList === void 0 ? false : _ref$hideWaitingList;
4268
4400
 
4269
4401
  var _useState = useState({}),
4270
4402
  selectedTickets = _useState[0],
@@ -4304,7 +4436,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
4304
4436
  promoCode = _useState8[0],
4305
4437
  setPromoCode = _useState8[1];
4306
4438
 
4307
- var _useState9 = useState(queryPromoCode),
4439
+ var _useState9 = useState(getQueryVariable('r') || queryPromoCode),
4308
4440
  promoCodeUpdated = _useState9[0],
4309
4441
  setPromoCodeUpdated = _useState9[1];
4310
4442
 
@@ -4555,9 +4687,14 @@ var TicketsContainer = function TicketsContainer(_ref) {
4555
4687
  getTicketsApi();
4556
4688
  };
4557
4689
 
4558
- var isAllTicketsSoldOut = !_some(tickets, function (item) {
4559
- return !(item.sold_out || item.soldOut);
4690
+ var isAllTicketsSoldOut = _every(tickets, function (item) {
4691
+ return item.sold_out || item.soldOut;
4560
4692
  });
4693
+
4694
+ var isTicketOnSale = _some(tickets, function (item) {
4695
+ return item.salesStarted && !item.salesEnded && !item.soldOut;
4696
+ });
4697
+
4561
4698
  var themeMui = createTheme$1(themeOptions);
4562
4699
  useEffect(function () {
4563
4700
  isWindowDefined && window.document.addEventListener('custom-logout', handleLogout);
@@ -4581,13 +4718,15 @@ var TicketsContainer = function TicketsContainer(_ref) {
4581
4718
  selectedTickets: selectedTickets,
4582
4719
  handleTicketSelect: handleTicketSelect,
4583
4720
  promoCodeIsApplied: promoCodeIsApplied
4584
- }), event != null && event.salesEnded ? React.createElement("p", null, "Sales for this event are closed.") : event != null && event.salesStart ? React.createElement(Countdown, {
4721
+ }), event != null && event.salesEnded ? React.createElement("p", {
4722
+ className: 'event-closed-message'
4723
+ }, "Sales for this event are closed.") : !(event != null && event.salesStarted) && event != null && event.salesStart ? React.createElement(Countdown, {
4585
4724
  startDate: event.salesStart,
4586
4725
  timezone: event.timezone,
4587
4726
  title: "Sales start in:",
4588
4727
  message: "No tickets are currently available for this event.",
4589
4728
  callback: updateTickets
4590
- }) : null, showWaitingList && event.salesStarted && React.createElement(WaitingList, {
4729
+ }) : null, showWaitingList && event.salesStarted && !hideWaitingList && React.createElement(WaitingList, {
4591
4730
  tickets: tickets,
4592
4731
  eventId: eventId
4593
4732
  }), React.createElement(PromoCodeSection, {
@@ -4600,7 +4739,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
4600
4739
  isPromotionsEnabled: isPromotionsEnabled,
4601
4740
  isAccessCodeEnabled: isAccessCodeEnabled,
4602
4741
  isAllTicketsSoldOut: isAllTicketsSoldOut
4603
- }), !isAllTicketsSoldOut && React.createElement(Button$1, {
4742
+ }), (isTicketOnSale || !(event != null && event.salesEnded)) && React.createElement(Button$1, {
4604
4743
  "aria-hidden": true,
4605
4744
  className: "book-button " + (handleBookIsLoading || _isEmpty(selectedTickets) || Object.values(selectedTickets)[0] === 0 ? 'disabled' : ''),
4606
4745
  onClick: !handleBookIsLoading && !_isEmpty(selectedTickets) && Object.values(selectedTickets)[0] > 0 ? handleBook : function () {}