tf-checkout-react 1.0.100 → 1.0.104

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.
Files changed (84) hide show
  1. package/dist/components/billing-info-container/index.d.ts +3 -1
  2. package/dist/components/common/RedirectModal.d.ts +7 -0
  3. package/dist/components/common/SnackbarAlert.d.ts +13 -0
  4. package/dist/components/confirmationContainer/index.d.ts +2 -1
  5. package/dist/components/ticketsContainer/index.d.ts +2 -1
  6. package/dist/env.d.ts +1 -0
  7. package/dist/images/done.svg +3 -3
  8. package/dist/index.d.ts +1 -0
  9. package/dist/tf-checkout-react.cjs.development.js +317 -136
  10. package/dist/tf-checkout-react.cjs.development.js.map +1 -1
  11. package/dist/tf-checkout-react.cjs.production.min.js +1 -1
  12. package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
  13. package/dist/tf-checkout-react.esm.js +318 -138
  14. package/dist/tf-checkout-react.esm.js.map +1 -1
  15. package/dist/tf-checkout-styles.css +1 -1
  16. package/package.json +89 -89
  17. package/src/.DS_Store +0 -0
  18. package/src/.d.ts +2 -2
  19. package/src/api/index.ts +293 -278
  20. package/src/assets/images/done.svg +3 -3
  21. package/src/components/.DS_Store +0 -0
  22. package/src/components/billing-info-container/index.tsx +796 -777
  23. package/src/components/billing-info-container/style.css +105 -105
  24. package/src/components/billing-info-container/utils.ts +224 -224
  25. package/src/components/common/CheckboxField.tsx +41 -41
  26. package/src/components/common/CustomField.tsx +84 -84
  27. package/src/components/common/FormikPhoneNumberField.tsx +51 -51
  28. package/src/components/common/Loader.tsx +9 -9
  29. package/src/components/common/RadioField.tsx +35 -35
  30. package/src/components/common/RedirectModal.tsx +43 -0
  31. package/src/components/common/SelectField.tsx +80 -80
  32. package/src/components/common/SnackbarAlert.tsx +54 -0
  33. package/src/components/common/index.tsx +4 -4
  34. package/src/components/confirmModal/index.tsx +51 -51
  35. package/src/components/confirmModal/style.css +21 -21
  36. package/src/components/confirmationContainer/config.ts +72 -72
  37. package/src/components/confirmationContainer/index.tsx +197 -194
  38. package/src/components/confirmationContainer/social-buttons.tsx +94 -94
  39. package/src/components/confirmationContainer/style.css +202 -202
  40. package/src/components/countdown/index.tsx +89 -89
  41. package/src/components/countdown/style.css +9 -9
  42. package/src/components/index.ts +7 -7
  43. package/src/components/loginModal/index.tsx +209 -209
  44. package/src/components/loginModal/style.css +71 -71
  45. package/src/components/myTicketsContainer/index.tsx +196 -137
  46. package/src/components/myTicketsContainer/row.tsx +41 -41
  47. package/src/components/myTicketsContainer/style.css +39 -39
  48. package/src/components/myTicketsContainer/tableConfig.tsx +34 -34
  49. package/src/components/orderDetailsContainer/index.tsx +249 -249
  50. package/src/components/orderDetailsContainer/style.css +72 -72
  51. package/src/components/orderDetailsContainer/ticketsTable.tsx +124 -124
  52. package/src/components/paymentContainer/index.tsx +284 -284
  53. package/src/components/registerModal/index.tsx +190 -190
  54. package/src/components/stripePayment/index.tsx +253 -253
  55. package/src/components/stripePayment/style.css +59 -59
  56. package/src/components/ticketResale/index.tsx +56 -56
  57. package/src/components/ticketResaleModal/index.tsx +210 -210
  58. package/src/components/ticketResaleModal/style.css +28 -28
  59. package/src/components/ticketsContainer/PromoCodeSection.tsx +99 -99
  60. package/src/components/ticketsContainer/ReferralLogic.tsx +33 -33
  61. package/src/components/ticketsContainer/TicketRow.tsx +83 -83
  62. package/src/components/ticketsContainer/TicketsSection.tsx +81 -81
  63. package/src/components/ticketsContainer/index.tsx +427 -409
  64. package/src/components/ticketsContainer/style.css +181 -181
  65. package/src/components/ticketsContainer/utils.ts +11 -11
  66. package/src/components/timerWidget/index.tsx +70 -70
  67. package/src/components/timerWidget/style.css +26 -26
  68. package/src/components/waitingList/index.tsx +178 -178
  69. package/src/components/waitingList/style.css +26 -26
  70. package/src/env.ts +20 -19
  71. package/src/index.ts +14 -13
  72. package/src/normalizers/index.ts +45 -45
  73. package/src/types/billing-info-data.ts +37 -37
  74. package/src/types/payment-field.ts +7 -7
  75. package/src/types/referral-promotion.ts +7 -7
  76. package/src/utils/createCheckoutDataBodyWithDefaultHolder.ts +59 -59
  77. package/src/utils/downloadPDF.tsx +30 -30
  78. package/src/utils/formikErrorFocus.ts +24 -24
  79. package/src/utils/getImage.ts +14 -14
  80. package/src/utils/getQueryVariable.ts +13 -13
  81. package/src/utils/index.ts +5 -5
  82. package/src/utils/setConfigs.ts +26 -26
  83. package/src/utils/showZero.tsx +10 -10
  84. package/src/validators/index.ts +20 -20
