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.
@@ -1,5 +1,5 @@
1
1
  import { IGroupItem } from '../../types';
2
- import { FormikValues } from 'formik';
2
+ import { FormikErrors, FormikValues } from 'formik';
3
3
  export interface ILoggedInValues {
4
4
  emailLogged?: string;
5
5
  firstNameLogged?: string;
@@ -50,6 +50,6 @@ export declare const setLoggedUserData: (data: IUserData) => {
50
50
  export declare const createCheckoutDataBody: (ticketsQuantity: number, values?: IValues, logedInValues?: ILoggedInValues, includeDob?: boolean) => ICheckoutBody;
51
51
  export declare const getValidateFunctions: (element: IGroupItem, states: {
52
52
  [key: string]: any;
53
- }[], values: FormikValues) => (...value: any) => any;
53
+ }[], values: FormikValues, errors: FormikErrors<any>) => (...value: any) => any;
54
54
  export declare const assingUniqueIds: (data: any) => any;
55
55
  export {};
@@ -9,4 +9,4 @@ export interface IPhoneNumberField {
9
9
  fill: boolean;
10
10
  setPhoneValidationIsLoading: (isLoading: boolean) => void;
11
11
  }
12
- export declare const PhoneNumberField: ({ label, field, form: { errors, touched, setFieldError, values, initialValues, setFieldValue, setFieldTouched, }, disableDropdown, fill, setPhoneValidationIsLoading, }: IPhoneNumberField) => JSX.Element;
12
+ export declare const PhoneNumberField: ({ label, field, form: { errors, touched, setFieldError, values, initialValues, setFieldValue, setFieldTouched, setErrors, }, disableDropdown, fill, setPhoneValidationIsLoading, }: IPhoneNumberField) => JSX.Element;
@@ -7,6 +7,11 @@ export interface IShareButton {
7
7
  platform: string;
8
8
  shareData: any;
9
9
  }
10
+ export interface IConfirmationLabels {
11
+ confirmationTitle?: string;
12
+ confirmationMain?: string;
13
+ confirmationHelper?: string;
14
+ }
10
15
  export interface IConfirmationPage {
11
16
  hasCopyIcon?: boolean;
12
17
  isReferralEnabled: boolean;
@@ -17,5 +22,6 @@ export interface IConfirmationPage {
17
22
  onGetConfirmationDataError: (e: AxiosError) => void;
18
23
  onLinkCopied: () => void;
19
24
  orderHash?: string;
25
+ confirmationLabels: IConfirmationLabels;
20
26
  }
21
- export declare const ConfirmationContainer: ({ hasCopyIcon, isReferralEnabled, showDefaultShareButtons, messengerAppId, shareButtons, onGetConfirmationDataSuccess, onGetConfirmationDataError, orderHash, onLinkCopied }: IConfirmationPage) => JSX.Element;
27
+ export declare const ConfirmationContainer: ({ confirmationLabels, hasCopyIcon, isReferralEnabled, showDefaultShareButtons, messengerAppId, shareButtons, onGetConfirmationDataSuccess, onGetConfirmationDataError, orderHash, onLinkCopied }: IConfirmationPage) => JSX.Element;
@@ -1720,7 +1720,13 @@ var DatePickerField = function DatePickerField(_ref) {
1720
1720
  placeholder: 'dd/mm/yyyy'
1721
1721
  }),
1722
1722
  theme: theme,
1723
- field: field,
1723
+ field: _extends({}, field, {
1724
+ onChange: function onChange(evt) {
1725
+ if (params.inputProps && params.inputProps.onChange) {
1726
+ params.inputProps.onChange(evt);
1727
+ }
1728
+ }
1729
+ }),
1724
1730
  form: form,
1725
1731
  label: label,
1726
1732
  type: "tel"
@@ -1760,6 +1766,7 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
1760
1766
  initialValues = _ref$form.initialValues,
1761
1767
  setFieldValue = _ref$form.setFieldValue,
1762
1768
  setFieldTouched = _ref$form.setFieldTouched,
1769
+ setErrors = _ref$form.setErrors,
1763
1770
  _ref$disableDropdown = _ref.disableDropdown,
1764
1771
  disableDropdown = _ref$disableDropdown === void 0 ? true : _ref$disableDropdown,
1765
1772
  _ref$fill = _ref.fill,
@@ -1779,46 +1786,63 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
1779
1786
  }
1780
1787
 
