tf-checkout-react 1.3.1 → 1.3.3

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.
@@ -1713,7 +1713,13 @@ var DatePickerField = function DatePickerField(_ref) {
1713
1713
  placeholder: 'dd/mm/yyyy'
1714
1714
  }),
1715
1715
  theme: theme,
1716
- field: field,
1716
+ field: _extends({}, field, {
1717
+ onChange: function onChange(evt) {
1718
+ if (params.inputProps && params.inputProps.onChange) {
1719
+ params.inputProps.onChange(evt);
1720
+ }
1721
+ }
1722
+ }),
1717
1723
  form: form,
1718
1724
  label: label,
1719
1725
  type: "tel"
@@ -1753,6 +1759,7 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
1753
1759
  initialValues = _ref$form.initialValues,
1754
1760
  setFieldValue = _ref$form.setFieldValue,
1755
1761
  setFieldTouched = _ref$form.setFieldTouched,
1762
+ setErrors = _ref$form.setErrors,
1756
1763
  _ref$disableDropdown = _ref.disableDropdown,
1757
1764
  disableDropdown = _ref$disableDropdown === void 0 ? true : _ref$disableDropdown,
1758
1765
  _ref$fill = _ref.fill,
@@ -1772,46 +1779,63 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
1772
1779
  }
1773
1780
 
1774
1781
  debounceCb( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1775
- var message;
1782
+ var newErrors, _newErrors, message;
1783
+
1776
1784
  return runtime_1.wrap(function _callee$(_context) {
1777
1785
  while (1) {
1778
1786
  switch (_context.prev = _context.next) {
1779
1787
  case 0:
1780
1788
  _context.prev = 0;
1781
1789
 
1790
+ if (values[field.name]) {
1791
+ _context.next = 6;
1792
+ break;
1793
+ }
1794
+
1795
+ newErrors = _extends({}, errors);
1796
+ delete newErrors[field.name];
1797
+ setErrors(newErrors);
1798
+ return _context.abrupt("return");
1799
+
1800
+ case 6:
1782
1801
  if (!values[field.name]) {
1783
- _context.next = 4;
1802
+ _context.next = 9;
1784
1803
  break;
1785
1804
  }
1786
1805
 
1787
- _context.next = 4;
1806
+ _context.next = 9;
1788
1807
  return validatePhoneNumber(values[field.name]);
1789
1808
 
1790
- case 4:
1791
- setFieldError(field.name, '');
1792
- _context.next = 11;
1809
+ case 9:
1810
+ if (errors[field.name]) {
1811
+ _newErrors = _extends({}, errors);
1812
+ delete _newErrors[field.name];
1813
+ setErrors(_newErrors);
1814
+ }
1815
+
1816
+ _context.next = 16;
1793
1817
  break;
1794
1818
 
1795
- case 7:
1796
- _context.prev = 7;
1819
+ case 12:
1820
+ _context.prev = 12;
1797
1821
  _context.t0 = _context["catch"](0);
1798
1822
  message = _get(_context.t0, 'response.data.message', 'Invalid phone number');
1799
1823
 
1800
- if (values[field.name]) {
1824
+ if (values[field.name] && errors[field.name] !== message) {
1801
1825
  setFieldError(field.name, message);
1802
1826
  }
1803
1827
 
1804
- case 11:
1805
- _context.prev = 11;
1828
+ case 16:
1829
+ _context.prev = 16;
1806
1830
  setPhoneValidationIsLoading(false);
1807
- return _context.finish(11);
1831
+ return _context.finish(16);
1808
1832
 
1809
- case 14:
1833
+ case 19:
1810
1834
  case "end":
1811
1835
  return _context.stop();
1812
1836
  }
1813
1837
  }
1814
- }, _callee, null, [[0, 7, 11, 14]]);
1838
+ }, _callee, null, [[0, 12, 16, 19]]);
1815
1839
  }))); // eslint-disable-next-line
1816
1840
  }, [field.value]);
1817
1841
  return React.createElement(React.Fragment, null, React.createElement(MuiPhoneNumber, {
@@ -1834,7 +1858,8 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
1834
1858
  helperText: (isTouched || fill) && error,
1835
1859
  fullWidth: true,
1836
1860
  autoFormat: false,
1837
- disableAreaCodes: true
1861
+ disableAreaCodes: true,
1862
+ countryCodeEditable: false
1838
1863
  }));
1839
1864
  };
1840
1865
 
@@ -2686,7 +2711,7 @@ var createCheckoutDataBody = function createCheckoutDataBody(ticketsQuantity, va
2686
2711
 
2687
2712
  return body;
2688
2713
  };