@@ -9,7 +9,7 @@ import _isEqual from 'lodash-es/isEqual';
9
9
  import _isEmpty from 'lodash-es/isEmpty';
10
10
  import axios from 'axios';
11
11
  import _forEach from 'lodash-es/forEach';
12
- import { TextField, FormControl, FormHelperText, InputLabel, CircularProgress as CircularProgress$1, Alert, createTheme as createTheme$1 } from '@mui/material';
12
+ import { TextField, FormControl, FormHelperText, InputLabel, Snackbar, Alert, CircularProgress as CircularProgress$1, createTheme as createTheme$1 } from '@mui/material';
13
13
  import Modal from '@mui/material/Modal';
14
14
  import Box from '@mui/material/Box';
15
15
  import _flatMapDeep from 'lodash-es/flatMapDeep';
@@ -25,12 +25,12 @@ import CircularProgress from '@mui/material/CircularProgress';
25
25
  import Select from '@mui/material/Select';
26
26
  import { createTheme, ThemeProvider } from '@mui/material/styles';
27
27
  import Backdrop from '@mui/material/Backdrop';
28
+ import Countdown$1 from 'react-countdown';
29
+ import _isNumber from 'lodash-es/isNumber';
28
30
  import Container from '@mui/material/Container';
29
31
  import Alert$1 from '@mui/material/Alert';
30
32
  import { useStripe, useElements, CardNumberElement, CardExpiryElement, CardCvcElement, Elements } from '@stripe/react-stripe-js';
31
33
  import { loadStripe } from '@stripe/stripe-js';
32
- import Countdown$1 from 'react-countdown';
33
- import _isNumber from 'lodash-es/isNumber';
34
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';
35
35
  import _some from 'lodash-es/some';
36
36
  import _every from 'lodash-es/every';
@@ -1114,6 +1114,13 @@ var publicRequest = /*#__PURE__*/axios.create({
1114
1114
  headers: ttfHeaders
1115
1115
  });
