tf-checkout-react 1.3.13 → 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,9 @@ 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';
3080
+ var flagFreeTicket = getQueryVariable('free_ticket') === 'true';
3059
3081
  var hidePhoneField = getQueryVariable('hide_phone_field') === 'true'; // Get prevProps
3060
3082
 
3061
3083
  var prevData = useRef(data);
@@ -3625,6 +3647,23 @@ var BillingInfoContainer = /*#__PURE__*/React.memo(function (_ref4) {
3625
3647
  }
3626
3648
  }
3627
3649
 
3650
+ if (el.name === 'data_capture[wallet_address]') {
3651
+ if (collectOptionalWalletAddress) {
3652
+ el.required = false;
3653
+ }
3654
+
3655
+ if (collectMandatoryWalletAddress) {
3656
+ el.required = true;
3657
+ }
3658
+ }
3659
+
3660
+ if (['street_address', 'country', 'state', 'city', 'zip'].includes(el.name)) {
3661
+ if (flagFreeTicket) {
3662
+ el.required = false;
3663
+ return false;
3664
+ }
3665
+ }
3666
+
3628
3667
  return true;
3629
3668
  }), function (element) {
3630
3669
  return ['password', 'confirmPassword', 'password-info'].includes(element.name) && isLoggedIn ? null : React.createElement(React.Fragment, {
@@ -3634,7 +3673,7 @@ var BillingInfoContainer = /*#__PURE__*/React.memo(function (_ref4) {
3634
3673
  }, element.component ? element.component : React.createElement(Field, {
3635
3674
  setPhoneValidationIsLoading: element.type === 'phone' ? setPhoneValidationIsLoading : undefined,
3636
3675
  name: element.name,
3637
- 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,
3638
3677
  type: element.type,
3639
3678
  fill: element.fill,
3640
3679
  validate: getValidateFunctions(element, states, props.values, props.errors),
@@ -4832,6 +4871,51 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
4832
4871
  }))))));
4833
4872
  };
4834
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
+
4835
4919
  var isTimeExpired = function isTimeExpired(startDate, timezone) {
4836
4920
  return !moment(startDate).isAfter(moment.tz(moment(), timezone).format('YYYY-MM-DD HH:mm:ss'));
4837
4921
  };
@@ -5410,7 +5494,11 @@ var TicketsContainer = function TicketsContainer(_ref) {
5410
5494
  _ref$enableInfluencer = _ref.enableInfluencersSection,
5411
5495
  enableInfluencersSection = _ref$enableInfluencer === void 0 ? true : _ref$enableInfluencer,
5412
5496
  _ref$enableAddOns = _ref.enableAddOns,
5413
- 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;
5414
5502
 
5415
5503
  var _useState = useState({}),
5416
5504
  selectedTickets = _useState[0],
@@ -5479,6 +5567,14 @@ var TicketsContainer = function TicketsContainer(_ref) {
5479
5567
  error = _useState16[0],
5480
5568
  setError = _useState16[1];
5481
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
+
5482
5578
  var ticketsContainerRef = useRef(null);
5483
5579
  useEffect(function () {
5484
5580
  if (typeof window !== 'undefined') {
@@ -5657,7 +5753,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
5657
5753
  var _ref4 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
5658
5754
  var _product_options, _product_options2, _ticket_types;
5659
5755
 
5660
- var ticket, optionName, ticketId, ticketQuantity, data, result, pageConfigsDataResponse, _pageConfigsData$skip, _pageConfigsData$name, _pageConfigsData$age_, _pageConfigsData$phon, _pageConfigsData$hide, _pageConfigsData$has_, pageConfigsData, skipBillingPage, nameIsRequired, ageIsRequired, phoneIsRequired, hidePhoneField, hasAddOn, 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;
5661
5757
 
5662
5758
  return runtime_1.wrap(function _callee2$(_context2) {
5663
5759
  while (1) {
@@ -5714,7 +5810,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
5714
5810
  pageConfigsDataResponse = _context2.t0;
5715
5811
 
5716
5812
  if (!(result.status === 200 && pageConfigsDataResponse.status === 200)) {
5717
- _context2.next = 45;
5813
+ _context2.next = 48;
5718
5814
  break;
5719
5815
  }
5720
5816
 
@@ -5725,13 +5821,16 @@ var TicketsContainer = function TicketsContainer(_ref) {
5725
5821
  phoneIsRequired = (_pageConfigsData$phon = pageConfigsData.phone_required) != null ? _pageConfigsData$phon : false;
5726
5822
  hidePhoneField = (_pageConfigsData$hide = pageConfigsData.hide_phone_field) != null ? _pageConfigsData$hide : false;
5727
5823
  hasAddOn = (_pageConfigsData$has_ = pageConfigsData.has_add_on) != null ? _pageConfigsData$has_ : false;
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;
5728
5827
  hash = '';
5729
5828
  total = '';
5730
5829
  _isWindowDefined = typeof window !== 'undefined';
5731
5830
  _isWindowDefined && window.localStorage.removeItem('add_ons');
5732
5831
 
5733
5832
  if (!(skipBillingPage && !hasAddOn)) {
5734
- _context2.next = 44;
5833
+ _context2.next = 47;
5735
5834
  break;
5736
5835
  }
5737
5836
 
@@ -5741,63 +5840,76 @@ var TicketsContainer = function TicketsContainer(_ref) {
5741
5840
  checkoutBody = createCheckoutDataBodyWithDefaultHolder(ticketQuantity, userData);
5742
5841
 
5743
5842
  if (!enableBillingInfoAutoCreate) {
5744
- _context2.next = 40;
5843
+ _context2.next = 43;
5745
5844
  break;
5746
5845
  }
5747
5846
 
5748
- _context2.next = 37;
5847
+ _context2.next = 40;
5749
5848
  return postOnCheckout(checkoutBody, access_token);
5750
5849
 
5751
- case 37:
5850
+ case 40:
5752
5851
  _context2.t1 = _context2.sent;
5753
- _context2.next = 41;
5852
+ _context2.next = 44;
5754
5853
  break;
5755
5854
 
5756
- case 40:
5855
+ case 43:
5757
5856
  _context2.t1 = null;
5758
5857
 
5759
- case 41:
5858
+ case 44:
5760
5859
  checkoutResult = _context2.t1;
5761
5860
  hash = _get(checkoutResult, 'data.data.attributes.hash');
5762
5861
  total = _get(checkoutResult, 'data.data.attributes.total');
5763
5862
 
5764
- case 44:
5863
+ case 47:
5765
5864
  onAddToCartSuccess({
5766
5865
  skip_billing_page: skipBillingPage,
5767
5866
  names_required: nameIsRequired,
5768
5867
  phone_required: phoneIsRequired,
5769
5868
  age_required: ageIsRequired,
5770
5869
  hide_phone_field: hidePhoneField,
5870
+ free_ticket: freeTicket,
5871
+ collect_optional_wallet_address: collectOptionalWalletAddress,
5872
+ collect_mandatory_wallet_address: collectMandatoryWalletAddress,
5771
5873
  event_id: String(eventId),
5772
5874
  hash: hash,
5773
5875
  total: total,
5774
5876
  hasAddOn: hasAddOn
5775
5877
  });
5776
5878
 
5777
- case 45:
5778
- _context2.next = 50;
5879
+ case 48:
5880
+ _context2.next = 53;
5779
5881
  break;
5780
5882
 
5781
- case 47:
5782
- _context2.prev = 47;
5883
+ case 50:
5884
+ _context2.prev = 50;
5783
5885
  _context2.t2 = _context2["catch"](6);
5784
5886
 
5785
5887
  if (axios.isAxiosError(_context2.t2)) {
5786
5888
  onAddToCartError(_context2.t2);
5787
- 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
+ }
5788
5900
  }
5789
5901
 
5790
- case 50:
5791
- _context2.prev = 50;
5902
+ case 53:
5903
+ _context2.prev = 53;
5792
5904
  setHandleBookIsLoading(false);
5793
- return _context2.finish(50);
5905
+ return _context2.finish(53);
5794
5906
 
5795
- case 53:
5907
+ case 56:
5796
5908
  case "end":
5797
5909
  return _context2.stop();
5798
5910
  }
5799
5911
  }
5800
- }, _callee2, null, [[6, 47, 50, 53]]);
5912
+ }, _callee2, null, [[6, 50, 53, 56]]);
5801
5913
  }));
