tf-checkout-react-native 1.0.29 → 1.0.31

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 (60) hide show
  1. package/README.md +19 -1
  2. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  3. package/android/.gradle/7.4/dependencies-accessors/dependencies-accessors.lock +0 -0
  4. package/android/.gradle/7.4/executionHistory/executionHistory.lock +0 -0
  5. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  7. package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
  8. package/lib/api/ApiClient.js +31 -7
  9. package/lib/api/ApiClient.js.map +1 -1
  10. package/lib/api/types.d.ts +3 -0
  11. package/lib/api/types.js.map +1 -1
  12. package/lib/components/checkbox/Checkbox.js +13 -5
  13. package/lib/components/checkbox/Checkbox.js.map +1 -1
  14. package/lib/components/checkbox/types.d.ts +2 -1
  15. package/lib/components/datePicker/DatePicker.js +6 -2
  16. package/lib/components/datePicker/DatePicker.js.map +1 -1
  17. package/lib/components/datePicker/types.d.ts +1 -1
  18. package/lib/components/input/Input.js +1 -1
  19. package/lib/components/input/Input.js.map +1 -1
  20. package/lib/components/login/components/LoginForm.js +7 -7
  21. package/lib/components/login/components/LoginForm.js.map +1 -1
  22. package/lib/components/phoneInput/PhoneInput.js +7 -5
  23. package/lib/components/phoneInput/PhoneInput.js.map +1 -1
  24. package/lib/components/phoneInput/types.d.ts +1 -2
  25. package/lib/containers/billingInfo/Billing.js +515 -132
  26. package/lib/containers/billingInfo/Billing.js.map +1 -1
  27. package/lib/containers/billingInfo/types.d.ts +25 -1
  28. package/lib/containers/myOrderDetails/MyOrderDetailsView.js +1 -1
  29. package/lib/containers/myOrderDetails/MyOrderDetailsView.js.map +1 -1
  30. package/lib/core/LoginCore/LoginCore.js +1 -0
  31. package/lib/core/LoginCore/LoginCore.js.map +1 -1
  32. package/lib/helpers/Validators.d.ts +5 -3
  33. package/lib/helpers/Validators.js +28 -2
  34. package/lib/helpers/Validators.js.map +1 -1
  35. package/lib/types/IUserProfile.d.ts +1 -0
  36. package/package.json +3 -3
  37. package/android/.gradle/7.4/checksums/md5-checksums.bin +0 -0
  38. package/android/.gradle/7.4/checksums/sha1-checksums.bin +0 -0
  39. package/android/.gradle/7.4/executionHistory/executionHistory.bin +0 -0
  40. package/android/.gradle/7.4/fileHashes/fileHashes.bin +0 -0
  41. package/android/.gradle/7.4/fileHashes/resourceHashesCache.bin +0 -0
  42. package/android/.gradle/7.5.1/checksums/checksums.lock +0 -0
  43. package/android/.gradle/7.5.1/checksums/md5-checksums.bin +0 -0
  44. package/android/.gradle/7.5.1/checksums/sha1-checksums.bin +0 -0
  45. package/android/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  46. package/android/.gradle/7.5.1/dependencies-accessors/gc.properties +0 -0
  47. package/android/.gradle/7.5.1/executionHistory/executionHistory.lock +0 -0
  48. package/android/.gradle/7.5.1/fileChanges/last-build.bin +0 -0
  49. package/android/.gradle/7.5.1/fileHashes/fileHashes.bin +0 -0
  50. package/android/.gradle/7.5.1/fileHashes/fileHashes.lock +0 -0
  51. package/android/.gradle/7.5.1/gc.properties +0 -0
  52. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  53. package/android/.gradle/file-system.probe +0 -0
  54. package/android/.idea/compiler.xml +0 -6
  55. package/android/.idea/gradle.xml +0 -18
  56. package/android/.idea/jarRepositories.xml +0 -25
  57. package/android/.idea/misc.xml +0 -10
  58. package/android/.idea/vcs.xml +0 -6
  59. package/android/local.properties +0 -8
  60. package/ios/TFCheckoutRNModule.xcodeproj/project.xcworkspace/xcuserdata/jorgtz.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-unreachable */
2
1
  import _every from 'lodash/every';
3
2
  import _find from 'lodash/find';
4
3
  import _forEach from 'lodash/forEach';
@@ -15,7 +14,7 @@ import { getCountryDialCode } from '../../helpers/CountryCodes';
15
14
  import { useDebounced } from '../../helpers/Debounced';
16
15
  import { getData, LocalStorageKeys } from '../../helpers/LocalStorage';
17
16
  import { emptyPhone } from '../../helpers/StringsHelper';
18
- import { validateAge, validateEmail, validateEmpty, validatePasswords, validatePhoneNumber, } from '../../helpers/Validators';
17
+ import { validateAge, validateDropDownEmpty, validateEmail, validateEmpty, validatePasswords, validatePhoneNumber, } from '../../helpers/Validators';
19
18
  import R from '../../res';
20
19
  import s from './styles';
21
20
  /*
@@ -26,11 +25,48 @@ import s from './styles';
26
25
  - Post Code/Zip
27
26
  - Country
28
27
  */
29
- const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameRequired, isPhoneRequired, minimumAge, isBillingRequired, isTicketFree, isPhoneHidden, }, loginBrandImages, skipBillingConfig, areAlertsEnabled = true, areLoadingIndicatorsEnabled = true, onLoadingChange, onLoginError, onLoginSuccess, onRegisterError, onRegisterSuccess, onCheckoutSuccess, onCheckoutError, onFetchUserProfileSuccess, onFetchUserProfileError, onFetchCartError, onFetchCartSuccess, onFetchCountriesError, onFetchCountriesSuccess, onFetchStatesError, onFetchStatesSuccess, onSkippingStatusChange, onLogoutSuccess, onLogoutError, onCartExpired, shouldCartTimerNotMinimizeOnTap, }, ref) => {
28
+ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameRequired, isPhoneRequired, minimumAge, isBillingRequired, isTicketFree, isPhoneHidden, }, loginBrandImages, skipBillingConfig, areAlertsEnabled = true, areLoadingIndicatorsEnabled = true, onLoadingChange, onLoginError, onLoginSuccess, onRegisterError, onRegisterSuccess, onCheckoutSuccess, onCheckoutError, onFetchUserProfileSuccess, onFetchUserProfileError, onFetchCartError, onFetchCartSuccess, onFetchCountriesError, onFetchCountriesSuccess, onFetchStatesError, onFetchStatesSuccess, onSkippingStatusChange, onLogoutSuccess, onLogoutError, onCartExpired, shouldCartTimerNotMinimizeOnTap, config = {
29
+ isCheckoutAlwaysButtonEnabled: false,
30
+ shouldHideTicketHolderSectionOnSingleTicket: false,
31
+ }, }, ref) => {
30
32
  var _a, _b;
33
+ //#region State
34
+ const [isLoading, setIsLoading] = useState(false);
35
+ const [isSubmittingData, setIsSubmittingData] = useState(false);
36
+ const [loggedUserFirstName, setLoggedUserFirstName] = useState('');
37
+ const [loginMessage, setLoginMessage] = useState('');
38
+ const [firstName, setFirstName] = useState('');
39
+ const [lastName, setLastName] = useState('');
40
+ const [email, setEmail] = useState('');
41
+ const [emailConfirmation, setEmailConfirmation] = useState('');
42
+ const [password, setPassword] = useState('');
43
+ const [passwordConfirmation, setPasswordConfirmation] = useState('');
44
+ const [isSubToTicketFairy, setIsSubToTicketFairy] = useState(false);
45
+ const [isSubToBrand, setIsSubToBrand] = useState(false);
46
+ const [phone, setPhone] = useState('');
47
+ const [street, setStreet] = useState('');
48
+ const [city, setCity] = useState('');
49
+ const [countryId, setCountryId] = useState('');
50
+ const [stateId, setStateId] = useState('');
51
+ const [postalCode, setPostalCode] = useState('');
52
+ const [dateOfBirth, setDateOfBirth] = useState(undefined);
53
+ const [selectedCountry, setSelectedCountry] = useState(undefined);
54
+ const [selectedState, setSelectedState] = useState(undefined);
55
+ const [ticketHoldersData, setTicketHoldersData] = useState([]);
56
+ const [numberOfTicketHolders, setNumberOfTicketHolders] = useState(0);
57
+ const [states, setStates] = useState([]);
58
+ const [countries, setCountries] = useState([]);
59
+ const [isLoginDialogVisible, setIsLoginDialogVisible] = useState(false);
60
+ const [skippingStatus, setSkippingStatus] = useState(undefined);
61
+ const [isTtfCheckboxHidden, setIsTtfCheckboxHidden] = useState(false);
62
+ //#endregion State
31
63
  //#region Labels
32
64
  const holderLabels = useMemo(() => {
33
65
  var _a, _b, _c, _d, _e, _f, _g;
66
+ if (numberOfTicketHolders === 1 &&
67
+ config.shouldHideTicketHolderSectionOnSingleTicket) {
68
+ return null;
69
+ }
34
70
  const optional = isNameRequired
35
71
  ? ''
36
72
  : ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.optional) || '(optional)';
@@ -48,7 +84,8 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
48
84
  ? `${texts.form.holderPhone} ${((_g = texts === null || texts === void 0 ? void 0 : texts.form) === null || _g === void 0 ? void 0 : _g.optional) || '(optional)'}`
49
85
  : `Phone ${optional}`,
50
86
  };
51
- }, [isNameRequired, texts]);
87
+ // eslint-disable-next-line react-hooks/exhaustive-deps
88
+ }, [isNameRequired, texts, numberOfTicketHolders]);
52
89
  const brandCheckBoxText = ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.isSubToBrand) ||