1781
1788
  debounceCb( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1782
- var message;
1789
+ var newErrors, _newErrors, message;
1790
+
1783
1791
  return runtime_1.wrap(function _callee$(_context) {
1784
1792
  while (1) {
1785
1793
  switch (_context.prev = _context.next) {
1786
1794
  case 0:
1787
1795
  _context.prev = 0;
1788
1796
 
1797
+ if (values[field.name]) {
1798
+ _context.next = 6;
1799
+ break;
1800
+ }
1801
+
1802
+ newErrors = _extends({}, errors);
1803
+ delete newErrors[field.name];
1804
+ setErrors(newErrors);
1805
+ return _context.abrupt("return");
1806
+
1807
+ case 6:
1789
1808
  if (!values[field.name]) {
1790
- _context.next = 4;
1809
+ _context.next = 9;
1791
1810
  break;
1792
1811
  }
1793
1812
 
1794
- _context.next = 4;
1813
+ _context.next = 9;
1795
1814
  return validatePhoneNumber(values[field.name]);
1796
1815
 
1797
- case 4:
1798
- setFieldError(field.name, '');
1799
- _context.next = 11;
1816
+ case 9:
1817
+ if (errors[field.name]) {
1818
+ _newErrors = _extends({}, errors);
1819
+ delete _newErrors[field.name];
1820
+ setErrors(_newErrors);
1821
+ }
1822
+
1823
+ _context.next = 16;
1800
1824
  break;
1801
1825
 
1802
- case 7:
1803
- _context.prev = 7;
1826
+ case 12:
1827
+ _context.prev = 12;
1804
1828
  _context.t0 = _context["catch"](0);
1805
1829
  message = _get(_context.t0, 'response.data.message', 'Invalid phone number');
1806
1830
 
1807
- if (values[field.name]) {
1831
+ if (values[field.name] && errors[field.name] !== message) {
1808
1832
  setFieldError(field.name, message);
1809
1833
  }
1810
1834
 
1811
- case 11:
1812
- _context.prev = 11;
1835
+ case 16:
1836
+ _context.prev = 16;
1813
1837
  setPhoneValidationIsLoading(false);
1814
- return _context.finish(11);
1838
+ return _context.finish(16);
1815
1839
 
1816
- case 14:
1840
+ case 19:
1817
1841
  case "end":
1818
1842
  return _context.stop();
1819
1843
  }
1820
1844
  }
1821
- }, _callee, null, [[0, 7, 11, 14]]);
1845
+ }, _callee, null, [[0, 12, 16, 19]]);
1822
1846
  }))); // eslint-disable-next-line
1823
1847
  }, [field.value]);
1824
1848
  return React__default.createElement(React__default.Fragment, null, React__default.createElement(MuiPhoneNumber, {
@@ -1841,7 +1865,8 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
1841
1865
  helperText: (isTouched || fill) && error,
1842
1866
  fullWidth: true,
1843
1867
  autoFormat: false,
1844
- disableAreaCodes: true
1868
+ disableAreaCodes: true,
1869
+ countryCodeEditable: false
1845
1870
  }));
1846
1871
  };
1847
1872
 
@@ -2688,7 +2713,7 @@ var createCheckoutDataBody = function createCheckoutDataBody(ticketsQuantity, va
2688
2713
 
2689
2714
  return body;
2690
2715
  };
