tf-checkout-react 1.2.15 → 1.2.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.
@@ -1,9 +1,9 @@
1
- /// <reference types="react" />
2
1
  import './style.css';
3
2
  import { ThemeOptions } from '@mui/material';
4
3
  import { CSSProperties } from '@mui/styles';
5
4
  import { AxiosError } from 'axios';
6
5
  import { FormikHelpers, FormikValues } from 'formik';
6
+ import React from 'react';
7
7
  import { IBillingInfoData } from '../../types';
8
8
  export interface IBillingInfoPage {
9
9
  data?: IBillingInfoData[];
@@ -49,4 +49,4 @@ export interface IBillingInfoPage {
49
49
  showSignUpButton?: boolean;
50
50
  brandOptIn?: boolean;
51
51
  }
52
- export declare const BillingInfoContainer: ({ data, ticketHoldersFields, initialValues, buttonName, handleSubmit, theme, onRegisterSuccess, onRegisterError, onSubmitError, onGetCartSuccess, onGetCartError, onGetCountriesSuccess, onGetCountriesError, onGetStatesSuccess, onGetStatesError, onGetProfileDataSuccess, onGetProfileDataError, onAuthorizeSuccess, onAuthorizeError, onLogin, onLoginSuccess, isLoggedIn: pIsLoggedIn, accountInfoTitle, hideLogo, themeOptions, onErrorClose, hideErrorsAlertSection, onSkipBillingPage, skipPage, canSkipHolderNames, onForgotPasswordSuccess, onForgotPasswordError, shouldFetchCountries, onCountdownFinish, enableTimer, logo, showForgotPasswordButton, showSignUpButton, brandOptIn, }: IBillingInfoPage) => JSX.Element;
52
+ export declare const BillingInfoContainer: React.MemoExoticComponent<({ data, ticketHoldersFields, initialValues, buttonName, handleSubmit, theme, onRegisterSuccess, onRegisterError, onSubmitError, onGetCartSuccess, onGetCartError, onGetCountriesSuccess, onGetCountriesError, onGetStatesSuccess, onGetStatesError, onGetProfileDataSuccess, onGetProfileDataError, onAuthorizeSuccess, onAuthorizeError, onLogin, onLoginSuccess, isLoggedIn: pIsLoggedIn, accountInfoTitle, hideLogo, themeOptions, onErrorClose, hideErrorsAlertSection, onSkipBillingPage, skipPage, canSkipHolderNames, onForgotPasswordSuccess, onForgotPasswordError, shouldFetchCountries, onCountdownFinish, enableTimer, logo, showForgotPasswordButton, showSignUpButton, brandOptIn, }: IBillingInfoPage) => JSX.Element>;
@@ -7,5 +7,6 @@ export interface IPhoneNumberField {
7
7
  type: string;
8
8
  disableDropdown: boolean;
9
9
  fill: boolean;
10
+ setPhoneValidationIsLoading: (isLoading: boolean) => void;
10
11
  }
11
- export declare const PhoneNumberField: ({ label, field, form: { errors, touched, setFieldError, setStatus, values, initialValues, setFieldValue, setFieldTouched, }, disableDropdown, fill, }: IPhoneNumberField) => JSX.Element;
12
+ export declare const PhoneNumberField: ({ label, field, form: { errors, touched, setFieldError, values, initialValues, setFieldValue, setFieldTouched, }, disableDropdown, fill, setPhoneValidationIsLoading, }: IPhoneNumberField) => JSX.Element;
@@ -1682,7 +1682,6 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
1682
1682
  errors = _ref$form.errors,
1683
1683
  touched = _ref$form.touched,
1684
1684
  setFieldError = _ref$form.setFieldError,
1685
- setStatus = _ref$form.setStatus,
1686
1685
  values = _ref$form.values,
1687
1686
  initialValues = _ref$form.initialValues,
1688
1687
  setFieldValue = _ref$form.setFieldValue,
@@ -1690,7 +1689,8 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
1690
1689
  _ref$disableDropdown = _ref.disableDropdown,
1691
1690
  disableDropdown = _ref$disableDropdown === void 0 ? true : _ref$disableDropdown,
1692
1691
  _ref$fill = _ref.fill,
1693
- fill = _ref$fill === void 0 ? false : _ref$fill;
1692
+ fill = _ref$fill === void 0 ? false : _ref$fill,
1693
+ setPhoneValidationIsLoading = _ref.setPhoneValidationIsLoading;
1694
1694
 
1695
1695
  var error = _get(errors, field.name);
1696
1696
 
@@ -1700,34 +1700,25 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
1700
1700
  return void cb();
1701
1701
  }, 1000), []);
