tf-checkout-react-native 1.0.16 → 1.0.19

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.
Files changed (156) hide show
  1. package/README.md +796 -13
  2. package/lib/api/ApiClient.d.ts +14 -36
  3. package/lib/api/ApiClient.js +85 -30
  4. package/lib/api/ApiClient.js.map +1 -1
  5. package/lib/api/Constants.d.ts +2 -0
  6. package/lib/api/Constants.js +2 -0
  7. package/lib/api/Constants.js.map +1 -1
  8. package/lib/api/types.d.ts +100 -21
  9. package/lib/components/dropdown/styles.js +1 -1
  10. package/lib/components/dropdownMaterial/DropdownMaterial.d.ts +3 -0
  11. package/lib/components/dropdownMaterial/DropdownMaterial.js +53 -0
  12. package/lib/components/dropdownMaterial/DropdownMaterial.js.map +1 -0
  13. package/lib/components/dropdownMaterial/styles.d.ts +79 -0
  14. package/lib/components/dropdownMaterial/styles.js +88 -0
  15. package/lib/components/dropdownMaterial/styles.js.map +1 -0
  16. package/lib/components/dropdownMaterial/types.d.ts +21 -0
  17. package/lib/components/dropdownMaterial/types.js +2 -0
  18. package/lib/components/dropdownMaterial/types.js.map +1 -0
  19. package/lib/components/index.d.ts +3 -0
  20. package/lib/components/index.js +3 -0
  21. package/lib/components/index.js.map +1 -1
  22. package/lib/components/input/Input.js +1 -1
  23. package/lib/components/input/Input.js.map +1 -1
  24. package/lib/components/input/types.d.ts +4 -3
  25. package/lib/components/loggedIn/LoggedIn.js +3 -3
  26. package/lib/components/loggedIn/LoggedIn.js.map +1 -1
  27. package/lib/components/login/Login.d.ts +2 -1
  28. package/lib/components/login/Login.js +25 -63
  29. package/lib/components/login/Login.js.map +1 -1
  30. package/lib/components/login/LoginView.d.ts +2 -1
  31. package/lib/components/login/LoginView.js +18 -7
  32. package/lib/components/login/LoginView.js.map +1 -1
  33. package/lib/components/login/types.d.ts +9 -9
  34. package/lib/components/phoneInput/PhoneInput.d.ts +4 -0
  35. package/lib/components/phoneInput/PhoneInput.js +33 -0
  36. package/lib/components/phoneInput/PhoneInput.js.map +1 -0
  37. package/lib/components/phoneInput/styles.d.ts +28 -0
  38. package/lib/components/phoneInput/styles.js +30 -0
  39. package/lib/components/phoneInput/styles.js.map +1 -0
  40. package/lib/components/phoneInput/types.d.ts +30 -0
  41. package/lib/components/phoneInput/types.js +2 -0
  42. package/lib/components/phoneInput/types.js.map +1 -0
  43. package/lib/components/promoCode/PromoCode.d.ts +2 -1
  44. package/lib/components/promoCode/PromoCode.js +30 -44
  45. package/lib/components/promoCode/PromoCode.js.map +1 -1
  46. package/lib/components/promoCode/styles.d.ts +20 -16
  47. package/lib/components/promoCode/styles.js +21 -17
  48. package/lib/components/promoCode/styles.js.map +1 -1
  49. package/lib/components/promoCode/types.d.ts +9 -7
  50. package/lib/components/stripePayment/StripePayment.d.ts +4 -0
  51. package/lib/components/stripePayment/StripePayment.js +23 -0
  52. package/lib/components/stripePayment/StripePayment.js.map +1 -0
  53. package/lib/components/stripePayment/types.d.ts +12 -0
  54. package/lib/components/stripePayment/types.js +2 -0
  55. package/lib/components/stripePayment/types.js.map +1 -0
  56. package/lib/components/waitingList/WaitingList.d.ts +2 -1
  57. package/lib/components/waitingList/WaitingList.js +32 -29
  58. package/lib/components/waitingList/WaitingList.js.map +1 -1
  59. package/lib/components/waitingList/WaitingListView.d.ts +2 -1
  60. package/lib/components/waitingList/WaitingListView.js.map +1 -1
  61. package/lib/components/waitingList/types.d.ts +0 -1
  62. package/lib/containers/billingInfo/Billing.js +300 -196
  63. package/lib/containers/billingInfo/Billing.js.map +1 -1
  64. package/lib/containers/billingInfo/types.d.ts +12 -6
  65. package/lib/containers/checkout/Checkout.d.ts +2 -1
  66. package/lib/containers/checkout/Checkout.js +58 -65
  67. package/lib/containers/checkout/Checkout.js.map +1 -1
  68. package/lib/containers/checkout/types.d.ts +1 -1
  69. package/lib/containers/myOrderDetails/MyOrderDetailsView.js +4 -3
  70. package/lib/containers/myOrderDetails/MyOrderDetailsView.js.map +1 -1
  71. package/lib/containers/myOrderDetails/types.d.ts +10 -2
  72. package/lib/containers/myOrders/MyOrders.js +26 -4
  73. package/lib/containers/myOrders/MyOrders.js.map +1 -1
  74. package/lib/containers/myOrders/MyOrdersView.d.ts +2 -1
  75. package/lib/containers/myOrders/MyOrdersView.js.map +1 -1
  76. package/lib/containers/myOrders/types.d.ts +2 -2
  77. package/lib/containers/purchaseConfirmation/PurchaseConfirmation.d.ts +2 -1
  78. package/lib/containers/purchaseConfirmation/PurchaseConfirmation.js +23 -8
  79. package/lib/containers/purchaseConfirmation/PurchaseConfirmation.js.map +1 -1
  80. package/lib/containers/purchaseConfirmation/PurchaseConfirmationView.d.ts +2 -1
  81. package/lib/containers/purchaseConfirmation/PurchaseConfirmationView.js.map +1 -1
  82. package/lib/containers/tickets/Tickets.d.ts +2 -1
  83. package/lib/containers/tickets/Tickets.js +81 -86
  84. package/lib/containers/tickets/Tickets.js.map +1 -1
  85. package/lib/containers/tickets/TicketsView.d.ts +1 -1
  86. package/lib/containers/tickets/TicketsView.js +4 -5
  87. package/lib/containers/tickets/TicketsView.js.map +1 -1
  88. package/lib/containers/tickets/types.d.ts +6 -15
  89. package/lib/core/BillingCore/BillingCore.d.ts +5 -0
  90. package/lib/core/BillingCore/BillingCore.js +28 -0
  91. package/lib/core/BillingCore/BillingCore.js.map +1 -0
  92. package/lib/core/BillingCore/BillingCoreTypes.d.ts +16 -0
  93. package/lib/core/BillingCore/BillingCoreTypes.js +2 -0
  94. package/lib/core/BillingCore/BillingCoreTypes.js.map +1 -0
  95. package/lib/core/CheckoutCore/CheckoutCore.d.ts +5 -0
  96. package/lib/core/CheckoutCore/CheckoutCore.js +25 -0
  97. package/lib/core/CheckoutCore/CheckoutCore.js.map +1 -0
  98. package/lib/core/CheckoutCore/CheckoutCoreTypes.d.ts +8 -0
  99. package/lib/core/CheckoutCore/CheckoutCoreTypes.js +2 -0
  100. package/lib/core/CheckoutCore/CheckoutCoreTypes.js.map +1 -0
  101. package/lib/core/CoreProps.d.ts +4 -0
  102. package/lib/core/CoreProps.js +2 -0
  103. package/lib/core/CoreProps.js.map +1 -0
  104. package/lib/core/LoginCore/LoginCore.d.ts +5 -0
  105. package/lib/core/LoginCore/LoginCore.js +100 -0
  106. package/lib/core/LoginCore/LoginCore.js.map +1 -0
  107. package/lib/core/LoginCore/LoginCoreTypes.d.ts +10 -0
  108. package/lib/core/LoginCore/LoginCoreTypes.js +2 -0
  109. package/lib/core/LoginCore/LoginCoreTypes.js.map +1 -0
  110. package/lib/core/MyOrdersCore/MyOrdersCore.d.ts +3 -0
  111. package/lib/core/MyOrdersCore/MyOrdersCore.js +16 -0
  112. package/lib/core/MyOrdersCore/MyOrdersCore.js.map +1 -0
  113. package/lib/core/MyOrdersCore/MyOrdersCoreTypes.d.ts +5 -0
  114. package/lib/core/MyOrdersCore/MyOrdersCoreTypes.js +2 -0
  115. package/lib/core/MyOrdersCore/MyOrdersCoreTypes.js.map +1 -0
  116. package/lib/core/PurchaseConfirmationCore/PurchaseConfirmationCore.d.ts +5 -0
  117. package/lib/core/PurchaseConfirmationCore/PurchaseConfirmationCore.js +12 -0
  118. package/lib/core/PurchaseConfirmationCore/PurchaseConfirmationCore.js.map +1 -0
  119. package/lib/core/PurchaseConfirmationCore/PurchaseConfirmationCoreTypes.d.ts +4 -0
  120. package/lib/core/PurchaseConfirmationCore/PurchaseConfirmationCoreTypes.js +2 -0
  121. package/lib/core/PurchaseConfirmationCore/PurchaseConfirmationCoreTypes.js.map +1 -0
  122. package/lib/core/TicketsCore/TicketsCore.d.ts +5 -0
  123. package/lib/core/TicketsCore/TicketsCore.js +59 -0
  124. package/lib/core/TicketsCore/TicketsCore.js.map +1 -0
  125. package/lib/core/TicketsCore/TicketsCoreTypes.d.ts +15 -0
  126. package/lib/core/TicketsCore/TicketsCoreTypes.js +2 -0
  127. package/lib/core/TicketsCore/TicketsCoreTypes.js.map +1 -0
  128. package/lib/core/WaitingListCore/WaitingListCore.d.ts +5 -0
  129. package/lib/core/WaitingListCore/WaitingListCore.js +17 -0
  130. package/lib/core/WaitingListCore/WaitingListCore.js.map +1 -0
  131. package/lib/core/WaitingListCore/WaitingListCoreTypes.d.ts +9 -0
  132. package/lib/core/WaitingListCore/WaitingListCoreTypes.js +2 -0
  133. package/lib/core/WaitingListCore/WaitingListCoreTypes.js.map +1 -0
  134. package/lib/core/index.d.ts +14 -0
  135. package/lib/core/index.js +8 -0
  136. package/lib/core/index.js.map +1 -0
  137. package/lib/helpers/Config.d.ts +2 -1
  138. package/lib/helpers/Config.js +14 -5
  139. package/lib/helpers/Config.js.map +1 -1
  140. package/lib/helpers/CountryCodes.d.ts +15 -0
  141. package/lib/helpers/CountryCodes.js +3382 -0
  142. package/lib/helpers/CountryCodes.js.map +1 -0
  143. package/lib/helpers/LocalStorage.d.ts +1 -0
  144. package/lib/helpers/LocalStorage.js +4 -1
  145. package/lib/helpers/LocalStorage.js.map +1 -1
  146. package/lib/helpers/Validators.d.ts +6 -0
  147. package/lib/helpers/Validators.js +10 -0
  148. package/lib/helpers/Validators.js.map +1 -1
  149. package/lib/index.d.ts +4 -2
  150. package/lib/index.js +3 -1
  151. package/lib/index.js.map +1 -1
  152. package/lib/types/IEvent.d.ts +6 -0
  153. package/lib/types/ITicket.d.ts +10 -1
  154. package/lib/types/IUserProfile.d.ts +15 -11
  155. package/package.json +14 -7
  156. package/src/index.tsx +78 -0