2689
- var getValidateFunctions = function getValidateFunctions(element, states, values) {
2714
+ var getValidateFunctions = function getValidateFunctions(element, states, values, errors) {
2690
2715
  var validationFunctions = [];
2691
2716
 
2692
2717
  if (element.required) {
@@ -2699,6 +2724,14 @@ var getValidateFunctions = function getValidateFunctions(element, states, values
2699
2724
  validationFunctions.push(element.onValidate);
2700
2725
  }
2701
2726
 
2727
+ if (element.name === 'phone') {
2728
+ var invalidPhone = function invalidPhone() {
2729
+ return errors.phone === 'Invalid phone number' ? 'Invalid phone number' : null;
2730
+ };
2731
+
2732
+ validationFunctions.push(invalidPhone);
2733
+ }
2734
+
2702
2735
  if (element.name === 'confirmEmail') {
2703
2736
  var isSameEmail = function isSameEmail(confirmEmail) {
2704
2737
  return values.email !== confirmEmail ? 'Please confirm your email address correctly' : null;
@@ -3220,7 +3253,7 @@ var BillingInfoContainer = /*#__PURE__*/React.memo(function (_ref3) {
3220
3253
  while (1) {
3221
3254
  switch (_context5.prev = _context5.next) {
3222
3255
  case 0:
3223
- if (!(skipPage && !_isEmpty(ticketsQuantity) && !showDOB)) {
3256
+ if (!(skipPage && !_isEmpty(ticketsQuantity) && !showDOB && !loading)) {
3224
3257
  _context5.next = 18;
3225
3258
  break;
3226
3259
  }
@@ -3585,7 +3618,7 @@ var BillingInfoContainer = /*#__PURE__*/React.memo(function (_ref3) {
3585
3618
  label: element.name === 'phone' ? "" + element.label + (flagRequirePhone ? '' : ' (optional)') + " " : element.label,
3586
3619
  type: element.type,
3587
3620
  fill: element.fill,
3588
- validate: getValidateFunctions(element, states, props.values),
3621
+ validate: getValidateFunctions(element, states, props.values, props.errors),
3589
3622
  setFieldValue: props.setFieldValue,
3590
3623
  onBlur: props.handleBlur,
3591
3624
  component: element.type === 'checkbox' ? CheckboxField : element.type === 'select' ? SelectField : element.type === 'phone' ? PhoneNumberField : element.type === 'date' ? DatePickerField : CustomField,
@@ -3608,12 +3641,16 @@ var BillingInfoContainer = /*#__PURE__*/React.memo(function (_ref3) {
3608
3641
  }, React.createElement("div", {
3609
3642
  className: groupClassname
3610
3643
  }, _map(groupItems, function (element) {
3644
+ if (_includes(['holderFirstName', 'holderLastName'], element.name)) {
3645
+ element.required = showTicketHolders;
3646
+ }
3647
+
3611
3648
  return React.createElement("div", {
3612
3649
  className: element.className,
3613
3650
  key: element.name
3614
3651
  }, React.createElement(Field, {
3615
3652
  name: element.name + "-" + index,
3616
- label: element.label,
3653
+ label: "" + element.label + (element.required ? '' : ' (optional)'),
3617
3654
  type: element.type,
3618
3655
  component: element.type === 'checkbox' ? CheckboxField : element.type === 'phone' ? PhoneNumberField : CustomField,
3619
3656
  validate: combineValidators(element.required ? requiredValidator : function () {
@@ -4569,7 +4606,8 @@ var SocialButtons = function SocialButtons(_ref2) {
4569
4606
  };
4570
4607
 
4571
4608
  var ConfirmationContainer = function ConfirmationContainer(_ref) {
4572
- var _ref$hasCopyIcon = _ref.hasCopyIcon,
4609
+ var confirmationLabels = _ref.confirmationLabels,
4610
+ _ref$hasCopyIcon = _ref.hasCopyIcon,
4573
4611
  hasCopyIcon = _ref$hasCopyIcon === void 0 ? true : _ref$hasCopyIcon,
4574
4612
  isReferralEnabled = _ref.isReferralEnabled,
4575
4613
  showDefaultShareButtons = _ref.showDefaultShareButtons,
@@ -4668,6 +4706,12 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
4668
4706
  setData(newData);
4669
4707
  };
4670
4708
 
4709
+ var _confirmationLabels$c = confirmationLabels.confirmationTitle,
4710
+ confirmationTitle = _confirmationLabels$c === void 0 ? 'Your Tickets are Confirmed!' : _confirmationLabels$c,
4711
+ _confirmationLabels$c2 = confirmationLabels.confirmationMain,
4712
+ confirmationMain = _confirmationLabels$c2 === void 0 ? 'Your tickets are available in My Tickets section' : _confirmationLabels$c2,
4713
+ _confirmationLabels$c3 = confirmationLabels.confirmationHelper,
4714
+ confirmationHelper = _confirmationLabels$c3 === void 0 ? 'Please bring them with you to the event' : _confirmationLabels$c3;
4671
4715
  return React.createElement("div", {
4672
4716
  className: "confirmation-page"
4673
4717
  }, data && React.createElement(React.Fragment, null, React.createElement("div", {
@@ -4681,15 +4725,15 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
4681
4725
  className: "header-product-text"
4682
4726
  }, React.createElement("p", {
4683
4727
  className: "title"
4684
- }, "Your Tickets are Confirmed!"), React.createElement("div", {
4728
+ }, confirmationTitle), React.createElement("div", {
4685
4729
  className: "share-message-section"
4686
4730
  }, data.attach_tickets ? React.createElement("span", {
4687
4731
  className: "main"
4688
4732
  }, "Your tickets have been emailed to you") : React.createElement("span", {
4689
4733
  className: "main"
4690
- }, "Your tickets are available in My Tickets section"), React.createElement("span", {
4734
+ }, confirmationMain), React.createElement("span", {
4691
4735
  className: "helper"
4692
- }, "Please bring them with you to the event")))), data.disable_referral === false && isReferralEnabled && React.createElement(React.Fragment, null, React.createElement("div", {
4736
+ }, data.attach_tickets ? 'Please bring them with you to the event' : confirmationHelper)))), data.disable_referral === false && isReferralEnabled && React.createElement(React.Fragment, null, React.createElement("div", {
4693
4737
  className: "referral_text_image_section"
4694
4738
  }, React.createElement("div", {
4695
4739
  className: "referral_text_section"
@@ -5713,15 +5757,11 @@ var TicketsContainer = function TicketsContainer(_ref) {
5713
5757
  var isSalesClosed = event == null ? void 0 : event.salesEnded;
5714
5758
  var themeMui = createTheme$1(themeOptions);
5715
5759
  useEffect(function () {
5716
- isWindowDefined && window.document.addEventListener('custom-logout', handleLogout);
5760
+ window.document.addEventListener('custom-login', handleExternalLogin);
5761
+ window.document.addEventListener('custom-logout', handleLogout);
5717
5762
  return function () {
5718
- isWindowDefined && window.document.removeEventListener('custom-logout', handleLogout);
5719
- };
5720
- }, []);
5721
- useEffect(function () {
5722
- isWindowDefined && window.document.addEventListener('custom-login', handleExternalLogin);
5723
- return function () {
5724
- isWindowDefined && window.document.removeEventListener('custom-login', handleExternalLogin);
5763
+ window.document.removeEventListener('custom-login', handleExternalLogin);
5764
+ window.document.removeEventListener('custom-logout', handleLogout);
5725
5765
  };
5726
5766
  }, []);
5727
5767
 
@@ -5740,14 +5780,29 @@ var TicketsContainer = function TicketsContainer(_ref) {
5740
5780
  };
5741
5781
 
5742
5782
  var bookButtonIsDisabled = handleBookIsLoading || _isEmpty(selectedTickets) || Object.values(selectedTickets)[0] === 0;
5783
+
5784
+ var isTicketAvailable = _some(tickets, function (ticket) {
5785
+ return ticket.displayTicket && !ticket.soldOut && ticket.salesStarted;
5786
+ });
5787
+
5743
5788
  var wrappedActionsSectionComponent = React.isValidElement(ActionsSectionComponent) ? React.cloneElement(ActionsSectionComponent, {
5744
5789
  handleGetTicketClick: handleGetTicketClick,
5745
- isTicketOnSale: isTicketOnSale
5790
+ isTicketOnSale: isTicketOnSale,
5791
+ isTicketAvailable: isTicketAvailable
5746
5792
  }) : null;
5747
5793
  var externalUrl = event == null ? void 0 : event.redirectUrl;
5748
- var eventSaleIsNotStarted = !(event != null && event.salesStarted) && (event == null ? void 0 : event.salesStart);
5794
+ var eventSaleIsNotStarted = !(event != null && event.salesStarted) && (event == null ? void 0 : event.salesStart) && !isTicketAvailable;
5749
5795
  var influencers = event != null && event.referralsEnabled ? event == null ? void 0 : event.referrals : [];
5750
5796
  var previewKey = getQueryVariable('pk') || undefined;
5797
+
5798
+ var canShowGetTicketBtn = function canShowGetTicketBtn() {
5799
+ if (!wrappedActionsSectionComponent && !eventSaleIsNotStarted && isTicketOnSale && !(event != null && event.salesEnded) && !externalUrl && !previewKey) {
5800
+ return true;
5801
+ }
5802
+
5803
+ return false;
5804
+ };
5805
+
5751
5806
  return React.createElement(ThemeProvider$1, {
5752
5807
  theme: themeMui
5753
5808
  }, !isLoading && React.createElement(ReferralLogic, {
@@ -5797,7 +5852,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
5797
5852
  setShowPromoInput: setShowPromoInput,
5798
5853
  setCode: setCode,
5799
5854
  updateTickets: updateTickets
5800
- }) : null, wrappedActionsSectionComponent, !wrappedActionsSectionComponent && !eventSaleIsNotStarted && isTicketOnSale && !(event != null && event.salesEnded) && !externalUrl && !previewKey && React.createElement(Button$1, {
5855
+ }) : null, wrappedActionsSectionComponent, canShowGetTicketBtn() && React.createElement(Button$1, {
5801
5856
  "aria-hidden": true,
5802
5857
  className: "book-button \n " + (bookButtonIsDisabled ? 'disabled' : '') + " \n " + (isButtonScrollable ? 'is-scrollable' : '') + "\n " + (!isLoggedIn ? 'on-bottom' : '') + "\n ",
5803
5858
  onClick: handleGetTicketClick