53
90
  'I would like to be updated on news, events and offers.';
54
91
  const phoneLabel = useMemo(() => {
@@ -69,39 +106,10 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
69
106
  ? `${texts.form.street} ${optionalAddress}`
70
107
  : `Street ${optionalAddress}`;
71
108
  }, [texts]);
72
- //#endregion
73
- //#region State
74
- const [isLoading, setIsLoading] = useState(false);
75
- const [isSubmittingData, setIsSubmittingData] = useState(false);
76
- const [loggedUserFirstName, setLoggedUserFirstName] = useState('');
77
- const [loginMessage, setLoginMessage] = useState('');
78
- const [firstName, setFirstName] = useState('');
79
- const [lastName, setLastName] = useState('');
80
- const [email, setEmail] = useState('');
81
- const [emailConfirmation, setEmailConfirmation] = useState('');
82
- const [password, setPassword] = useState('');
83
- const [passwordConfirmation, setPasswordConfirmation] = useState('');
84
- const [isSubToTicketFairy, setIsSubToTicketFairy] = useState(false);
85
- const [isSubToBrand, setIsSubToBrand] = useState(false);
86
- const [phone, setPhone] = useState('');
87
- const [street, setStreet] = useState('');
88
- const [city, setCity] = useState('');
89
- const [countryId, setCountryId] = useState('');
90
- const [stateId, setStateId] = useState('');
91
- const [postalCode, setPostalCode] = useState('');
92
- const [dateOfBirth, setDateOfBirth] = useState(new Date());
93
- const [selectedCountry, setSelectedCountry] = useState(undefined);
94
- const [selectedState, setSelectedState] = useState(undefined);
95
- const [ticketHoldersData, setTicketHoldersData] = useState([]);
96
- const [numberOfTicketHolders, setNumberOfTicketHolders] = useState();
97
- const [states, setStates] = useState([]);
98
- const [countries, setCountries] = useState([]);
99
- const [isLoginDialogVisible, setIsLoginDialogVisible] = useState(false);
100
- const [skippingStatus, setSkippingStatus] = useState(undefined);
101
- const [isTtfCheckboxHidden, setIsTtfCheckboxHidden] = useState(false);
109
+ //#endregion Labels
102
110
  // Cart expiration timer
103
111
  const [secondsLeft, setSecondsLeft] = React.useState(420);
104
- // Errors state
112
+ //#region Errors state
105
113
  const firstNameError = useDebounced(firstName, validateEmpty);
106
114
  const lastNameError = useDebounced(lastName, validateEmpty);
107
115
  const emailError = useDebounced(email, () => validateEmail(email, emailConfirmation));
@@ -112,15 +120,31 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
112
120
  const streetError = useDebounced(street, validateEmpty);
113
121
  const cityError = useDebounced(city, validateEmpty);
114
122
  const postalCodeError = useDebounced(postalCode, validateEmpty);
115
- const [dateOfBirthError, setDateOfBirthError] = useState('');
116
123
  const [ttfPrivacyPolicyError, setTtfPrivacyPolicyError] = useState('');
117
- // End of errors state
124
+ const [firstNameErrorState, setFirstNameErrorState] = useState('');
125
+ const [lastNameErrorState, setLastNameErrorState] = useState('');
126
+ const [streetErrorState, setStreetErrorState] = useState('');
127
+ const [dateOfBirthError, setDateOfBirthError] = useState('');
128
+ const [emailErrorState, setEmailErrorState] = useState('');
129
+ const [emailConfirmationErrorState, setEmailConfirmationErrorState] = useState('');
130
+ const [cityErrorState, setCityErrorState] = useState('');
131
+ const [postalCodeErrorState, setPostalCodeErrorState] = useState('');
132
+ const [countryErrorState, setCountryErrorState] = useState('');
133
+ const [stateErrorState, setStateErrorState] = useState('');
134
+ const [passwordErrorState, setPasswordErrorState] = useState('');
135
+ const [confirmPasswordErrorState, setConfirmPasswordErrorState] = useState('');
136
+ //#endregion Errors state
118
137
  //#endregion