2691
- var getValidateFunctions = function getValidateFunctions(element, states, values) {
2716
+ var getValidateFunctions = function getValidateFunctions(element, states, values, errors) {
2692
2717
  var validationFunctions = [];
2693
2718
 
2694
2719
  if (element.required) {
@@ -2701,6 +2726,14 @@ var getValidateFunctions = function getValidateFunctions(element, states, values
2701
2726
  validationFunctions.push(element.onValidate);
2702
2727
  }
2703
2728
 
2729
+ if (element.name === 'phone') {
2730
+ var invalidPhone = function invalidPhone() {
2731
+ return errors.phone === 'Invalid phone number' ? 'Invalid phone number' : null;
2732
+ };
2733
+
2734
+ validationFunctions.push(invalidPhone);
2735
+ }
2736
+
2704
2737
  if (element.name === 'confirmEmail') {
2705
2738
  var isSameEmail = function isSameEmail(confirmEmail) {
2706
2739
  return values.email !== confirmEmail ? 'Please confirm your email address correctly' : null;
@@ -3222,7 +3255,7 @@ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref3) {
3222
3255
  while (1) {
3223
3256
  switch (_context5.prev = _context5.next) {
3224
3257
  case 0:
3225
- if (!(skipPage && !_isEmpty(ticketsQuantity) && !showDOB)) {
3258
+ if (!(skipPage && !_isEmpty(ticketsQuantity) && !showDOB && !loading)) {
3226
3259
  _context5.next = 18;
3227
3260
  break;
3228
3261
  }
@@ -3587,7 +3620,7 @@ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref3) {
3587
3620
  label: element.name === 'phone' ? "" + element.label + (flagRequirePhone ? '' : ' (optional)') + " " : element.label,
3588
3621
  type: element.type,
3589
3622
  fill: element.fill,
3590
- validate: getValidateFunctions(element, states, props.values),
3623
+ validate: getValidateFunctions(element, states, props.values, props.errors),
3591
3624
  setFieldValue: props.setFieldValue,
3592
3625
  onBlur: props.handleBlur,
3593
3626
  component: element.type === 'checkbox' ? CheckboxField : element.type === 'select' ? SelectField : element.type === 'phone' ? PhoneNumberField : element.type === 'date' ? DatePickerField : CustomField,
@@ -3610,12 +3643,16 @@ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref3) {
3610
3643
  }, React__default.createElement("div", {
3611
3644
  className: groupClassname
3612
3645
  }, _map(groupItems, function (element) {
3646
+ if (_includes(['holderFirstName', 'holderLastName'], element.name)) {
3647
+ element.required = showTicketHolders;
3648
+ }
3649
+
3613
3650
  return React__default.createElement("div", {
3614
3651
  className: element.className,
3615
3652
  key: element.name
3616
3653
  }, React__default.createElement(formik.Field, {
3617
3654
  name: element.name + "-" + index,
3618
- label: element.label,
3655
+ label: "" + element.label + (element.required ? '' : ' (optional)'),
3619
3656
  type: element.type,
3620
3657
  component: element.type === 'checkbox' ? CheckboxField : element.type === 'phone' ? PhoneNumberField : CustomField,
3621
3658
  validate: combineValidators(element.required ? requiredValidator : function () {
@@ -4571,7 +4608,8 @@ var SocialButtons = function SocialButtons(_ref2) {
4571
4608
  };
4572
4609
 
4573
4610
  var ConfirmationContainer = function ConfirmationContainer(_ref) {
4574
- var _ref$hasCopyIcon = _ref.hasCopyIcon,
4611
+ var confirmationLabels = _ref.confirmationLabels,
4612
+ _ref$hasCopyIcon = _ref.hasCopyIcon,
4575
4613
  hasCopyIcon = _ref$hasCopyIcon === void 0 ? true : _ref$hasCopyIcon,
4576
4614
  isReferralEnabled = _ref.isReferralEnabled,
4577
4615
  showDefaultShareButtons = _ref.showDefaultShareButtons,
@@ -4670,6 +4708,12 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
4670
4708
  setData(newData);
4671
4709
  };
4672
4710
 
4711
+ var _confirmationLabels$c = confirmationLabels.confirmationTitle,
4712
+ confirmationTitle = _confirmationLabels$c === void 0 ? 'Your Tickets are Confirmed!' : _confirmationLabels$c,
4713
+ _confirmationLabels$c2 = confirmationLabels.confirmationMain,
4714
+ confirmationMain = _confirmationLabels$c2 === void 0 ? 'Your tickets are available in My Tickets section' : _confirmationLabels$c2,
4715
+ _confirmationLabels$c3 = confirmationLabels.confirmationHelper,
4716
+ confirmationHelper = _confirmationLabels$c3 === void 0 ? 'Please bring them with you to the event' : _confirmationLabels$c3;
4673
4717
  return React__default.createElement("div", {
4674
4718
  className: "confirmation-page"
4675
4719
  }, data && React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
@@ -4683,15 +4727,15 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
4683
4727
  className: "header-product-text"
4684
4728
  }, React__default.createElement("p", {
4685
4729
  className: "title"
4686
- }, "Your Tickets are Confirmed!"), React__default.createElement("div", {
4730
+ }, confirmationTitle), React__default.createElement("div", {
4687
4731
  className: "share-message-section"
4688
4732
  }, data.attach_tickets ? React__default.createElement("span", {
4689
4733
  className: "main"
4690
4734
  }, "Your tickets have been emailed to you") : React__default.createElement("span", {
4691
4735
  className: "main"
4692
- }, "Your tickets are available in My Tickets section"), React__default.createElement("span", {
4736
+ }, confirmationMain), React__default.createElement("span", {
4693
4737
  className: "helper"
4694
- }, "Please bring them with you to the event")))), data.disable_referral === false && isReferralEnabled && React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
4738
+ }, data.attach_tickets ? 'Please bring them with you to the event' : confirmationHelper)))), data.disable_referral === false && isReferralEnabled && React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
4695
4739
  className: "referral_text_image_section"
4696
4740
  }, React__default.createElement("div", {
4697
4741
  className: "referral_text_section"
@@ -5715,15 +5759,11 @@ var TicketsContainer = function TicketsContainer(_ref) {
5715
5759
  var isSalesClosed = event == null ? void 0 : event.salesEnded;
5716
5760
  var themeMui = material.createTheme(themeOptions);
5717
5761
  React.useEffect(function () {
5718
- isWindowDefined && window.document.addEventListener('custom-logout', handleLogout);
5762
+ window.document.addEventListener('custom-login', handleExternalLogin);
5763
+ window.document.addEventListener('custom-logout', handleLogout);
5719
5764
  return function () {
5720
- isWindowDefined && window.document.removeEventListener('custom-logout', handleLogout);
5721
- };
5722
- }, []);
5723
- React.useEffect(function () {
5724
- isWindowDefined && window.document.addEventListener('custom-login', handleExternalLogin);
5725
- return function () {
5726
- isWindowDefined && window.document.removeEventListener('custom-login', handleExternalLogin);
5765
+ window.document.removeEventListener('custom-login', handleExternalLogin);
5766
+ window.document.removeEventListener('custom-logout', handleLogout);
5727
5767
  };
5728
5768
  }, []);
5729
5769
 
@@ -5742,14 +5782,29 @@ var TicketsContainer = function TicketsContainer(_ref) {
5742
5782
  };
5743
5783
 
5744
5784
  var bookButtonIsDisabled = handleBookIsLoading || _isEmpty(selectedTickets) || Object.values(selectedTickets)[0] === 0;
5785
+
5786
+ var isTicketAvailable = _some(tickets, function (ticket) {
5787
+ return ticket.displayTicket && !ticket.soldOut && ticket.salesStarted;
5788
+ });
5789
+
5745
5790
  var wrappedActionsSectionComponent = React__default.isValidElement(ActionsSectionComponent) ? React__default.cloneElement(ActionsSectionComponent, {
5746
5791
  handleGetTicketClick: handleGetTicketClick,
5747
- isTicketOnSale: isTicketOnSale
5792
+ isTicketOnSale: isTicketOnSale,
5793
+ isTicketAvailable: isTicketAvailable
5748
5794
  }) : null;
5749
5795
  var externalUrl = event == null ? void 0 : event.redirectUrl;
5750
- var eventSaleIsNotStarted = !(event != null && event.salesStarted) && (event == null ? void 0 : event.salesStart);
5796
+ var eventSaleIsNotStarted = !(event != null && event.salesStarted) && (event == null ? void 0 : event.salesStart) && !isTicketAvailable;
5751
5797
  var influencers = event != null && event.referralsEnabled ? event == null ? void 0 : event.referrals : [];
5752
5798
  var previewKey = getQueryVariable('pk') || undefined;
5799
+
5800
+ var canShowGetTicketBtn = function canShowGetTicketBtn() {
5801
+ if (!wrappedActionsSectionComponent && !eventSaleIsNotStarted && isTicketOnSale && !(event != null && event.salesEnded) && !externalUrl && !previewKey) {
5802
+ return true;
5803
+ }
5804
+
5805
+ return false;
5806
+ };
5807
+
5753
5808
  return React__default.createElement(privateTheming.ThemeProvider, {
5754
5809
  theme: themeMui
5755
5810
  }, !isLoading && React__default.createElement(ReferralLogic, {
@@ -5799,7 +5854,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
5799
5854
  setShowPromoInput: setShowPromoInput,
5800
5855
  setCode: setCode,
5801
5856
  updateTickets: updateTickets
5802
- }) : null, wrappedActionsSectionComponent, !wrappedActionsSectionComponent && !eventSaleIsNotStarted && isTicketOnSale && !(event != null && event.salesEnded) && !externalUrl && !previewKey && React__default.createElement(Button$1, {
5857
+ }) : null, wrappedActionsSectionComponent, canShowGetTicketBtn() && React__default.createElement(Button$1, {
5803
5858
  "aria-hidden": true,
5804
5859
  className: "book-button \n " + (bookButtonIsDisabled ? 'disabled' : '') + " \n " + (isButtonScrollable ? 'is-scrollable' : '') + "\n " + (!isLoggedIn ? 'on-bottom' : '') + "\n ",
5805
5860
  onClick: handleGetTicketClick