5802
5914
 
5803
5915
  return function handleBook() {
@@ -5863,6 +5975,17 @@ var TicketsContainer = function TicketsContainer(_ref) {
5863
5975
  return false;
5864
5976
  };
5865
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
+
5866
5989
  return React.createElement(ThemeProvider$1, {
5867
5990
  theme: themeMui
5868
5991
  }, !isLoading && React.createElement(ReferralLogic, {
@@ -5870,7 +5993,25 @@ var TicketsContainer = function TicketsContainer(_ref) {
5870
5993
  }), React.createElement("div", {
5871
5994
  className: "get-tickets-page " + theme,
5872
5995
  style: contentStyle
5873
- }, 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, {
5874
6015
  severity: "error",
5875
6016
  onClose: onErrorClose,
5876
6017
  variant: "filled",
@@ -6198,49 +6339,6 @@ var MyTicketsContainer = function MyTicketsContainer(_ref) {
6198
6339
  })));
6199
6340
  };
6200
6341
 
6201
- var style$3 = {
6202
- position: 'absolute',
6203
- top: '50%',
6204
- left: '50%',
6205
- transform: 'translate(-50%, -50%)',
6206
- minWidth: 480,
6207
- backgroundColor: '#e3e3e3',
6208
- border: '1px solid white',
6209
- outline: 'none',
6210
- padding: '14px',
6211
- maxHeight: '85vh',
6212
- overflow: 'auto'
6213
- };
6214
-
6215
- var ConfirmModal = function ConfirmModal(_ref) {
6216
- var _ref$message = _ref.message,
6217
- message = _ref$message === void 0 ? '' : _ref$message,
6218
- _ref$loading = _ref.loading,
6219
- loading = _ref$loading === void 0 ? false : _ref$loading,
6220
- _ref$onClose = _ref.onClose,
6221
- onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,
6222
- _ref$onConfirm = _ref.onConfirm,
6223
- onConfirm = _ref$onConfirm === void 0 ? function () {} : _ref$onConfirm;
6224
- return React.createElement(Modal$1, {
6225
- open: true,
6226
- onClose: onClose,
6227
- "aria-labelledby": "modal-modal-title",
6228
- "aria-describedby": "modal-modal-description",
6229
- className: 'confirm-modal'
6230
- }, React.createElement(Box$1, {
6231
- style: style$3
6232
- }, React.createElement("p", null, message), React.createElement("div", {
6233
- className: 'footer'
6234
- }, React.createElement(Button, {
6235
- onClick: onClose,
6236
- disabled: loading
6237
- }, "Cancel"), React.createElement(Button, {
6238
- onClick: onConfirm
6239
- }, loading ? React.createElement(CircularProgress, {
6240
- size: "22px"
6241
- }) : 'OK'))));
6242
- };
6243
-
6244
6342
  var _excluded$2 = ["label", "field", "theme", "disableDropdown"];
6245
6343
  var RadioField = function RadioField(_ref) {
6246
6344
  var label = _ref.label,