tf-checkout-react 1.3.14 → 1.3.15

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.
@@ -11,7 +11,7 @@ import _isEmpty from 'lodash-es/isEmpty';
11
11
  import _isEqual from 'lodash-es/isEqual';
12
12
  import _map from 'lodash-es/map';
13
13
  import { nanoid } from 'nanoid';
14
- import React, { Component, useCallback, useEffect, useState, memo, useRef, Fragment } from 'react';
14
+ import React, { Component, useState, useCallback, useEffect, memo, useRef, Fragment } from 'react';
15
15
  import _forEach from 'lodash-es/forEach';
16
16
  import { DatePicker } from '@mui/x-date-pickers';
17
17
  import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
@@ -1323,7 +1323,6 @@ function getEvent(id, pk) {
1323
1323
  var referralIdlocal = '';
1324
1324
 
1325
1325
  if (referral_key) {
1326
- // eslint-disable-next-line prefer-destructuring
1327
1326
  referralIdlocal = referral_key.split('.')[1];
1328
1327
  }
1329
1328
 
@@ -1344,9 +1343,11 @@ function getEvent(id, pk) {
1344
1343
  return response;
1345
1344
  }
1346
1345
  function getTickets(id, promoCode, pk) {
1346
+ var invitationHash = getQueryVariable('invitation-hash');
1347
1347
  var response = publicRequest.get("v1/event/" + id + "/tickets", {
1348
1348
  params: {
1349
- pk: pk
1349
+ pk: pk,
1350
+ 'invitation-hash': invitationHash
1350
1351
  },
1351
1352
  headers: promoCode ? _extends({}, ttfHeaders, {
1352
1353
  'Promotion-Event': String(id),
@@ -1604,6 +1605,11 @@ var CustomField = function CustomField(_ref) {
1604
1605
  _ref$InputProps = _ref.InputProps,
1605
1606
  InputProps = _ref$InputProps === void 0 ? {} : _ref$InputProps,
1606
1607
  inputRef = _ref.inputRef;
1608
+
1609
+ var _useState = useState(Boolean(field.value)),
1610
+ isShrinked = _useState[0],
1611
+ setIsShrinked = _useState[1];
1612
+
1607
1613
  var isSelectField = type === 'select';
1608
1614
 
1609
1615
  var error = _get(errors, field.name);
@@ -1614,6 +1620,7 @@ var CustomField = function CustomField(_ref) {
1614
1620
  sx: customTheme == null ? void 0 : customTheme.input
1615
1621
  };
1616
1622
  return React.createElement(TextField, Object.assign({
1623
+ placeholder: "",
1617
1624
  id: field.name,
1618
1625
  label: label,
1619
1626
  type: type,
@@ -1621,6 +1628,9 @@ var CustomField = function CustomField(_ref) {
1621
1628
  fullWidth: true,
1622
1629
  error: !!error && isTouched,
1623
1630
  helperText: isTouched && error,
1631
+ onFocus: function onFocus() {
1632
+ setIsShrinked(true);
1633
+ },
1624
1634
  SelectProps: {
1625
1635
  "native": true,
1626
1636
  className: theme,
@@ -1629,12 +1639,21 @@ var CustomField = function CustomField(_ref) {
1629
1639
  }
1630
1640
  },
1631
1641
  InputLabelProps: {
1632
- sx: customTheme == null ? void 0 : customTheme.input
1642
+ sx: customTheme == null ? void 0 : customTheme.input,
1643
+ shrink: isShrinked || Boolean(field.value)
1633
1644
  },
1634
1645
  InputProps: InputProps,
1635
1646
  inputProps: _extends({}, inputProps, pInputProps),
1636
1647
  inputRef: inputRef
1637
- }, field), isSelectField ? _map(selectOptions, function (option) {
1648
+ }, field, {
1649
+ onBlur: function onBlur(e) {
1650
+ setIsShrinked(Boolean(field.value));
1651
+
1652
+ if (field.onBlur) {
1653
+ field.onBlur(e);
1654
+ }
1655
+ }
1656
+ }), isSelectField ? _map(selectOptions, function (option) {
1638
1657
  return React.createElement("option", {
1639
1658
  key: option.value,
1640
1659
  value: option.value,
@@ -3056,6 +3075,8 @@ var BillingInfoContainer = /*#__PURE__*/React.memo(function (_ref4) {
3056
3075
  var expirationTime = _get(cartInfoData, 'expiresAt');
3057
3076
 
3058
3077
  var flagRequirePhone = getQueryVariable('phone_required') === 'true';
3078
+ var collectOptionalWalletAddress = getQueryVariable('collect_optional_wallet_address') === 'true';
3079
+ var collectMandatoryWalletAddress = getQueryVariable('collect_mandatory_wallet_address') === 'true';
3059
3080
  var flagFreeTicket = getQueryVariable('free_ticket') === 'true';
3060
3081
  var hidePhoneField = getQueryVariable('hide_phone_field') === 'true'; // Get prevProps
3061
3082
 
@@ -3626,14 +3647,17 @@ var BillingInfoContainer = /*#__PURE__*/React.memo(function (_ref4) {
3626
3647
  }
3627
3648
  }
3628
3649
 
3629
- if (el.name === 'zip') {
3630
- if (flagFreeTicket) {
3650
+ if (el.name === 'data_capture[wallet_address]') {
3651
+ if (collectOptionalWalletAddress) {
3631
3652
  el.required = false;
3632
- return false;
3653
+ }
3654
+
3655
+ if (collectMandatoryWalletAddress) {
3656
+ el.required = true;
3633
3657
  }
3634
3658
  }
3635
3659
 
3636
- if (el.name === 'street_address') {
3660
+ if (['street_address', 'country', 'state', 'city', 'zip'].includes(el.name)) {
3637
3661
  if (flagFreeTicket) {
3638
3662
  el.required = false;
3639
3663
  return false;
@@ -3649,7 +3673,7 @@ var BillingInfoContainer = /*#__PURE__*/React.memo(function (_ref4) {
3649
3673
  }, element.component ? element.component : React.createElement(Field, {
3650
3674
  setPhoneValidationIsLoading: element.type === 'phone' ? setPhoneValidationIsLoading : undefined,
3651
3675
  name: element.name,
3652
- label: element.name === 'phone' ? "" + element.label + (flagRequirePhone ? '' : ' (optional)') + " " : element.label,
3676
+ label: element.name === 'phone' ? "" + element.label + (flagRequirePhone ? '' : ' (optional)') + " " : element.name === 'data_capture[wallet_address]' ? "" + element.label + (collectOptionalWalletAddress ? ' (optional)' : '') + " " : element.label,
3653
3677
  type: element.type,
3654
3678
  fill: element.fill,
3655
3679
  validate: getValidateFunctions(element, states, props.values, props.errors),
@@ -4847,6 +4871,51 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
4847
4871
  }))))));
4848
4872
  };
4849
4873
 
4874
+ var style$3 = {
4875
+ position: 'absolute',
4876
+ top: '50%',
4877
+ left: '50%',
4878
+ transform: 'translate(-50%, -50%)',
4879
+ minWidth: 480,
4880
+ backgroundColor: '#e3e3e3',
4881
+ border: '1px solid white',
4882
+ outline: 'none',
4883
+ padding: '14px',
4884
+ maxHeight: '85vh',
4885
+ overflow: 'auto'
4886
+ };
4887
+
4888
+ var ConfirmModal = function ConfirmModal(_ref) {
4889
+ var _ref$message = _ref.message,
4890
+ message = _ref$message === void 0 ? '' : _ref$message,
4891
+ _ref$loading = _ref.loading,
4892
+ loading = _ref$loading === void 0 ? false : _ref$loading,
4893
+ _ref$hideCancelBtn = _ref.hideCancelBtn,
4894
+ hideCancelBtn = _ref$hideCancelBtn === void 0 ? false : _ref$hideCancelBtn,
4895
+ _ref$onClose = _ref.onClose,
4896
+ onClose = _ref$onClose === void 0 ? _identity : _ref$onClose,
4897
+ _ref$onConfirm = _ref.onConfirm,
4898
+ onConfirm = _ref$onConfirm === void 0 ? _identity : _ref$onConfirm;
4899
+ return React.createElement(Modal$1, {
4900
+ open: true,
4901
+ onClose: onClose,
4902
+ "aria-labelledby": "modal-modal-title",
4903
+ "aria-describedby": "modal-modal-description",
4904
+ className: "confirm-modal"
4905
+ }, React.createElement(Box$1, {
4906
+ style: style$3
4907
+ }, React.createElement("p", null, message), React.createElement("div", {
4908
+ className: "footer"
4909
+ }, !hideCancelBtn && React.createElement(Button, {
4910
+ onClick: onClose,
4911
+ disabled: loading
4912
+ }, "Cancel"), React.createElement(Button, {
4913
+ onClick: onConfirm
4914
+ }, loading ? React.createElement(CircularProgress, {
4915
+ size: "22px"
4916
+ }) : 'OK'))));
4917
+ };
4918
+
4850
4919
  var isTimeExpired = function isTimeExpired(startDate, timezone) {
4851
4920
  return !moment(startDate).isAfter(moment.tz(moment(), timezone).format('YYYY-MM-DD HH:mm:ss'));
4852
4921
  };
@@ -5425,7 +5494,11 @@ var TicketsContainer = function TicketsContainer(_ref) {
5425
5494
  _ref$enableInfluencer = _ref.enableInfluencersSection,
5426
5495
  enableInfluencersSection = _ref$enableInfluencer === void 0 ? true : _ref$enableInfluencer,
5427
5496
  _ref$enableAddOns = _ref.enableAddOns,
5428
- enableAddOns = _ref$enableAddOns === void 0 ? true : _ref$enableAddOns;
5497
+ enableAddOns = _ref$enableAddOns === void 0 ? true : _ref$enableAddOns,
5498
+ _ref$handleNotInvited = _ref.handleNotInvitedModalClose,
5499
+ handleNotInvitedModalClose = _ref$handleNotInvited === void 0 ? _identity : _ref$handleNotInvited,
5500
+ _ref$handleInvalidLin = _ref.handleInvalidLinkModalClose,
5501
+ handleInvalidLinkModalClose = _ref$handleInvalidLin === void 0 ? _identity : _ref$handleInvalidLin;
5429
5502
 
5430
5503
  var _useState = useState({}),
5431
5504
  selectedTickets = _useState[0],
@@ -5494,6 +5567,14 @@ var TicketsContainer = function TicketsContainer(_ref) {
5494
5567
  error = _useState16[0],
5495
5568
  setError = _useState16[1];
5496
5569
 
5570
+ var _useState17 = useState(''),
5571
+ isNotInvitedError = _useState17[0],
5572
+ setIsNotInvitedError = _useState17[1];
5573
+
5574
+ var _useState18 = useState(''),
5575
+ isInvalidLinkError = _useState18[0],
5576
+ setIsInvalidLinkError = _useState18[1];
5577
+
5497
5578
  var ticketsContainerRef = useRef(null);
5498
5579
  useEffect(function () {
5499
5580
  if (typeof window !== 'undefined') {
@@ -5672,7 +5753,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
5672
5753
  var _ref4 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
5673
5754
  var _product_options, _product_options2, _ticket_types;
5674
5755
 
5675
- var ticket, optionName, ticketId, ticketQuantity, data, result, pageConfigsDataResponse, _pageConfigsData$skip, _pageConfigsData$name, _pageConfigsData$age_, _pageConfigsData$phon, _pageConfigsData$hide, _pageConfigsData$has_, _pageConfigsData$free, pageConfigsData, skipBillingPage, nameIsRequired, ageIsRequired, phoneIsRequired, hidePhoneField, hasAddOn, freeTicket, hash, total, _isWindowDefined, userData, access_token, checkoutBody, checkoutResult;
5756
+ var ticket, optionName, ticketId, ticketQuantity, data, result, pageConfigsDataResponse, _pageConfigsData$skip, _pageConfigsData$name, _pageConfigsData$age_, _pageConfigsData$phon, _pageConfigsData$hide, _pageConfigsData$has_, _pageConfigsData$free, _pageConfigsData$coll, _pageConfigsData$coll2, pageConfigsData, skipBillingPage, nameIsRequired, ageIsRequired, phoneIsRequired, hidePhoneField, hasAddOn, freeTicket, collectOptionalWalletAddress, collectMandatoryWalletAddress, hash, total, _isWindowDefined, userData, access_token, checkoutBody, checkoutResult, message, _isInvalidLinkError, _isNotInvitedError;
5676
5757
 
5677
5758
  return runtime_1.wrap(function _callee2$(_context2) {
5678
5759
  while (1) {
@@ -5729,7 +5810,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
5729
5810
  pageConfigsDataResponse = _context2.t0;
5730
5811
 
5731
5812
  if (!(result.status === 200 && pageConfigsDataResponse.status === 200)) {
5732
- _context2.next = 46;
5813
+ _context2.next = 48;
5733
5814
  break;
5734
5815
  }
5735
5816
 
@@ -5741,13 +5822,15 @@ var TicketsContainer = function TicketsContainer(_ref) {
5741
5822
  hidePhoneField = (_pageConfigsData$hide = pageConfigsData.hide_phone_field) != null ? _pageConfigsData$hide : false;
5742
5823
  hasAddOn = (_pageConfigsData$has_ = pageConfigsData.has_add_on) != null ? _pageConfigsData$has_ : false;
5743
5824
  freeTicket = (_pageConfigsData$free = pageConfigsData.free_ticket) != null ? _pageConfigsData$free : false;
5825
+ collectOptionalWalletAddress = (_pageConfigsData$coll = pageConfigsData.collect_optional_wallet_address) != null ? _pageConfigsData$coll : false;
5826
+ collectMandatoryWalletAddress = (_pageConfigsData$coll2 = pageConfigsData.collect_mandatory_wallet_address) != null ? _pageConfigsData$coll2 : false;
5744
5827
  hash = '';
5745
5828
  total = '';
5746
5829
  _isWindowDefined = typeof window !== 'undefined';
5747
5830
  _isWindowDefined && window.localStorage.removeItem('add_ons');
5748
5831
 
5749
5832
  if (!(skipBillingPage && !hasAddOn)) {
5750
- _context2.next = 45;
5833
+ _context2.next = 47;
5751
5834
  break;
5752
5835
  }
5753
5836
 
@@ -5757,27 +5840,27 @@ var TicketsContainer = function TicketsContainer(_ref) {
5757
5840
  checkoutBody = createCheckoutDataBodyWithDefaultHolder(ticketQuantity, userData);
5758
5841
 
5759
5842
  if (!enableBillingInfoAutoCreate) {
5760
- _context2.next = 41;
5843
+ _context2.next = 43;
5761
5844
  break;
5762
5845
  }
5763
5846
 
5764
- _context2.next = 38;
5847
+ _context2.next = 40;
5765
5848
  return postOnCheckout(checkoutBody, access_token);
5766
5849
 
5767
- case 38:
5850
+ case 40:
5768
5851
  _context2.t1 = _context2.sent;
5769
- _context2.next = 42;
5852
+ _context2.next = 44;
5770
5853
  break;
5771
5854
 
5772
- case 41:
5855
+ case 43:
5773
5856
  _context2.t1 = null;
5774
5857
 
5775
- case 42:
5858
+ case 44:
5776
5859
  checkoutResult = _context2.t1;
5777
5860
  hash = _get(checkoutResult, 'data.data.attributes.hash');
5778
5861
  total = _get(checkoutResult, 'data.data.attributes.total');
5779
5862
 
5780
- case 45:
5863
+ case 47:
5781
5864
  onAddToCartSuccess({
5782
5865
  skip_billing_page: skipBillingPage,
5783
5866
  names_required: nameIsRequired,
@@ -5785,36 +5868,48 @@ var TicketsContainer = function TicketsContainer(_ref) {
5785
5868
  age_required: ageIsRequired,
5786
5869
  hide_phone_field: hidePhoneField,
5787
5870
  free_ticket: freeTicket,
5871
+ collect_optional_wallet_address: collectOptionalWalletAddress,
5872
+ collect_mandatory_wallet_address: collectMandatoryWalletAddress,
5788
5873
  event_id: String(eventId),
5789
5874
  hash: hash,
5790
5875
  total: total,
5791
5876
  hasAddOn: hasAddOn
5792
5877
  });
5793
5878
 
5794
- case 46:
5795
- _context2.next = 51;
5879
+ case 48:
5880
+ _context2.next = 53;
5796
5881
  break;
5797
5882
 
5798
- case 48:
5799
- _context2.prev = 48;
5883
+ case 50:
5884
+ _context2.prev = 50;
5800
5885
  _context2.t2 = _context2["catch"](6);
5801
5886
 
5802
5887
  if (axios.isAxiosError(_context2.t2)) {
5803
5888
  onAddToCartError(_context2.t2);
5804
- setError(_get(_context2.t2, 'response.data.message'));
5889
+ message = _get(_context2.t2, 'response.data.message', '');
5890
+ _isInvalidLinkError = _includes(message, 'No more of this ticket type are available right now');
5891
+ _isNotInvitedError = _includes(message, 'You must have been invited to this event to attend');
5892
+
5893
+ if (_isInvalidLinkError) {
5894
+ setIsInvalidLinkError(message);
5895
+ } else if (_isNotInvitedError) {
5896
+ setIsNotInvitedError(message);
5897
+ } else {
5898
+ setError(message);
5899
+ }
5805
5900
  }
5806
5901
 
5807
- case 51:
5808
- _context2.prev = 51;
5902
+ case 53:
5903
+ _context2.prev = 53;
5809
5904
  setHandleBookIsLoading(false);
5810
- return _context2.finish(51);
5905
+ return _context2.finish(53);
5811
5906
 
5812
- case 54:
5907
+ case 56:
5813
5908
  case "end":
5814
5909
  return _context2.stop();
5815
5910
  }
5816
5911
  }
5817
- }, _callee2, null, [[6, 48, 51, 54]]);
5912
+ }, _callee2, null, [[6, 50, 53, 56]]);
5818
5913
  }));
5819
5914
 
5820
5915
  return function handleBook() {
@@ -5880,6 +5975,17 @@ var TicketsContainer = function TicketsContainer(_ref) {
5880
5975
  return false;
5881
5976
  };
5882
5977
 
5978
+ var _onClose = function onClose(value) {
5979
+ if (value === 'notInvited') {
5980
+ handleNotInvitedModalClose();
5981
+ } else if (value === 'invalidLink') {
5982
+ handleInvalidLinkModalClose();
5983
+ }
5984
+
5985
+ setIsNotInvitedError('');
5986
+ setIsInvalidLinkError('');
5987
+ };
5988
+
5883
5989
  return React.createElement(ThemeProvider$1, {
5884
5990
  theme: themeMui
5885
5991
  }, !isLoading && React.createElement(ReferralLogic, {
@@ -5887,7 +5993,25 @@ var TicketsContainer = function TicketsContainer(_ref) {
5887
5993
  }), React.createElement("div", {
5888
5994
  className: "get-tickets-page " + theme,
5889
5995
  style: contentStyle
5890
- }, error && React.createElement(Alert$1, {
5996
+ }, isInvalidLinkError && React.createElement(ConfirmModal, {
5997
+ message: isInvalidLinkError,
5998
+ hideCancelBtn: true,
5999
+ onClose: function onClose() {
6000
+ return _onClose('invalidLink');
6001
+ },
6002
+ onConfirm: function onConfirm() {
6003
+ return _onClose('invalidLink');
6004
+ }
6005
+ }), isNotInvitedError && React.createElement(ConfirmModal, {
6006
+ hideCancelBtn: true,
6007
+ message: isNotInvitedError,
6008
+ onClose: function onClose() {
6009
+ return _onClose('notInvited');
6010
+ },
6011
+ onConfirm: function onConfirm() {
6012
+ return _onClose('notInvited');
6013
+ }
6014
+ }), error && React.createElement(Alert$1, {
5891
6015
  severity: "error",
5892
6016
  onClose: onErrorClose,
5893
6017
  variant: "filled",
@@ -6215,49 +6339,6 @@ var MyTicketsContainer = function MyTicketsContainer(_ref) {
6215
6339
  })));
6216
6340
  };
6217
6341
 
6218
- var style$3 = {
6219
- position: 'absolute',
6220
- top: '50%',
6221
- left: '50%',
6222
- transform: 'translate(-50%, -50%)',
6223
- minWidth: 480,
6224
- backgroundColor: '#e3e3e3',
6225
- border: '1px solid white',
6226
- outline: 'none',
6227
- padding: '14px',
6228
- maxHeight: '85vh',
6229
- overflow: 'auto'
6230
- };
6231
-
6232
- var ConfirmModal = function ConfirmModal(_ref) {
6233
- var _ref$message = _ref.message,
6234
- message = _ref$message === void 0 ? '' : _ref$message,
6235
- _ref$loading = _ref.loading,
6236
- loading = _ref$loading === void 0 ? false : _ref$loading,
6237
- _ref$onClose = _ref.onClose,
6238
- onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,
6239
- _ref$onConfirm = _ref.onConfirm,
6240
- onConfirm = _ref$onConfirm === void 0 ? function () {} : _ref$onConfirm;
6241
- return React.createElement(Modal$1, {
6242
- open: true,
6243
- onClose: onClose,
6244
- "aria-labelledby": "modal-modal-title",
6245
- "aria-describedby": "modal-modal-description",
6246
- className: 'confirm-modal'
6247
- }, React.createElement(Box$1, {
6248
- style: style$3
6249
- }, React.createElement("p", null, message), React.createElement("div", {
6250
- className: 'footer'
6251
- }, React.createElement(Button, {
6252
- onClick: onClose,
6253
- disabled: loading
6254
- }, "Cancel"), React.createElement(Button, {
6255
- onClick: onConfirm
6256
- }, loading ? React.createElement(CircularProgress, {
6257
- size: "22px"
6258
- }) : 'OK'))));
6259
- };
6260
-
6261
6342
  var _excluded$2 = ["label", "field", "theme", "disableDropdown"];
6262
6343
  var RadioField = function RadioField(_ref) {
6263
6344
  var label = _ref.label,