119
138
  const getSkippingStatus = (numOfTickets) => {
139
+ // DO NOT SKIP IF
140
+ // * User is not logged in.
141
+ // * Event Collect_names is turned on and tickets are more than one.
142
+ // * Event validate_age is turned on.
143
+ // * phone_required is turned on and customer does not have a phone number.
120
144
  if (isBillingRequired || skippingStatus === 'fail') {
121
145
  return 'false';
122
146
  }
123
- if (numOfTickets > 1 || isAgeRequired) {
147
+ if ((isNameRequired && numOfTickets > 1) || isAgeRequired) {
124
148
  return 'false';
125
149
  }
126
150
  else {
@@ -133,6 +157,23 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
133
157
  const phoneErrorCounter = useRef(0);
134
158
  const billingCoreRef = useRef(null);
135
159
  const sessionHandleRef = useRef(null);
160
+ const phoneCountryCode = useRef('');
161
+ const errorsRef = useRef({
162
+ firstName: '',
163
+ lastName: '',
164
+ email: '',
165
+ confirmEmail: '',
166
+ password: '',
167
+ confirmPassword: '',
168
+ dateOfBirth: '',
169
+ phone: '',
170
+ street: '',
171
+ city: '',
172
+ country: '',
173
+ zipCode: '',
174
+ state: '',
175
+ privacy: '',
176
+ });
136
177
  //#endregion
137
178
  //#region Imperative Handler
138
179
  useImperativeHandle(ref, () => ({
@@ -165,13 +206,19 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
165
206
  }
166
207
  }, [isPhoneRequired, phone.length]);
167
208
  const handleOnChangePhoneNumber = (payload) => {
168
- var _a, _b;
209
+ var _a, _b, _c, _d;
169
210
  setPhone(payload.input);
211
+ if (payload.isValid) {
212
+ errorsRef.current.phone = '';
213
+ setPhoneError('');
214
+ return;
215
+ }
170
216
  if (!payload.isValid && phoneErrorCounter.current > 0) {
171
- 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');
217
+ errorsRef.current.phone =
218
+ ((_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';
219
+ return handleSetPhoneError(((_d = (_c = texts === null || texts === void 0 ? void 0 : texts.form) === null || _c === void 0 ? void 0 : _c.phoneInput) === null || _d === void 0 ? void 0 : _d.customError) || 'Invalid phone number');
172
220
  }
173
221
  phoneErrorCounter.current = phoneErrorCounter.current + 1;
174
- setPhoneError('');
175
222
  };
176
223
  const handleOnLoadingChange = useCallback((loading) => {
177
224
  if (onLoadingChange) {
@@ -192,7 +239,16 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
192
239
  setIsSubToBrand(!isSubToBrand);
193
240
  };
194
241
  const handleIsSubToTicketFairyToggle = () => {
195
- setIsSubToTicketFairy(!isSubToTicketFairy);
242
+ const newValue = !isSubToTicketFairy;
243
+ if (newValue) {
244
+ errorsRef.current.privacy = '';
245
+ setTtfPrivacyPolicyError('');
246
+ }
247
+ else {
248
+ errorsRef.current.privacy = 'Required';
249
+ setTtfPrivacyPolicyError('Required');
250
+ }
251
+ setIsSubToTicketFairy(newValue);
196
252
  };
197
253
  const handleOpenPrivacyLink = async () => {
198
254
  const canOpenLink = await Linking.canOpenURL(Constants.PRIVACY_POLICY_LINK);
@@ -213,6 +269,12 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
213
269
  setCountryId(userProfile.countryId);
214
270
  setStateId(userProfile.stateId);
215
271
  setLoggedUserFirstName(userProfile.firstName);
272
+ let dob;
273
+ if (userProfile.dateOfBirth) {
274
+ const dobSplitted = userProfile.dateOfBirth.split('-');
275
+ dob = new Date(parseInt(dobSplitted[0], 10), parseInt(dobSplitted[1], 10) - 1, parseInt(dobSplitted[2], 10));
276
+ handleOnSelectDate(dob);
277
+ }
216
278
  const thData = [...ticketHoldersData];
217
279
  thData.forEach((th, index) => {
218
280
  th.firstName = index === 0 ? userProfile.firstName : '';
@@ -224,10 +286,66 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
224
286
  if (accessToken) {
225
287
  storedToken.current = accessToken;
226
288
  }
289
+ showErrorMessages({
290
+ firstName: userProfile.firstName,
291
+ lastName: userProfile.lastName,
292
+ email: userProfile.email,
293
+ confirmEmail: userProfile.email,
294
+ street: userProfile.streetAddress,
295
+ city: userProfile.city,
296
+ selectedCountry: userProfile.countryId
297
+ ? {
298
+ label: '',
299
+ value: userProfile.countryId,
300
+ }
301
+ : undefined,
302
+ selectedState: userProfile.stateId
303
+ ? {
304
+ label: '',
305
+ value: userProfile.stateId,
306
+ }
307
+ : undefined,
308
+ postalCode: userProfile.zipCode,
309
+ dateOfBirth: dob,
310
+ phoneNumber: userProfile.phone,
311
+ isRegistering: !loggedUserFirstName && !storedToken.current,
312
+ ticketHolderData: ticketHoldersData,
313
+ });
314
+ };
315
+ const clearFormErrors = () => {
316
+ setFirstNameErrorState('');
317
+ setLastNameErrorState('');
318
+ setEmailErrorState('');
319
+ setEmailConfirmationErrorState('');
320
+ setDateOfBirthError('');
321
+ setPhoneError('');
322
+ setStreetErrorState('');
323
+ setCityErrorState('');
324
+ setCountryErrorState('');
325
+ setPostalCodeErrorState('');
326
+ setStateErrorState('');
327
+ setTtfPrivacyPolicyError('');
328
+ errorsRef.current = {
329
+ firstName: '',
330
+ lastName: '',
331
+ email: '',
332
+ confirmEmail: '',
333
+ password: '',
334
+ confirmPassword: '',
335
+ dateOfBirth: '',
336
+ phone: '',
337
+ street: '',
338
+ city: '',
339
+ country: '',
340
+ zipCode: '',
341
+ state: '',
342
+ privacy: '',
343
+ };
227
344
  };
228
345
  const handleOnLoginSuccess = async ({ userProfile, accessTokenData, }) => {
229
346
  var _a, _b, _c;
230
- let phoneCountry = 'US';
347
+ clearFormErrors();
348
+ let countryCode = 'US';
231
349
  const accessToken = await getData(LocalStorageKeys.ACCESS_TOKEN);
232
350
  const usrProfile = { ...userProfile };
233
351
  onLoginSuccess === null || onLoginSuccess === void 0 ? void 0 : onLoginSuccess({
@@ -236,13 +354,18 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
236
354
  });
237
355
  try {
238
356
  const deviceCountry = await DeviceCountry.getCountryCode(TYPE_ANY);
239
- phoneCountry = deviceCountry.code.toUpperCase();
357
+ countryCode = deviceCountry.code.toUpperCase();
240
358
  }
241
359
  catch (err) {
242
- phoneCountry = 'US';
360
+ countryCode = 'US';
243
361
  }
244
- if (!((_a = usrProfile.phone) === null || _a === void 0 ? void 0 : _a.includes('+'))) {
245
- usrProfile.phone = `${getCountryDialCode(phoneCountry)}${usrProfile.phone}`;
362
+ if (!userProfile.phone) {
363
+ usrProfile.phone = '';
364
+ }
365
+ else {
366
+ if (!((_a = usrProfile.phone) === null || _a === void 0 ? void 0 : _a.includes('+'))) {
367
+ usrProfile.phone = `${getCountryDialCode(countryCode)}${usrProfile.phone}`;
368
+ }
246
369
  }
247
370
  if (!isBillingRequired && skippingStatus === 'fail') {
248
371
  setSkippingStatus('skipping');
@@ -250,11 +373,9 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
250
373
  phoneNumber: userProfile.phone,
251
374
  customError: (_c = (_b = texts === null || texts === void 0 ? void 0 : texts.form) === null || _b === void 0 ? void 0 : _b.phoneInput) === null || _c === void 0 ? void 0 : _c.customError,
252
375
  });
253
- if (phoneValidError) {
376
+ if (phoneValidError && isPhoneRequired) {
254
377
  setIsLoading(false);
255
- showAlert((texts === null || texts === void 0 ? void 0 : texts.invalidPhoneNumberError) ||
256
- 'Please enter a valid phone number');
257
- return handleSetPhoneError((texts === null || texts === void 0 ? void 0 : texts.invalidPhoneNumberError) ||
378
+ handleSetPhoneError((texts === null || texts === void 0 ? void 0 : texts.invalidPhoneNumberError) ||
258
379
  'Please enter a valid phone number');
259
380
  }
260
381
  await performCheckout(getCheckoutBodyWhenSkipping({
@@ -281,7 +402,7 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
281
402
  setPasswordConfirmation('');
282
403
  setCountryId('');
283
404
  setStateId('');
284
- const eventCountry = await getData(LocalStorageKeys.EVENT_COUNTRY);
405
+ handleOnSelectDate(undefined);
285
406
  setSelectedCountry({
286
407
  value: '-1',
287
408
  label: ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.country) || 'Country',
@@ -303,57 +424,266 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
303
424
  th.lastName = '';
304
425
  th.email = '';
305
426
  th.phone = '';
427
+ th.firstNameError = '';
428
+ th.lastNameError = '';
306
429
  });
307
430
  setTicketHoldersData(thData);
308
431
  onLogoutSuccess === null || onLogoutSuccess === void 0 ? void 0 : onLogoutSuccess();
309
432
  };
433
+ //#region Handlers input changed
310
434
  const handleOnSelectDate = (newDate) => {
311
- const ageError = validateAge(newDate, minimumAge);
312
435
  setDateOfBirth(newDate);
313
- setDateOfBirthError(ageError);
436
+ if (dateOfBirthError.length > 0 && newDate) {
437
+ setDateOfBirthError('');
438
+ }
439
+ if (minimumAge) {
440
+ const ageError = validateAge(newDate, minimumAge);
441
+ setDateOfBirthError(ageError);
442
+ }
443
+ else {
444
+ if (!newDate) {
445
+ setDateOfBirthError('Required');
446
+ }
447
+ }
448
+ };
449
+ const handleOnStreetChanged = (text) => {
450
+ if (streetErrorState.length > 0 && text.length > 0) {
451
+ setStreetErrorState('');
452
+ }
453
+ setStreet(text);
454
+ };
455
+ const handleOnCityChanged = (text) => {
456
+ if (cityErrorState.length > 0 && text.length > 0) {
457
+ setCityErrorState('');
458
+ }
459
+ setCity(text);
460
+ };
461
+ const handleOnFirstNameChanged = (text) => {
462
+ if (firstNameErrorState.length > 0 && text.length > 0) {
463
+ setFirstNameErrorState('');
464
+ }
465
+ setFirstName(text);
466
+ };
467
+ const handleOnLastNameChanged = (text) => {
468
+ if (lastNameErrorState.length > 0 && text.length > 0) {
469
+ setLastNameErrorState('');
470
+ }
471
+ setLastName(text);
472
+ };
473
+ const handleOnEmailChanged = (text) => {
474
+ if (emailErrorState.length > 0 && text.length > 0) {
475
+ setEmailErrorState('');
476
+ }
477
+ setEmail(text);
314
478
  };
479
+ const handleOnEmailConfirmationChanged = (text) => {
480
+ if (emailConfirmationErrorState.length > 0 && text.length > 0) {
481
+ setEmailConfirmationErrorState('');
482
+ }
483
+ setEmailConfirmation(text);
484
+ };
485
+ const handleOnPostalCodeChanged = (text) => {
486
+ if (postalCodeErrorState.length > 0 && text.length > 0) {
487
+ setPostalCodeErrorState('');
488
+ }
489
+ setPostalCode(text);
490
+ };
491
+ const handleOnStateChanged = (itm) => {
492
+ if (stateErrorState.length > 0 && itm.value !== '-1') {
493
+ setStateErrorState('');
494
+ }
495
+ else if (itm.value === '-1') {
496
+ setStateErrorState('Required');
497
+ }
498
+ setSelectedState(itm);
499
+ };
500
+ const handleOnCountryChanged = (itm) => {
501
+ if (countryErrorState.length > 0 && itm.value !== '-1') {
502
+ setCountryErrorState('');
503
+ }
504
+ else if (itm.value === '-1') {
505
+ setCountryErrorState('Required');
506
+ }
507
+ setSelectedCountry(itm);
508
+ };
509
+ const handleOnPasswordChanged = (text) => {
510
+ if (passwordErrorState.length > 0 && text.length > 0) {
511
+ setPasswordErrorState('');
512
+ }
513
+ setPassword(text);
514
+ };
515
+ const handleOnConfirmPasswordChanged = (text) => {
516
+ if (confirmPasswordErrorState.length > 0 && text.length > 0) {
517
+ setConfirmPasswordErrorState('');
518
+ }
519
+ setPasswordConfirmation(text);
520
+ };
521
+ //#endregion Handlers input changed
315
522
  //#endregion
316
523
  //#region Form validation
317
524
  const checkIsStoredPhoneNumberFormat = (storedPhoneNumber) => {
525
+ if (!storedPhoneNumber) {
526
+ handleSetPhoneError((texts === null || texts === void 0 ? void 0 : texts.invalidPhoneNumberError) || 'Please enter a valid phone number');
527
+ return false;
528
+ }
318
529
  if (!storedPhoneNumber.includes('+')) {
319
530
  handleSetPhoneError((texts === null || texts === void 0 ? void 0 : texts.invalidPhoneNumberError) || 'Please enter a valid phone number');
320
531
  return false;
321
532
  }
322
533
  return true;
323
534
  };
535
+ const showErrorMessages = (data) => {
536
+ var _a, _b, _c, _d, _e, _f;
537
+ if (secondsLeft === 0) {
538
+ return false;
539
+ }
540
+ const validateFirstName = validateEmpty(data.firstName);
541
+ const validateLastName = validateEmpty(data.lastName);
542
+ const validateEmails = validateEmail(data.email, data.confirmEmail);
543
+ const validateEmailsConfirmation = validateEmail(data.confirmEmail, data.email);
544
+ if (isTicketFree) {
545
+ setFirstNameErrorState(validateFirstName);
546
+ setLastNameErrorState(validateLastName);
547
+ errorsRef.current.firstName = validateFirstName;
548
+ errorsRef.current.lastName = validateLastName;
549
+ setEmailErrorState(validateEmails);
550
+ setEmailConfirmationErrorState(validateEmailsConfirmation);
551
+ errorsRef.current.email = validateEmails;
552
+ errorsRef.current.confirmEmail = validateEmailsConfirmation;
553
+ if (data.isRegistering) {
554
+ const validatePassword = validatePasswords(data.password, data.confirmPassword);
555
+ const validatePasswordConfirmation = validatePasswords(data.confirmPassword, data.password);
556
+ setPasswordErrorState(validatePassword);
557
+ setConfirmPasswordErrorState(validatePasswordConfirmation);
558
+ errorsRef.current.password = validatePassword;
559
+ errorsRef.current.confirmPassword = validatePasswordConfirmation;
560
+ }
561
+ if (isAgeRequired) {
562
+ if (minimumAge) {
563
+ const birthdayValidation = validateAge(data.dateOfBirth, minimumAge);
564
+ setDateOfBirthError(birthdayValidation);
565
+ errorsRef.current.dateOfBirth = birthdayValidation;
566
+ }
567
+ else {
568
+ setDateOfBirthError(data.dateOfBirth ? '' : 'Required');
569
+ errorsRef.current.dateOfBirth = data.dateOfBirth ? '' : 'Required';
570
+ }
571
+ }
572
+ if (isPhoneRequired && !isPhoneHidden) {
573
+ const validatePhone = validatePhoneNumber({
574
+ phoneNumber: data.phoneNumber,
575
+ 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,
576
+ countryCode: phoneCountryCode.current,
577
+ });
578
+ setPhoneError(validatePhone);
579
+ errorsRef.current.phone = validatePhone;
580
+ }
581
+ errorsRef.current.privacy = isSubToTicketFairy ? '' : 'Required';
582
+ if (isNameRequired) {
583
+ const ticketHoldersDataCopy = [...data.ticketHolderData];
584
+ _map(data.ticketHolderData, (th, index) => {
585
+ if (isNameRequired) {
586
+ ticketHoldersDataCopy[index].firstNameError = validateEmpty(th.firstName);
587
+ ticketHoldersDataCopy[index].lastNameError = validateEmpty(th.lastName);
588
+ }
589
+ });
590
+ setTicketHoldersData(ticketHoldersDataCopy);
591
+ }
592
+ return;
593
+ } // end of Ticket Free
594
+ const validateStreet = validateEmpty(data.street);
595
+ const validateCity = validateEmpty(data.city);
596
+ const validatePostalCode = validateEmpty(data.postalCode);
597
+ setStreetErrorState(validateStreet);
598
+ setCityErrorState(validateCity);
599
+ setPostalCodeErrorState(validatePostalCode);
600
+ setFirstNameErrorState(validateFirstName);
601
+ setLastNameErrorState(validateLastName);
602
+ setEmailErrorState(validateEmails);
603
+ setEmailConfirmationErrorState(validateEmailsConfirmation);
604
+ errorsRef.current.street = validateStreet;
605
+ errorsRef.current.city = validateCity;
606
+ errorsRef.current.zipCode = validatePostalCode;
607
+ errorsRef.current.firstName = validateFirstName;
608
+ errorsRef.current.lastName = validateLastName;
609
+ errorsRef.current.email = validateEmails;
610
+ errorsRef.current.confirmEmail = validateEmailsConfirmation;
611
+ if (data.isRegistering) {
612
+ const validatePassword = validatePasswords(data.password, data.confirmPassword);
613
+ const validatePasswordConfirmation = validatePasswords(data.confirmPassword, data.password);
614
+ setPasswordErrorState(validatePassword);
615
+ setConfirmPasswordErrorState(validatePasswordConfirmation);
616
+ errorsRef.current.password = validatePassword;
617
+ errorsRef.current.confirmPassword = validatePasswordConfirmation;
618
+ }
619
+ const countryValidation = validateDropDownEmpty((_c = data.selectedCountry) === null || _c === void 0 ? void 0 : _c.value);
620
+ setCountryErrorState(countryValidation);
621
+ errorsRef.current.country = countryValidation;
622
+ if (isAgeRequired) {
623
+ if (minimumAge) {
624
+ const birthdayValidation = validateAge(data.dateOfBirth, minimumAge);
625
+ setDateOfBirthError(birthdayValidation);
626
+ errorsRef.current.dateOfBirth = birthdayValidation;
627
+ }
628
+ else {
629
+ setDateOfBirthError(data.dateOfBirth ? '' : 'Required');
630
+ errorsRef.current.dateOfBirth = data.dateOfBirth ? '' : 'Required';
631
+ }
632
+ }
633
+ const validateState = validateDropDownEmpty((_d = data.selectedState) === null || _d === void 0 ? void 0 : _d.value);
634
+ setStateErrorState(validateState);
635
+ errorsRef.current.state = validateState;
636
+ if (isPhoneRequired && !isPhoneHidden) {
637
+ const validatePhone = validatePhoneNumber({
638
+ phoneNumber: data.phoneNumber,
639
+ customError: (_f = (_e = texts === null || texts === void 0 ? void 0 : texts.form) === null || _e === void 0 ? void 0 : _e.phoneInput) === null || _f === void 0 ? void 0 : _f.customError,
640
+ countryCode: phoneCountryCode.current,
641
+ });
642
+ setPhoneError(validatePhone);
643
+ errorsRef.current.phone = validatePhone;
644
+ }
645
+ //setTtfPrivacyPolicyError(isSubToTicketFairy ? '' : 'Required')
646
+ errorsRef.current.privacy = isSubToTicketFairy ? '' : 'Required';
647
+ if (isNameRequired) {
648
+ const ticketHoldersDataCopy = [...data.ticketHolderData];
649
+ _map(data.ticketHolderData, (th, index) => {
650
+ if (isNameRequired) {
651
+ ticketHoldersDataCopy[index].firstNameError = validateEmpty(th.firstName);
652
+ ticketHoldersDataCopy[index].lastNameError = validateEmpty(th.lastName);
653
+ }
654
+ });
655
+ setTicketHoldersData(ticketHoldersDataCopy);
656
+ }
657
+ };
324
658
  const checkBasicDataValid = () => {
325
- var _a, _b;
326
659
  if (secondsLeft === 0) {
327
660
  return false;
328
661
  }
329
662
  if (isTicketFree) {
330
- if (!firstName || !lastName || !email || !emailConfirmation) {
663
+ if (errorsRef.current.firstName ||
664
+ errorsRef.current.lastName ||
665
+ errorsRef.current.email ||
666
+ errorsRef.current.confirmEmail) {
331
667
  return false;
332
668
  }
333
669
  }
334
670
  else {
335
- if (!firstName ||
336
- !lastName ||
337
- !email ||
338
- !emailConfirmation ||
339
- !city ||
340
- !postalCode ||
341
- (selectedState === null || selectedState === void 0 ? void 0 : selectedState.value) === '-1' ||
342
- (selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.value) === '-1') {
671
+ if (errorsRef.current.firstName ||
672
+ errorsRef.current.lastName ||
673
+ errorsRef.current.email ||
674
+ errorsRef.current.confirmEmail ||
675
+ errorsRef.current.city ||
676
+ errorsRef.current.zipCode ||
677
+ errorsRef.current.state ||
678
+ errorsRef.current.country ||
679
+ errorsRef.current.street) {
343
680
  return false;
344
681
  }
345
- if (Config.IS_BILLING_STREET_NAME_REQUIRED && !street) {
682
+ }
683
+ if (isPhoneRequired && !isPhoneHidden && errorsRef.current.phone) {
684
+ if (isLoading) {
346
685
  setIsLoading(false);
347
- return false;
348
686
  }
349
- }
350
- if (isPhoneRequired &&
351
- !isPhoneHidden &&
352
- validatePhoneNumber({
353
- phoneNumber: phone,
354
- 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,
355
- })) {
356
- setIsLoading(false);
357
687
  return false;
358
688
  }
359
689
  return true;
@@ -364,18 +694,28 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
364
694
  var _a;
365
695
  if (!isTtfCheckboxHidden && !isSubToTicketFairy) {
366
696
  setTtfPrivacyPolicyError(((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.ttfPrivacyPolicyRequiredError) || 'Required');
367
- return 'Please accept our Privacy Policy';
697
+ return 'Please review the errors';
368
698
  }
369
699
  if (isAgeRequired) {
370
- const ageValidationMessage = validateAge(dateOfBirth, minimumAge);
371
- if (ageValidationMessage) {
372
- setDateOfBirthError(ageValidationMessage);
373
- return ageValidationMessage;
700
+ if (!dateOfBirth) {
701
+ setDateOfBirthError('Required');
702
+ return 'Please enter your date of birth';
703
+ }
704
+ if (minimumAge) {
705
+ const ageValidationMessage = validateAge(dateOfBirth, minimumAge);
706
+ if (ageValidationMessage) {
707
+ setDateOfBirthError(ageValidationMessage);
708
+ return ageValidationMessage;
709
+ }
374
710
  }
375
711
  }
376
712
  if (!isNameRequired) {
377
713
  return '';
378
714
  }
715
+ if (ticketHoldersData.length === 1 &&
716
+ config.shouldHideTicketHolderSectionOnSingleTicket) {
717
+ return '';
718
+ }
379
719
  return _every(_map(ticketHoldersData, (th) => validateEmpty(th.firstName) || validateEmpty(th.lastName)), (itm) => itm === '')
380
720
  ? ''
381
721
  : fillAllRequiredFieldsAlert;
@@ -434,8 +774,8 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
434
774
  }
435
775
  if (!registerNewUserResponseData) {
436
776
  setIsSubmittingData(false);
437
- handleOnRegisterFail('Register returned no data');
438
- return showAlert('Register returned no data');
777
+ handleOnRegisterFail('Register user returned no data');
778
+ return showAlert('Register user returned no data');
439
779
  }
440
780
  storedToken.current =
441
781
  registerNewUserResponseData.accessTokenData.accessToken;
@@ -479,18 +819,34 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
479
819
  if (body.attributes.phone === undefined) {
480
820
  delete body.attributes.phone;
481
821
  }
822
+ if (isAgeRequired && dateOfBirth) {
823
+ body.attributes.dob_day = dateOfBirth.getDate();
824
+ body.attributes.dob_month = dateOfBirth.getMonth() + 1;
825
+ body.attributes.dob_year = dateOfBirth.getFullYear();
826
+ }
482
827
  return body;
483
828
  };
484
829
  const getCheckoutBody = () => {
485
830
  let parsedTicketHolders = [];
486
- for (let i = 0; i <= numberOfTicketHolders - 1; i++) {
487
- const individualHolder = {
488
- first_name: ticketHoldersData[i].firstName || '',
489
- last_name: ticketHoldersData[i].lastName || '',
490
- phone: ticketHoldersData[i].phone || '',
491
- email: ticketHoldersData[i].email || '',
492
- };
493
- parsedTicketHolders.push(individualHolder);
831
+ if (config.shouldHideTicketHolderSectionOnSingleTicket &&
832
+ numberOfTicketHolders) {
833
+ parsedTicketHolders.push({
834
+ first_name: firstName,
835
+ last_name: lastName,
836
+ phone: phone,
837
+ email: email,
838
+ });
839
+ }
840
+ else {
841
+ for (let i = 0; i <= numberOfTicketHolders - 1; i++) {
842
+ const individualHolder = {
843
+ first_name: ticketHoldersData[i].firstName || '',
844
+ last_name: ticketHoldersData[i].lastName || '',
845
+ phone: ticketHoldersData[i].phone || '',
846
+ email: ticketHoldersData[i].email || '',
847
+ };
848
+ parsedTicketHolders.push(individualHolder);
849
+ }
494
850
  }
495
851
  const formattedPhone = isPhoneRequired ? phone : emptyPhone(phone);
496
852
  const checkoutBody = isTicketFree
@@ -525,7 +881,7 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
525
881
  brand_opt_in: isSubToBrand,
526
882
  },
527
883
  };
528
- if (isAgeRequired) {
884
+ if (isAgeRequired && dateOfBirth) {
529
885
  checkoutBody.attributes.dob_day = dateOfBirth.getDate();
530
886
  checkoutBody.attributes.dob_month = dateOfBirth.getMonth() + 1;
531
887
  checkoutBody.attributes.dob_year = dateOfBirth.getFullYear();
@@ -595,9 +951,27 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
595
951
  return checkoutBody;
596
952
  };
597
953
  const onSubmit = async () => {
598
- const isExtraDataValid = checkExtraDataValid();
599
- if (isExtraDataValid) {
600
- return showAlert(isExtraDataValid);
954
+ showErrorMessages({
955
+ firstName: firstName,
956
+ lastName: lastName,
957
+ email: email,
958
+ confirmEmail: emailConfirmation,
959
+ password: password,
960
+ confirmPassword: passwordConfirmation,
961
+ street: street,
962
+ city: city,
963
+ selectedCountry: selectedCountry,
964
+ selectedState: selectedState,
965
+ postalCode: postalCode,
966
+ dateOfBirth: dateOfBirth,
967
+ phoneNumber: phone,
968
+ isRegistering: !loggedUserFirstName && !storedToken.current,
969
+ ticketHolderData: ticketHoldersData,
970
+ });
971
+ const isBasicDataValid = checkBasicDataValid();
972
+ const isExtraDataValidErrors = checkExtraDataValid();
973
+ if (isExtraDataValidErrors || !isBasicDataValid) {
974
+ return;
601
975
  }
602
976
  if (loggedUserFirstName && storedToken.current) {
603
977
  await performCheckout();
@@ -698,6 +1072,8 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
698
1072
  lastName: i === 0 && usrPrfl ? usrPrfl.lastName : '',
699
1073
  email: i === 0 && usrPrfl ? usrPrfl.email : '',
700
1074
  phone: i === 0 && usrPrfl ? usrPrfl.phone : '',
1075
+ firstNameError: '',
1076
+ lastNameError: '',
701
1077
  });
702
1078
  }
703
1079
  let phoneCountry = 'US';
@@ -720,7 +1096,7 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
720
1096
  if (usrPrfl) {
721
1097
  if (!isPhoneHidden && isPhoneRequired) {
722
1098
  if (!checkIsStoredPhoneNumberFormat(usrPrfl.phone)) {
723
- showAlert((texts === null || texts === void 0 ? void 0 : texts.invalidPhoneNumberError) ||
1099
+ setPhoneError((texts === null || texts === void 0 ? void 0 : texts.invalidPhoneNumberError) ||
724
1100
  'Please enter a valid phone number');
725
1101
  skippingStatusInner = 'fail';
726
1102
  setSkippingStatus('fail');
@@ -757,14 +1133,18 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
757
1133
  }
758
1134
  }
759
1135
  }
760
- const userPhone = usrPrfl.phone === null ? '' : usrPrfl.phone;
1136
+ const userPhone = usrPrfl.phone === null ? phoneCountryDialCode : usrPrfl.phone;
1137
+ if (userPhone.length <= 5) {
1138
+ phoneCountryCode.current = userPhone;
1139
+ }
761
1140
  handleSetFormDataFromUserProfile({
762
1141
  ...usrPrfl,
763
- phone: `${phoneCountryDialCode}${userPhone}`,
1142
+ phone: userPhone,
764
1143
  });
765
1144
  }
766
1145
  else {
767
1146
  // There is no user profile data
1147
+ phoneCountryCode.current = phoneCountryDialCode;
768
1148
  setPhone(phoneCountryDialCode);
769
1149
  }
770
1150
  setCountries(parsedCountries);
@@ -789,6 +1169,7 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
789
1169
  else {
790
1170
  setCountryByEvent();
791
1171
  }
1172
+ // eslint-disable-next-line react-hooks/exhaustive-deps
792
1173
  }, [countries, countryId]);
793
1174
  useEffect(() => {
794
1175
  const getStates = async () => {
@@ -835,18 +1216,6 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
835
1216
  }
836
1217
  // eslint-disable-next-line react-hooks/exhaustive-deps
837
1218
  }, [stateId, states]);
838
- const initTicketHoldersErrors = useCallback(() => {
839
- if (ticketHoldersData.length > 1) {
840
- const tHolders = [];
841
- for (let i = 0; i < ticketHoldersData.length; i++) {
842
- tHolders.push({
843
- firstNameError: '',
844
- lastNameError: '',
845
- });
846
- }
847
- }
848
- }, [ticketHoldersData]);
849
- initTicketHoldersErrors();
850
1219
  useEffect(() => {
851
1220
  var _a, _b;
852
1221
  setCountries([
@@ -865,10 +1234,16 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
865
1234
  // eslint-disable-next-line react-hooks/exhaustive-deps
866
1235
  }, []);
867
1236
  //#endregion
1237
+ const isDataValid = checkBasicDataValid();
1238
+ const isButtonDisabled = config.isCheckoutAlwaysButtonEnabled
1239
+ ? false
1240
+ : !isDataValid;
868
1241
  //#region RENDER
869
1242
  const renderTicketHolders = () => {
870
- var _a;
871
- if (!numberOfTicketHolders) {
1243
+ var _a, _b;
1244
+ if (!numberOfTicketHolders ||
1245
+ !holderLabels ||
1246
+ ticketHoldersData.length === 0) {
872
1247
  return null;
873
1248
  }
874
1249
  let tHolders = [];
@@ -882,13 +1257,15 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
882
1257
  React.createElement(Input, { label: holderLabels.firstName, value: ticketHoldersData[i].firstName, onChangeText: (text) => {
883
1258
  const copyTicketHolders = [...ticketHoldersData];
884
1259
  copyTicketHolders[i].firstName = text;
1260
+ copyTicketHolders[i].firstNameError = validateEmpty(text);
885
1261
  setTicketHoldersData(copyTicketHolders);
886
- }, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
1262
+ }, error: ticketHoldersData[i].firstNameError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
887
1263
  React.createElement(Input, { label: holderLabels.lastName, value: ticketHoldersData[i].lastName, onChangeText: (text) => {
888
1264
  const copyTicketHolders = [...ticketHoldersData];
889
1265
  copyTicketHolders[i].lastName = text;
1266
+ copyTicketHolders[i].lastNameError = validateEmpty(text);
890
1267
  setTicketHoldersData(copyTicketHolders);
891
- }, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
1268
+ }, error: ticketHoldersData[i].lastNameError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
892
1269
  React.createElement(Input, { label: holderLabels.email, value: ticketHoldersData[i].email, onChangeText: (text) => {
893
1270
  const copyTicketHolders = [...ticketHoldersData];
894
1271
  copyTicketHolders[i].email = text;
@@ -900,7 +1277,9 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
900
1277
  setTicketHoldersData(copyTicketHolders);
901
1278
  }, keyboardType: 'phone-pad', styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles })));
902
1279
  }
903
- return tHolders;
1280
+ return (React.createElement(React.Fragment, null,
1281
+ React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.ticketHoldersTitle }, ((_b = texts === null || texts === void 0 ? void 0 : texts.form) === null || _b === void 0 ? void 0 : _b.ticketHoldersTitle) || 'Ticket Holders'),
1282
+ tHolders));
904
1283
  };
905
1284
  const renderCheckingOut = () => {
906
1285
  var _a, _b;
@@ -918,42 +1297,47 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
918
1297
  React.createElement(View, { style: styles === null || styles === void 0 ? void 0 : styles.rootContainer },
919
1298
  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 }),
920
1299
  React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.screenTitle }, ((_a = texts === null || texts === void 0 ? void 0 : texts.form) === null || _a === void 0 ? void 0 : _a.getYourTicketsTitle) || 'Get Your Tickets'),
921
- React.createElement(Input, { label: ((_b = texts === null || texts === void 0 ? void 0 : texts.form) === null || _b === void 0 ? void 0 : _b.firstName) || 'First name', value: firstName, onChangeText: setFirstName, error: firstNameError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
922
- React.createElement(Input, { label: ((_c = texts === null || texts === void 0 ? void 0 : texts.form) === null || _c === void 0 ? void 0 : _c.lastName) || 'Last name', value: lastName, onChangeText: setLastName, error: lastNameError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
1300
+ React.createElement(Input, { label: ((_b = texts === null || texts === void 0 ? void 0 : texts.form) === null || _b === void 0 ? void 0 : _b.firstName) || 'First name', value: firstName, onChangeText: handleOnFirstNameChanged, error: firstNameError || firstNameErrorState, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
1301
+ React.createElement(Input, { label: ((_c = texts === null || texts === void 0 ? void 0 : texts.form) === null || _c === void 0 ? void 0 : _c.lastName) || 'Last name', value: lastName, onChangeText: handleOnLastNameChanged, error: lastNameError || lastNameErrorState, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
923
1302
  React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.texts }, ((_d = texts === null || texts === void 0 ? void 0 : texts.form) === null || _d === void 0 ? void 0 : _d.emailsAdvice) ||
924
1303
  `IMPORTANT: Please double check that your email address is correct.\nIt's where we send your confirmation and e-tickets to!`),
925
- React.createElement(Input, { label: ((_e = texts === null || texts === void 0 ? void 0 : texts.form) === null || _e === void 0 ? void 0 : _e.email) || 'Email', value: email, onChangeText: setEmail, keyboardType: 'email-address', error: emailError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles, autoCapitalize: 'none' }),
926
- React.createElement(Input, { label: ((_f = texts === null || texts === void 0 ? void 0 : texts.form) === null || _f === void 0 ? void 0 : _f.confirmEmail) || 'Confirm email', value: emailConfirmation, onChangeText: setEmailConfirmation, keyboardType: 'email-address', error: confirmEmailError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles, autoCapitalize: 'none' }),
1304
+ React.createElement(Input, { label: ((_e = texts === null || texts === void 0 ? void 0 : texts.form) === null || _e === void 0 ? void 0 : _e.email) || 'Email', value: email, onChangeText: handleOnEmailChanged, keyboardType: 'email-address', error: emailError || emailErrorState, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles, autoCapitalize: 'none' }),
1305
+ React.createElement(Input, { label: ((_f = texts === null || texts === void 0 ? void 0 : texts.form) === null || _f === void 0 ? void 0 : _f.confirmEmail) || 'Confirm email', value: emailConfirmation, onChangeText: handleOnEmailConfirmationChanged, keyboardType: 'email-address', error: confirmEmailError || emailConfirmationErrorState, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles, autoCapitalize: 'none' }),
927
1306
  isAgeRequired && (React.createElement(DatePicker, { text: ((_g = texts === null || texts === void 0 ? void 0 : texts.form) === null || _g === void 0 ? void 0 : _g.dateOfBirth) || 'Date of Birth', onSelectDate: handleOnSelectDate, selectedDate: dateOfBirth, styles: styles === null || styles === void 0 ? void 0 : styles.datePicker, error: dateOfBirthError })),
928
1307
  !loggedUserFirstName && (React.createElement(React.Fragment, null,
929
1308
  React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.passwordTitle }, ((_h = texts === null || texts === void 0 ? void 0 : texts.form) === null || _h === void 0 ? void 0 : _h.choosePassword) ||
930
1309
  'Choose a password for your new TICKETFAIRY account'),
931
- React.createElement(Input, { label: ((_j = texts === null || texts === void 0 ? void 0 : texts.form) === null || _j === void 0 ? void 0 : _j.password) || 'Password', isSecure: true, onChangeText: setPassword, error: passwordError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles, autoCapitalize: 'none', secureTextEntry: true, textContentType: 'oneTimeCode' }),
932
- React.createElement(Input, { label: ((_k = texts === null || texts === void 0 ? void 0 : texts.form) === null || _k === void 0 ? void 0 : _k.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' }))),
1310
+ React.createElement(Input, { label: ((_j = texts === null || texts === void 0 ? void 0 : texts.form) === null || _j === void 0 ? void 0 : _j.password) || 'Password', isSecure: true, onChangeText: handleOnPasswordChanged, error: passwordError || passwordErrorState, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles, autoCapitalize: 'none', secureTextEntry: true, textContentType: 'oneTimeCode' }),
1311
+ React.createElement(Input, { label: ((_k = texts === null || texts === void 0 ? void 0 : texts.form) === null || _k === void 0 ? void 0 : _k.confirmPassword) || 'Confirm password', isSecure: true, onChangeText: handleOnConfirmPasswordChanged, error: confirmPasswordError || confirmPasswordErrorState, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles, autoCapitalize: 'none', secureTextEntry: true, textContentType: 'oneTimeCode' }))),
933
1312
  !isPhoneHidden && (React.createElement(PhoneInput, { phoneNumber: phone, onChangePhoneNumber: handleOnChangePhoneNumber, styles: styles === null || styles === void 0 ? void 0 : styles.phoneInput, error: phoneError, texts: {
934
1313
  label: phoneLabel,
935
1314
  ...(_l = texts === null || texts === void 0 ? void 0 : texts.form) === null || _l === void 0 ? void 0 : _l.phoneInput,
936
1315
  } })),
937
1316
  !isTicketFree && (React.createElement(React.Fragment, null,
938
- React.createElement(Input, { label: addressLabel, value: street, onChangeText: setStreet, error: streetError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
939
- React.createElement(Input, { label: ((_m = texts === null || texts === void 0 ? void 0 : texts.form) === null || _m === void 0 ? void 0 : _m.city) || 'City', value: city, onChangeText: setCity, error: cityError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
940
- React.createElement(DropdownMaterial, { items: countries, onSelectItem: setSelectedCountry, selectedOption: selectedCountry, styles: styles === null || styles === void 0 ? void 0 : styles.dropdownMaterialStyles, materialInputProps: {
1317
+ React.createElement(Input, { label: addressLabel, value: street, onChangeText: handleOnStreetChanged, error: streetError || streetErrorState, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
1318
+ React.createElement(Input, { label: ((_m = texts === null || texts === void 0 ? void 0 : texts.form) === null || _m === void 0 ? void 0 : _m.city) || 'City', value: city, onChangeText: handleOnCityChanged, error: cityError || cityErrorState, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
1319
+ React.createElement(DropdownMaterial, { items: countries, onSelectItem: handleOnCountryChanged, selectedOption: selectedCountry, styles: styles === null || styles === void 0 ? void 0 : styles.dropdownMaterialStyles, materialInputProps: {
941
1320
  label: ((_o = texts === null || texts === void 0 ? void 0 : texts.form) === null || _o === void 0 ? void 0 : _o.country) || 'Country',
1321
+ error: countryErrorState,
942
1322
  } }),
943
- React.createElement(Input, { label: ((_p = texts === null || texts === void 0 ? void 0 : texts.form) === null || _p === void 0 ? void 0 : _p.zipCode) || 'Postal Code / Zip Code', value: postalCode, onChangeText: setPostalCode, error: postalCodeError, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
944
- React.createElement(DropdownMaterial, { items: states, onSelectItem: setSelectedState, selectedOption: selectedState, styles: styles === null || styles === void 0 ? void 0 : styles.dropdownMaterialStyles, materialInputProps: {
1323
+ React.createElement(Input, { label: ((_p = texts === null || texts === void 0 ? void 0 : texts.form) === null || _p === void 0 ? void 0 : _p.zipCode) || 'Postal Code / Zip Code', value: postalCode, onChangeText: handleOnPostalCodeChanged, error: postalCodeError || postalCodeErrorState, styles: styles === null || styles === void 0 ? void 0 : styles.inputStyles }),
1324
+ React.createElement(DropdownMaterial, { items: states, onSelectItem: handleOnStateChanged, selectedOption: selectedState, styles: styles === null || styles === void 0 ? void 0 : styles.dropdownMaterialStyles, materialInputProps: {
945
1325
  label: ((_q = texts === null || texts === void 0 ? void 0 : texts.form) === null || _q === void 0 ? void 0 : _q.state) || 'State',
1326
+ error: stateErrorState,
946
1327
  } }))),
947
1328
  React.createElement(Checkbox, { onPress: handleIsSubToBrandToggle, text: brandCheckBoxText, isActive: isSubToBrand, styles: styles === null || styles === void 0 ? void 0 : styles.checkboxStyles }),
948
- !isTtfCheckboxHidden && (React.createElement(Checkbox, { onPress: handleIsSubToTicketFairyToggle, isActive: isSubToTicketFairy, customTextComp: React.createElement(Text, { style: (_r = styles === null || styles === void 0 ? void 0 : styles.customCheckbox) === null || _r === void 0 ? void 0 : _r.text },
949
- ((_s = texts === null || texts === void 0 ? void 0 : texts.form) === null || _s === void 0 ? void 0 : _s.isSubToTicketFairy) ||
1329
+ !isTtfCheckboxHidden && (React.createElement(Checkbox, { onPress: handleIsSubToTicketFairyToggle, isActive: isSubToTicketFairy, customTextComp: React.createElement(Text, { style: [
1330
+ (_r = styles === null || styles === void 0 ? void 0 : styles.customCheckbox) === null || _r === void 0 ? void 0 : _r.text,
1331
+ !!ttfPrivacyPolicyError && {
1332
+ color: (_s = styles === null || styles === void 0 ? void 0 : styles.customCheckbox) === null || _s === void 0 ? void 0 : _s.errorColor,
1333
+ },
1334
+ ] },
1335
+ ((_t = texts === null || texts === void 0 ? void 0 : texts.form) === null || _t === void 0 ? void 0 : _t.isSubToTicketFairy) ||
950
1336
  `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 `,
951
- React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.privacyPolicyLinkStyle, onPress: handleOpenPrivacyLink }, ((_t = texts === null || texts === void 0 ? void 0 : texts.form) === null || _t === void 0 ? void 0 : _t.privacyPolicy) || 'Privacy Policy'),
1337
+ React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.privacyPolicyLinkStyle, onPress: handleOpenPrivacyLink }, ((_u = texts === null || texts === void 0 ? void 0 : texts.form) === null || _u === void 0 ? void 0 : _u.privacyPolicy) || 'Privacy Policy'),
952
1338
  "."), styles: { error: s.ttfPolicyError, ...styles === null || styles === void 0 ? void 0 : styles.checkboxStyles }, error: ttfPrivacyPolicyError })),
953
- ticketHoldersData.length > 0 && (React.createElement(React.Fragment, null,
954
- React.createElement(Text, { style: styles === null || styles === void 0 ? void 0 : styles.ticketHoldersTitle }, ((_u = texts === null || texts === void 0 ? void 0 : texts.form) === null || _u === void 0 ? void 0 : _u.ticketHoldersTitle) || 'Ticket Holders'),
955
- renderTicketHolders())),
956
- React.createElement(Button, { onPress: onSubmit, text: (texts === null || texts === void 0 ? void 0 : texts.checkoutButton) || 'CHECKOUT', isDisabled: !isDataValid, isLoading: isSubmittingData, styles: !isDataValid
1339
+ renderTicketHolders(),
1340
+ React.createElement(Button, { onPress: onSubmit, text: (texts === null || texts === void 0 ? void 0 : texts.checkoutButton) || 'CHECKOUT', isDisabled: isButtonDisabled, isLoading: isSubmittingData, styles: isButtonDisabled
957
1341
  ? {
958
1342
  button: s.submitButtonDisabled,
959
1343
  ...styles === null || styles === void 0 ? void 0 : styles.checkoutButtonDisabled,
@@ -969,7 +1353,6 @@ const Billing = forwardRef(({ styles, texts, cartProps: { isAgeRequired, isNameR
969
1353
  areLoadingIndicatorsEnabled && isLoading && React.createElement(Loading, null)),
970
1354
  React.createElement(CartTimer, { secondsLeft: secondsLeft, styles: styles === null || styles === void 0 ? void 0 : styles.cartTimer, texts: texts === null || texts === void 0 ? void 0 : texts.cartTimer, shouldNotMinimize: shouldCartTimerNotMinimizeOnTap })));
971
1355
  };
972
- const isDataValid = checkBasicDataValid();
973
1356
  return (React.createElement(BillingCore, { ref: billingCoreRef, onSecondsLeftChange: setSecondsLeft, onCartExpired: onCartExpired },
974
1357
  React.createElement(SessionHandle, { ref: sessionHandleRef }, skippingStatus === 'skipping' && areLoadingIndicatorsEnabled
975
1358
  ? renderCheckingOut()