@@ -4,67 +4,59 @@ import _forEach from 'lodash/forEach';
4
4
  import _map from 'lodash/map';
5
5
  import React, { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
6
6
  import { ActivityIndicator, Alert, Image, Linking, Text, View, } from 'react-native';
7
+ import DeviceCountry, { TYPE_ANY } from 'react-native-device-country';
7
8
  import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
8
- import { checkoutOrder, fetchCart, fetchCountries, fetchStates, fetchUserProfile, registerNewUser, } from '../../api/ApiClient';
9
9
  import Constants from '../../api/Constants';
10
- import { Button, Checkbox, DatePicker, Dropdown, Input, Loading, Login, } from '../../components';
10
+ import { Button, Checkbox, DatePicker, DropdownMaterial, Input, Loading, Login, PhoneInput, } from '../../components';
11
+ import { BillingCore } from '../../core';
11
12
  import { Config } from '../../helpers/Config';
13
+ import { getCountryDialCode } from '../../helpers/CountryCodes';
12
14
  import { useDebounced } from '../../helpers/Debounced';
13
15
  import { getData, LocalStorageKeys } from '../../helpers/LocalStorage';
14
- import { validateAge, validateEmail, validateEmpty, validatePasswords, } from '../../helpers/Validators';
16
+ import { validateAge, validateEmail, validateEmpty, validatePasswords, validatePhoneNumber, } from '../../helpers/Validators';
15
17
  import R from '../../res';
16
18
  import s from './styles';
17
- const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, isPhoneRequired, minimumAge, isBillingRequired, }, loginBrandImages, skipBillingConfig, areAlertsEnabled = true, areLoadingIndicatorsEnabled = true, onLoadingChange, onLoginError, onLoginSuccess, onRegisterError, onRegisterSuccess, onCheckoutSuccess, onCheckoutError, onFetchUserProfileSuccess, onFetchUserProfileError, onFetchCartError, onFetchCartSuccess, onFetchCountriesError, onFetchCountriesSuccess, onFetchStatesError, onFetchStatesSuccess, onFetchAccessTokenError, onFetchAccessTokenSuccess, onSkippingStatusChange, }) => {
19
+ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, isPhoneRequired, minimumAge, isBillingRequired, }, loginBrandImages, skipBillingConfig, areAlertsEnabled = true, areLoadingIndicatorsEnabled = true, onLoadingChange, onLoginError, onLoginSuccess, onRegisterError, onRegisterSuccess, onCheckoutSuccess, onCheckoutError, onFetchUserProfileSuccess, onFetchUserProfileError, onFetchCartError, onFetchCartSuccess, onFetchCountriesError, onFetchCountriesSuccess, onFetchStatesError, onFetchStatesSuccess, onSkippingStatusChange, onLogoutSuccess, onLogoutError, }) => {
18
20
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
19
21
  //#region Labels
20
- const countryLabel = ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.country) || 'Country';
21
- const stateLabel = ((_b = texts === null || texts === void 0 ? void 0 : texts.form) === null || _b === void 0 ? void 0 : _b.country) || 'State/County';
22
- const defaultCountry = { value: '-1', label: countryLabel };
23
- const defaultState = { value: '-1', label: stateLabel };
24
- const optionalText = ((_c = texts === null || texts === void 0 ? void 0 : texts.form) === null || _c === void 0 ? void 0 : _c.optional) || ' (optional)';
25
- const brandCheckBoxText = useMemo(() => {
26
- var _a, _b;
27
- return ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.isSubToBrand)
28
- ? (_b = texts.form) === null || _b === void 0 ? void 0 : _b.isSubToBrand
29
- : 'I would like to be updated on news, events and offers.';
30
- }, [(_d = texts === null || texts === void 0 ? void 0 : texts.form) === null || _d === void 0 ? void 0 : _d.isSubToBrand]);
22
+ const holderLabels = useMemo(() => {
23
+ var _a, _b, _c, _d, _e, _f, _g;
24
+ const optional = isNameRequired ? '' : ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.optional) || '(optional)';
25
+ return {
26
+ firstName: ((_b = texts === null || texts === void 0 ? void 0 : texts.form) === null || _b === void 0 ? void 0 : _b.holderFirstName)
27
+ ? `${texts.form.holderFirstName} ${optional}`
28
+ : `First Name ${optional}`,
29
+ lastName: ((_c = texts === null || texts === void 0 ? void 0 : texts.form) === null || _c === void 0 ? void 0 : _c.holderLastName)
30
+ ? `${texts.form.holderLastName} ${optional}`
31
+ : `Last Name ${optional}`,
32
+ email: ((_d = texts === null || texts === void 0 ? void 0 : texts.form) === null || _d === void 0 ? void 0 : _d.holderEmail)
33
+ ? `${texts.form.holderEmail} ${((_e = texts === null || texts === void 0 ? void 0 : texts.form) === null || _e === void 0 ? void 0 : _e.optional) || '(optional)'}`
34
+ : `Email ${optional}`,
35
+ phone: ((_f = texts === null || texts === void 0 ? void 0 : texts.form) === null || _f === void 0 ? void 0 : _f.holderPhone)
36
+ ? `${texts.form.holderPhone} ${((_g = texts === null || texts === void 0 ? void 0 : texts.form) === null || _g === void 0 ? void 0 : _g.optional) || '(optional)'}`
37
+ : `Phone ${optional}`,
38
+ };
39
+ }, [isNameRequired, texts]);
40
+ const brandCheckBoxText = ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.isSubToBrand) ||
41
+ 'I would like to be updated on news, events and offers.';
31
42
  const phoneLabel = useMemo(() => {
32
- var _a, _b;
33
- const optionalPhone = isPhoneRequired ? '' : optionalText;
34
- return ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.phone)
35
- ? `${(_b = texts === null || texts === void 0 ? void 0 : texts.form) === null || _b === void 0 ? void 0 : _b.phone} ${optionalPhone}`
43
+ var _a, _b, _c;
44
+ const optionalPhone = isPhoneRequired
45
+ ? ''
46
+ : ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.optional) || ' (optional)';
47
+ return ((_b = texts === null || texts === void 0 ? void 0 : texts.form) === null || _b === void 0 ? void 0 : _b.phone)
48
+ ? `${(_c = texts === null || texts === void 0 ? void 0 : texts.form) === null || _c === void 0 ? void 0 : _c.phone} ${optionalPhone}`
36
49
  : `Phone ${optionalPhone}`;