1702
1702
  React.useEffect(function () {
1703
- if (field.value === '+') {
1704
- setFieldError(field.name, '');
1705
- setFieldTouched(field.name, false);
1706
- return;
1707
- }
1708
-
1709
1703
  if (field.value) {
1710
- var _setStatus;
1711
-
1712
- setStatus((_setStatus = {}, _setStatus[field.name] = true, _setStatus));
1704
+ setPhoneValidationIsLoading(true);
1713
1705
  }
1714
1706
 
1715
1707
  debounceCb( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1716
- var message, _setStatus2;
1717
-
1708
+ var message;
1718
1709
  return runtime_1.wrap(function _callee$(_context) {
1719
1710
  while (1) {
1720
1711
  switch (_context.prev = _context.next) {
1721
1712
  case 0:
1722
1713
  _context.prev = 0;
1723
1714
 
1724
- if (!field.value) {
1715
+ if (!values[field.name]) {
1725
1716
  _context.next = 4;
1726
1717
  break;
1727
1718
  }
1728
1719
 
1729
1720
  _context.next = 4;
1730
- return validatePhoneNumber(field.value);
1721
+ return validatePhoneNumber(values[field.name]);
1731
1722
 
1732
1723
  case 4:
1733
1724
  setFieldError(field.name, '');
@@ -1738,11 +1729,14 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
1738
1729
  _context.prev = 7;
1739
1730
  _context.t0 = _context["catch"](0);
1740
1731
  message = _get(_context.t0, 'response.data.message', 'Invalid phone number');
1741
- setFieldError(field.name, message);
1732
+
1733
+ if (values[field.name]) {
1734
+ setFieldError(field.name, message);
1735
+ }
1742
1736
 
1743
1737
  case 11:
1744
1738
  _context.prev = 11;
1745
- setStatus((_setStatus2 = {}, _setStatus2[field.name] = false, _setStatus2));
1739
+ setPhoneValidationIsLoading(false);
1746
1740
  return _context.finish(11);
1747
1741
 
1748
1742
  case 14:
@@ -1755,14 +1749,14 @@ var PhoneNumberField = function PhoneNumberField(_ref) {
1755
1749
  }, [field.value]);
1756
1750
  return React__default.createElement(React__default.Fragment, null, React__default.createElement(MuiPhoneNumber, {
1757
1751
  name: field.name,
1758
- value: fill ? values.phone : initialValues.phone,
1752
+ value: fill ? values[field.name] : initialValues[field.name],
1759
1753
  onChange: function onChange(value, country) {
1760
- if ("+" + (country == null ? void 0 : country.dialCode) !== value) {
1761
- setFieldTouched(field.name, true);
1762
- setFieldValue(field.name, value);
1763
- } else {
1754
+ if ("+" + (country == null ? void 0 : country.dialCode) === value || value === '+') {
1764
1755
  setFieldValue(field.name, '');
1765
1756
  setFieldError(field.name, '');
1757
+ } else {
1758
+ setFieldTouched(field.name, true);
1759
+ setFieldValue(field.name, value);
1766
1760
  }
1767
1761
  },
1768
1762
  variant: "outlined",
@@ -2764,7 +2758,7 @@ var LogicRunner = function LogicRunner(_ref) {
2764
2758
  return null;
2765
2759
  };
2766
2760
 
2767
- var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2761
+ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref3) {
2768
2762
  var _ref3$data = _ref3.data,
2769
2763
  data = _ref3$data === void 0 ? [] : _ref3$data,
2770
2764
  _ref3$ticketHoldersFi = _ref3.ticketHoldersFields,
@@ -2781,34 +2775,34 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2781
2775
  _ref3$theme = _ref3.theme,
2782
2776
  theme = _ref3$theme === void 0 ? 'light' : _ref3$theme,
2783
2777
  _ref3$onRegisterSucce = _ref3.onRegisterSuccess,
2784
- onRegisterSuccess = _ref3$onRegisterSucce === void 0 ? function () {} : _ref3$onRegisterSucce,
2778
+ onRegisterSuccess = _ref3$onRegisterSucce === void 0 ? _identity : _ref3$onRegisterSucce,
2785
2779
  _ref3$onRegisterError = _ref3.onRegisterError,
2786
- onRegisterError = _ref3$onRegisterError === void 0 ? function () {} : _ref3$onRegisterError,
2780
+ onRegisterError = _ref3$onRegisterError === void 0 ? _identity : _ref3$onRegisterError,
2787
2781
  _ref3$onSubmitError = _ref3.onSubmitError,
2788
- onSubmitError = _ref3$onSubmitError === void 0 ? function () {} : _ref3$onSubmitError,
2782
+ onSubmitError = _ref3$onSubmitError === void 0 ? _identity : _ref3$onSubmitError,
2789
2783
  _ref3$onGetCartSucces = _ref3.onGetCartSuccess,
2790
- onGetCartSuccess = _ref3$onGetCartSucces === void 0 ? function () {} : _ref3$onGetCartSucces,
2784
+ onGetCartSuccess = _ref3$onGetCartSucces === void 0 ? _identity : _ref3$onGetCartSucces,
2791
2785
  _ref3$onGetCartError = _ref3.onGetCartError,
2792
- onGetCartError = _ref3$onGetCartError === void 0 ? function () {} : _ref3$onGetCartError,
2786
+ onGetCartError = _ref3$onGetCartError === void 0 ? _identity : _ref3$onGetCartError,
2793
2787
  _ref3$onGetCountriesS = _ref3.onGetCountriesSuccess,
2794
- onGetCountriesSuccess = _ref3$onGetCountriesS === void 0 ? function () {} : _ref3$onGetCountriesS,
2788
+ onGetCountriesSuccess = _ref3$onGetCountriesS === void 0 ? _identity : _ref3$onGetCountriesS,
2795
2789
  _ref3$onGetCountriesE = _ref3.onGetCountriesError,
2796
- onGetCountriesError = _ref3$onGetCountriesE === void 0 ? function () {} : _ref3$onGetCountriesE,
2790
+ onGetCountriesError = _ref3$onGetCountriesE === void 0 ? _identity : _ref3$onGetCountriesE,
2797
2791
  _ref3$onGetStatesSucc = _ref3.onGetStatesSuccess,
2798
- onGetStatesSuccess = _ref3$onGetStatesSucc === void 0 ? function () {} : _ref3$onGetStatesSucc,
2792
+ onGetStatesSuccess = _ref3$onGetStatesSucc === void 0 ? _identity : _ref3$onGetStatesSucc,
2799
2793
  _ref3$onGetStatesErro = _ref3.onGetStatesError,
2800
- onGetStatesError = _ref3$onGetStatesErro === void 0 ? function () {} : _ref3$onGetStatesErro,
2794
+ onGetStatesError = _ref3$onGetStatesErro === void 0 ? _identity : _ref3$onGetStatesErro,
2801
2795
  _ref3$onGetProfileDat = _ref3.onGetProfileDataSuccess,
2802
- _onGetProfileDataSuccess = _ref3$onGetProfileDat === void 0 ? function () {} : _ref3$onGetProfileDat,
2796
+ _onGetProfileDataSuccess = _ref3$onGetProfileDat === void 0 ? _identity : _ref3$onGetProfileDat,
2803
2797
  _ref3$onGetProfileDat2 = _ref3.onGetProfileDataError,
2804
- onGetProfileDataError = _ref3$onGetProfileDat2 === void 0 ? function () {} : _ref3$onGetProfileDat2,
2798
+ onGetProfileDataError = _ref3$onGetProfileDat2 === void 0 ? _identity : _ref3$onGetProfileDat2,
2805
2799
  _ref3$onAuthorizeSucc = _ref3.onAuthorizeSuccess,
2806
- onAuthorizeSuccess = _ref3$onAuthorizeSucc === void 0 ? function () {} : _ref3$onAuthorizeSucc,
2800
+ onAuthorizeSuccess = _ref3$onAuthorizeSucc === void 0 ? _identity : _ref3$onAuthorizeSucc,
2807
2801
  _ref3$onAuthorizeErro = _ref3.onAuthorizeError,
2808
- onAuthorizeError = _ref3$onAuthorizeErro === void 0 ? function () {} : _ref3$onAuthorizeErro,
2802
+ onAuthorizeError = _ref3$onAuthorizeErro === void 0 ? _identity : _ref3$onAuthorizeErro,
2809
2803
  onLogin = _ref3.onLogin,
2810
2804
  _ref3$onLoginSuccess = _ref3.onLoginSuccess,
2811
- onLoginSuccess = _ref3$onLoginSuccess === void 0 ? function () {} : _ref3$onLoginSuccess,
2805
+ onLoginSuccess = _ref3$onLoginSuccess === void 0 ? _identity : _ref3$onLoginSuccess,
2812
2806
  _ref3$isLoggedIn = _ref3.isLoggedIn,
2813
2807
  pIsLoggedIn = _ref3$isLoggedIn === void 0 ? false : _ref3$isLoggedIn,
2814
2808
  _ref3$accountInfoTitl = _ref3.accountInfoTitle,
@@ -2816,23 +2810,23 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2816
2810
  hideLogo = _ref3.hideLogo,
2817
2811
  themeOptions = _ref3.themeOptions,
2818
2812
  _ref3$onErrorClose = _ref3.onErrorClose,
2819
- onErrorClose = _ref3$onErrorClose === void 0 ? function () {} : _ref3$onErrorClose,
2813
+ onErrorClose = _ref3$onErrorClose === void 0 ? _identity : _ref3$onErrorClose,
2820
2814
  _ref3$hideErrorsAlert = _ref3.hideErrorsAlertSection,
2821
2815
  hideErrorsAlertSection = _ref3$hideErrorsAlert === void 0 ? false : _ref3$hideErrorsAlert,
2822
2816
  _ref3$onSkipBillingPa = _ref3.onSkipBillingPage,
2823
- onSkipBillingPage = _ref3$onSkipBillingPa === void 0 ? function () {} : _ref3$onSkipBillingPa,
2817
+ onSkipBillingPage = _ref3$onSkipBillingPa === void 0 ? _identity : _ref3$onSkipBillingPa,
2824
2818
  _ref3$skipPage = _ref3.skipPage,
2825
2819
  skipPage = _ref3$skipPage === void 0 ? false : _ref3$skipPage,
2826
2820
  _ref3$canSkipHolderNa = _ref3.canSkipHolderNames,
2827
2821
  canSkipHolderNames = _ref3$canSkipHolderNa === void 0 ? false : _ref3$canSkipHolderNa,
2828
2822
  _ref3$onForgotPasswor = _ref3.onForgotPasswordSuccess,
2829
- onForgotPasswordSuccess = _ref3$onForgotPasswor === void 0 ? function () {} : _ref3$onForgotPasswor,
2823
+ onForgotPasswordSuccess = _ref3$onForgotPasswor === void 0 ? _identity : _ref3$onForgotPasswor,
2830
2824
  _ref3$onForgotPasswor2 = _ref3.onForgotPasswordError,
2831
- onForgotPasswordError = _ref3$onForgotPasswor2 === void 0 ? function () {} : _ref3$onForgotPasswor2,
2825
+ onForgotPasswordError = _ref3$onForgotPasswor2 === void 0 ? _identity : _ref3$onForgotPasswor2,
2832
2826
  _ref3$shouldFetchCoun = _ref3.shouldFetchCountries,
2833
2827
  shouldFetchCountries = _ref3$shouldFetchCoun === void 0 ? true : _ref3$shouldFetchCoun,
2834
2828
  _ref3$onCountdownFini = _ref3.onCountdownFinish,
2835
- onCountdownFinish = _ref3$onCountdownFini === void 0 ? function () {} : _ref3$onCountdownFini,
2829
+ onCountdownFinish = _ref3$onCountdownFini === void 0 ? _identity : _ref3$onCountdownFini,
2836
2830
  _ref3$enableTimer = _ref3.enableTimer,
2837
2831
  enableTimer = _ref3$enableTimer === void 0 ? false : _ref3$enableTimer,
2838
2832
  logo = _ref3.logo,
@@ -2920,6 +2914,10 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2920
2914
  error = _useState14[0],
2921
2915
  setError = _useState14[1];
2922
2916
 
2917
+ var _useState15 = React.useState(false),
2918
+ phoneValidationIsLoading = _useState15[0],
2919
+ setPhoneValidationIsLoading = _useState15[1];
2920
+
2923
2921
  var emailLogged = _get(userData, 'email', '') || _get(userValues, 'email', '');
2924
2922
 
2925
2923
  var firstNameLogged = _get(userData, 'first_name', '') || _get(userValues, 'first_name', '');
@@ -3125,6 +3123,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
3125
3123
 
3126
3124
  React.useEffect(function () {
3127
3125
  fetchUserData(access_token);
3126
+ fetchCart();
3128
3127
  }, [access_token, isLoggedIn]);
3129
3128
  React.useEffect(function () {
3130
3129
  var collectPaymentData = /*#__PURE__*/function () {
@@ -3521,7 +3520,8 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
3521
3520
  }, element.onValidate ? element.onValidate : function () {
3522
3521
  return props.errors[element.name + "-" + index];
3523
3522
  }),
3524
- disableDropdown: element.disableDropdown
3523
+ disableDropdown: element.disableDropdown,
3524
+ setPhoneValidationIsLoading: setPhoneValidationIsLoading
3525
3525
  }));
3526
3526
  })));
3527
3527
  }));
@@ -3531,7 +3531,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
3531
3531
  type: "submit",
3532
3532
  variant: "contained",
3533
3533
  className: "login-register-button",
3534
- disabled: props.isSubmitting
3534
+ disabled: props.isSubmitting || phoneValidationIsLoading
3535
3535
  }, props.isSubmitting ? React__default.createElement(material.CircularProgress, {
3536
3536
  size: 26
3537
3537
  }) : buttonName))));
@@ -3586,7 +3586,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
3586
3586
  onForgotPasswordSuccess: onForgotPasswordSuccess,
3587
3587
  onForgotPasswordError: onForgotPasswordError
3588
3588
  }));
3589
- };
3589
+ });
3590
3590
 
3591
3591
  var currencyNormalizerCreator = function currencyNormalizerCreator(value, currency) {
3592
3592
  return !value ? '' : "" + getCurrencySymbolByCurrency(currency) + value;