tf-checkout-react 1.2.16 → 1.2.19

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,8 +8,8 @@ export declare const publicRequest: IPublicRequest;
8
8
  export declare const setXSourceOrigin: (sourceOrigin: string) => void;
9
9
  export declare const setCustomHeader: (response: any) => void;
10
10
  export declare const handleSetAccessToken: (token: string) => void;
11
- export declare function getEvent(id: string | number): Promise<AxiosResponse<any, any>>;
12
- export declare function getTickets(id: string | number, promoCode: string): Promise<AxiosResponse<any, any>>;
11
+ export declare function getEvent(id: string | number, pk?: string): Promise<AxiosResponse<any, any>>;
12
+ export declare function getTickets(id: string | number, promoCode: string, pk?: string): Promise<AxiosResponse<any, any>>;
13
13
  export declare const addToCart: (id: string | number, data: any) => Promise<AxiosResponse<any, any>>;
14
14
  export declare const getCart: () => Promise<AxiosResponse<any, any>>;
15
15
  export declare const postOnCheckout: (data: any, accessToken?: string | undefined) => Promise<AxiosResponse<any, any>>;
@@ -1,9 +1,9 @@
1
- /// <reference types="react" />
2
1
  import './style.css';
3
2
  import { ThemeOptions } from '@mui/material';
4
3
  import { CSSProperties } from '@mui/styles';
5
4
  import { AxiosError } from 'axios';
6
5
  import { FormikHelpers, FormikValues } from 'formik';
6
+ import React from 'react';
7
7
  import { IBillingInfoData } from '../../types';
8
8
  export interface IBillingInfoPage {
9
9
  data?: IBillingInfoData[];
@@ -49,4 +49,4 @@ export interface IBillingInfoPage {
49
49
  showSignUpButton?: boolean;
50
50
  brandOptIn?: boolean;
51
51
  }
52
- export declare const BillingInfoContainer: ({ data, ticketHoldersFields, initialValues, buttonName, handleSubmit, theme, onRegisterSuccess, onRegisterError, onSubmitError, onGetCartSuccess, onGetCartError, onGetCountriesSuccess, onGetCountriesError, onGetStatesSuccess, onGetStatesError, onGetProfileDataSuccess, onGetProfileDataError, onAuthorizeSuccess, onAuthorizeError, onLogin, onLoginSuccess, isLoggedIn: pIsLoggedIn, accountInfoTitle, hideLogo, themeOptions, onErrorClose, hideErrorsAlertSection, onSkipBillingPage, skipPage, canSkipHolderNames, onForgotPasswordSuccess, onForgotPasswordError, shouldFetchCountries, onCountdownFinish, enableTimer, logo, showForgotPasswordButton, showSignUpButton, brandOptIn, }: IBillingInfoPage) => JSX.Element;
52
+ export declare const BillingInfoContainer: React.MemoExoticComponent<({ data, ticketHoldersFields, initialValues, buttonName, handleSubmit, theme, onRegisterSuccess, onRegisterError, onSubmitError, onGetCartSuccess, onGetCartError, onGetCountriesSuccess, onGetCountriesError, onGetStatesSuccess, onGetStatesError, onGetProfileDataSuccess, onGetProfileDataError, onAuthorizeSuccess, onAuthorizeError, onLogin, onLoginSuccess, isLoggedIn: pIsLoggedIn, accountInfoTitle, hideLogo, themeOptions, onErrorClose, hideErrorsAlertSection, onSkipBillingPage, skipPage, canSkipHolderNames, onForgotPasswordSuccess, onForgotPasswordError, shouldFetchCountries, onCountdownFinish, enableTimer, logo, showForgotPasswordButton, showSignUpButton, brandOptIn, }: IBillingInfoPage) => JSX.Element>;
@@ -7,5 +7,6 @@ export interface IPhoneNumberField {
7
7
  type: string;
8
8
  disableDropdown: boolean;
9
9
  fill: boolean;
10
+ setPhoneValidationIsLoading: (isLoading: boolean) => void;
10
11
  }
11
- export declare const PhoneNumberField: ({ label, field, form: { errors, touched, setFieldError, values, initialValues, setFieldValue, setFieldTouched, }, disableDropdown, fill, }: IPhoneNumberField) => JSX.Element;
12
+ export declare const PhoneNumberField: ({ label, field, form: { errors, touched, setFieldError, values, initialValues, setFieldValue, setFieldTouched, }, disableDropdown, fill, setPhoneValidationIsLoading, }: IPhoneNumberField) => JSX.Element;
@@ -50,5 +50,5 @@ export interface ITicket {
50
50
  export interface ISelectedTickets {
51
51
  [key: string]: string | number;
52
52
  }
53
- export declare const TicketsContainer: ({ onLoginSuccess, getTicketsLabel, eventId, onAddToCartSuccess, contentStyle, onAddToCartError, onGetTicketsSuccess, onGetTicketsError, onLogoutSuccess, onLogoutError, theme, queryPromoCode, isPromotionsEnabled, themeOptions, isAccessCodeEnabled, hideSessionButtons, hideWaitingList, enableBillingInfoAutoCreate, isButtonScrollable, sortBySoldOut, disableCountdownLeadingZero, isLoggedIn, actionsSectionComponent: ActionsSectionComponent, ticketsHeaderComponent, hideTicketsHeader, enableInfluencersSection }: IGetTickets) => JSX.Element;
53
+ export declare const TicketsContainer: ({ onLoginSuccess, getTicketsLabel, eventId, onAddToCartSuccess, contentStyle, onAddToCartError, onGetTicketsSuccess, onGetTicketsError, onLogoutSuccess, onLogoutError, theme, queryPromoCode, isPromotionsEnabled, themeOptions, isAccessCodeEnabled, hideSessionButtons, hideWaitingList, enableBillingInfoAutoCreate, isButtonScrollable, sortBySoldOut, disableCountdownLeadingZero, isLoggedIn, actionsSectionComponent: ActionsSectionComponent, ticketsHeaderComponent, hideTicketsHeader, enableInfluencersSection, }: IGetTickets) => JSX.Element;
54
54
  export {};
@@ -1312,7 +1312,7 @@ var handleSetAccessToken = function handleSetAccessToken(token) {
1312
1312
  }
1313
1313
  }
1314
1314
  };