37
- // eslint-disable-next-line react-hooks/exhaustive-deps
38
50
  }, [isPhoneRequired, texts]);
39
51
  const addressLabel = useMemo(() => {
40
- var _a;
52
+ var _a, _b;
41
53
  const optionalAddress = Config.IS_BILLING_STREET_NAME_REQUIRED
42
54
  ? ''
43
- : optionalText;
44
- return ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.street)
55
+ : ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.optional) || ' (optional)';
56
+ return ((_b = texts === null || texts === void 0 ? void 0 : texts.form) === null || _b === void 0 ? void 0 : _b.street)
45
57
  ? `${texts.form.street} ${optionalAddress}`
46
58
  : `Street ${optionalAddress}`;
47
- // eslint-disable-next-line react-hooks/exhaustive-deps
48
59
  }, [texts]);
49
- const holderLabels = useMemo(() => {
50
- var _a, _b, _c, _d;
51
- const optional = isNameRequired ? '' : optionalText;
52
- return {
53
- firstName: ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.holderFirstName)
54
- ? `${texts.form.holderFirstName} ${optional}`
55
- : `First Name ${optional}`,
56
- lastName: ((_b = texts === null || texts === void 0 ? void 0 : texts.form) === null || _b === void 0 ? void 0 : _b.holderLastName)
57
- ? `${texts.form.holderLastName} ${optional}`
58
- : `Last Name ${optional}`,
59
- email: ((_c = texts === null || texts === void 0 ? void 0 : texts.form) === null || _c === void 0 ? void 0 : _c.holderEmail)
60
- ? `${texts.form.holderEmail} ${optionalText}`
61
- : `Email ${optionalText}`,
62
- phone: ((_d = texts === null || texts === void 0 ? void 0 : texts.form) === null || _d === void 0 ? void 0 : _d.holderPhone)
63
- ? `${texts.form.holderPhone} ${optionalText}`
64
- : `Phone ${optionalText}`,
65
- };
66
- // eslint-disable-next-line react-hooks/exhaustive-deps
67
- }, [isNameRequired, texts]);
68
60
  //#endregion
69
61
  //#region State
70
62
  const [isLoading, setIsLoading] = useState(false);
@@ -90,8 +82,8 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
90
82
  const [selectedState, setSelectedState] = useState(undefined);
91
83
  const [ticketHoldersData, setTicketHoldersData] = useState([]);
92
84
  const [numberOfTicketHolders, setNumberOfTicketHolders] = useState();
93
- const [countries, setCountries] = useState([defaultCountry]);
94
- const [states, setStates] = useState([defaultState]);
85
+ const [states, setStates] = useState([]);
86
+ const [countries, setCountries] = useState([]);
95
87
  const [isLoginDialogVisible, setIsLoginDialogVisible] = useState(false);
96
88
  const [skipping, setSkippingStatus] = useState(undefined);
97
89
  const [isTtfCheckboxHidden, setIsTtfCheckboxHidden] = useState(false);
@@ -102,7 +94,7 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
102
94
  const confirmEmailError = useDebounced(emailConfirmation, () => validateEmail(emailConfirmation, email));
103
95
  const passwordError = useDebounced(password, () => validatePasswords(password, passwordConfirmation));
104
96
  const confirmPasswordError = useDebounced(passwordConfirmation, () => validatePasswords(passwordConfirmation, password));
105
- const phoneError = useDebounced(phone, validateEmpty);
97
+ const [phoneError, setPhoneError] = useState('');
106
98
  const streetError = useDebounced(street, validateEmpty);
107
99
  const cityError = useDebounced(city, validateEmpty);
108
100
  const postalCodeError = useDebounced(postalCode, validateEmpty);
@@ -110,7 +102,7 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
110
102
  // End of errors state
111
103
  //#endregion