1116
1116
  publicRequest.interceptors.response.use(function (response) {
1117
+ var authGuestToken = _get(response, 'headers.authorization-guest');
1118
+
1119
+ if (isWindowDefined && authGuestToken) {
1120
+ window.localStorage.setItem('auth_guest_token', authGuestToken);
1121
+ publicRequest.setGuestToken(authGuestToken);
1122
+ }
1123
+
1117
1124
  return response;
1118
1125
  }, function (error) {
1119
1126
  var _error$response;
@@ -1122,7 +1129,6 @@ publicRequest.interceptors.response.use(function (response) {
1122
1129
  if (isWindowDefined) {
1123
1130
  var _error$response2, _error$response2$data;
1124
1131
 
1125
- window.localStorage.removeItem('auth_guest_token');
1126
1132
  window.localStorage.removeItem('user_data');
1127
1133
  window.localStorage.removeItem('access_token');
1128
1134
  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;
@@ -1133,6 +1139,13 @@ publicRequest.interceptors.response.use(function (response) {
1133
1139
  }
1134
1140
  }
1135
1141
 
1142
+ var authGuestToken = _get(error, 'response.headers.authorization-guest');
1143
+
1144
+ if (isWindowDefined && authGuestToken) {
1145
+ window.localStorage.setItem('auth_guest_token', authGuestToken);
1146
+ publicRequest.setGuestToken(authGuestToken);
1147
+ }
1148
+
1136
1149
  return Promise.reject(error);
1137
1150
  });
1138
1151
  publicRequest.interceptors.request.use(function (config) {
@@ -2160,6 +2173,99 @@ var SelectField = function SelectField(_ref) {
2160
2173
  }, error) : null);
2161
2174
  };
2162
2175
 
2176
+ var showZero = function showZero(value) {
2177
+ if (value === void 0) {
2178
+ value = 0;
2179
+ }
2180
+
2181
+ var intNumber = Number(value);
2182
+ return _isNumber(intNumber) ? intNumber >= 0 && intNumber < 10 ? '0' + intNumber : intNumber : null;
2183
+ };
2184
+
2185
+ var TimerWidget = function TimerWidget(_ref) {
2186
+ var expires_at = _ref.expires_at,
2187
+ buyLoading = _ref.buyLoading,
2188
+ _ref$onCountdownFinis = _ref.onCountdownFinish,
2189
+ onCountdownFinish = _ref$onCountdownFinis === void 0 ? function () {} : _ref$onCountdownFinis;
2190
+
2191
+ var _useState = useState(true),
2192
+ showTimer = _useState[0],
2193
+ setShowTimer = _useState[1];
2194
+
2195
+ var handleCountdownFinish = function handleCountdownFinish() {
2196
+ setShowTimer(false);
2197
+
2198
+ if (!buyLoading) {
2199
+ onCountdownFinish();
2200
+ }
2201
+ };
2202
+
2203
+ var _renderer = function renderer(_ref2) {
2204
+ var minutes = _ref2.minutes,
2205
+ seconds = _ref2.seconds,
2206
+ completed = _ref2.completed,
2207
+ handleCountdownFinish = _ref2.handleCountdownFinish;
2208
+
2209
+ if (completed) {
2210
+ handleCountdownFinish();
2211
+ return null;
2212
+ }
2213
+
2214
+ return React.createElement("span", null, showZero(minutes), ":", showZero(seconds));
2215
+ };
2216
+
2217
+ return showTimer && !!expires_at ? React.createElement("div", {
2218
+ className: "timer"
2219
+ }, React.createElement("div", {
2220
+ className: "toast-message"
2221
+ }, React.createElement("p", null, "Please complete your purchase before the timer reaches zero."), React.createElement("p", {
2222
+ className: "countdown"
2223
+ }, React.createElement(Countdown$1, {
2224
+ date: Date.now() + expires_at * 1000,
2225
+ renderer: function renderer(props) {
2226
+ return _renderer(_extends({}, props, {
2227
+ handleCountdownFinish: handleCountdownFinish
2228
+ }));
2229
+ }
2230
+ })))) : null;
2231
+ };
2232
+
2233
+ var SnackbarAlert = function SnackbarAlert(_ref) {
2234
+ var isOpen = _ref.isOpen,
2235
+ message = _ref.message,
2236
+ type = _ref.type,
2237
+ position = _ref.position,
2238
+ _ref$autoHideDuration = _ref.autoHideDuration,
2239
+ autoHideDuration = _ref$autoHideDuration === void 0 ? 3000 : _ref$autoHideDuration,
2240
+ variant = _ref.variant,
2241
+ onClose = _ref.onClose;
2242
+ return React.createElement("div", {
2243
+ className: "snackbar-alert-container"
2244
+ }, React.createElement(Snackbar, {
2245
+ autoHideDuration: autoHideDuration,
2246
+ open: isOpen,
2247
+ anchorOrigin: position || {
2248
+ vertical: 'top',
2249
+ horizontal: 'center'
2250
+ },
2251
+ onClose: onClose,
2252
+ classes: {
2253
+ root: 'snackbar-alert-snackbar-root'
2254
+ }
2255
+ }, React.createElement(Alert, {
2256
+ severity: type,
2257
+ onClose: onClose,
2258
+ variant: variant || 'filled',
2259
+ classes: {
2260
+ icon: 'snackbar-alert-icon',
2261
+ root: 'snackbar-alert-alert-root',
2262
+ action: 'snackbar-alert-action',
2263
+ message: 'snackbar-alert-message',
2264
+ filled: 'snackbar-alert-filled'
2265
+ }
2266
+ }, message)));
2267
+ };
2268
+
2163
2269
  var LogicRunner = function LogicRunner(_ref) {
2164
2270
  var values = _ref.values,
2165
2271
  setStates = _ref.setStates,
@@ -2322,7 +2428,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2322
2428
  _ref3$skipPage = _ref3.skipPage,
2323
2429
  skipPage = _ref3$skipPage === void 0 ? false : _ref3$skipPage,
2324
2430
  _ref3$canSkipHolderNa = _ref3.canSkipHolderNames,
2325
- canSkipHolderNames = _ref3$canSkipHolderNa === void 0 ? false : _ref3$canSkipHolderNa;
2431
+ canSkipHolderNames = _ref3$canSkipHolderNa === void 0 ? false : _ref3$canSkipHolderNa,
2432
+ _ref3$onCountdownFini = _ref3.onCountdownFinish,
2433
+ onCountdownFinish = _ref3$onCountdownFini === void 0 ? function () {} : _ref3$onCountdownFini,
2434
+ _ref3$enableTimer = _ref3.enableTimer,
2435
+ enableTimer = _ref3$enableTimer === void 0 ? false : _ref3$enableTimer;
2326
2436
 
2327
2437
  var themeMui = createTheme(themeOptions);
2328
2438
  var isWindowDefined = typeof window !== 'undefined';
@@ -2411,6 +2521,8 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2411
2521
 
2412
2522
  var hideTtfOptIn = _get(cartInfoData, 'hide_ttf_opt_in', true);
2413
2523
 
2524
+ var expirationTime = _get(cartInfoData, 'expires_at');
2525
+
2414
2526
  var flagRequirePhone = getQueryVariable('phone_required') === 'true'; // Get prevProps
2415
2527
 
2416
2528
  var prevData = useRef(data);
@@ -2685,7 +2797,10 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2685
2797
 
2686
2798
  return React.createElement(ThemeProvider, {
2687
2799
  theme: themeMui
2688
- }, React.createElement(Formik, {
2800
+ }, expirationTime && enableTimer && React.createElement(TimerWidget, {
2801
+ expires_at: expirationTime,
2802
+ onCountdownFinish: onCountdownFinish
2803
+ }), React.createElement(Formik, {
2689
2804
  initialValues: getInitialValues(dataWithUniqueIds, _extends({}, initialValues, {
2690
2805
  country: _get(userData, 'country', '') || '1',
2691
2806
  state: _get(userData, 'state', '') || '1',
@@ -2782,6 +2897,10 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2782
2897
  setShowModalLogin(true);
2783
2898
  }
2784
2899
 
2900
+ if (_includes(_error, 'The cart is expired') && !hideErrorsAlertSection) {
2901
+ setError(_error);
2902
+ }
2903
+
2785
2904
  onRegisterError(_context6.t0, values.email);
2786
2905
  }
2787
2906
 
@@ -2824,11 +2943,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2824
2943
  }
2825
2944
  }
2826
2945
 
2827
- if ((_e$response3 = _context6.t1.response) != null && _e$response3.data.message) {
2828
- if (typeof document !== undefined) {
2829
- document.body.scrollTop = document.documentElement.scrollTop = 0;
2830
- }
2831
-
2946
+ if ((_e$response3 = _context6.t1.response) != null && _e$response3.data.message && !hideErrorsAlertSection) {
2832
2947
  setError(_get(_context6.t1, 'response.data.message'));
2833
2948
  }
2834
2949
 
@@ -2862,11 +2977,15 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2862
2977
  onGetStatesError: onGetStatesError
2863
2978
  }), React.createElement("div", {
2864
2979
  className: "billing-info-container " + theme
2865
- }, error && !hideErrorsAlertSection && React.createElement(Alert, {
2866
- severity: "error",
2867
- onClose: onErrorClose,
2868
- variant: "filled"
2869
- }, error), !isLoggedIn && React.createElement("div", {
2980
+ }, React.createElement(SnackbarAlert, {
2981
+ type: "error",
2982
+ isOpen: !!error,
2983
+ message: error || '',
2984
+ onClose: function onClose() {
2985
+ setError(null);
2986
+ onErrorClose();
2987
+ }
2988
+ }), !isLoggedIn && React.createElement("div", {
2870
2989
  className: "account-actions-block"
2871
2990
  }, React.createElement("div", null, accountInfoTitle), React.createElement("div", null, "Login & skip ahead:"), React.createElement("div", {
2872
2991
  className: "login-block"
@@ -3272,63 +3391,6 @@ var CheckoutForm = function CheckoutForm(_ref) {
3272
3391
  }) : "Pay " + getCurrencySymbolByCurrency(currency) + total))));
3273
3392
  };
3274
3393
 
3275
- var showZero = function showZero(value) {
3276
- if (value === void 0) {
3277
- value = 0;
3278
- }
3279
-
3280
- var intNumber = Number(value);
3281
- return _isNumber(intNumber) ? intNumber >= 0 && intNumber < 10 ? '0' + intNumber : intNumber : null;
3282
- };
3283
-
3284
- var TimerWidget = function TimerWidget(_ref) {
3285
- var expires_at = _ref.expires_at,
3286
- buyLoading = _ref.buyLoading,
3287
- _ref$onCountdownFinis = _ref.onCountdownFinish,
3288
- onCountdownFinish = _ref$onCountdownFinis === void 0 ? function () {} : _ref$onCountdownFinis;
3289
-
3290
- var _useState = useState(true),
3291
- showTimer = _useState[0],
3292
- setShowTimer = _useState[1];
3293
-
3294
- var handleCountdownFinish = function handleCountdownFinish() {
3295
- setShowTimer(false);
3296
-
3297
- if (!buyLoading) {
3298
- onCountdownFinish();
3299
- }
3300
- };
3301
-
3302
- var _renderer = function renderer(_ref2) {
3303
- var minutes = _ref2.minutes,
3304
- seconds = _ref2.seconds,
3305
- completed = _ref2.completed,
3306
- handleCountdownFinish = _ref2.handleCountdownFinish;
3307
-
3308
- if (completed) {
3309
- handleCountdownFinish();
3310
- return null;
3311
- }
3312
-
3313
- return React.createElement("span", null, showZero(minutes), ":", showZero(seconds));
3314
- };
3315
-
3316
- return showTimer && !!expires_at ? React.createElement("div", {
3317
- className: "timer"
3318
- }, React.createElement("div", {
3319
- className: "toast-message"
3320
- }, React.createElement("p", null, "Please complete your purchase before the timer reaches zero."), React.createElement("p", {
3321
- className: "countdown"
3322
- }, React.createElement(Countdown$1, {
3323
- date: Date.now() + expires_at * 1000,
3324
- renderer: function renderer(props) {
3325
- return _renderer(_extends({}, props, {
3326
- handleCountdownFinish: handleCountdownFinish
3327
- }));
3328
- }
3329
- })))) : null;
3330
- };
3331
-
3332
3394
  var publishableKey = CONFIGS.STRIPE_PUBLISHABLE_KEY || '';
3333
3395
 
3334
3396
  var getStripePromise = function getStripePromise(reviewData) {
@@ -3830,7 +3892,9 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
3830
3892
  onGetConfirmationDataSuccess = _ref$onGetConfirmatio === void 0 ? function () {} : _ref$onGetConfirmatio,
3831
3893
  _ref$onGetConfirmatio2 = _ref.onGetConfirmationDataError,
3832
3894
  onGetConfirmationDataError = _ref$onGetConfirmatio2 === void 0 ? function () {} : _ref$onGetConfirmatio2,
3833
- orderHash = _ref.orderHash;
3895
+ orderHash = _ref.orderHash,
3896
+ _ref$onLinkCopied = _ref.onLinkCopied,
3897
+ onLinkCopied = _ref$onLinkCopied === void 0 ? function () {} : _ref$onLinkCopied;
3834
3898
  var inputRef = useRef(null);
3835
3899
 
3836
3900
  var _useState = useState(null),
@@ -3968,7 +4032,8 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
3968
4032
  }), React.createElement("div", {
3969
4033
  className: "share-by-link-copy-icon",
3970
4034
  onClick: function onClick() {
3971
- return navigator.clipboard.writeText(_get(inputRef, 'current.value'));
4035
+ navigator.clipboard.writeText(_get(inputRef, 'current.value'));
4036
+ onLinkCopied();
3972
4037
  }
3973
4038
  }, React.createElement("img", {
3974
4039
  src: "https://img.icons8.com/office/50/000000/copy.png",
@@ -4519,7 +4584,9 @@ var TicketsContainer = function TicketsContainer(_ref) {
4519
4584
  _ref$hideSessionButto = _ref.hideSessionButtons,
4520
4585
  hideSessionButtons = _ref$hideSessionButto === void 0 ? false : _ref$hideSessionButto,
4521
4586
  _ref$hideWaitingList = _ref.hideWaitingList,
4522
- hideWaitingList = _ref$hideWaitingList === void 0 ? false : _ref$hideWaitingList;
4587
+ hideWaitingList = _ref$hideWaitingList === void 0 ? false : _ref$hideWaitingList,
4588
+ _ref$isButtonScrollab = _ref.isButtonScrollable,
4589
+ isButtonScrollable = _ref$isButtonScrollab === void 0 ? false : _ref$isButtonScrollab;
4523
4590
 
4524
4591
  var _useState = useState({}),
4525
4592
  selectedTickets = _useState[0],
@@ -4531,50 +4598,51 @@ var TicketsContainer = function TicketsContainer(_ref) {
4531
4598
  isLogged = _useState2[0],
4532
4599
  setIsLogged = _useState2[1];
4533
4600
 
4534
- var _React$useState = React.useState(false),
4535
- showLoginModal = _React$useState[0],
4536
- setShowLoginModal = _React$useState[1];
4537
-
4538
- var _useState3 = useState([]),
4539
- tickets = _useState3[0],
4540
- setTickets = _useState3[1];
4601
+ var _useState3 = useState(false),
4602
+ showLoginModal = _useState3[0],
4603
+ setShowLoginModal = _useState3[1];
4541
4604
 
4542
- var _useState4 = useState(null),
4543
- event = _useState4[0],
4544
- setEvent = _useState4[1];
4605
+ var _useState4 = useState([]),
4606
+ tickets = _useState4[0],
4607
+ setTickets = _useState4[1];
4545
4608
 
4546
- var _useState5 = useState(false),
4547
- showWaitingList = _useState5[0],
4548
- setShowWaitingList = _useState5[1];
4609
+ var _useState5 = useState(null),
4610
+ event = _useState5[0],
4611
+ setEvent = _useState5[1];
4549
4612
 
4550
4613
  var _useState6 = useState(false),
4551
- isLoading = _useState6[0],
4552
- setIsLoading = _useState6[1];
4614
+ showWaitingList = _useState6[0],
4615
+ setShowWaitingList = _useState6[1];
4553
4616
 
4554
- var _useState7 = useState(false),
4555
- isPromoLoading = _useState7[0],
4556
- setIsPromoLoading = _useState7[1];
4617
+ var _useState7 = useState(true),
4618
+ isLoading = _useState7[0],
4619
+ setIsLoading = _useState7[1];
4557
4620
 
4558
4621
  var _useState8 = useState(false),
4559
- handleBookIsLoading = _useState8[0],
4560
- setHandleBookIsLoading = _useState8[1];
4622
+ isPromoLoading = _useState8[0],
4623
+ setIsPromoLoading = _useState8[1];
4561
4624
 
4562
- var _useState9 = useState(''),
4563
- promoCode = _useState9[0],
4564
- setPromoCode = _useState9[1];
4625
+ var _useState9 = useState(false),
4626
+ handleBookIsLoading = _useState9[0],
4627
+ setHandleBookIsLoading = _useState9[1];
4565
4628
 
4566
- var _useState10 = useState(getQueryVariable('r') || queryPromoCode),
4567
- promoCodeUpdated = _useState10[0],
4568
- setPromoCodeUpdated = _useState10[1];
4629
+ var _useState10 = useState(''),
4630
+ promoCode = _useState10[0],
4631
+ setPromoCode = _useState10[1];
4569
4632
 
4570
- var _useState11 = useState(false),
4571
- showPromoInput = _useState11[0],
4572
- setShowPromoInput = _useState11[1];
4633
+ var _useState11 = useState(getQueryVariable('r') || queryPromoCode),
4634
+ promoCodeUpdated = _useState11[0],
4635
+ setPromoCodeUpdated = _useState11[1];
4573
4636
 
4574
4637
  var _useState12 = useState(false),
4575
- promoCodeIsApplied = _useState12[0],
4576
- setPromoCodeIsApplied = _useState12[1];
4638
+ showPromoInput = _useState12[0],
4639
+ setShowPromoInput = _useState12[1];
4640
+
4641
+ var _useState13 = useState(false),
4642
+ promoCodeIsApplied = _useState13[0],
4643
+ setPromoCodeIsApplied = _useState13[1];
4577
4644
 
4645
+ var ticketsContainerRef = useRef(null);
4578
4646
  useEffect(function () {
4579
4647
  if (typeof window !== 'undefined') {
4580
4648
  var access_token = window.localStorage.getItem('access_token');
@@ -4605,6 +4673,19 @@ var TicketsContainer = function TicketsContainer(_ref) {
4605
4673
  }
4606
4674
  };
4607
4675
 
4676
+ useEffect(function () {
4677
+ try {
4678
+ if (typeof window !== 'undefined') {
4679
+ var userData = window.localStorage.getItem('user_data') ? JSON.parse(window.localStorage.getItem('user_data') || '{}') : {};
4680
+
4681
+ if (userData.country === '') {
4682
+ handleLogout();
4683
+ window.open("https://www.ticketfairy.com/account/change_information?need_country=true");
4684
+ }
4685
+ }
4686
+ } catch (e) {}
4687
+ }, []);
4688
+
4608
4689
  var handleExternalLogin = function handleExternalLogin() {
4609
4690
  setIsLogged(true);
4610
4691
  };
@@ -4649,7 +4730,6 @@ var TicketsContainer = function TicketsContainer(_ref) {
4649
4730
  eventResponse = _context2.sent;
4650
4731
 
4651
4732
  if (response.data.success) {
4652
- setCustomHeader(response);
4653
4733
  attributes = _get(response, 'data.data.attributes');
4654
4734
  setPromoCodeIsApplied(attributes.ValidPromoCode);
4655
4735
  setTickets(_get(attributes, 'tickets'));
@@ -4745,11 +4825,10 @@ var TicketsContainer = function TicketsContainer(_ref) {
4745
4825
  result = _context.sent;
4746
4826
 
4747
4827
  if (!(result.status === 200)) {
4748
- _context.next = 27;
4828
+ _context.next = 26;
4749
4829
  break;
4750
4830
  }
4751
4831
 
4752
- setCustomHeader(result);
4753
4832
  skipBillingPage = (_result$data$data$att = result == null ? void 0 : (_result$data = result.data) == null ? void 0 : (_result$data$data = _result$data.data) == null ? void 0 : (_result$data$data$att2 = _result$data$data.attributes) == null ? void 0 : _result$data$data$att2.skip_billing_page) != null ? _result$data$data$att : false;
4754
4833
  nameIsRequired = (_result$data$data$att3 = result == null ? void 0 : (_result$data2 = result.data) == null ? void 0 : (_result$data2$data = _result$data2.data) == null ? void 0 : (_result$data2$data$at = _result$data2$data.attributes) == null ? void 0 : _result$data2$data$at.names_required) != null ? _result$data$data$att3 : false;
4755
4834
  ageIsRequired = (_result$data$data$att4 = result == null ? void 0 : (_result$data3 = result.data) == null ? void 0 : (_result$data3$data = _result$data3.data) == null ? void 0 : (_result$data3$data$at = _result$data3$data.attributes) == null ? void 0 : _result$data3$data$at.age_required) != null ? _result$data$data$att4 : false;
@@ -4757,7 +4836,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
4757
4836
  hash = '';
4758
4837
 
4759
4838
  if (!skipBillingPage) {
4760
- _context.next = 26;
4839
+ _context.next = 25;
4761
4840
  break;
4762
4841
  }
4763
4842
 
@@ -4766,14 +4845,14 @@ var TicketsContainer = function TicketsContainer(_ref) {
4766
4845
  userData = _isWindowDefined && window.localStorage.getItem('user_data') ? JSON.parse(window.localStorage.getItem('user_data') || '') : {};
4767
4846
  access_token = _isWindowDefined && window.localStorage.getItem('access_token') ? window.localStorage.getItem('access_token') || '' : '';
4768
4847
  checkoutBody = createCheckoutDataBodyWithDefaultHolder(ticketQuantity, userData);
4769
- _context.next = 24;
4848
+ _context.next = 23;
4770
4849
  return postOnCheckout(checkoutBody, access_token);
4771
4850
 
4772
- case 24:
4851
+ case 23:
4773
4852
  checkoutResult = _context.sent;
4774
4853
  hash = _get(checkoutResult, 'data.data.attributes.hash');
4775
4854
 
4776
- case 26:
4855
+ case 25:
4777
4856
  onAddToCartSuccess({
4778
4857
  skip_billing_page: skipBillingPage,
4779
4858
  names_required: nameIsRequired,
@@ -4783,29 +4862,29 @@ var TicketsContainer = function TicketsContainer(_ref) {
4783
4862
  hash: hash
4784
4863
  });
4785
4864
 
4786
- case 27:
4787
- _context.next = 32;
4865
+ case 26:
4866
+ _context.next = 31;
4788
4867
  break;
4789
4868
 
4790
- case 29:
4791
- _context.prev = 29;
4869
+ case 28:
4870
+ _context.prev = 28;
4792
4871
  _context.t0 = _context["catch"](6);
4793
4872
 
4794
4873
  if (axios.isAxiosError(_context.t0)) {
4795
4874
  onAddToCartError(_context.t0);
4796
4875
  }
4797
4876
 
4798
- case 32:
4799
- _context.prev = 32;
4877
+ case 31:
4878
+ _context.prev = 31;
4800
4879
  setHandleBookIsLoading(false);
4801
- return _context.finish(32);
4880
+ return _context.finish(31);
4802
4881
 
4803
- case 35:
4882
+ case 34:
4804
4883
  case "end":
4805
4884
  return _context.stop();
4806
4885
  }
4807
4886
  }
4808
- }, _callee, null, [[6, 29, 32, 35]]);
4887
+ }, _callee, null, [[6, 28, 31, 34]]);
4809
4888
  }));
4810
4889
 
4811
4890
  return function handleBook() {
@@ -4838,14 +4917,32 @@ var TicketsContainer = function TicketsContainer(_ref) {
4838
4917
  isWindowDefined && window.document.removeEventListener('custom-login', handleExternalLogin);
4839
4918
  };
4840
4919
  }, []);
4920
+
4921
+ var handleGetTicketClick = function handleGetTicketClick() {
4922
+ if (!handleBookIsLoading && !_isEmpty(selectedTickets) && Object.values(selectedTickets)[0] > 0) {
4923
+ handleBook();
4924
+ } else {
4925
+ if (isButtonScrollable && ticketsContainerRef && ticketsContainerRef.current) {
4926
+ ticketsContainerRef.current.scrollIntoView({
4927
+ behavior: 'smooth',
4928
+ block: 'center',
4929
+ inline: 'nearest'
4930
+ });
4931
+ }
4932
+ }
4933
+ };
4934
+
4935
+ var bookButtonIsDisabled = handleBookIsLoading || _isEmpty(selectedTickets) || Object.values(selectedTickets)[0] === 0;
4841
4936
  return React.createElement(ThemeProvider$1, {
4842
4937
  theme: themeMui
4843
- }, React.createElement(ReferralLogic, {
4938
+ }, !isLoading && React.createElement(ReferralLogic, {
4844
4939
  eventId: eventId
4845
4940
  }), React.createElement("div", {
4846
4941
  className: "get-tickets-page " + theme,
4847
4942
  style: contentStyle
4848
- }, isLoading ? React.createElement(Loader, null) : React.createElement("div", null, React.createElement(TicketsSection, {
4943
+ }, isLoading ? React.createElement(Loader, null) : React.createElement("div", {
4944
+ ref: ticketsContainerRef
4945
+ }, React.createElement(TicketsSection, {
4849
4946
  ticketsList: tickets,
4850
4947
  selectedTickets: selectedTickets,
4851
4948
  handleTicketSelect: handleTicketSelect,
@@ -4874,8 +4971,8 @@ var TicketsContainer = function TicketsContainer(_ref) {
4874
4971
  isPromoLoading: isPromoLoading
4875
4972
  }), (isTicketOnSale || !(event != null && event.salesEnded)) && React.createElement(Button$1, {
4876
4973
  "aria-hidden": true,
4877
- className: "book-button " + (handleBookIsLoading || _isEmpty(selectedTickets) || Object.values(selectedTickets)[0] === 0 ? 'disabled' : ''),
4878
- onClick: !handleBookIsLoading && !_isEmpty(selectedTickets) && Object.values(selectedTickets)[0] > 0 ? handleBook : function () {}
4974
+ className: "book-button \n " + (bookButtonIsDisabled ? 'disabled' : '') + " \n " + (isButtonScrollable ? 'is-scrollable' : '') + "\n ",
4975
+ onClick: handleGetTicketClick
4879
4976
  }, getTicketsLabel || 'GET TICKETS'), isLogged && !hideSessionButtons ? React.createElement("div", {
4880
4977
  className: "session-wrapper"
4881
4978
  }, React.createElement("span", {
@@ -4985,16 +5082,30 @@ var MyTicketsContainer = function MyTicketsContainer(_ref) {
4985
5082
 
4986
5083
  var _useState4 = useState(''),
4987
5084
  filter = _useState4[0],
4988
- setFilter = _useState4[1]; //just once
5085
+ setFilter = _useState4[1];
5086
+
5087
+ var isWindowDefined = typeof window !== 'undefined';
5088
+
5089
+ var _useState5 = useState(isWindowDefined ? !!window.localStorage.getItem('access_token') : false),
5090
+ isLogged = _useState5[0],
5091
+ setIsLogged = _useState5[1];
5092
+
5093
+ var _useState6 = useState(false),
5094
+ showModalLogin = _useState6[0],
5095
+ setShowModalLogin = _useState6[1];
5096
+
5097
+ var _useState7 = useState(false),
5098
+ userExpired = _useState7[0],
5099
+ setUserExpired = _useState7[1]; //just once
4989
5100
 
4990
5101
 
4991
5102
  useEffect(function () {
4992
5103
  fetchData(1, limit, filter);
4993
- }, []);
5104
+ }, [isLogged]);
4994
5105
 
4995
5106
  var fetchData = /*#__PURE__*/function () {
4996
5107
  var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(page, limit, filter) {
4997
- var response, _data;
5108
+ var response, _data, _error$response;
4998
5109
 
4999
5110
  return runtime_1.wrap(function _callee$(_context) {
5000
5111
  while (1) {
@@ -5011,25 +5122,37 @@ var MyTicketsContainer = function MyTicketsContainer(_ref) {
5011
5122
  _data = _get(response, 'data.data.attributes');
5012
5123
  _data.page -= 1;
5013
5124
  setData(_data);
5014
- _context.next = 14;
5125
+ _context.next = 15;
5015
5126
  break;
5016
5127
 
5017
5128
  case 11:
5018
5129
  _context.prev = 11;
5019
5130
  _context.t0 = _context["catch"](0);
5131
+
5132
+ if (axios.isAxiosError(_context.t0)) {
5133
+ if (((_error$response = _context.t0.response) == null ? void 0 : _error$response.data.error) === 'invalid_token') {
5134
+ if (isWindowDefined) {
5135
+ window.localStorage.removeItem('user_data');
5136
+ window.localStorage.removeItem('access_token');
5137
+ setUserExpired(true);
5138
+ setShowModalLogin(true);
5139
+ }
5140
+ }
5141
+ }
5142
+
5020
5143
  onGetOrdersError(_context.t0);
5021
5144
 
5022
- case 14:
5023
- _context.prev = 14;
5145
+ case 15:
5146
+ _context.prev = 15;
5024
5147
  setLoading(false);
5025
- return _context.finish(14);
5148
+ return _context.finish(15);
5026
5149
 
5027
- case 17:
5150
+ case 18:
5028
5151
  case "end":
5029
5152
  return _context.stop();
5030
5153
  }
5031
5154
  }
5032
- }, _callee, null, [[0, 11, 14, 17]]);
5155
+ }, _callee, null, [[0, 11, 15, 18]]);
5033
5156
  }));
5034
5157
 
5035
5158
  return function fetchData(_x, _x2, _x3) {
@@ -5055,7 +5178,22 @@ var MyTicketsContainer = function MyTicketsContainer(_ref) {
5055
5178
  className: "my-ticket " + theme
5056
5179
  }, loading && React.createElement("div", {
5057
5180
  className: "loading"
5058
- }, React.createElement(CircularProgress, null)), data && React.createElement(React.Fragment, null, React.createElement(Autocomplete, {
5181
+ }, React.createElement(CircularProgress, null)), !isLogged ? React.createElement("div", {
5182
+ className: "account-actions-block"
5183
+ }, React.createElement("div", {
5184
+ className: "login-block"
5185
+ }, React.createElement("button", {
5186
+ className: "login-register-button",
5187
+ type: "button",
5188
+ onClick: function onClick() {
5189
+ setShowModalLogin(true);
5190
+ }
5191
+ }, "Login"), React.createElement("div", {
5192
+ className: "logo-image-container"
5193
+ }, React.createElement("img", {
5194
+ src: theme === 'dark' ? 'https://www.ticketfairy.com/resources/images/logo-ttf.svg' : 'https://www.ticketfairy.com/resources/images/logo-ttf-black.svg',
5195
+ alt: "nodata"
5196
+ })))) : null, data && React.createElement(React.Fragment, null, React.createElement(Autocomplete, {
5059
5197
  disablePortal: true,
5060
5198
  id: "combo-box-demo",
5061
5199
  getOptionLabel: function getOptionLabel(option) {
@@ -5094,6 +5232,16 @@ var MyTicketsContainer = function MyTicketsContainer(_ref) {
5094
5232
  page: data.page,
5095
5233
  onPageChange: handleChangePage,
5096
5234
  onRowsPerPageChange: handleChangeRowsPerPage
5235
+ })), React.createElement(React.Fragment, null, showModalLogin && React.createElement(LoginModal, {
5236
+ onClose: function onClose() {
5237
+ setShowModalLogin(false);
5238
+ },
5239
+ onLogin: function onLogin() {
5240
+ setShowModalLogin(false);
5241
+ setUserExpired(false);
5242
+ setIsLogged(true);
5243
+ },
5244
+ userExpired: userExpired
5097
5245
  })));
5098
5246
  };
5099
5247
 
@@ -5690,5 +5838,37 @@ var TicketResaleContainer = function TicketResaleContainer(_ref) {
5690
5838
  }, React.createElement("h3", null, error)));
5691
5839
  };
5692
5840
 
5693
- export { BillingInfoContainer, ConfirmationContainer, LoginModal, MyTicketsContainer, OrderDetailsContainer, PaymentContainer, TicketResaleContainer, TicketsContainer, createFixedFloatNormalizer, currencyNormalizerCreator, setConfigs };
5841
+ var style$3 = {
5842
+ position: 'absolute',
5843
+ top: '10%',
5844
+ left: '50%',
5845
+ transform: 'translate(-50%, -50%)',
5846
+ minWidth: 480,
5847
+ backgroundColor: '#e3e3e3',
5848
+ border: '1px solid white',
5849
+ outline: 'none',
5850
+ padding: '14px',
5851
+ maxHeight: '85vh',
5852
+ overflow: 'auto'
5853
+ };
5854
+ var RedirectModal = function RedirectModal(_ref) {
5855
+ var _ref$message = _ref.message,
5856
+ message = _ref$message === void 0 ? 'Your cart has expired. Please click on "OK" to return to the ticket selection page.' : _ref$message,
5857
+ _ref$onClickOk = _ref.onClickOk,
5858
+ onClickOk = _ref$onClickOk === void 0 ? function () {} : _ref$onClickOk;
5859
+ return React.createElement(Modal, {
5860
+ open: true,
5861
+ "aria-labelledby": "modal-modal-title",
5862
+ "aria-describedby": "modal-modal-description",
5863
+ className: "redirect-modal"
5864
+ }, React.createElement(Box, {
5865
+ style: style$3
5866
+ }, React.createElement("p", null, message), React.createElement("div", {
5867
+ className: "footer"
5868
+ }, React.createElement("button", {
5869
+ onClick: onClickOk
5870
+ }, "OK"))));
5871
+ };
5872
+
5873
+ export { BillingInfoContainer, ConfirmationContainer, LoginModal, MyTicketsContainer, OrderDetailsContainer, PaymentContainer, RedirectModal, TicketResaleContainer, TicketsContainer, createFixedFloatNormalizer, currencyNormalizerCreator, setConfigs };
5694
5874
  //# sourceMappingURL=tf-checkout-react.esm.js.map