1315
- function getEvent(id) {
1315
+ function getEvent(id, pk) {
1316
1316
  var referralValue = '';
1317
1317
 
1318
1318
  if (isWindowDefined) {
@@ -1330,6 +1330,9 @@ function getEvent(id) {
1330
1330
  }
1331
1331
 
1332
1332
  var response = publicRequest.get("v1/event/" + id, {
1333
+ params: {
1334
+ pk: pk
1335
+ },
1333
1336
  headers: _extends({}, ttfHeaders, {
1334
1337
  'Referer-Url': isDocumentDefined ? document.referrer : '',
1335
1338
  'Referrer-Id': isWindowDefined ? referralValue : ''
@@ -1339,8 +1342,11 @@ function getEvent(id) {
1339
1342
  });
1340
1343
  return response;
1341
1344
  }
1342
- function getTickets(id, promoCode) {
1343
- var response = publicRequest.get("v1/event/" + id + "/tickets/", {
1345
+ function getTickets(id, promoCode, pk) {
1346
+ var response = publicRequest.get("v1/event/" + id + "/tickets", {
1347
+ params: {
1348
+ pk: pk
1349
+ },
1344
1350
  headers: promoCode ? _extends({}, ttfHeaders, {
1345
1351
  'Promotion-Event': String(id),
1346
1352
  'Promotion-Code': promoCode
@@ -1689,7 +1695,8 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
1689
1695
  _ref$disableDropdown = _ref.disableDropdown,
1690
1696
  disableDropdown = _ref$disableDropdown === void 0 ? true : _ref$disableDropdown,
1691
1697
  _ref$fill = _ref.fill,
1692
- fill = _ref$fill === void 0 ? false : _ref$fill;
1698
+ fill = _ref$fill === void 0 ? false : _ref$fill,
1699
+ setPhoneValidationIsLoading = _ref.setPhoneValidationIsLoading;
1693
1700
 
1694
1701
  var error = _get(errors, field.name);
1695
1702
 
@@ -1699,11 +1706,8 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
1699
1706
  return void cb();
1700
1707
  }, 1000), []);
1701
1708
  React.useEffect(function () {
1702
- if (field.value === '+') {
1703
- setFieldError(field.name, '');
1704
- setFieldTouched(field.name, false);
1705
- setFieldValue(field.name, '');
1706
- return;
1709
+ if (field.value) {
1710
+ setPhoneValidationIsLoading(true);
1707
1711
  }
1708
1712
 
1709
1713
  debounceCb( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
@@ -1737,11 +1741,16 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
1737
1741
  }
1738
1742
 
1739
1743
  case 11:
1744
+ _context.prev = 11;
1745
+ setPhoneValidationIsLoading(false);
1746
+ return _context.finish(11);
1747
+
1748
+ case 14:
1740
1749
  case "end":
1741
1750
  return _context.stop();
1742
1751
  }
1743
1752
  }
1744
- }, _callee, null, [[0, 7]]);
1753
+ }, _callee, null, [[0, 7, 11, 14]]);
1745
1754
  }))); // eslint-disable-next-line
1746
1755
  }, [field.value]);
1747
1756
  return React__default.createElement(React__default.Fragment, null, React__default.createElement(MuiPhoneNumber, {
@@ -2755,7 +2764,7 @@ var LogicRunner = function LogicRunner(_ref) {
2755
2764
  return null;
2756
2765
  };
2757
2766
 
2758
- var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2767
+ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref3) {
2759
2768
  var _ref3$data = _ref3.data,
2760
2769
  data = _ref3$data === void 0 ? [] : _ref3$data,
2761
2770
  _ref3$ticketHoldersFi = _ref3.ticketHoldersFields,
@@ -2772,34 +2781,34 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2772
2781
  _ref3$theme = _ref3.theme,
2773
2782
  theme = _ref3$theme === void 0 ? 'light' : _ref3$theme,
2774
2783
  _ref3$onRegisterSucce = _ref3.onRegisterSuccess,
2775
- onRegisterSuccess = _ref3$onRegisterSucce === void 0 ? function () {} : _ref3$onRegisterSucce,
2784
+ onRegisterSuccess = _ref3$onRegisterSucce === void 0 ? _identity : _ref3$onRegisterSucce,
2776
2785
  _ref3$onRegisterError = _ref3.onRegisterError,
2777
- onRegisterError = _ref3$onRegisterError === void 0 ? function () {} : _ref3$onRegisterError,
2786
+ onRegisterError = _ref3$onRegisterError === void 0 ? _identity : _ref3$onRegisterError,
2778
2787
  _ref3$onSubmitError = _ref3.onSubmitError,
2779
- onSubmitError = _ref3$onSubmitError === void 0 ? function () {} : _ref3$onSubmitError,
2788
+ onSubmitError = _ref3$onSubmitError === void 0 ? _identity : _ref3$onSubmitError,
2780
2789
  _ref3$onGetCartSucces = _ref3.onGetCartSuccess,
2781
- onGetCartSuccess = _ref3$onGetCartSucces === void 0 ? function () {} : _ref3$onGetCartSucces,
2790
+ onGetCartSuccess = _ref3$onGetCartSucces === void 0 ? _identity : _ref3$onGetCartSucces,
2782
2791
  _ref3$onGetCartError = _ref3.onGetCartError,
2783
- onGetCartError = _ref3$onGetCartError === void 0 ? function () {} : _ref3$onGetCartError,
2792
+ onGetCartError = _ref3$onGetCartError === void 0 ? _identity : _ref3$onGetCartError,
2784
2793
  _ref3$onGetCountriesS = _ref3.onGetCountriesSuccess,
2785
- onGetCountriesSuccess = _ref3$onGetCountriesS === void 0 ? function () {} : _ref3$onGetCountriesS,
2794
+ onGetCountriesSuccess = _ref3$onGetCountriesS === void 0 ? _identity : _ref3$onGetCountriesS,
2786
2795
  _ref3$onGetCountriesE = _ref3.onGetCountriesError,
2787
- onGetCountriesError = _ref3$onGetCountriesE === void 0 ? function () {} : _ref3$onGetCountriesE,
2796
+ onGetCountriesError = _ref3$onGetCountriesE === void 0 ? _identity : _ref3$onGetCountriesE,
2788
2797
  _ref3$onGetStatesSucc = _ref3.onGetStatesSuccess,
2789
- onGetStatesSuccess = _ref3$onGetStatesSucc === void 0 ? function () {} : _ref3$onGetStatesSucc,
2798
+ onGetStatesSuccess = _ref3$onGetStatesSucc === void 0 ? _identity : _ref3$onGetStatesSucc,
2790
2799
  _ref3$onGetStatesErro = _ref3.onGetStatesError,
2791
- onGetStatesError = _ref3$onGetStatesErro === void 0 ? function () {} : _ref3$onGetStatesErro,
2800
+ onGetStatesError = _ref3$onGetStatesErro === void 0 ? _identity : _ref3$onGetStatesErro,
2792
2801
  _ref3$onGetProfileDat = _ref3.onGetProfileDataSuccess,
2793
- _onGetProfileDataSuccess = _ref3$onGetProfileDat === void 0 ? function () {} : _ref3$onGetProfileDat,
2802
+ _onGetProfileDataSuccess = _ref3$onGetProfileDat === void 0 ? _identity : _ref3$onGetProfileDat,
2794
2803
  _ref3$onGetProfileDat2 = _ref3.onGetProfileDataError,
2795
- onGetProfileDataError = _ref3$onGetProfileDat2 === void 0 ? function () {} : _ref3$onGetProfileDat2,
2804
+ onGetProfileDataError = _ref3$onGetProfileDat2 === void 0 ? _identity : _ref3$onGetProfileDat2,
2796
2805
  _ref3$onAuthorizeSucc = _ref3.onAuthorizeSuccess,
2797
- onAuthorizeSuccess = _ref3$onAuthorizeSucc === void 0 ? function () {} : _ref3$onAuthorizeSucc,
2806
+ onAuthorizeSuccess = _ref3$onAuthorizeSucc === void 0 ? _identity : _ref3$onAuthorizeSucc,
2798
2807
  _ref3$onAuthorizeErro = _ref3.onAuthorizeError,
2799
- onAuthorizeError = _ref3$onAuthorizeErro === void 0 ? function () {} : _ref3$onAuthorizeErro,
2808
+ onAuthorizeError = _ref3$onAuthorizeErro === void 0 ? _identity : _ref3$onAuthorizeErro,
2800
2809
  onLogin = _ref3.onLogin,
2801
2810
  _ref3$onLoginSuccess = _ref3.onLoginSuccess,
2802
- onLoginSuccess = _ref3$onLoginSuccess === void 0 ? function () {} : _ref3$onLoginSuccess,
2811
+ onLoginSuccess = _ref3$onLoginSuccess === void 0 ? _identity : _ref3$onLoginSuccess,
2803
2812
  _ref3$isLoggedIn = _ref3.isLoggedIn,
2804
2813
  pIsLoggedIn = _ref3$isLoggedIn === void 0 ? false : _ref3$isLoggedIn,
2805
2814
  _ref3$accountInfoTitl = _ref3.accountInfoTitle,
@@ -2807,23 +2816,23 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2807
2816
  hideLogo = _ref3.hideLogo,
2808
2817
  themeOptions = _ref3.themeOptions,
2809
2818
  _ref3$onErrorClose = _ref3.onErrorClose,
2810
- onErrorClose = _ref3$onErrorClose === void 0 ? function () {} : _ref3$onErrorClose,
2819
+ onErrorClose = _ref3$onErrorClose === void 0 ? _identity : _ref3$onErrorClose,
2811
2820
  _ref3$hideErrorsAlert = _ref3.hideErrorsAlertSection,
2812
2821
  hideErrorsAlertSection = _ref3$hideErrorsAlert === void 0 ? false : _ref3$hideErrorsAlert,
2813
2822
  _ref3$onSkipBillingPa = _ref3.onSkipBillingPage,
2814
- onSkipBillingPage = _ref3$onSkipBillingPa === void 0 ? function () {} : _ref3$onSkipBillingPa,
2823
+ onSkipBillingPage = _ref3$onSkipBillingPa === void 0 ? _identity : _ref3$onSkipBillingPa,
2815
2824
  _ref3$skipPage = _ref3.skipPage,
2816
2825
  skipPage = _ref3$skipPage === void 0 ? false : _ref3$skipPage,
2817
2826
  _ref3$canSkipHolderNa = _ref3.canSkipHolderNames,
2818
2827
  canSkipHolderNames = _ref3$canSkipHolderNa === void 0 ? false : _ref3$canSkipHolderNa,
2819
2828
  _ref3$onForgotPasswor = _ref3.onForgotPasswordSuccess,
2820
- onForgotPasswordSuccess = _ref3$onForgotPasswor === void 0 ? function () {} : _ref3$onForgotPasswor,
2829
+ onForgotPasswordSuccess = _ref3$onForgotPasswor === void 0 ? _identity : _ref3$onForgotPasswor,
2821
2830
  _ref3$onForgotPasswor2 = _ref3.onForgotPasswordError,
2822
- onForgotPasswordError = _ref3$onForgotPasswor2 === void 0 ? function () {} : _ref3$onForgotPasswor2,
2831
+ onForgotPasswordError = _ref3$onForgotPasswor2 === void 0 ? _identity : _ref3$onForgotPasswor2,
2823
2832
  _ref3$shouldFetchCoun = _ref3.shouldFetchCountries,
2824
2833
  shouldFetchCountries = _ref3$shouldFetchCoun === void 0 ? true : _ref3$shouldFetchCoun,
2825
2834
  _ref3$onCountdownFini = _ref3.onCountdownFinish,
2826
- onCountdownFinish = _ref3$onCountdownFini === void 0 ? function () {} : _ref3$onCountdownFini,
2835
+ onCountdownFinish = _ref3$onCountdownFini === void 0 ? _identity : _ref3$onCountdownFini,
2827
2836
  _ref3$enableTimer = _ref3.enableTimer,
2828
2837
  enableTimer = _ref3$enableTimer === void 0 ? false : _ref3$enableTimer,
2829
2838
  logo = _ref3.logo,
@@ -2911,6 +2920,10 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2911
2920
  error = _useState14[0],
2912
2921
  setError = _useState14[1];
2913
2922
 
2923
+ var _useState15 = React.useState(false),
2924
+ phoneValidationIsLoading = _useState15[0],
2925
+ setPhoneValidationIsLoading = _useState15[1];
2926
+
2914
2927
  var emailLogged = _get(userData, 'email', '') || _get(userValues, 'email', '');
2915
2928
 
2916
2929
  var firstNameLogged = _get(userData, 'first_name', '') || _get(userValues, 'first_name', '');
@@ -3116,6 +3129,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
3116
3129
 
3117
3130
  React.useEffect(function () {
3118
3131
  fetchUserData(access_token);
3132
+ fetchCart();
3119
3133
  }, [access_token, isLoggedIn]);
3120
3134
  React.useEffect(function () {
3121
3135
  var collectPaymentData = /*#__PURE__*/function () {
@@ -3512,7 +3526,8 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
3512
3526
  }, element.onValidate ? element.onValidate : function () {
3513
3527
  return props.errors[element.name + "-" + index];
3514
3528
  }),
3515
- disableDropdown: element.disableDropdown
3529
+ disableDropdown: element.disableDropdown,
3530
+ setPhoneValidationIsLoading: setPhoneValidationIsLoading
3516
3531
  }));
3517
3532
  })));