112
104
  const getSkippingStatus = (numOfTickets) => {
113
- if (isBillingRequired) {
105
+ if (isBillingRequired || skipping === 'fail') {
114
106
  return 'false';
115
107
  }
116
108
  if (numOfTickets > 1 || isAgeRequired) {
@@ -123,8 +115,24 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
123
115
  //#region Refs
124
116
  const storedToken = useRef('');
125
117
  const storedProfileData = useRef({});
118
+ const phoneErrorCounter = useRef(0);
119
+ const billingCoreRef = useRef(null);
126
120
  //#endregion
127
121
  //#region Handlers
122
+ const handleSetPhoneError = useCallback((error) => {
123
+ if (isPhoneRequired && phone.length > 0) {
124
+ setPhoneError(error);
125
+ }
126
+ }, [isPhoneRequired, phone.length]);
127
+ const handleOnChangePhoneNumber = (payload) => {
128
+ var _a, _b;
129
+ setPhone(payload.input);
130
+ if (!payload.isValid && phoneErrorCounter.current > 0) {
131
+ return handleSetPhoneError(((_b = (_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.phoneInput) === null || _b === void 0 ? void 0 : _b.customError) || 'Invalid phone number');
132
+ }
133
+ phoneErrorCounter.current = phoneErrorCounter.current + 1;
134
+ setPhoneError('');
135
+ };
128
136
  const handleOnLoadingChange = useCallback((loading) => {
129
137
  if (onLoadingChange) {
130
138
  onLoadingChange(loading);
@@ -178,28 +186,44 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
178
186
  storedToken.current = accessToken;
179
187
  }
180
188
  };
181
- const handleOnLoginSuccess = async (userProfile, accessToken) => {
182
- if (onLoginSuccess) {
183
- onLoginSuccess({
184
- accessToken: accessToken,
185
- userData: userProfile,
186
- });
189
+ const handleOnLoginSuccess = async (userProfile) => {
190
+ var _a, _b;
191
+ let phoneCountry = 'US';
192
+ const accessToken = await getData(LocalStorageKeys.ACCESS_TOKEN);
193
+ const usrProfile = { ...userProfile };
194
+ onLoginSuccess === null || onLoginSuccess === void 0 ? void 0 : onLoginSuccess(usrProfile);
195
+ try {
196
+ const deviceCountry = await DeviceCountry.getCountryCode(TYPE_ANY);
197
+ phoneCountry = deviceCountry.code.toUpperCase();
198
+ }
199
+ catch (err) {
200
+ phoneCountry = 'US';
201
+ }
202
+ if (!usrProfile.phone.includes('+')) {
203
+ usrProfile.phone = `${getCountryDialCode(phoneCountry)}${usrProfile.phone}`;
187
204
  }
188
205
  if (!isBillingRequired && skipping === 'fail') {
189
206
  setSkippingStatus('skipping');
207
+ const phoneValidError = validatePhoneNumber({
208
+ phoneNumber: userProfile.phone,
209
+ customError: (_b = (_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.phoneInput) === null || _b === void 0 ? void 0 : _b.customError,
210
+ });
211
+ if (phoneValidError) {
212
+ showAlert((texts === null || texts === void 0 ? void 0 : texts.invalidPhoneNumberError) || 'Please enter a valid phone number');
213
+ return handleSetPhoneError((texts === null || texts === void 0 ? void 0 : texts.invalidPhoneNumberError) || 'Please enter a valid phone number');
214
+ }
190
215
  await performCheckout(getCheckoutBodyWhenSkipping({
191
- userProfile: userProfile,
216
+ userProfile: usrProfile,
192
217
  ticketsQuantity: numberOfTicketHolders || 1,
193
- }), accessToken);
218
+ }));
194
219
  }
195
- handleSetFormDataFromUserProfile(userProfile, accessToken);
220
+ handleSetFormDataFromUserProfile(usrProfile, accessToken);
196
221
  };
197
- const handleOnLoginFail = (error) => {
198
- if (onLoginError) {
199
- onLoginError(error);
200
- }
222
+ const handleOnLoginError = (error) => {
223
+ onLoginError === null || onLoginError === void 0 ? void 0 : onLoginError(error);
201
224
  };
202
225
  const handleOnLogoutSuccess = () => {
226
+ var _a, _b;
203
227
  setFirstName('');
204
228
  setLastName('');
205
229
  setEmail('');
@@ -212,8 +236,16 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
212
236
  setPasswordConfirmation('');
213
237
  setCountryId('');
214
238
  setStateId('');
215
- setSelectedCountry(defaultCountry);
216
- setStates([defaultState]);
239
+ setSelectedCountry({
240
+ value: '-1',
241
+ label: ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.country) || 'Country',
242
+ });
243
+ setStates([
244
+ {
245
+ value: '-1',
246
+ label: ((_b = texts === null || texts === void 0 ? void 0 : texts.form) === null || _b === void 0 ? void 0 : _b.state) || 'State/County',
247
+ },
248
+ ]);
217
249
  setIsSubToTicketFairy(false);
218
250
  setIsSubToBrand(false);
219
251
  storedToken.current = '';
@@ -226,6 +258,7 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
226
258
  th.phone = '';
227
259
  });
228
260
  setTicketHoldersData(thData);
261
+ onLogoutSuccess === null || onLogoutSuccess === void 0 ? void 0 : onLogoutSuccess();
229
262
  };
230
263
  const handleOnSelectDate = (newDate) => {
231
264
  const ageError = validateAge(newDate, minimumAge);
@@ -234,7 +267,15 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
234
267
  };
235
268
  //#endregion
236
269
  //#region Form validation
270
+ const checkIsStoredPhoneNumberFormat = (storedPhoneNumber) => {
271
+ if (!storedPhoneNumber.includes('+')) {
272
+ handleSetPhoneError((texts === null || texts === void 0 ? void 0 : texts.invalidPhoneNumberError) || 'Please enter a valid phone number');
273
+ return false;
274
+ }
275
+ return true;
276
+ };
237
277
  const checkBasicDataValid = () => {
278
+ var _a, _b;
238
279
  if (!firstName ||
239
280
  !lastName ||
240
281
  !email ||
@@ -245,7 +286,11 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
245
286
  (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.value) === '-1') {
246
287
  return false;
247
288
  }
248
- if (isPhoneRequired && !phone) {
289
+ if (isPhoneRequired &&
290
+ validatePhoneNumber({
291
+ phoneNumber: phone,
292
+ customError: (_b = (_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.phoneInput) === null || _b === void 0 ? void 0 : _b.customError,
293
+ })) {
249
294
  return false;
250
295
  }
251
296
  if (Config.IS_BILLING_STREET_NAME_REQUIRED && !street) {
@@ -253,7 +298,7 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
253
298
  }
254
299
  return true;
255
300
  };
256
- const fillAllRequiredFieldsAlert = ((_e = texts === null || texts === void 0 ? void 0 : texts.form) === null || _e === void 0 ? void 0 : _e.fillAllRequiredFieldsAlert) ||
301
+ const fillAllRequiredFieldsAlert = ((_b = texts === null || texts === void 0 ? void 0 : texts.form) === null || _b === void 0 ? void 0 : _b.fillAllRequiredFieldsAlert) ||
257
302
  'You must fill all Ticket Holder required fields';
258
303
  const checkExtraDataValid = () => {
259
304
  if (isAgeRequired) {
@@ -273,38 +318,27 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
273
318
  //#endregion
274
319
  //#region Submit form
275
320
  const handleOnRegisterFail = (rawError) => {
276
- if (onRegisterError) {
277
- onRegisterError(rawError);
278
- }
321
+ onRegisterError === null || onRegisterError === void 0 ? void 0 : onRegisterError(rawError);
279
322
  };
280
- const performCheckout = async (checkoutBody, pToken) => {
281
- try {
282
- setIsSubmittingData(true);
283
- const { error: checkoutError, data: checkoutData } = await checkoutOrder(checkoutBody, pToken);
284
- setIsSubmittingData(false);
285
- if (checkoutError) {
286
- onCheckoutError === null || onCheckoutError === void 0 ? void 0 : onCheckoutError(checkoutError);
287
- setSkippingStatus('false');
288
- return showAlert(checkoutError.message);
289
- }
290
- const checkoutResponseData = {
291
- id: checkoutData.data.data.attributes.id,
292
- hash: checkoutData.data.data.attributes.hash,
293
- total: checkoutData.data.data.attributes.total,
294
- status: checkoutData.data.data.attributes.status,
295
- };
296
- setSkippingStatus('success');
297
- onCheckoutSuccess(checkoutResponseData);
323
+ const performCheckout = async (checkoutBody) => {
324
+ if (!billingCoreRef.current) {
325
+ return onCheckoutError === null || onCheckoutError === void 0 ? void 0 : onCheckoutError({ message: 'BillingCore is not ready' });
298
326
  }
299
- catch (err) {
300
- setIsSubmittingData(false);
327
+ setIsSubmittingData(true);
328
+ const { error: checkoutError, data: checkoutData } = await billingCoreRef.current.checkoutOrder(checkoutBody);
329
+ setIsSubmittingData(false);
330
+ if (checkoutError) {
331
+ onCheckoutError === null || onCheckoutError === void 0 ? void 0 : onCheckoutError(checkoutError);
301
332
  setSkippingStatus('false');
302
- if (onCheckoutError) {
303
- onCheckoutError({
304
- message: 'Error while performing checkout',
305
- });
306
- }
333
+ return showAlert(checkoutError.message);
307
334
  }
335
+ if (!checkoutData) {
336
+ onCheckoutError === null || onCheckoutError === void 0 ? void 0 : onCheckoutError({ message: 'Checkout returned not data' });
337
+ setSkippingStatus('false');
338
+ return showAlert('Checkout returned not data');
339
+ }
340
+ setSkippingStatus('success');
341
+ onCheckoutSuccess(checkoutData);
308
342
  };
309
343
  const getRegisterFormData = (checkoutBody) => {
310
344
  const bodyFormData = new FormData();
@@ -317,9 +351,13 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
317
351
  return bodyFormData;
318
352
  };
319
353
  const performNewUserRegister = async (checkoutBody) => {
320
- const registerForm = getRegisterFormData(checkoutBody);
354
+ if (!billingCoreRef.current) {
355
+ showAlert('BillingCore is not ready');
356
+ return onRegisterError === null || onRegisterError === void 0 ? void 0 : onRegisterError({ message: 'BillingCore is not initialized' });
357
+ }
321
358
  setIsSubmittingData(true);
322
- const { data: registerResponseData, error: registerResponseError } = await registerNewUser(registerForm);
359
+ const registerForm = getRegisterFormData(checkoutBody);
360
+ const { data: registerResponseData, error: registerResponseError } = await billingCoreRef.current.registerNewUser(registerForm);
323
361
  if (registerResponseError) {
324
362
  setIsSubmittingData(false);
325
363
  if (registerResponseError.isAlreadyRegistered) {
@@ -335,15 +373,15 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
335
373
  handleOnRegisterFail('Register returned no data');
336
374
  return showAlert('Register returned no data');
337
375
  }
376
+ const accessToken = await getData(LocalStorageKeys.ACCESS_TOKEN);
377
+ const refreshToken = await getData(LocalStorageKeys.REFRESH_TOKEN);
338
378
  const tokens = {
339
- accessToken: registerResponseData.access_token,
340
- refreshToken: registerResponseData.refresh_token,
379
+ accessToken: accessToken,
380
+ refreshToken: refreshToken,
341
381
  };
342
382
  storedToken.current = tokens.accessToken;
343
- if (onRegisterSuccess) {
344
- onRegisterSuccess(tokens);
345
- }
346
- await performCheckout(checkoutBody, tokens.accessToken);
383
+ onRegisterSuccess === null || onRegisterSuccess === void 0 ? void 0 : onRegisterSuccess();
384
+ await performCheckout(checkoutBody);
347
385
  };
348
386
  const getCheckoutBody = () => {
349
387
  let parsedTicketHolders = [];
@@ -430,7 +468,7 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
430
468
  }
431
469
  const checkoutBody = getCheckoutBody();
432
470
  if (loggedUserFirstName && storedToken.current) {
433
- await performCheckout(checkoutBody, storedToken.current);
471
+ await performCheckout(checkoutBody);
434
472
  }
435
473
  else {
436
474
  await performNewUserRegister(checkoutBody);
@@ -438,57 +476,76 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
438
476
  };
439
477
  //#endregion
440
478
  const fetchData = async () => {
479
+ var _a, _b;
480
+ if (!billingCoreRef.current) {
481
+ onFetchCartError === null || onFetchCartError === void 0 ? void 0 : onFetchCartError({ message: 'BillingCoreRef not initialized' });
482
+ return showAlert('BillingCoreRef not initialized');
483
+ }
441
484
  setIsLoading(true);
485
+ let phoneCountry = 'US';
486
+ let phoneCountryDialCode = '+1';
442
487
  let usrPrfl;
488
+ try {
489
+ const deviceCountry = await DeviceCountry.getCountryCode(TYPE_ANY);
490
+ phoneCountry = deviceCountry.code.toUpperCase();
491
+ phoneCountryDialCode = getCountryDialCode(phoneCountry);
492
+ }
493
+ catch (err) {
494
+ phoneCountry = 'US';
495
+ }
443
496
  const usrTkn = await getData(LocalStorageKeys.ACCESS_TOKEN);
444
- const { data: countriesData, error: countriesError } = await fetchCountries();
497
+ let skippingStatus;
498
+ const { countriesData, countriesError } = await billingCoreRef.current.getCountries();
445
499
  if (countriesError) {
500
+ setSkippingStatus('fail');
446
501
  setIsLoading(false);
447
- if (onFetchCountriesError) {
448
- onFetchCountriesError(countriesError);
449
- }
502
+ onFetchCountriesError === null || onFetchCountriesError === void 0 ? void 0 : onFetchCountriesError(countriesError);
450
503
  return showAlert(countriesError.message || 'Error fetching countries');
451
504
  }
452
- if (onFetchCountriesSuccess) {
453
- onFetchCountriesSuccess();
454
- }
505
+ onFetchCountriesSuccess === null || onFetchCountriesSuccess === void 0 ? void 0 : onFetchCountriesSuccess();
455
506
  const parsedCountries = _map(countriesData, (item, index) => {
456
507
  return { label: item, value: index };
457
508
  });
458
509
  if (usrTkn) {
459
510
  storedToken.current = usrTkn;
460
- const { error: userProfileError, userProfile: userProfileResponse } = await fetchUserProfile(usrTkn);
461
- if (userProfileError || !userProfileResponse) {
511
+ const { userProfileError, userProfileData } = await billingCoreRef.current.getUserProfile();
512
+ if (userProfileError || !userProfileData) {
513
+ setSkippingStatus('fail');
462
514
  setIsLoading(false);
463
- if (onFetchUserProfileError) {
464
- onFetchUserProfileError(userProfileError);
465
- }
515
+ onFetchUserProfileError === null || onFetchUserProfileError === void 0 ? void 0 : onFetchUserProfileError(userProfileError);
466
516
  return showAlert((userProfileError === null || userProfileError === void 0 ? void 0 : userProfileError.message) || 'Error fetching user profile');
467
517
  }
468
- if (onFetchUserProfileSuccess) {
469
- onFetchUserProfileSuccess({
470
- firstName: userProfileResponse.firstName,
471
- lastName: userProfileResponse.lastName,
472
- });
473
- }
474
- usrPrfl = userProfileResponse;
518
+ onFetchUserProfileSuccess === null || onFetchUserProfileSuccess === void 0 ? void 0 : onFetchUserProfileSuccess({
519
+ firstName: userProfileData.firstName,
520
+ lastName: userProfileData.lastName,
521
+ });
522
+ usrPrfl = userProfileData;
475
523
  }
476
524
  else {
477
- parsedCountries.unshift(defaultCountry);
478
- setSelectedCountry(defaultCountry);
525
+ skippingStatus = 'fail';
526
+ parsedCountries.unshift({
527
+ value: '-1',
528
+ label: ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.country) || 'Country',
529
+ });
530
+ setSelectedCountry({
531
+ value: '-1',
532
+ label: ((_b = texts === null || texts === void 0 ? void 0 : texts.form) === null || _b === void 0 ? void 0 : _b.country) || 'Country',
533
+ });
479
534
  }
480
- const { cartData, cartError } = await fetchCart();
481
- if (cartError) {
535
+ const { cartData, cartError } = await billingCoreRef.current.getCart();
536
+ if (cartError || !cartData) {
537
+ setSkippingStatus('fail');
482
538
  setIsLoading(false);
483
- if (onFetchCartError) {
484
- onFetchCartError(cartError);
485
- }
486
- return showAlert(cartError.message);
539
+ onFetchCartError === null || onFetchCartError === void 0 ? void 0 : onFetchCartError(cartError || { message: 'Error fetching cart' });
540
+ return showAlert((cartError === null || cartError === void 0 ? void 0 : cartError.message) || 'Error fetching cart');
487
541
  }
488
- if (onFetchCartSuccess) {
489
- onFetchCartSuccess();
542
+ onFetchCartSuccess === null || onFetchCartSuccess === void 0 ? void 0 : onFetchCartSuccess();
543
+ if (skippingStatus === 'fail') {
544
+ setSkippingStatus('fail');
545
+ }
546
+ else {
547
+ setSkippingStatus(getSkippingStatus(cartData.quantity));
490
548
  }
491
- setSkippingStatus(getSkippingStatus(cartData.quantity));
492
549
  setNumberOfTicketHolders(cartData.quantity);
493
550
  setIsSubToBrand(cartData.isMarketingOptedIn);
494
551
  setIsSubToTicketFairy(cartData.isTfOptIn);
@@ -502,20 +559,36 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
502
559
  phone: i === 0 && usrPrfl ? usrPrfl.phone : '',
503
560
  });
504
561
  }
505
- if (!isBillingRequired && usrTkn && usrPrfl && cartData) {
506
- const checkoutBody = getCheckoutBodyWhenSkipping({
507
- userProfile: usrPrfl,
508
- ticketsQuantity: cartData.quantity,
509
- });
510
- await performCheckout(checkoutBody, usrTkn);
511
- }
512
- else {
513
- if (skipping === 'skipping') {
562
+ if (usrPrfl) {
563
+ if (!checkIsStoredPhoneNumberFormat(usrPrfl.phone)) {
564
+ showAlert((texts === null || texts === void 0 ? void 0 : texts.invalidPhoneNumberError) || 'Please enter a valid phone number');
565
+ skippingStatus = 'fail';
514
566
  setSkippingStatus('fail');
567
+ setIsLoading(false);
515
568
  }
569
+ else {
570
+ // We can perfom Checkout process since phone is valid
571
+ if (!isBillingRequired && usrTkn && cartData) {
572
+ const checkoutBody = getCheckoutBodyWhenSkipping({
573
+ userProfile: usrPrfl,
574
+ ticketsQuantity: cartData.quantity,
575
+ });
576
+ return await performCheckout(checkoutBody);
577
+ }
578
+ else {
579
+ if (skipping === 'skipping') {
580
+ setSkippingStatus('fail');
581
+ }
582
+ }
583
+ }
584
+ handleSetFormDataFromUserProfile({
585
+ ...usrPrfl,
586
+ phone: `${phoneCountryDialCode}${usrPrfl.phone}`,
587
+ });
516
588
  }
517
- if (usrPrfl) {
518
- handleSetFormDataFromUserProfile(usrPrfl);
589
+ else {
590
+ // There is no user profile data
591
+ setPhone(phoneCountryDialCode);
519
592
  }
520
593
  setCountries(parsedCountries);
521
594
  setTicketHoldersData(tHolders);
@@ -536,19 +609,22 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
536
609
  }, [countries, countryId]);
537
610
  useEffect(() => {
538
611
  const getStates = async () => {
539
- const { data: statesData, error: statesError } = await fetchStates(selectedCountry.value);
612
+ if (!selectedCountry) {
613
+ return;
614
+ }
615
+ if (!billingCoreRef.current) {
616
+ onFetchCartError === null || onFetchCartError === void 0 ? void 0 : onFetchCartError({ message: 'BillingCoreRef not initialized' });
617
+ return showAlert('BillingCoreRef not initialized');
618
+ }
619
+ const { statesData, statesError } = await billingCoreRef.current.getStates(selectedCountry.value.toString());
540
620
  if (statesError) {
541
- if (onFetchStatesError) {
542
- onFetchStatesError(statesError);
543
- }
621
+ onFetchStatesError === null || onFetchStatesError === void 0 ? void 0 : onFetchStatesError(statesError);
544
622
  return showAlert((statesError === null || statesError === void 0 ? void 0 : statesError.message) || 'Error fetching states');
545
623
  }
546
624
  const parsedStates = _map(statesData, (item, index) => {
547
625
  return { label: item, value: index };
548
626
  });
549
- if (onFetchStatesSuccess) {
550
- onFetchStatesSuccess();
551
- }
627
+ onFetchStatesSuccess === null || onFetchStatesSuccess === void 0 ? void 0 : onFetchStatesSuccess();
552
628
  setStates(parsedStates);
553
629
  };
554
630
  if (selectedCountry && selectedCountry.value !== '-1') {
@@ -557,15 +633,22 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
557
633
  // eslint-disable-next-line react-hooks/exhaustive-deps
558
634
  }, [selectedCountry]);
559
635
  useEffect(() => {
636
+ var _a, _b;
560
637
  if (states.length > 1 && stateId) {
561
638
  const selectedStateItem = _find(states, (item) => item.value === stateId);
562
639
  if (!selectedStateItem) {
563
- return setSelectedState(defaultState);
640
+ return setSelectedState({
641
+ value: '-1',
642
+ label: ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.state) || 'State/County',
643
+ });
564
644
  }
565
645
  setSelectedState(selectedStateItem);
566
646
  }
567
647
  else {
568
- setSelectedState(defaultState);
648
+ setSelectedState({
649
+ value: '-1',
650
+ label: ((_b = texts === null || texts === void 0 ? void 0 : texts.form) === null || _b === void 0 ? void 0 : _b.state) || 'State/County',
651
+ });
569
652
  }
570
653
  // eslint-disable-next-line react-hooks/exhaustive-deps
571
654
  }, [stateId, states]);
@@ -582,6 +665,19 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
582
665
  }, [ticketHoldersData]);
583
666
  initTicketHoldersErrors();
584
667
  useEffect(() => {
668
+ var _a, _b;
669
+ setCountries([
670
+ {
671
+ value: '-1',
672
+ label: ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.country) || 'Country',
673
+ },
674
+ ]);
675
+ setStates([
676
+ {
677
+ value: '-1',
678
+ label: ((_b = texts === null || texts === void 0 ? void 0 : texts.form) === null || _b === void 0 ? void 0 : _b.state) || 'State/County',
679
+ },
680
+ ]);
585
681
  fetchData();
586
682
  // eslint-disable-next-line react-hooks/exhaustive-deps
587
683
  }, []);
@@ -633,51 +729,59 @@ const Billing = ({ styles, texts, cartProps: { isAgeRequired, isNameRequired, is
633
729
  !!(skipBillingConfig === null || skipBillingConfig === void 0 ? void 0 : skipBillingConfig.isActivityIndicatorVisible) && (React.createElement(ActivityIndicator, { color: ((_a = skippingStyles === null || skippingStyles === void 0 ? void 0 : skippingStyles.activityIndicator) === null || _a === void 0 ? void 0 : _a.color) || R.colors.black, size: ((_b = skippingStyles === null || skippingStyles === void 0 ? void 0 : skippingStyles.activityIndicator) === null || _b === void 0 ? void 0 : _b.size) || 'large' })))));
634
730
  };
635
731
  const isDataValid = checkBasicDataValid();
636
- return skipping === 'skipping' && areLoadingIndicatorsEnabled ? (renderCheckingOut()) : (React.createElement(KeyboardAwareScrollView, { extraScrollHeight: 32 },
637
- React.createElement(View, { style: styles === null || styles === void 0 ? void 0 : styles.rootContainer },
638
- React.createElement(Login, { onLoginSuccessful: handleOnLoginSuccess, onLogoutSuccess: handleOnLogoutSuccess, isLoginDialogVisible: isLoginDialogVisible, showLoginDialog: showLoginDialog, hideLoginDialog: hideLoginDialog, userFirstName: loggedUserFirstName, onLoginError: handleOnLoginFail, texts: texts === null || texts === void 0 ? void 0 : texts.loginTexts, styles: styles === null || styles === void 0 ? void 0 : styles.loginStyles, brandImages: loginBrandImages, onFetchAccessTokenError: onFetchAccessTokenError, onFetchAccessTokenSuccess: onFetchAccessTokenSuccess, onFetchUserProfileError: onFetchUserProfileError, onFetchUserProfileSuccess: onFetchUserProfileSuccess }),
639
- React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.screenTitle }, ((_f = texts === null || texts === void 0 ? void 0 : texts.form) === null || _f === void 0 ? void 0 : _f.getYourTicketsTitle) || 'Get Your Tickets'),
640
- React.createElement(Input, { label: ((_g = texts === null || texts === void 0 ? void 0 : texts.form) === null || _g === void 0 ? void 0 : _g.firstName) || 'First name', value: firstName, onChangeText: setFirstName, error: firstNameError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
641
- React.createElement(Input, { label: ((_h = texts === null || texts === void 0 ? void 0 : texts.form) === null || _h === void 0 ? void 0 : _h.lastName) || 'Last name', value: lastName, onChangeText: setLastName, error: lastNameError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
642
- React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.texts }, ((_j = texts === null || texts === void 0 ? void 0 : texts.form) === null || _j === void 0 ? void 0 : _j.emailsAdvice) ||
643
- `IMPORTANT: Please double check that your email address is correct.\nIt's where we send your confirmation and e-tickets to!`),
644
- React.createElement(Input, { label: ((_k = texts === null || texts === void 0 ? void 0 : texts.form) === null || _k === void 0 ? void 0 : _k.email) || 'Email', value: email, onChangeText: setEmail, keyboardType: 'email-address', error: emailError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles, autoCapitalize: 'none' }),
645
- React.createElement(Input, { label: ((_l = texts === null || texts === void 0 ? void 0 : texts.form) === null || _l === void 0 ? void 0 : _l.confirmEmail) || 'Confirm email', value: emailConfirmation, onChangeText: setEmailConfirmation, keyboardType: 'email-address', error: confirmEmailError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles, autoCapitalize: 'none' }),
646
- isAgeRequired && (React.createElement(DatePicker, { text: ((_m = texts === null || texts === void 0 ? void 0 : texts.form) === null || _m === void 0 ? void 0 : _m.dateOfBirth) || 'Date of Birth', onSelectDate: handleOnSelectDate, selectedDate: dateOfBirth, styles: styles === null || styles === void 0 ? void 0 : styles.datePicker, error: dateOfBirthError })),
647
- !loggedUserFirstName && (React.createElement(React.Fragment, null,
648
- React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.passwordTitle }, ((_o = texts === null || texts === void 0 ? void 0 : texts.form) === null || _o === void 0 ? void 0 : _o.choosePassword) ||
649
- 'Choose a password for your new TICKETFAIRY account'),
650
- React.createElement(Input, { label: ((_p = texts === null || texts === void 0 ? void 0 : texts.form) === null || _p === void 0 ? void 0 : _p.password) || 'Password', isSecure: true, onChangeText: setPassword, error: passwordError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles, autoCapitalize: 'none', secureTextEntry: true }),
651
- React.createElement(Input, { label: ((_q = texts === null || texts === void 0 ? void 0 : texts.form) === null || _q === void 0 ? void 0 : _q.confirmPassword) || 'Confirm password', isSecure: true, onChangeText: setPasswordConfirmation, error: confirmPasswordError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles, autoCapitalize: 'none', secureTextEntry: true }))),
652
- React.createElement(Input, { label: phoneLabel, value: phone, onChangeText: setPhone, keyboardType: 'phone-pad', error: phoneError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
653
- React.createElement(Input, { label: addressLabel, value: street, onChangeText: setStreet, error: streetError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
654
- React.createElement(Input, { label: ((_r = texts === null || texts === void 0 ? void 0 : texts.form) === null || _r === void 0 ? void 0 : _r.city) || 'City', value: city, onChangeText: setCity, error: cityError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
655
- React.createElement(Dropdown, { items: countries, onSelectItem: setSelectedCountry, selectedOption: selectedCountry, styles: styles === null || styles === void 0 ? void 0 : styles.dropdownStyles }),
656
- React.createElement(Input, { label: ((_s = texts === null || texts === void 0 ? void 0 : texts.form) === null || _s === void 0 ? void 0 : _s.zipCode) || 'Postal Code / Zip Code', value: postalCode, onChangeText: setPostalCode, error: postalCodeError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
657
- React.createElement(Dropdown, { items: states, onSelectItem: setSelectedState, selectedOption: selectedState, styles: styles === null || styles === void 0 ? void 0 : styles.dropdownStyles }),
658
- React.createElement(Checkbox, { onPress: handleIsSubToBrandToggle, text: brandCheckBoxText, isActive: isSubToBrand, styles: styles === null || styles === void 0 ? void 0 : styles.checkboxStyles }),
659
- !isTtfCheckboxHidden && (React.createElement(Checkbox, { onPress: handleIsSubToTicketFairyToggle, isActive: isSubToTicketFairy, customTextComp: React.createElement(Text, { style: (_t = styles === null || styles === void 0 ? void 0 : styles.customCheckbox) === null || _t === void 0 ? void 0 : _t.text },
660
- ((_u = texts === null || texts === void 0 ? void 0 : texts.form) === null || _u === void 0 ? void 0 : _u.isSubToTicketFairy) ||
661
- `I agree that The Ticket Fairy may use the personal data that have provided for marketing purposes, such as recommending events that I might be interested in, in accordance with its `,
662
- React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.privacyPolicyLinkStyle, onPress: handleOpenPrivacyLink }, ((_v = texts === null || texts === void 0 ? void 0 : texts.form) === null || _v === void 0 ? void 0 : _v.privacyPolicy) || 'Privacy Policy'),
663
- "."), styles: styles === null || styles === void 0 ? void 0 : styles.checkboxStyles })),
664
- ticketHoldersData.length > 0 && (React.createElement(React.Fragment, null,
665
- React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.ticketHoldersTitle }, ((_w = texts === null || texts === void 0 ? void 0 : texts.form) === null || _w === void 0 ? void 0 : _w.ticketHoldersTitle) || 'Ticket Holders'),
666
- renderTicketHolders())),
667
- React.createElement(Button, { onPress: onSubmit, text: (texts === null || texts === void 0 ? void 0 : texts.checkoutButton) || 'CHECKOUT', isDisabled: !isDataValid, isLoading: isSubmittingData, styles: !isDataValid
668
- ? {
669
- button: s.submitButtonDisabled,
670
- ...styles === null || styles === void 0 ? void 0 : styles.checkoutButtonDisabled,
671
- }
672
- : {
673
- container: [
674
- s.submitButton,
675
- (_x = styles === null || styles === void 0 ? void 0 : styles.checkoutButton) === null || _x === void 0 ? void 0 : _x.container,
676
- ],
677
- text: (_y = styles === null || styles === void 0 ? void 0 : styles.checkoutButton) === null || _y === void 0 ? void 0 : _y.text,
678
- button: (_z = styles === null || styles === void 0 ? void 0 : styles.checkoutButton) === null || _z === void 0 ? void 0 : _z.button,
679
- } })),
680
- areLoadingIndicatorsEnabled && isLoading && React.createElement(Loading, null)));
732
+ return skipping === 'skipping' && areLoadingIndicatorsEnabled ? (renderCheckingOut()) : (React.createElement(BillingCore, { ref: billingCoreRef },
733
+ React.createElement(KeyboardAwareScrollView, { extraScrollHeight: 32 },
734
+ React.createElement(View, { style: styles === null || styles === void 0 ? void 0 : styles.rootContainer },
735
+ React.createElement(Login, { onLoginSuccessful: handleOnLoginSuccess, onLoginError: handleOnLoginError, onLogoutSuccess: handleOnLogoutSuccess, onLogoutError: onLogoutError, isLoginDialogVisible: isLoginDialogVisible, showLoginDialog: showLoginDialog, hideLoginDialog: hideLoginDialog, userFirstName: loggedUserFirstName, texts: { ...texts === null || texts === void 0 ? void 0 : texts.loginTexts, message: loginMessage }, styles: styles === null || styles === void 0 ? void 0 : styles.loginStyles, brandImages: loginBrandImages }),
736
+ React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.screenTitle }, ((_c = texts === null || texts === void 0 ? void 0 : texts.form) === null || _c === void 0 ? void 0 : _c.getYourTicketsTitle) || 'Get Your Tickets'),
737
+ React.createElement(Input, { label: ((_d = texts === null || texts === void 0 ? void 0 : texts.form) === null || _d === void 0 ? void 0 : _d.firstName) || 'First name', value: firstName, onChangeText: setFirstName, error: firstNameError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
738
+ React.createElement(Input, { label: ((_e = texts === null || texts === void 0 ? void 0 : texts.form) === null || _e === void 0 ? void 0 : _e.lastName) || 'Last name', value: lastName, onChangeText: setLastName, error: lastNameError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
739
+ React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.texts }, ((_f = texts === null || texts === void 0 ? void 0 : texts.form) === null || _f === void 0 ? void 0 : _f.emailsAdvice) ||
740
+ `IMPORTANT: Please double check that your email address is correct.\nIt's where we send your confirmation and e-tickets to!`),
741
+ React.createElement(Input, { label: ((_g = texts === null || texts === void 0 ? void 0 : texts.form) === null || _g === void 0 ? void 0 : _g.email) || 'Email', value: email, onChangeText: setEmail, keyboardType: 'email-address', error: emailError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles, autoCapitalize: 'none' }),
742
+ React.createElement(Input, { label: ((_h = texts === null || texts === void 0 ? void 0 : texts.form) === null || _h === void 0 ? void 0 : _h.confirmEmail) || 'Confirm email', value: emailConfirmation, onChangeText: setEmailConfirmation, keyboardType: 'email-address', error: confirmEmailError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles, autoCapitalize: 'none' }),
743
+ isAgeRequired && (React.createElement(DatePicker, { text: ((_j = texts === null || texts === void 0 ? void 0 : texts.form) === null || _j === void 0 ? void 0 : _j.dateOfBirth) || 'Date of Birth', onSelectDate: handleOnSelectDate, selectedDate: dateOfBirth, styles: styles === null || styles === void 0 ? void 0 : styles.datePicker, error: dateOfBirthError })),
744
+ !loggedUserFirstName && (React.createElement(React.Fragment, null,
745
+ React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.passwordTitle }, ((_k = texts === null || texts === void 0 ? void 0 : texts.form) === null || _k === void 0 ? void 0 : _k.choosePassword) ||
746
+ 'Choose a password for your new TICKETFAIRY account'),
747
+ React.createElement(Input, { label: ((_l = texts === null || texts === void 0 ? void 0 : texts.form) === null || _l === void 0 ? void 0 : _l.password) || 'Password', isSecure: true, onChangeText: setPassword, error: passwordError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles, autoCapitalize: 'none', secureTextEntry: true, textContentType: 'oneTimeCode' }),
748
+ React.createElement(Input, { label: ((_m = texts === null || texts === void 0 ? void 0 : texts.form) === null || _m === void 0 ? void 0 : _m.confirmPassword) || 'Confirm password', isSecure: true, onChangeText: setPasswordConfirmation, error: confirmPasswordError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles, autoCapitalize: 'none', secureTextEntry: true, textContentType: 'oneTimeCode' }))),
749
+ React.createElement(PhoneInput, { phoneNumber: phone, onChangePhoneNumber: handleOnChangePhoneNumber, styles: styles === null || styles === void 0 ? void 0 : styles.phoneInput, error: phoneError, texts: {
750
+ label: phoneLabel,
751
+ ...(_o = texts === null || texts === void 0 ? void 0 : texts.form) === null || _o === void 0 ? void 0 : _o.phoneInput,
752
+ } }),
753
+ React.createElement(Input, { label: addressLabel, value: street, onChangeText: setStreet, error: streetError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
754
+ React.createElement(Input, { label: ((_p = texts === null || texts === void 0 ? void 0 : texts.form) === null || _p === void 0 ? void 0 : _p.city) || 'City', value: city, onChangeText: setCity, error: cityError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
755
+ React.createElement(DropdownMaterial, { items: countries, onSelectItem: setSelectedCountry, selectedOption: selectedCountry, styles: styles === null || styles === void 0 ? void 0 : styles.dropdownMaterialStyles, materialInputProps: {
756
+ label: ((_q = texts === null || texts === void 0 ? void 0 : texts.form) === null || _q === void 0 ? void 0 : _q.country) || 'Country',
757
+ } }),
758
+ React.createElement(Input, { label: ((_r = texts === null || texts === void 0 ? void 0 : texts.form) === null || _r === void 0 ? void 0 : _r.zipCode) || 'Postal Code / Zip Code', value: postalCode, onChangeText: setPostalCode, error: postalCodeError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
759
+ React.createElement(DropdownMaterial, { items: states, onSelectItem: setSelectedState, selectedOption: selectedState, styles: styles === null || styles === void 0 ? void 0 : styles.dropdownMaterialStyles, materialInputProps: {
760
+ label: ((_s = texts === null || texts === void 0 ? void 0 : texts.form) === null || _s === void 0 ? void 0 : _s.state) || 'State',
761
+ } }),
762
+ React.createElement(Checkbox, { onPress: handleIsSubToBrandToggle, text: brandCheckBoxText, isActive: isSubToBrand, styles: styles === null || styles === void 0 ? void 0 : styles.checkboxStyles }),
763
+ !isTtfCheckboxHidden && (React.createElement(Checkbox, { onPress: handleIsSubToTicketFairyToggle, isActive: isSubToTicketFairy, customTextComp: React.createElement(Text, { style: (_t = styles === null || styles === void 0 ? void 0 : styles.customCheckbox) === null || _t === void 0 ? void 0 : _t.text },
764
+ ((_u = texts === null || texts === void 0 ? void 0 : texts.form) === null || _u === void 0 ? void 0 : _u.isSubToTicketFairy) ||
765
+ `I agree that The Ticket Fairy may use the personal data that have provided for marketing purposes, such as recommending events that I might be interested in, in accordance with its `,
766
+ React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.privacyPolicyLinkStyle, onPress: handleOpenPrivacyLink }, ((_v = texts === null || texts === void 0 ? void 0 : texts.form) === null || _v === void 0 ? void 0 : _v.privacyPolicy) || 'Privacy Policy'),
767
+ "."), styles: styles === null || styles === void 0 ? void 0 : styles.checkboxStyles })),
768
+ ticketHoldersData.length > 0 && (React.createElement(React.Fragment, null,
769
+ React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.ticketHoldersTitle }, ((_w = texts === null || texts === void 0 ? void 0 : texts.form) === null || _w === void 0 ? void 0 : _w.ticketHoldersTitle) || 'Ticket Holders'),
770
+ renderTicketHolders())),
771
+ React.createElement(Button, { onPress: onSubmit, text: (texts === null || texts === void 0 ? void 0 : texts.checkoutButton) || 'CHECKOUT', isDisabled: !isDataValid, isLoading: isSubmittingData, styles: !isDataValid
772
+ ? {
773
+ button: s.submitButtonDisabled,
774
+ ...styles === null || styles === void 0 ? void 0 : styles.checkoutButtonDisabled,
775
+ }
776
+ : {
777
+ container: [
778
+ s.submitButton,
779
+ (_x = styles === null || styles === void 0 ? void 0 : styles.checkoutButton) === null || _x === void 0 ? void 0 : _x.container,
780
+ ],
781
+ text: (_y = styles === null || styles === void 0 ? void 0 : styles.checkoutButton) === null || _y === void 0 ? void 0 : _y.text,
782
+ button: (_z = styles === null || styles === void 0 ? void 0 : styles.checkoutButton) === null || _z === void 0 ? void 0 : _z.button,
783
+ } })),
784
+ areLoadingIndicatorsEnabled && isLoading && React.createElement(Loading, null))));
681
785
  //#endregion
682
786
  };
683
787
  export default Billing;