tf-checkout-react 1.3.16 → 1.3.18

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.
@@ -5,7 +5,7 @@ export declare function getEvent(id: string | number, pk?: string): Promise<Axio
5
5
  export declare function getTickets(id: string | number, promoCode: string, pk?: string): Promise<AxiosResponse<any, any>>;
6
6
  export declare const addToCart: (id: string | number, data: any) => Promise<AxiosResponse<any, any>>;
7
7
  export declare const getCart: () => Promise<AxiosResponse<any, any>>;
8
- export declare const postOnCheckout: (data: any, accessToken?: string | undefined) => Promise<AxiosResponse<any, any>>;
8
+ export declare const postOnCheckout: (data: any, accessToken?: string | undefined, freeTicket?: boolean) => Promise<AxiosResponse<any, any>>;
9
9
  export declare const authorize: (data: {
10
10
  email: string;
11
11
  password: string;
@@ -1,5 +1,5 @@
1
- import { IGroupItem } from '../../types';
2
1
  import { FormikErrors, FormikValues } from 'formik';
2
+ import { IGroupItem } from '../../types';
3
3
  export interface ILoggedInValues {
4
4
  emailLogged?: string;
5
5
  firstNameLogged?: string;
@@ -13,7 +13,7 @@ export declare const createRegisterFormData: (values: IValues | undefined, check
13
13
  attributes: {
14
14
  [key: string]: any;
15
15
  };
16
- }) => FormData;
16
+ }, flagFreeTicket?: boolean) => FormData;
17
17
  interface ICheckoutBody {
18
18
  attributes: {
19
19
  [key: string]: any;
@@ -1379,7 +1379,19 @@ var getCart = function getCart() {
1379
1379
  var res = publicRequest.get("v1/cart/");
1380
1380
  return res;
1381
1381
  };
1382
- var postOnCheckout = function postOnCheckout(data, accessToken) {
1382
+ var postOnCheckout = function postOnCheckout(data, accessToken, freeTicket) {
1383
+ if (freeTicket === void 0) {
1384
+ freeTicket = false;
1385
+ }
1386
+
1387
+ if (freeTicket) {
1388
+ delete data.attributes.city;
1389
+ delete data.attributes.country;
1390
+ delete data.attributes.state;
1391
+ delete data.attributes.zip;
1392
+ delete data.attributes.street_address;
1393
+ }
1394
+
1383
1395
  var res = publicRequest.post("v1/on-checkout/", {
1384
1396
  data: data
1385
1397
  }, {
@@ -2624,11 +2636,15 @@ var getInitialValues = function getInitialValues(data, propsInitialValues, userV
2624
2636
  initialValues['holderEmail-0'] = propsInitialValues.email || userValues.email || '';
2625
2637
  return initialValues;
2626
2638
  };
2627
- var createRegisterFormData = function createRegisterFormData(values, checkoutBody) {
2639
+ var createRegisterFormData = function createRegisterFormData(values, checkoutBody, flagFreeTicket) {
2628
2640
  if (values === void 0) {
2629
2641
  values = {};
2630
2642
  }
2631
2643
 
2644
+ if (flagFreeTicket === void 0) {
2645
+ flagFreeTicket = false;
2646
+ }
2647
+
2632
2648
  var bodyFormData = new FormData();
2633
2649
  bodyFormData.append('first_name', values.firstName);
2634
2650
  bodyFormData.append('last_name', values.lastName);
@@ -2640,7 +2656,9 @@ var createRegisterFormData = function createRegisterFormData(values, checkoutBod
2640
2656
  bodyFormData.append('check_cart_expiration', 'true');
2641
2657
 
2642
2658
  _forEach(checkoutBody.attributes, function (item, key) {
2643
- bodyFormData.append(key, item);
2659
+ if (!(flagFreeTicket && ['country', 'state', 'city', 'street_address', 'zip'].includes(key))) {
2660
+ bodyFormData.append(key, item);
2661
+ }
2644
2662
  });
2645
2663
 
2646
2664
  return bodyFormData;
@@ -3078,10 +3096,10 @@ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref4) {
3078
3096
 
3079
3097
  var flagRequirePhone = getQueryVariable('phone_required') === 'true';
3080
3098
  var collectMandatoryWalletAddress = getQueryVariable('collect_mandatory_wallet_address') === 'true';
3099
+ var collectOptionalWalletAddress = getQueryVariable('collect_optional_wallet_address') === 'true';
3081
3100
  var flagFreeTicket = getQueryVariable('free_ticket') === 'true';
3082
- var hidePhoneField = getQueryVariable('hide_phone_field') === 'true'; // temp change
3083
-
3084
- var hideWalletAddressField = Number(eventId) === 18164; // Get prevProps
3101
+ var hidePhoneField = getQueryVariable('hide_phone_field') === 'true';
3102
+ var hideWalletAddressField = !collectOptionalWalletAddress && !collectMandatoryWalletAddress; // Get prevProps
3085
3103
 
3086
3104
  var prevData = React.useRef(data);
3087
3105
 
@@ -3300,7 +3318,7 @@ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref4) {
3300
3318
  }
3301
3319
 
3302
3320
  _context5.next = 7;
3303
- return postOnCheckout(checkoutBody, access_token);
3321
+ return postOnCheckout(checkoutBody, access_token, flagFreeTicket);
3304
3322
 
3305
3323
  case 7:
3306
3324
  res = _context5.sent;
@@ -3413,7 +3431,7 @@ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref4) {
3413
3431
  }
3414
3432
 
3415
3433
  _context6.next = 6;
3416
- return postOnCheckout(_checkoutBody, access_token);
3434
+ return postOnCheckout(_checkoutBody, access_token, flagFreeTicket);
3417
3435
 
3418
3436
  case 6:
3419
3437
  _res = _context6.sent;
@@ -3443,7 +3461,7 @@ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref4) {
3443
3461
  firstNameLogged: firstNameLogged,
3444
3462
  lastNameLogged: lastNameLogged
3445
3463
  }, showDOB);
3446
- bodyFormData = createRegisterFormData(values, checkoutBodyForRegistration);
3464
+ bodyFormData = createRegisterFormData(values, checkoutBodyForRegistration, flagFreeTicket);
3447
3465
  _context6.prev = 19;
3448
3466
  setLoading(true);
3449
3467
  _context6.next = 23;
@@ -3517,7 +3535,7 @@ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref4) {
3517
3535
  }
3518
3536
 
3519
3537
  _context6.next = 47;
3520
- return postOnCheckout(checkoutBody);
3538
+ return postOnCheckout(checkoutBody, undefined, flagFreeTicket);
3521
3539
 
3522
3540
  case 47:
3523
3541
  res = _context6.sent;
@@ -5844,7 +5862,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
5844
5862
  }
5845
5863
 
5846
5864
  _context2.next = 40;
5847
- return postOnCheckout(checkoutBody, access_token);
5865
+ return postOnCheckout(checkoutBody, access_token, freeTicket);
5848
5866
 
5849
5867
  case 40:
5850
5868
  _context2.t1 = _context2.sent;
@@ -7756,7 +7774,7 @@ var AddonsContainter = function AddonsContainter(_ref) {
7756
7774
 
7757
7775
  var handleConfirm = /*#__PURE__*/function () {
7758
7776
  var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(values, skipAddonPage) {
7759
- var _pageConfigsData$skip, _pageConfigsData$name, _pageConfigsData$age_, _pageConfigsData$phon, _pageConfigsData$has_, pageConfigsDataResponse, pageConfigsData, isWindowDefined, skipBillingPage, nameIsRequired, ageIsRequired, phoneIsRequired, hasAddOn, ticketsQuantity, userData, checkoutBody, checkoutResponse, hash, total;
7777
+ var _pageConfigsData$skip, _pageConfigsData$name, _pageConfigsData$age_, _pageConfigsData$phon, _pageConfigsData$has_, _pageConfigsData$free, _pageConfigsData$coll, _pageConfigsData$coll2, pageConfigsDataResponse, pageConfigsData, isWindowDefined, skipBillingPage, nameIsRequired, ageIsRequired, phoneIsRequired, hasAddOn, freeTicket, collectOptionalWalletAddress, collectMandatoryWalletAddress, ticketsQuantity, userData, checkoutBody, checkoutResponse, hash, total;
7760
7778
 
7761
7779
  return runtime_1.wrap(function _callee2$(_context2) {
7762
7780
  while (1) {
@@ -7775,24 +7793,27 @@ var AddonsContainter = function AddonsContainter(_ref) {
7775
7793
  ageIsRequired = (_pageConfigsData$age_ = pageConfigsData.age_required) != null ? _pageConfigsData$age_ : false;
7776
7794
  phoneIsRequired = (_pageConfigsData$phon = pageConfigsData.phone_required) != null ? _pageConfigsData$phon : false;
7777
7795
  hasAddOn = (_pageConfigsData$has_ = pageConfigsData.has_add_on) != null ? _pageConfigsData$has_ : false;
7796
+ freeTicket = (_pageConfigsData$free = pageConfigsData.free_ticket) != null ? _pageConfigsData$free : false;
7797
+ collectOptionalWalletAddress = (_pageConfigsData$coll = pageConfigsData.collect_optional_wallet_address) != null ? _pageConfigsData$coll : false;
7798
+ collectMandatoryWalletAddress = (_pageConfigsData$coll2 = pageConfigsData.collect_mandatory_wallet_address) != null ? _pageConfigsData$coll2 : false;
7778
7799
 
7779
7800
  if (!(skipBillingPage && enableBillingInfoAutoCreate)) {
7780
- _context2.next = 33;
7801
+ _context2.next = 36;
7781
7802
  break;
7782
7803
  }
7783
7804
 
7784
7805
  ticketsQuantity = window.localStorage.getItem('quantity');
7785
7806
  userData = JSON.parse(window.localStorage.getItem('user_data') || '{}');
7786
7807
  checkoutBody = createCheckoutDataBodyWithDefaultHolder(Number(ticketsQuantity) || 0, userData);
7787
- _context2.prev = 15;
7788
- _context2.next = 18;
7808
+ _context2.prev = 18;
7809
+ _context2.next = 21;
7789
7810
  return postOnCheckout(_extends({}, checkoutBody, {
7790
7811
  attributes: _extends({}, checkoutBody.attributes, !skipAddonPage && {
7791
7812
  add_ons: values
7792
7813
  })
7793
7814
  }));
7794
7815
 
7795
- case 18:
7816
+ case 21:
7796
7817
  checkoutResponse = _context2.sent;
7797
7818
  hash = _get(checkoutResponse, 'data.data.attributes.hash');
7798
7819
  total = _get(checkoutResponse, 'data.data.attributes.total');
@@ -7807,22 +7828,25 @@ var AddonsContainter = function AddonsContainter(_ref) {
7807
7828
  event_id: String(eventId),
7808
7829
  hash: hash,
7809
7830
  total: total,
7810
- hasAddOn: hasAddOn
7831
+ hasAddOn: hasAddOn,
7832
+ free_ticket: freeTicket,
7833
+ collect_optional_wallet_address: collectOptionalWalletAddress,
7834
+ collect_mandatory_wallet_address: collectMandatoryWalletAddress
7811
7835
  });
7812
- _context2.next = 31;
7836
+ _context2.next = 34;
7813
7837
  break;
7814
7838
 
7815
- case 27:
7816
- _context2.prev = 27;
7817
- _context2.t0 = _context2["catch"](15);
7839
+ case 30:
7840
+ _context2.prev = 30;
7841
+ _context2.t0 = _context2["catch"](18);
7818
7842
  onPostCheckoutError(_context2.t0);
7819
7843
  onConfirmSelectionError(_context2.t0);
7820
7844
 
7821
- case 31:
7822
- _context2.next = 34;
7845
+ case 34:
7846
+ _context2.next = 37;
7823
7847
  break;
7824
7848
 
7825
- case 33:
7849
+ case 36:
7826
7850
  if (isWindowDefined) {
7827
7851
  if (!skipAddonPage) {
7828
7852
  window.localStorage.setItem('add_ons', JSON.stringify(values));
@@ -7843,21 +7867,21 @@ var AddonsContainter = function AddonsContainter(_ref) {
7843
7867
  });
7844
7868
  }
7845
7869
 
7846
- case 34:
7847
- _context2.next = 39;
7870
+ case 37:
7871
+ _context2.next = 42;
7848
7872
  break;
7849
7873
 
7850
- case 36:
7851
- _context2.prev = 36;
7874
+ case 39:
7875
+ _context2.prev = 39;
7852
7876
  _context2.t1 = _context2["catch"](0);
7853
7877
  onConfirmSelectionError(_context2.t1);
7854
7878
 
7855
- case 39:
7879
+ case 42:
7856
7880
  case "end":
7857
7881
  return _context2.stop();
7858
7882
  }
7859
7883
  }
7860
- }, _callee2, null, [[0, 36], [15, 27]]);
7884
+ }, _callee2, null, [[0, 39], [18, 30]]);
7861
7885
  }));
7862
7886
 
7863
7887
  return function handleConfirm(_x, _x2) {