3518
3533
  }));
@@ -3522,7 +3537,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
3522
3537
  type: "submit",
3523
3538
  variant: "contained",
3524
3539
  className: "login-register-button",
3525
- disabled: props.isSubmitting
3540
+ disabled: props.isSubmitting || phoneValidationIsLoading
3526
3541
  }, props.isSubmitting ? React__default.createElement(material.CircularProgress, {
3527
3542
  size: 26
3528
3543
  }) : buttonName))));
@@ -3577,7 +3592,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
3577
3592
  onForgotPasswordSuccess: onForgotPasswordSuccess,
3578
3593
  onForgotPasswordError: onForgotPasswordError
3579
3594
  }));
3580
- };
3595
+ });
3581
3596
 
3582
3597
  var currencyNormalizerCreator = function currencyNormalizerCreator(value, currency) {
3583
3598
  return !value ? '' : "" + getCurrencySymbolByCurrency(currency) + value;
@@ -5361,7 +5376,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
5361
5376
 
5362
5377
  function _getTicketsApi() {
5363
5378
  _getTicketsApi = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(isUpdateingCode, type) {
5364
- var response, eventResponse, attributes, _event2;
5379
+ var previewKey, response, eventResponse, attributes, _event2;
5365
5380
 
5366
5381
  return runtime_1.wrap(function _callee3$(_context3) {
5367
5382
  while (1) {
@@ -5369,15 +5384,16 @@ var TicketsContainer = function TicketsContainer(_ref) {
5369
5384
  case 0:
5370
5385
  _context3.prev = 0;
5371
5386
  isUpdateingCode ? setCodeIsLoading(true) : setIsLoading(true);
5372
- _context3.next = 4;
5373
- return getTickets(eventId, code);
5387
+ previewKey = getQueryVariable('pk') || undefined;
5388
+ _context3.next = 5;
5389
+ return getTickets(eventId, code, previewKey);
5374
5390
 
5375
- case 4:
5391
+ case 5:
5376
5392
  response = _context3.sent;
5377
- _context3.next = 7;
5378
- return getEvent(eventId);
5393
+ _context3.next = 8;
5394
+ return getEvent(eventId, previewKey);
5379
5395
 
5380
- case 7:
5396
+ case 8:
5381
5397
  eventResponse = _context3.sent;
5382
5398
 
5383
5399
  if (response.data.success) {
@@ -5396,29 +5412,29 @@ var TicketsContainer = function TicketsContainer(_ref) {
5396
5412
  setEvent(_event2);
5397
5413
  }
5398
5414
 
5399
- _context3.next = 15;
5415
+ _context3.next = 16;
5400
5416
  break;
5401
5417
 
5402
- case 12:
5403
- _context3.prev = 12;
5418
+ case 13:
5419
+ _context3.prev = 13;
5404
5420
  _context3.t0 = _context3["catch"](0);
5405
5421
 
5406
5422
  if (axios.isAxiosError(_context3.t0)) {
5407
5423
  onGetTicketsError(_context3.t0);
5408
5424
  }
5409
5425
 
5410
- case 15:
5411
- _context3.prev = 15;
5426
+ case 16:
5427
+ _context3.prev = 16;
5412
5428
  setIsLoading(false);
5413
5429
  setCodeIsLoading(false);
5414
- return _context3.finish(15);
5430
+ return _context3.finish(16);
5415
5431
 
5416
- case 19:
5432
+ case 20:
5417
5433
  case "end":
5418
5434
  return _context3.stop();
5419
5435
  }
5420
5436
  }
5421
- }, _callee3, null, [[0, 12, 15, 19]]);
5437
+ }, _callee3, null, [[0, 13, 16, 20]]);
5422
5438
  }));
5423
5439
  return _getTicketsApi.apply(this, arguments);
5424
5440
  }