tf-checkout-react 1.4.20 → 1.4.21

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 (59) hide show
  1. package/README.md +462 -229
  2. package/dist/api/guestTicketDelegation.d.ts +47 -0
  3. package/dist/api/index.d.ts +2 -2
  4. package/dist/components/common/CustomField.d.ts +1 -1
  5. package/dist/components/common/FieldSection/index.d.ts +19 -0
  6. package/dist/components/common/FieldSection/utils/index.d.ts +8 -0
  7. package/dist/components/common/index.d.ts +2 -2
  8. package/dist/components/confirmModal/index.d.ts +2 -2
  9. package/dist/components/delegationsContainer/IssueComponent.d.ts +10 -0
  10. package/dist/components/delegationsContainer/IssueTicketForm.d.ts +9 -0
  11. package/dist/components/delegationsContainer/TicketsAssignedTable.d.ts +11 -0
  12. package/dist/components/delegationsContainer/TicketsAvailableTable.d.ts +11 -0
  13. package/dist/components/delegationsContainer/index.d.ts +10 -0
  14. package/dist/components/idVerificationContainer/constants.d.ts +1 -0
  15. package/dist/components/index.d.ts +1 -0
  16. package/dist/components/loginForm/index.d.ts +45 -0
  17. package/dist/components/registerForm/adapters/index.d.ts +4 -0
  18. package/dist/components/registerForm/constants.d.ts +1 -0
  19. package/dist/components/registerForm/index.d.ts +16 -0
  20. package/dist/index.d.ts +3 -1
  21. package/dist/tf-checkout-react.cjs.development.js +1413 -283
  22. package/dist/tf-checkout-react.cjs.development.js.map +1 -1
  23. package/dist/tf-checkout-react.cjs.production.min.js +1 -1
  24. package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
  25. package/dist/tf-checkout-react.esm.js +1416 -288
  26. package/dist/tf-checkout-react.esm.js.map +1 -1
  27. package/dist/utils/form.d.ts +3 -0
  28. package/dist/utils/index.d.ts +3 -1
  29. package/dist/utils/replaceVarInString.d.ts +1 -0
  30. package/package.json +1 -1
  31. package/src/api/guestTicketDelegation.ts +79 -0
  32. package/src/api/index.ts +3 -2
  33. package/src/components/billing-info-container/utils.ts +1 -1
  34. package/src/components/common/CustomField.tsx +2 -0
  35. package/src/components/common/FieldSection/index.tsx +141 -0
  36. package/src/components/common/FieldSection/utils/index.tsx +92 -0
  37. package/src/components/common/SelectField/index.tsx +1 -1
  38. package/src/components/common/index.tsx +2 -2
  39. package/src/components/confirmModal/index.tsx +2 -2
  40. package/src/components/delegationsContainer/IssueComponent.tsx +155 -0
  41. package/src/components/delegationsContainer/IssueTicketForm.tsx +109 -0
  42. package/src/components/delegationsContainer/TicketsAssignedTable.tsx +55 -0
  43. package/src/components/delegationsContainer/TicketsAvailableTable.tsx +54 -0
  44. package/src/components/delegationsContainer/index.tsx +83 -0
  45. package/src/components/forgotPasswordModal/index.tsx +3 -9
  46. package/src/components/idVerificationContainer/constants.ts +5 -2
  47. package/src/components/index.ts +1 -0
  48. package/src/components/loginForm/index.tsx +195 -0
  49. package/src/components/registerForm/adapters/index.tsx +10 -0
  50. package/src/components/registerForm/constants.tsx +96 -0
  51. package/src/components/registerForm/index.tsx +192 -0
  52. package/src/index.ts +3 -4
  53. package/src/types/api/auth.d.ts +55 -0
  54. package/src/types/api/guestTicketDelegation.d.ts +18 -0
  55. package/src/types/formFields.d.ts +29 -0
  56. package/src/utils/form.ts +34 -0
  57. package/src/utils/index.ts +3 -1
  58. package/src/utils/replaceVarInString.ts +9 -0
  59. package/src/validators/index.ts +2 -2
@@ -39,18 +39,18 @@ var FormControlLabel = _interopDefault(require('@mui/material/FormControlLabel')
39
39
  var FormGroup = _interopDefault(require('@mui/material/FormGroup'));
40
40
  var MuiPhoneNumber = _interopDefault(require('material-ui-phone-number'));
41
41
  var _debounce = _interopDefault(require('lodash/debounce'));
42
- var Select = _interopDefault(require('@mui/material/Select'));
43
- var FormControl = _interopDefault(require('@mui/material/FormControl'));
44
42
  var FormHelperText = _interopDefault(require('@mui/material/FormHelperText'));
45
- var FormLabel = _interopDefault(require('@mui/material/FormLabel'));
46
- var Radio = _interopDefault(require('@mui/material/Radio'));
47
- var RadioGroup = _interopDefault(require('@mui/material/RadioGroup'));
48
43
  var ListItemText = _interopDefault(require('@mui/material/ListItemText'));
49
44
  var MenuItem = _interopDefault(require('@mui/material/MenuItem'));
50
45
  var OutlinedInput = _interopDefault(require('@mui/material/OutlinedInput'));
46
+ var Select = _interopDefault(require('@mui/material/Select'));
51
47
  var xDatePickers = require('@mui/x-date-pickers');
52
48
  var AdapterMoment = require('@mui/x-date-pickers/AdapterMoment');
53
49
  var LocalizationProvider = require('@mui/x-date-pickers/LocalizationProvider');
50
+ var FormControl = _interopDefault(require('@mui/material/FormControl'));
51
+ var FormLabel = _interopDefault(require('@mui/material/FormLabel'));
52
+ var Radio = _interopDefault(require('@mui/material/Radio'));
53
+ var RadioGroup = _interopDefault(require('@mui/material/RadioGroup'));
54
54
  var Alert = _interopDefault(require('@mui/material/Alert'));
55
55
  var Container = _interopDefault(require('@mui/material/Container'));
56
56
  var reactStripeJs = require('@stripe/react-stripe-js');
@@ -684,6 +684,48 @@ var createMarkup = function createMarkup(data) {
684
684
  };
685
685
  };
686
686
 
687
+ var replaceVarInString = function replaceVarInString(message, varArray) {
688
+ if (message === void 0) {
689
+ message = '';
690
+ }
691
+ var re = new RegExp(/\{.*?\}/g);
692
+ var index = 0;
693
+ return message.replace(re, function (_) {
694
+ var value = varArray[index] || '';
695
+ index++;
696
+ return value;
697
+ });
698
+ };
699
+
700
+ var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
701
+
702
+ var getFormInitialValues = function getFormInitialValues(fieldsSections) {
703
+ var initialValues = {};
704
+ var isWindowDefined = typeof window !== 'undefined';
705
+ var userData = JSON.parse(isWindowDefined ? window.localStorage.getItem('user_data') || '{}' : '{}');
706
+ _forEach(fieldsSections, function (item) {
707
+ _forEach(item.fields, function (fieldItem) {
708
+ switch (fieldItem.name) {
709
+ case 'country':
710
+ case 'numTickets':
711
+ case 'state':
712
+ initialValues[fieldItem.name] = '';
713
+ break;
714
+ case 'brandOptIn':
715
+ initialValues[fieldItem.name] = true;
716
+ break;
717
+ case 'confirmEmail':
718
+ initialValues[fieldItem.name] = _get(userData, fieldItem.name) || _get(userData, 'email') || '';
719
+ break;
720
+ default:
721
+ initialValues[fieldItem.name] = _get(userData, fieldItem.name) || '';
722
+ break;
723
+ }
724
+ });
725
+ });
726
+ return initialValues;
727
+ };
728
+
687
729
  var setLoggedUserData = function setLoggedUserData(data) {
688
730
  return {
689
731
  id: data.id,
@@ -700,8 +742,6 @@ var setLoggedUserData = function setLoggedUserData(data) {
700
742
  };
701
743
  };
702
744
 
703
- var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
704
-
705
745
  var isJson = function isJson(value) {
706
746
  try {
707
747
  JSON.parse(value);
@@ -711,6 +751,57 @@ var isJson = function isJson(value) {
711
751
  return true;
712
752
  };
713
753
 
754
+ var getCustomerExistsData = /*#__PURE__*/function () {
755
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(accessHash) {
756
+ var response;
757
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
758
+ while (1) switch (_context.prev = _context.next) {
759
+ case 0:
760
+ _context.next = 2;
761
+ return publicRequest.get("/v1/delegation-access/" + accessHash + "/customer-exists");
762
+ case 2:
763
+ response = _context.sent;
764
+ return _context.abrupt("return", response.data);
765
+ case 4:
766
+ case "end":
767
+ return _context.stop();
768
+ }
769
+ }, _callee);
770
+ }));
771
+ return function getCustomerExistsData(_x) {
772
+ return _ref.apply(this, arguments);
773
+ };
774
+ }();
775
+ var getDelegationTickets = function getDelegationTickets(accessHash) {
776
+ var res = publicRequest.get("v1/delegation-access/" + accessHash + "/consumer-page-info");
777
+ return res;
778
+ };
779
+ var issueTicket = /*#__PURE__*/function () {
780
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(accessHash, data) {
781
+ var response;
782
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
783
+ while (1) switch (_context2.prev = _context2.next) {
784
+ case 0:
785
+ _context2.next = 2;
786
+ return publicRequest.post("v1/delegation-access/" + accessHash + "/issue-ticket", {
787
+ data: {
788
+ attributes: data
789
+ }
790
+ });
791
+ case 2:
792
+ response = _context2.sent;
793
+ return _context2.abrupt("return", response.data);
794
+ case 4:
795
+ case "end":
796
+ return _context2.stop();
797
+ }
798
+ }, _callee2);
799
+ }));
800
+ return function issueTicket(_x2, _x3) {
801
+ return _ref2.apply(this, arguments);
802
+ };
803
+ }();
804
+
714
805
  var isWindowDefined = typeof window !== 'undefined';
715
806
  var isDocumentDefined = typeof document !== 'undefined';
716
807
  if (isWindowDefined && localStorage.getItem('auth_guest_token')) {
@@ -888,7 +979,6 @@ var postOnCheckout = function postOnCheckout(data, accessToken, freeTicket) {
888
979
  delete data.attributes.city;
889
980
  delete data.attributes.country;
890
981
  delete data.attributes.state;
891
- delete data.attributes.zip;
892
982
  delete data.attributes.street_address;
893
983
  }
894
984
  var res = publicRequest.post("v1/on-checkout/", {
@@ -1415,9 +1505,9 @@ function isFalsy(item) {
1415
1505
  try {
1416
1506
  if (!item ||
1417
1507
  // handles most, like false, 0, null, etc
1418
- typeof item == 'object' && Object.keys(item).length === 0 &&
1508
+ typeof item === 'object' && Object.keys(item).length === 0 &&
1419
1509
  // for empty objects, like {}, []
1420
- !(typeof item.addEventListener == 'function') // omit webpage elements
1510
+ !(typeof item.addEventListener === 'function') // omit webpage elements
1421
1511
  ) {
1422
1512
  return true;
1423
1513
  }
@@ -1494,7 +1584,8 @@ var CustomField = function CustomField(_ref2) {
1494
1584
  _ref2$multiline = _ref2.multiline,
1495
1585
  multiline = _ref2$multiline === void 0 ? false : _ref2$multiline,
1496
1586
  minRows = _ref2.minRows,
1497
- maxRows = _ref2.maxRows;
1587
+ maxRows = _ref2.maxRows,
1588
+ disabled = _ref2.disabled;
1498
1589
  var _useState = React.useState(Boolean(field.value)),
1499
1590
  isShrinked = _useState[0],
1500
1591
  setIsShrinked = _useState[1];
@@ -1515,6 +1606,7 @@ var CustomField = function CustomField(_ref2) {
1515
1606
  }
1516
1607
  });
1517
1608
  return React__default.createElement(TextField, Object.assign({
1609
+ disabled: disabled,
1518
1610
  placeholder: "",
1519
1611
  id: field.name,
1520
1612
  label: label,
@@ -2310,107 +2402,6 @@ var Loader = function Loader() {
2310
2402
  }, React__default.createElement(CircularProgress, null));
2311
2403
  };
2312
2404
 
2313
- var NativeSelectField = function NativeSelectField(_ref) {
2314
- var label = _ref.label,
2315
- _ref$type = _ref.type,
2316
- type = _ref$type === void 0 ? 'text' : _ref$type,
2317
- field = _ref.field,
2318
- _ref$selectOptions = _ref.selectOptions,
2319
- selectOptions = _ref$selectOptions === void 0 ? [] : _ref$selectOptions,
2320
- _ref$form = _ref.form,
2321
- touched = _ref$form.touched,
2322
- errors = _ref$form.errors,
2323
- setFieldValue = _ref$form.setFieldValue,
2324
- theme = _ref.theme,
2325
- _ref$onChange = _ref.onChange,
2326
- _onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange;
2327
- var isTouched = Boolean(_get(touched, field.name));
2328
- var error = _get(errors, field.name);
2329
- var customTheme = styles$1.useTheme();
2330
- return React__default.createElement(material.FormControl, {
2331
- fullWidth: true
2332
- }, React__default.createElement(material.InputLabel, {
2333
- style: customTheme == null ? void 0 : customTheme.input,
2334
- htmlFor: field.name,
2335
- error: !!error && isTouched,
2336
- shrink: true
2337
- }, label), React__default.createElement(Select, Object.assign({
2338
- id: field.name,
2339
- label: label,
2340
- type: type,
2341
- fullWidth: true,
2342
- error: !!error && isTouched,
2343
- inputProps: {
2344
- id: field.name
2345
- },
2346
- "native": true,
2347
- className: theme,
2348
- MenuProps: {
2349
- className: theme
2350
- }
2351
- }, field, {
2352
- style: customTheme == null ? void 0 : customTheme.input,
2353
- onChange: function onChange(e) {
2354
- _onChange(e);
2355
- setFieldValue(field.name, e.target.value);
2356
- }
2357
- }), _map(selectOptions, function (option) {
2358
- return React__default.createElement("option", {
2359
- key: option.value,
2360
- value: option.value,
2361
- disabled: option.disabled
2362
- }, option.label);
2363
- })), isTouched && error ? React__default.createElement(material.FormHelperText, {
2364
- error: !!error && isTouched
2365
- }, error) : null);
2366
- };
2367
-
2368
- var RadioGroupField = function RadioGroupField(_ref) {
2369
- var label = _ref.label,
2370
- field = _ref.field,
2371
- radios = _ref.radios,
2372
- disabled = _ref.disabled,
2373
- _ref$form = _ref.form,
2374
- touched = _ref$form.touched,
2375
- errors = _ref$form.errors,
2376
- setFieldValue = _ref$form.setFieldValue,
2377
- _ref$onChange = _ref.onChange,
2378
- onChange = _ref$onChange === void 0 ? _identity : _ref$onChange;
2379
- var radioId = "radio-" + field.name;
2380
- var error = _get(errors, field.name);
2381
- var isTouched = Boolean(_get(touched, field.name));
2382
- var handleChange = function handleChange(e) {
2383
- var value = e.target.value;
2384
- setFieldValue(field.name, value);
2385
- onChange(e);
2386
- };
2387
- if (!radios) return null;
2388
- return React__default.createElement(FormControl, {
2389
- disabled: disabled,
2390
- error: isTouched && Boolean(error)
2391
- }, isTouched && Boolean(error) ? React__default.createElement(FormHelperText, {
2392
- className: "radio-error",
2393
- error: true
2394
- }, error) : null, label && React__default.createElement(FormLabel, {
2395
- id: radioId
2396
- }, label), React__default.createElement(RadioGroup, {
2397
- "aria-labelledby": radioId,
2398
- name: field.name,
2399
- value: field.value,
2400
- onChange: handleChange
2401
- }, radios.map(function (radio) {
2402
- var id = radio.id,
2403
- label = radio.label,
2404
- value = radio.value;
2405
- return React__default.createElement(FormControlLabel, {
2406
- key: id,
2407
- label: label,
2408
- value: value,
2409
- control: React__default.createElement(Radio, null)
2410
- });
2411
- })));
2412
- };
2413
-
2414
2405
  function SelectField(_ref) {
2415
2406
  var label = _ref.label,
2416
2407
  isMultiple = _ref.isMultiple,
@@ -2469,7 +2460,7 @@ function SelectField(_ref) {
2469
2460
  sx: {
2470
2461
  textAlign: 'start'
2471
2462
  }
2472
- }, options.map(function (option) {
2463
+ }, options == null ? void 0 : options.map(function (option) {
2473
2464
  return React__default.createElement(MenuItem, {
2474
2465
  key: option.label,
2475
2466
  value: option.value
@@ -2572,93 +2563,194 @@ var DatePickerField = function DatePickerField(_ref) {
2572
2563
  })));
2573
2564
  };
2574
2565
 
2575
- var _excluded$1 = ["firstName", "lastName", "holderAge", "confirmEmail", "confirmPassword"];
2576
- var getInitialValues = function getInitialValues(data, propsInitialValues, userValues) {
2577
- if (data === void 0) {
2578
- data = [];
2579
- }
2580
- if (propsInitialValues === void 0) {
2581
- propsInitialValues = {};
2582
- }
2583
- if (userValues === void 0) {
2584
- userValues = {};
2585
- }
2586
- var results = _flatMapDeep(data, function (_ref) {
2587
- var fields = _ref.fields;
2588
- return _map(fields, function (_ref2) {
2589
- var groupItems = _ref2.groupItems;
2590
- return _map(groupItems, function (_ref3) {
2591
- var name = _ref3.name,
2592
- value = _ref3.value;
2593
- return {
2594
- name: name,
2595
- value: value
2596
- };
2597
- });
2598
- });
2599
- });
2600
- var initialValues = {};
2601
- _forEach(results, function (groupItem) {
2602
- var name = groupItem.name,
2603
- value = groupItem.value;
2604
- initialValues[name] = value || propsInitialValues[name] || userValues[name] || '';
2605
- });
2606
- // set logged in user as first ticket holder
2607
- initialValues['holderFirstName-0'] = propsInitialValues.firstName || userValues.firstName || '';
2608
- initialValues['holderLastName-0'] = propsInitialValues.lastName || userValues.lastName || '';
2609
- initialValues['holderEmail-0'] = propsInitialValues.email || userValues.email || '';
2610
- return initialValues;
2611
- };
2612
- var createRegisterFormData = function createRegisterFormData(values, checkoutBody, flagFreeTicket) {
2613
- if (values === void 0) {
2614
- values = {};
2615
- }
2616
- if (flagFreeTicket === void 0) {
2617
- flagFreeTicket = false;
2618
- }
2619
- var bodyFormData = new FormData();
2620
- bodyFormData.append('first_name', values.firstName);
2621
- bodyFormData.append('last_name', values.lastName);
2622
- bodyFormData.append('email', values.email);
2623
- bodyFormData.append('password', values.password);
2624
- bodyFormData.append('password_confirmation', values.confirmPassword);
2625
- bodyFormData.append('client_id', CONFIGS.CLIENT_ID || 'e9d8f8922797b4621e562255afe90dbf');
2626
- bodyFormData.append('client_secret', CONFIGS.CLIENT_SECRET || 'b89c191eff22fdcf84ac9bfd88d005355a151ec2c83b26b9');
2627
- bodyFormData.append('check_cart_expiration', 'true');
2628
- _forEach(checkoutBody.attributes, function (item, key) {
2629
- if (!(flagFreeTicket && ['country', 'state', 'city', 'street_address', 'zip'].includes(key))) {
2630
- bodyFormData.append(key, item);
2631
- }
2632
- });
2633
- return bodyFormData;
2634
- };
2635
- var setLoggedUserData$2 = function setLoggedUserData(data) {
2636
- return {
2637
- id: data.id,
2638
- first_name: data.firstName,
2639
- last_name: data.lastName,
2640
- email: data.email,
2641
- confirmEmail: data.email,
2642
- city: (data == null ? void 0 : data.city) || '',
2643
- country: (data == null ? void 0 : data.countryId) || (data == null ? void 0 : data.country) || '',
2644
- phone: (data == null ? void 0 : data.phone) || '',
2645
- street_address: (data == null ? void 0 : data.streetAddress) || '',
2646
- state: (data == null ? void 0 : data.stateId) || '',
2647
- zip: (data == null ? void 0 : data.zip) || (data == null ? void 0 : data.zipCode) || ''
2648
- };
2649
- };
2650
- var createCheckoutDataBody = function createCheckoutDataBody(ticketsQuantity, values, logedInValues, includeDob) {
2651
- if (values === void 0) {
2652
- values = {};
2653
- }
2654
- if (logedInValues === void 0) {
2655
- logedInValues = {};
2656
- }
2657
- if (includeDob === void 0) {
2658
- includeDob = false;
2659
- }
2660
- var _values = values,
2661
- firstName = _values.firstName,
2566
+ var NativeSelectField = function NativeSelectField(_ref) {
2567
+ var label = _ref.label,
2568
+ _ref$type = _ref.type,
2569
+ type = _ref$type === void 0 ? 'text' : _ref$type,
2570
+ field = _ref.field,
2571
+ _ref$selectOptions = _ref.selectOptions,
2572
+ selectOptions = _ref$selectOptions === void 0 ? [] : _ref$selectOptions,
2573
+ _ref$form = _ref.form,
2574
+ touched = _ref$form.touched,
2575
+ errors = _ref$form.errors,
2576
+ setFieldValue = _ref$form.setFieldValue,
2577
+ theme = _ref.theme,
2578
+ _ref$onChange = _ref.onChange,
2579
+ _onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange;
2580
+ var isTouched = Boolean(_get(touched, field.name));
2581
+ var error = _get(errors, field.name);
2582
+ var customTheme = styles$1.useTheme();
2583
+ return React__default.createElement(material.FormControl, {
2584
+ fullWidth: true
2585
+ }, React__default.createElement(material.InputLabel, {
2586
+ style: customTheme == null ? void 0 : customTheme.input,
2587
+ htmlFor: field.name,
2588
+ error: !!error && isTouched,
2589
+ shrink: true
2590
+ }, label), React__default.createElement(Select, Object.assign({
2591
+ id: field.name,
2592
+ label: label,
2593
+ type: type,
2594
+ fullWidth: true,
2595
+ error: !!error && isTouched,
2596
+ inputProps: {
2597
+ id: field.name
2598
+ },
2599
+ "native": true,
2600
+ className: theme,
2601
+ MenuProps: {
2602
+ className: theme
2603
+ }
2604
+ }, field, {
2605
+ style: customTheme == null ? void 0 : customTheme.input,
2606
+ onChange: function onChange(e) {
2607
+ _onChange(e);
2608
+ setFieldValue(field.name, e.target.value);
2609
+ }
2610
+ }), _map(selectOptions, function (option) {
2611
+ return React__default.createElement("option", {
2612
+ key: option.value,
2613
+ value: option.value,
2614
+ disabled: option.disabled
2615
+ }, option.label);
2616
+ })), isTouched && error ? React__default.createElement(material.FormHelperText, {
2617
+ error: !!error && isTouched
2618
+ }, error) : null);
2619
+ };
2620
+
2621
+ var RadioGroupField = function RadioGroupField(_ref) {
2622
+ var label = _ref.label,
2623
+ field = _ref.field,
2624
+ radios = _ref.radios,
2625
+ disabled = _ref.disabled,
2626
+ _ref$form = _ref.form,
2627
+ touched = _ref$form.touched,
2628
+ errors = _ref$form.errors,
2629
+ setFieldValue = _ref$form.setFieldValue,
2630
+ _ref$onChange = _ref.onChange,
2631
+ onChange = _ref$onChange === void 0 ? _identity : _ref$onChange;
2632
+ var radioId = "radio-" + field.name;
2633
+ var error = _get(errors, field.name);
2634
+ var isTouched = Boolean(_get(touched, field.name));
2635
+ var handleChange = function handleChange(e) {
2636
+ var value = e.target.value;
2637
+ setFieldValue(field.name, value);
2638
+ onChange(e);
2639
+ };
2640
+ if (!radios) return null;
2641
+ return React__default.createElement(FormControl, {
2642
+ disabled: disabled,
2643
+ error: isTouched && Boolean(error)
2644
+ }, isTouched && Boolean(error) ? React__default.createElement(FormHelperText, {
2645
+ className: "radio-error",
2646
+ error: true
2647
+ }, error) : null, label && React__default.createElement(FormLabel, {
2648
+ id: radioId
2649
+ }, label), React__default.createElement(RadioGroup, {
2650
+ "aria-labelledby": radioId,
2651
+ name: field.name,
2652
+ value: field.value,
2653
+ onChange: handleChange
2654
+ }, radios.map(function (radio) {
2655
+ var id = radio.id,
2656
+ label = radio.label,
2657
+ value = radio.value;
2658
+ return React__default.createElement(FormControlLabel, {
2659
+ key: id,
2660
+ label: label,
2661
+ value: value,
2662
+ control: React__default.createElement(Radio, null)
2663
+ });
2664
+ })));
2665
+ };
2666
+
2667
+ var _excluded$1 = ["firstName", "lastName", "holderAge", "confirmEmail", "confirmPassword"];
2668
+ var getInitialValues = function getInitialValues(data, propsInitialValues, userValues) {
2669
+ if (data === void 0) {
2670
+ data = [];
2671
+ }
2672
+ if (propsInitialValues === void 0) {
2673
+ propsInitialValues = {};
2674
+ }
2675
+ if (userValues === void 0) {
2676
+ userValues = {};
2677
+ }
2678
+ var results = _flatMapDeep(data, function (_ref) {
2679
+ var fields = _ref.fields;
2680
+ return _map(fields, function (_ref2) {
2681
+ var groupItems = _ref2.groupItems;
2682
+ return _map(groupItems, function (_ref3) {
2683
+ var name = _ref3.name,
2684
+ value = _ref3.value;
2685
+ return {
2686
+ name: name,
2687
+ value: value
2688
+ };
2689
+ });
2690
+ });
2691
+ });
2692
+ var initialValues = {};
2693
+ _forEach(results, function (groupItem) {
2694
+ var name = groupItem.name,
2695
+ value = groupItem.value;
2696
+ initialValues[name] = value || propsInitialValues[name] || userValues[name] || '';
2697
+ });
2698
+ // set logged in user as first ticket holder
2699
+ initialValues['holderFirstName-0'] = propsInitialValues.firstName || userValues.firstName || '';
2700
+ initialValues['holderLastName-0'] = propsInitialValues.lastName || userValues.lastName || '';
2701
+ initialValues['holderEmail-0'] = propsInitialValues.email || userValues.email || '';
2702
+ return initialValues;
2703
+ };
2704
+ var createRegisterFormData = function createRegisterFormData(values, checkoutBody, flagFreeTicket) {
2705
+ if (values === void 0) {
2706
+ values = {};
2707
+ }
2708
+ if (flagFreeTicket === void 0) {
2709
+ flagFreeTicket = false;
2710
+ }
2711
+ var bodyFormData = new FormData();
2712
+ bodyFormData.append('first_name', values.firstName);
2713
+ bodyFormData.append('last_name', values.lastName);
2714
+ bodyFormData.append('email', values.email);
2715
+ bodyFormData.append('password', values.password);
2716
+ bodyFormData.append('password_confirmation', values.confirmPassword);
2717
+ bodyFormData.append('client_id', CONFIGS.CLIENT_ID || 'e9d8f8922797b4621e562255afe90dbf');
2718
+ bodyFormData.append('client_secret', CONFIGS.CLIENT_SECRET || 'b89c191eff22fdcf84ac9bfd88d005355a151ec2c83b26b9');
2719
+ bodyFormData.append('check_cart_expiration', 'true');
2720
+ _forEach(checkoutBody.attributes, function (item, key) {
2721
+ if (!(flagFreeTicket && ['country', 'state', 'city', 'street_address'].includes(key))) {
2722
+ bodyFormData.append(key, item);
2723
+ }
2724
+ });
2725
+ return bodyFormData;
2726
+ };
2727
+ var setLoggedUserData$2 = function setLoggedUserData(data) {
2728
+ return {
2729
+ id: data.id,
2730
+ first_name: data.firstName,
2731
+ last_name: data.lastName,
2732
+ email: data.email,
2733
+ confirmEmail: data.email,
2734
+ city: (data == null ? void 0 : data.city) || '',
2735
+ country: (data == null ? void 0 : data.countryId) || (data == null ? void 0 : data.country) || '',
2736
+ phone: (data == null ? void 0 : data.phone) || '',
2737
+ street_address: (data == null ? void 0 : data.streetAddress) || '',
2738
+ state: (data == null ? void 0 : data.stateId) || '',
2739
+ zip: (data == null ? void 0 : data.zip) || (data == null ? void 0 : data.zipCode) || ''
2740
+ };
2741
+ };
2742
+ var createCheckoutDataBody = function createCheckoutDataBody(ticketsQuantity, values, logedInValues, includeDob) {
2743
+ if (values === void 0) {
2744
+ values = {};
2745
+ }
2746
+ if (logedInValues === void 0) {
2747
+ logedInValues = {};
2748
+ }
2749
+ if (includeDob === void 0) {
2750
+ includeDob = false;
2751
+ }
2752
+ var _values = values,
2753
+ firstName = _values.firstName,
2662
2754
  lastName = _values.lastName,
2663
2755
  holderAge = _values.holderAge,
2664
2756
  restValues = _objectWithoutPropertiesLoose(_values, _excluded$1);
@@ -8222,75 +8314,1125 @@ var AddonsContainter = function AddonsContainter(_ref) {
8222
8314
  }));
8223
8315
  };
8224
8316
 
8225
- var addToCartFunc = /*#__PURE__*/function () {
8226
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
8227
- var eventId, data, ticketQuantity, _ref$enableBillingInf, enableBillingInfoAutoCreate, isWindowDefined, result, pageConfigsDataResponse, pageConfigsData, _pageConfigsData$skip, skipBillingPage, _pageConfigsData$name, nameIsRequired, _pageConfigsData$age_, ageIsRequired, _pageConfigsData$phon, phoneIsRequired, _pageConfigsData$hide, hidePhoneField, _pageConfigsData$has_, hasAddOn, _pageConfigsData$free, freeTicket, _pageConfigsData$coll, collectOptionalWalletAddress, _pageConfigsData$coll2, collectMandatoryWalletAddress, hash, total, userData, checkoutBody, checkoutResult;
8228
- return _regeneratorRuntime().wrap(function _callee$(_context) {
8229
- while (1) switch (_context.prev = _context.next) {
8230
- case 0:
8231
- eventId = _ref.eventId, data = _ref.data, ticketQuantity = _ref.ticketQuantity, _ref$enableBillingInf = _ref.enableBillingInfoAutoCreate, enableBillingInfoAutoCreate = _ref$enableBillingInf === void 0 ? true : _ref$enableBillingInf;
8232
- isWindowDefined = typeof window !== 'undefined';
8233
- _context.next = 4;
8234
- return addToCart(eventId, data);
8235
- case 4:
8236
- result = _context.sent;
8237
- _context.next = 7;
8238
- return getCheckoutPageConfigs();
8239
- case 7:
8240
- pageConfigsDataResponse = _context.sent;
8241
- if (!(result.status === 200 && pageConfigsDataResponse.status === 200)) {
8242
- _context.next = 28;
8243
- break;
8244
- }
8245
- pageConfigsData = _get(pageConfigsDataResponse, 'data.attributes') || {};
8246
- _pageConfigsData$skip = pageConfigsData.skip_billing_page, skipBillingPage = _pageConfigsData$skip === void 0 ? false : _pageConfigsData$skip, _pageConfigsData$name = pageConfigsData.names_required, nameIsRequired = _pageConfigsData$name === void 0 ? false : _pageConfigsData$name, _pageConfigsData$age_ = pageConfigsData.age_required, ageIsRequired = _pageConfigsData$age_ === void 0 ? false : _pageConfigsData$age_, _pageConfigsData$phon = pageConfigsData.phone_required, phoneIsRequired = _pageConfigsData$phon === void 0 ? false : _pageConfigsData$phon, _pageConfigsData$hide = pageConfigsData.hide_phone_field, hidePhoneField = _pageConfigsData$hide === void 0 ? false : _pageConfigsData$hide, _pageConfigsData$has_ = pageConfigsData.has_add_on, hasAddOn = _pageConfigsData$has_ === void 0 ? false : _pageConfigsData$has_, _pageConfigsData$free = pageConfigsData.free_ticket, freeTicket = _pageConfigsData$free === void 0 ? false : _pageConfigsData$free, _pageConfigsData$coll = pageConfigsData.collect_optional_wallet_address, collectOptionalWalletAddress = _pageConfigsData$coll === void 0 ? false : _pageConfigsData$coll, _pageConfigsData$coll2 = pageConfigsData.collect_mandatory_wallet_address, collectMandatoryWalletAddress = _pageConfigsData$coll2 === void 0 ? false : _pageConfigsData$coll2;
8247
- hash = '';
8248
- total = '';
8249
- isWindowDefined && window.localStorage.removeItem('add_ons');
8250
- if (!(skipBillingPage && !hasAddOn)) {
8251
- _context.next = 27;
8252
- break;
8253
- }
8254
- // Get user data for checkout data
8255
- userData = isWindowDefined && window.localStorage.getItem('user_data') ? JSON.parse(window.localStorage.getItem('user_data') || '') : {};
8256
- checkoutBody = createCheckoutDataBodyWithDefaultHolder(ticketQuantity, userData);
8257
- if (!enableBillingInfoAutoCreate) {
8258
- _context.next = 23;
8259
- break;
8260
- }
8261
- _context.next = 20;
8262
- return postOnCheckout(checkoutBody, undefined, freeTicket);
8263
- case 20:
8264
- _context.t0 = _context.sent;
8265
- _context.next = 24;
8266
- break;
8267
- case 23:
8268
- _context.t0 = null;
8269
- case 24:
8270
- checkoutResult = _context.t0;
8271
- hash = _get(checkoutResult, 'data.data.attributes.hash') || '';
8272
- total = _get(checkoutResult, 'data.data.attributes.total') || '';
8273
- case 27:
8274
- return _context.abrupt("return", {
8275
- skip_billing_page: skipBillingPage,
8276
- names_required: nameIsRequired,
8277
- phone_required: phoneIsRequired,
8278
- age_required: ageIsRequired,
8279
- hide_phone_field: hidePhoneField,
8280
- free_ticket: freeTicket,
8281
- collect_optional_wallet_address: collectOptionalWalletAddress,
8282
- collect_mandatory_wallet_address: collectMandatoryWalletAddress,
8283
- event_id: String(eventId),
8284
- hash: hash,
8285
- total: total,
8286
- hasAddOn: hasAddOn
8287
- });
8288
- case 28:
8289
- return _context.abrupt("return", null);
8290
- case 29:
8291
- case "end":
8292
- return _context.stop();
8293
- }
8317
+ var setLoggedUserData$3 = function setLoggedUserData(data) {
8318
+ return {
8319
+ id: data.id,
8320
+ first_name: data.firstName,
8321
+ last_name: data.lastName,
8322
+ email: data.email,
8323
+ confirmEmail: data.email,
8324
+ city: (data == null ? void 0 : data.city) || '',
8325
+ country: (data == null ? void 0 : data.countryId) || (data == null ? void 0 : data.country) || '',
8326
+ phone: (data == null ? void 0 : data.phone) || '',
8327
+ street_address: (data == null ? void 0 : data.streetAddress) || '',
8328
+ state: (data == null ? void 0 : data.stateId) || '',
8329
+ zip: (data == null ? void 0 : data.zip) || (data == null ? void 0 : data.zipCode) || ''
8330
+ };
8331
+ };
8332
+ var LoginForm = function LoginForm(_ref) {
8333
+ var _ref$alreadyHasUser = _ref.alreadyHasUser,
8334
+ alreadyHasUser = _ref$alreadyHasUser === void 0 ? false : _ref$alreadyHasUser,
8335
+ _ref$userExpired = _ref.userExpired,
8336
+ userExpired = _ref$userExpired === void 0 ? false : _ref$userExpired,
8337
+ _ref$onLoginSuccess = _ref.onLoginSuccess,
8338
+ onLoginSuccess = _ref$onLoginSuccess === void 0 ? _identity : _ref$onLoginSuccess,
8339
+ _ref$onLoginError = _ref.onLoginError,
8340
+ onLoginError = _ref$onLoginError === void 0 ? _identity : _ref$onLoginError,
8341
+ _ref$onGetProfileData = _ref.onGetProfileDataSuccess,
8342
+ onGetProfileDataSuccess = _ref$onGetProfileData === void 0 ? _identity : _ref$onGetProfileData,
8343
+ _ref$onGetProfileData2 = _ref.onGetProfileDataError,
8344
+ onGetProfileDataError = _ref$onGetProfileData2 === void 0 ? _identity : _ref$onGetProfileData2,
8345
+ _ref$onForgotPassword = _ref.onForgotPasswordButtonClick,
8346
+ onForgotPasswordButtonClick = _ref$onForgotPassword === void 0 ? _identity : _ref$onForgotPassword,
8347
+ _ref$onSignupButtonCl = _ref.onSignupButtonClick,
8348
+ onSignupButtonClick = _ref$onSignupButtonCl === void 0 ? _identity : _ref$onSignupButtonCl,
8349
+ logo = _ref.logo,
8350
+ _ref$showForgotPasswo = _ref.showForgotPasswordButton,
8351
+ showForgotPasswordButton = _ref$showForgotPasswo === void 0 ? false : _ref$showForgotPasswo,
8352
+ _ref$showSignUpButton = _ref.showSignUpButton,
8353
+ showSignUpButton = _ref$showSignUpButton === void 0 ? false : _ref$showSignUpButton;
8354
+ var _useState = React.useState(''),
8355
+ error = _useState[0],
8356
+ setError = _useState[1];
8357
+ return React__default.createElement("div", {
8358
+ className: 'login-modal'
8359
+ }, React__default.createElement(formik.Formik, {
8360
+ initialValues: {
8361
+ email: '',
8362
+ password: ''
8363
+ },
8364
+ onSubmit: function () {
8365
+ var _onSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
8366
+ var email, password, body, authRes, profileResponse, profileSpecifiedData, profileDataObj, event, _e$response, _e$response$data, _error;
8367
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
8368
+ while (1) switch (_context.prev = _context.next) {
8369
+ case 0:
8370
+ email = _ref2.email, password = _ref2.password;
8371
+ _context.prev = 1;
8372
+ body = {
8373
+ email: email,
8374
+ password: password
8375
+ };
8376
+ _context.next = 5;
8377
+ return authorize(body);
8378
+ case 5:
8379
+ authRes = _context.sent;
8380
+ profileResponse = null;
8381
+ _context.prev = 7;
8382
+ _context.next = 10;
8383
+ return getProfileData();
8384
+ case 10:
8385
+ profileResponse = _context.sent;
8386
+ onGetProfileDataSuccess(_get(profileResponse, 'data.data'));
8387
+ _context.next = 18;
8388
+ break;
8389
+ case 14:
8390
+ _context.prev = 14;
8391
+ _context.t0 = _context["catch"](7);
8392
+ if (axios.isAxiosError(_context.t0)) {
8393
+ onGetProfileDataError(_context.t0);
8394
+ }
8395
+ return _context.abrupt("return");
8396
+ case 18:
8397
+ profileSpecifiedData = _get(profileResponse, 'data.data');
8398
+ profileDataObj = setLoggedUserData$3(profileSpecifiedData);
8399
+ if (typeof window !== 'undefined') {
8400
+ window.localStorage.setItem('user_data', JSON.stringify(profileDataObj));
8401
+ event = new window.CustomEvent('tf-login');
8402
+ window.document.dispatchEvent(event);
8403
+ }
8404
+ onLoginSuccess(_get(authRes, 'data.data'));
8405
+ _context.next = 27;
8406
+ break;
8407
+ case 24:
8408
+ _context.prev = 24;
8409
+ _context.t1 = _context["catch"](1);
8410
+ if (axios.isAxiosError(_context.t1)) {
8411
+ _error = (_context.t1 == null ? void 0 : (_e$response = _context.t1.response) == null ? void 0 : (_e$response$data = _e$response.data) == null ? void 0 : _e$response$data.message) || 'Error';
8412
+ setError(_error);
8413
+ onLoginError(_context.t1);
8414
+ } else if (_context.t1 instanceof Error) {
8415
+ setError((_context.t1 == null ? void 0 : _context.t1.message) || 'Error');
8416
+ }
8417
+ case 27:
8418
+ case "end":
8419
+ return _context.stop();
8420
+ }
8421
+ }, _callee, null, [[1, 24], [7, 14]]);
8422
+ }));
8423
+ function onSubmit(_x) {
8424
+ return _onSubmit.apply(this, arguments);
8425
+ }
8426
+ return onSubmit;
8427
+ }()
8428
+ }, function (props) {
8429
+ return React__default.createElement(formik.Form, {
8430
+ onSubmit: props.handleSubmit
8431
+ }, React__default.createElement("div", {
8432
+ className: "modal-title"
8433
+ }, "Login"), React__default.createElement("div", {
8434
+ className: "login-logo-container"
8435
+ }, React__default.createElement("img", {
8436
+ className: "login-logo-tff",
8437
+ src: logo || 'https://www.ticketfairy.com/resources/images/logo-ttf-black.svg',
8438
+ alt: "logo"
8439
+ })), React__default.createElement("div", {
8440
+ className: "server_auth__error"
8441
+ }, error), alreadyHasUser && React__default.createElement("p", {
8442
+ className: "info-text-for-login"
8443
+ }, "It appears this email is already attached to an account. Please log in here to complete your registration."), userExpired && React__default.createElement("p", {
8444
+ className: "info-text-for-login"
8445
+ }, "Your session has expired, please log in again."), React__default.createElement("div", {
8446
+ className: "login-modal-body"
8447
+ }, React__default.createElement("div", {
8448
+ className: "login-modal-body__email"
8449
+ }, React__default.createElement(formik.Field, {
8450
+ name: "email",
8451
+ label: "Email",
8452
+ type: "email",
8453
+ component: CustomField,
8454
+ validate: combineValidators(requiredValidator, emailValidator)
8455
+ })), React__default.createElement("div", {
8456
+ className: "login-modal-body__password"
8457
+ }, React__default.createElement(formik.Field, {
8458
+ name: "password",
8459
+ label: "Password",
8460
+ type: "password",
8461
+ component: CustomField,
8462
+ validate: requiredValidator
8463
+ })), React__default.createElement("div", {
8464
+ className: "login-action-button"
8465
+ }, React__default.createElement("button", {
8466
+ type: "submit"
8467
+ }, "Login")), showForgotPasswordButton && React__default.createElement("div", {
8468
+ className: "forgot-password"
8469
+ }, React__default.createElement("span", {
8470
+ "aria-hidden": "true",
8471
+ onClick: onForgotPasswordButtonClick
8472
+ }, "Forgot password?")), showSignUpButton && React__default.createElement("div", {
8473
+ className: "forgot-password"
8474
+ }, React__default.createElement("span", {
8475
+ "aria-hidden": "true",
8476
+ onClick: onSignupButtonClick
8477
+ }, "Sign up"))));
8478
+ }));
8479
+ };
8480
+
8481
+ var getValidateFunctions$1 = function getValidateFunctions(_ref) {
8482
+ var element = _ref.element,
8483
+ values = _ref.values;
8484
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8485
+ var validationFunctions = [];
8486
+ if (element.required) {
8487
+ validationFunctions.push(requiredValidator);
8488
+ }
8489
+ if (element.onValidate) {
8490
+ validationFunctions.push(element.onValidate);
8491
+ }
8492
+ if (element.name === 'confirmEmail') {
8493
+ var isSameEmail = function isSameEmail(confirmEmail) {
8494
+ return values.email !== confirmEmail ? 'Please confirm your email address correctly' : null;
8495
+ };
8496
+ validationFunctions.push(isSameEmail);
8497
+ }
8498
+ if (element.name === 'confirmPassword') {
8499
+ var isSame = function isSame(confirmPassword) {
8500
+ return values.password !== confirmPassword ? 'Password confirmation does not match' : null;
8501
+ };
8502
+ validationFunctions.push(isSame);
8503
+ }
8504
+ return combineValidators.apply(void 0, validationFunctions);
8505
+ };
8506
+ var updateFormFieldsAttributes = function updateFormFieldsAttributes(formFields, attributes) {
8507
+ if (attributes && !_isEmpty(attributes)) {
8508
+ var updatedFormFields = _map(formFields, function (fieldSection) {
8509
+ var fieldSectionAttributes = attributes[fieldSection.name] || {};
8510
+ var updatedFields = _map(fieldSection.fields, function (fieldItem) {
8511
+ var fieldItemAttributes = attributes[fieldItem.name] || {};
8512
+ return _extends({}, fieldItem, fieldItemAttributes);
8513
+ });
8514
+ return _extends({}, fieldSection, fieldSectionAttributes, {
8515
+ fields: updatedFields
8516
+ });
8517
+ });
8518
+ return updatedFormFields;
8519
+ }
8520
+ return formFields;
8521
+ };
8522
+ var getFieldClassNames = function getFieldClassNames(id, existingClassNames) {
8523
+ if (isBrowser) {
8524
+ var _elem$parentElement;
8525
+ var elem = document && document.getElementById(id);
8526
+ if (((elem == null ? void 0 : (_elem$parentElement = elem.parentElement) == null ? void 0 : _elem$parentElement.clientWidth) || 0) < 375) {
8527
+ return existingClassNames + ' full-width';
8528
+ }
8529
+ }
8530
+ return existingClassNames;
8531
+ };
8532
+ var insertHTML = function insertHTML(elementId, text) {
8533
+ if (text === void 0) {
8534
+ text = '';
8535
+ }
8536
+ if (isBrowser) {
8537
+ var elem = document && document.getElementById(elementId);
8538
+ if (!(elem != null && elem.childNodes.length)) {
8539
+ elem == null ? void 0 : elem.insertAdjacentHTML('afterbegin', text);
8540
+ }
8541
+ }
8542
+ return null;
8543
+ };
8544
+
8545
+ var SectionContainer = function SectionContainer(_ref) {
8546
+ var children = _ref.children,
8547
+ className = _ref.className;
8548
+ return React__default.createElement("div", {
8549
+ className: className
8550
+ }, children);
8551
+ };
8552
+ var FieldsSection = function FieldsSection(_ref2) {
8553
+ var _ref2$formFields = _ref2.formFields,
8554
+ formFields = _ref2$formFields === void 0 ? [] : _ref2$formFields,
8555
+ _ref2$countries = _ref2.countries,
8556
+ countries = _ref2$countries === void 0 ? [] : _ref2$countries,
8557
+ _ref2$states = _ref2.states,
8558
+ states = _ref2$states === void 0 ? [] : _ref2$states,
8559
+ values = _ref2.values,
8560
+ setFieldValue = _ref2.setFieldValue,
8561
+ theme = _ref2.theme,
8562
+ _ref2$containerClass = _ref2.containerClass,
8563
+ containerClass = _ref2$containerClass === void 0 ? '' : _ref2$containerClass,
8564
+ _ref2$setPhoneValidat = _ref2.setPhoneValidationIsLoading,
8565
+ setPhoneValidationIsLoading = _ref2$setPhoneValidat === void 0 ? _identity : _ref2$setPhoneValidat,
8566
+ _ref2$onFieldChange = _ref2.onFieldChange,
8567
+ onFieldChange = _ref2$onFieldChange === void 0 ? _identity : _ref2$onFieldChange,
8568
+ disableField = _ref2.disableField;
8569
+ return React__default.createElement(React__default.Fragment, null, _map(formFields, function (item, index) {
8570
+ var name = item.name,
8571
+ groupLabel = item.groupLabel,
8572
+ _item$groupLabelVars = item.groupLabelVars,
8573
+ groupLabelVars = _item$groupLabelVars === void 0 ? [] : _item$groupLabelVars,
8574
+ groupLabelClassName = item.groupLabelClassName,
8575
+ _item$groupClassName = item.groupClassName,
8576
+ groupClassName = _item$groupClassName === void 0 ? '' : _item$groupClassName,
8577
+ fields = item.fields;
8578
+ return React__default.createElement(SectionContainer, {
8579
+ key: name,
8580
+ className: groupClassName
8581
+ }, React__default.createElement("span", {
8582
+ id: "group_label_" + index,
8583
+ className: groupLabelClassName
8584
+ }, typeof groupLabel === 'string' ? insertHTML("group_label_" + index, replaceVarInString(groupLabel, groupLabelVars)) : groupLabel), React__default.createElement("div", {
8585
+ className: "fields-container " + groupClassName
8586
+ }, _map(fields, function (fieldData, fieldIndex) {
8587
+ var name = fieldData.name,
8588
+ label = fieldData.label,
8589
+ _fieldData$className = fieldData.className,
8590
+ className = _fieldData$className === void 0 ? 'full-width' : _fieldData$className,
8591
+ type = fieldData.type,
8592
+ component = fieldData.component,
8593
+ _fieldData$options = fieldData.options,
8594
+ options = _fieldData$options === void 0 ? [] : _fieldData$options,
8595
+ required = fieldData.required;
8596
+ var id = name + "-" + fieldIndex;
8597
+ var classNames = containerClass + "-container__field " + className;
8598
+ return component || React__default.createElement("div", {
8599
+ key: name,
8600
+ id: id,
8601
+ className: getFieldClassNames(id, classNames)
8602
+ }, React__default.createElement(formik.Field, {
8603
+ disabled: name === disableField || name === 'state' && !states.length,
8604
+ name: name,
8605
+ label: "" + label + (required ? '' : ' (optional)'),
8606
+ type: type,
8607
+ validate: name === 'state' && !states.length ? false : getValidateFunctions$1({
8608
+ element: fieldData,
8609
+ values: values
8610
+ }),
8611
+ setFieldValue: setFieldValue,
8612
+ component: type === 'checkbox' ? CheckboxField : type === 'select' ? SelectField : type === 'phone' ? PhoneNumberField : type === 'date' ? DatePickerField : CustomField,
8613
+ options: name === 'country' ? countries : name === 'state' ? states : options,
8614
+ theme: theme,
8615
+ setPhoneValidationIsLoading: type === 'phone' ? setPhoneValidationIsLoading : undefined,
8616
+ onChange: function onChange(e) {
8617
+ var element = e.target;
8618
+ var value = element.value;
8619
+ setFieldValue(name, value);
8620
+ onFieldChange(name, value);
8621
+ },
8622
+ disableDropdown: fieldData.disableDropdown
8623
+ }));
8624
+ })));
8625
+ }));
8626
+ };
8627
+
8628
+ var collectStates = function collectStates(states) {
8629
+ var mappedStates = _map(states, function (item, key) {
8630
+ return {
8631
+ label: item,
8632
+ value: key
8633
+ };
8634
+ });
8635
+ return mappedStates;
8636
+ };
8637
+
8638
+ var formDefaultFields = [{
8639
+ name: 'basic-info',
8640
+ groupLabel: 'Create your account.',
8641
+ groupLabelClassName: '',
8642
+ groupClassName: '',
8643
+ fields: [{
8644
+ className: 'half-width',
8645
+ name: 'firstName',
8646
+ label: 'First Name',
8647
+ type: 'text',
8648
+ required: true,
8649
+ onValidate: null
8650
+ }, {
8651
+ className: 'half-width',
8652
+ name: 'lastName',
8653
+ label: 'Last Name',
8654
+ type: 'text',
8655
+ required: true,
8656
+ onValidate: null
8657
+ }, {
8658
+ name: 'email',
8659
+ label: 'Email',
8660
+ type: 'email',
8661
+ required: true,
8662
+ onValidate: null
8663
+ }, {
8664
+ name: 'confirmEmail',
8665
+ label: 'Confirm Email',
8666
+ type: 'email',
8667
+ required: true,
8668
+ onValidate: null
8669
+ }]
8670
+ }, {
8671
+ name: 'billing-info',
8672
+ groupLabel: '',
8673
+ groupLabelClassName: '',
8674
+ groupClassName: '',
8675
+ fields: [{
8676
+ className: 'half-width',
8677
+ name: 'zip',
8678
+ label: 'Post Code/Zip',
8679
+ type: 'text',
8680
+ required: true,
8681
+ onValidate: null
8682
+ }, {
8683
+ className: 'half-width',
8684
+ name: 'country',
8685
+ label: 'Country',
8686
+ type: 'select',
8687
+ required: true,
8688
+ onValidate: null
8689
+ }]
8690
+ }, {
8691
+ name: 'password-info',
8692
+ groupLabel: /*#__PURE__*/React__default.createElement("div", {
8693
+ className: "email-info-block"
8694
+ }, /*#__PURE__*/React__default.createElement("span", null, "Choose a password for your new"), /*#__PURE__*/React__default.createElement("b", null, " Mana Common "), /*#__PURE__*/React__default.createElement("span", null, "account")),
8695
+ groupLabelClassName: '',
8696
+ groupClassName: '',
8697
+ fields: [{
8698
+ className: 'half-width',
8699
+ name: 'password',
8700
+ label: 'Password',
8701
+ type: 'password',
8702
+ required: true,
8703
+ onValidate: null
8704
+ }, {
8705
+ className: 'half-width',
8706
+ name: 'confirmPassword',
8707
+ label: 'Confirm Password',
8708
+ type: 'password',
8709
+ required: true,
8710
+ onValidate: null
8711
+ }]
8712
+ }];
8713
+
8714
+ var RegistrationForm = function RegistrationForm(_ref) {
8715
+ var formFields = _ref.formFields,
8716
+ additionalFieldAttribute = _ref.additionalFieldAttribute,
8717
+ registrationType = _ref.registrationType,
8718
+ customerEmail = _ref.customerEmail,
8719
+ _ref$onGetCountriesSu = _ref.onGetCountriesSuccess,
8720
+ onGetCountriesSuccess = _ref$onGetCountriesSu === void 0 ? _identity : _ref$onGetCountriesSu,
8721
+ _ref$onGetCountriesEr = _ref.onGetCountriesError,
8722
+ onGetCountriesError = _ref$onGetCountriesEr === void 0 ? _identity : _ref$onGetCountriesEr,
8723
+ _ref$onRegisterAccoun = _ref.onRegisterAccountSuccess,
8724
+ onRegisterAccountSuccess = _ref$onRegisterAccoun === void 0 ? _identity : _ref$onRegisterAccoun,
8725
+ _ref$onRegisterAccoun2 = _ref.onRegisterAccountError,
8726
+ onRegisterAccountError = _ref$onRegisterAccoun2 === void 0 ? _identity : _ref$onRegisterAccoun2,
8727
+ _ref$onGetStatesSucce = _ref.onGetStatesSuccess,
8728
+ onGetStatesSuccess = _ref$onGetStatesSucce === void 0 ? _identity : _ref$onGetStatesSucce,
8729
+ _ref$onGetStatesError = _ref.onGetStatesError,
8730
+ onGetStatesError = _ref$onGetStatesError === void 0 ? _identity : _ref$onGetStatesError;
8731
+ var _useState = React.useState(''),
8732
+ errorMessage = _useState[0],
8733
+ setErrorMessage = _useState[1];
8734
+ var _useState2 = React.useState([]),
8735
+ countries = _useState2[0],
8736
+ setCountries = _useState2[1];
8737
+ var _useState3 = React.useState([]),
8738
+ states = _useState3[0],
8739
+ setStates = _useState3[1];
8740
+ var _useState4 = React.useState(false),
8741
+ phoneValidationIsLoading = _useState4[0],
8742
+ setPhoneValidationIsLoading = _useState4[1];
8743
+ var _useState5 = React.useState(false),
8744
+ showErrorModal = _useState5[0],
8745
+ setshowErrorModal = _useState5[1];
8746
+ var updatedFormFields = updateFormFieldsAttributes(formFields || formDefaultFields, additionalFieldAttribute);
8747
+ // Fetch countries data
8748
+ var fetchCountries = /*#__PURE__*/function () {
8749
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
8750
+ var res, _e$response, _e$response$data, _errorMessage;
8751
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
8752
+ while (1) switch (_context.prev = _context.next) {
8753
+ case 0:
8754
+ _context.prev = 0;
8755
+ _context.next = 3;
8756
+ return getCountries();
8757
+ case 3:
8758
+ res = _context.sent;
8759
+ setCountries(_map(_get(res, 'data.data'), function (item) {
8760
+ return {
8761
+ label: item.name,
8762
+ value: item.id
8763
+ };
8764
+ }));
8765
+ onGetCountriesSuccess(res.data);
8766
+ _context.next = 11;
8767
+ break;
8768
+ case 8:
8769
+ _context.prev = 8;
8770
+ _context.t0 = _context["catch"](0);
8771
+ if (axios.isAxiosError(_context.t0)) {
8772
+ _errorMessage = (_context.t0 == null ? void 0 : (_e$response = _context.t0.response) == null ? void 0 : (_e$response$data = _e$response.data) == null ? void 0 : _e$response$data.message) || 'Error';
8773
+ setErrorMessage(_errorMessage);
8774
+ onGetCountriesError(_context.t0);
8775
+ }
8776
+ case 11:
8777
+ case "end":
8778
+ return _context.stop();
8779
+ }
8780
+ }, _callee, null, [[0, 8]]);
8781
+ }));
8782
+ return function fetchCountries() {
8783
+ return _ref2.apply(this, arguments);
8784
+ };
8785
+ }();
8786
+ // Fetch states data
8787
+ var fetchStates = /*#__PURE__*/function () {
8788
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(countryId) {
8789
+ var fetchCountryId, res, _states, mappedStates, _e$response2, _e$response2$data, _errorMessage2;
8790
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
8791
+ while (1) switch (_context2.prev = _context2.next) {
8792
+ case 0:
8793
+ _context2.prev = 0;
8794
+ fetchCountryId = countryId ? countryId : '1';
8795
+ _context2.next = 4;
8796
+ return getStates(fetchCountryId);
8797
+ case 4:
8798
+ res = _context2.sent;
8799
+ _states = _get(res, 'data.data', []);
8800
+ mappedStates = collectStates(_states);
8801
+ setStates(mappedStates);
8802
+ onGetStatesSuccess(res.data);
8803
+ _context2.next = 14;
8804
+ break;
8805
+ case 11:
8806
+ _context2.prev = 11;
8807
+ _context2.t0 = _context2["catch"](0);
8808
+ if (axios.isAxiosError(_context2.t0)) {
8809
+ _errorMessage2 = (_context2.t0 == null ? void 0 : (_e$response2 = _context2.t0.response) == null ? void 0 : (_e$response2$data = _e$response2.data) == null ? void 0 : _e$response2$data.message) || 'Error';
8810
+ onGetStatesError(_errorMessage2);
8811
+ }
8812
+ case 14:
8813
+ case "end":
8814
+ return _context2.stop();
8815
+ }
8816
+ }, _callee2, null, [[0, 11]]);
8817
+ }));
8818
+ return function fetchStates(_x) {
8819
+ return _ref3.apply(this, arguments);
8820
+ };
8821
+ }();
8822
+ var handleRegisterAccount = /*#__PURE__*/function () {
8823
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(values) {
8824
+ var accessHash, bodyFormData, profileRes, _e$response3, _e$response3$data, _errorMessage3;
8825
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
8826
+ while (1) switch (_context3.prev = _context3.next) {
8827
+ case 0:
8828
+ accessHash = getQueryVariable('hash') || '';
8829
+ _context3.prev = 1;
8830
+ bodyFormData = new FormData();
8831
+ bodyFormData.append('first_name', values.firstName);
8832
+ bodyFormData.append('last_name', values.lastName);
8833
+ bodyFormData.append('email', values.email);
8834
+ bodyFormData.append('zip', values.zip);
8835
+ bodyFormData.append('city', values.city);
8836
+ bodyFormData.append('country', values.country);
8837
+ bodyFormData.append('password', values.password);
8838
+ bodyFormData.append('phone', values.phone || '');
8839
+ bodyFormData.append('password_confirmation', values.confirmPassword);
8840
+ bodyFormData.append('client_id', CONFIGS.CLIENT_ID);
8841
+ bodyFormData.append('client_secret', CONFIGS.CLIENT_SECRET);
8842
+ bodyFormData.append('register_for', registrationType);
8843
+ bodyFormData.append('delegation_access_hash', accessHash);
8844
+ _context3.next = 18;
8845
+ return register(bodyFormData);
8846
+ case 18:
8847
+ _context3.next = 20;
8848
+ return getProfileData();
8849
+ case 20:
8850
+ profileRes = _context3.sent;
8851
+ window.localStorage.setItem('user_data', JSON.stringify(_get(profileRes, 'data.data')));
8852
+ onRegisterAccountSuccess(profileRes);
8853
+ _context3.next = 28;
8854
+ break;
8855
+ case 25:
8856
+ _context3.prev = 25;
8857
+ _context3.t0 = _context3["catch"](1);
8858
+ if (axios.isAxiosError(_context3.t0)) {
8859
+ console.log(_context3.t0);
8860
+ _errorMessage3 = (_context3.t0 == null ? void 0 : (_e$response3 = _context3.t0.response) == null ? void 0 : (_e$response3$data = _e$response3.data) == null ? void 0 : _e$response3$data.message) || 'Error';
8861
+ onRegisterAccountError(_context3.t0);
8862
+ setshowErrorModal(true);
8863
+ setErrorMessage(_errorMessage3);
8864
+ } else if (_context3.t0 instanceof Error) {
8865
+ setErrorMessage((_context3.t0 == null ? void 0 : _context3.t0.message) || 'Error');
8866
+ }
8867
+ case 28:
8868
+ case "end":
8869
+ return _context3.stop();
8870
+ }
8871
+ }, _callee3, null, [[1, 25]]);
8872
+ }));
8873
+ return function handleRegisterAccount(_x2) {
8874
+ return _ref4.apply(this, arguments);
8875
+ };
8876
+ }();
8877
+ React.useEffect(function () {
8878
+ fetchCountries();
8879
+ fetchStates();
8880
+ }, []);
8881
+ return React__default.createElement("div", {
8882
+ className: "register-form-container"
8883
+ }, React__default.createElement("h2", null, "Create an account"), React__default.createElement("div", {
8884
+ className: "register-sub-title"
8885
+ }, "To manage your tickets, please create an account:"), showErrorModal && React__default.createElement(ConfirmModal, {
8886
+ hideCancelBtn: true,
8887
+ message: errorMessage,
8888
+ onClose: function onClose() {
8889
+ return window.location.href = '/';
8890
+ },
8891
+ onConfirm: function onConfirm() {
8892
+ return window.location.href = '/';
8893
+ }
8894
+ }), errorMessage && React__default.createElement("div", {
8895
+ className: "register-error"
8896
+ }, errorMessage), React__default.createElement(formik.Formik, {
8897
+ initialValues: _extends({}, getFormInitialValues(updatedFormFields), {
8898
+ email: customerEmail
8899
+ }),
8900
+ enableReinitialize: true,
8901
+ onSubmit: handleRegisterAccount
8902
+ }, function (props) {
8903
+ return React__default.createElement(formik.Form, null, React__default.createElement("div", {
8904
+ className: "register-body"
8905
+ }, React__default.createElement(FieldsSection, {
8906
+ disableField: 'email',
8907
+ containerClass: "register",
8908
+ formFields: updatedFormFields,
8909
+ values: props.values,
8910
+ setFieldValue: props.setFieldValue,
8911
+ setPhoneValidationIsLoading: setPhoneValidationIsLoading,
8912
+ countries: countries,
8913
+ states: states,
8914
+ onFieldChange: function onFieldChange(name, value) {
8915
+ if (name === 'country') {
8916
+ fetchStates(value);
8917
+ }
8918
+ }
8919
+ })), React__default.createElement("div", {
8920
+ className: "button-container"
8921
+ }, React__default.createElement(material.Button, {
8922
+ className: "register-button",
8923
+ type: "submit",
8924
+ disabled: props.isSubmitting || phoneValidationIsLoading
8925
+ }, props.isSubmitting ? React__default.createElement(material.CircularProgress, {
8926
+ size: 26
8927
+ }) : 'Create Account')));
8928
+ }));
8929
+ };
8930
+
8931
+ /* eslint-disable max-len */
8932
+ var VERIFICATION_STATUSES = {
8933
+ PENDING: 'PENDING',
8934
+ APPROVED: 'APPROVED_VERIFIED',
8935
+ FAILED: 'FAILED',
8936
+ WRONG_CUSTOMER: 'WRONG_CUSTOMER'
8937
+ };
8938
+ var VERIFICATION_MESSAGES = {
8939
+ PENDING: 'Your ID verification is currently being processed. We will notify you as soon as it is completed. Thank you for your patience.',
8940
+ APPROVED: 'Your ID verification is approved!',
8941
+ FAILED: 'Unfortunately your ID verification has failed. Please try again.',
8942
+ WRONG_CUSTOMER: 'The order does not belong to the customer.'
8943
+ };
8944
+ var DELEGATION_ACCESS_ERROR = 'Delegation Access not found';
8945
+
8946
+ var IssueTicketForm = function IssueTicketForm(_ref) {
8947
+ var _ref$classNamePrefix = _ref.classNamePrefix,
8948
+ classNamePrefix = _ref$classNamePrefix === void 0 ? 'delegations' : _ref$classNamePrefix,
8949
+ _ref$handleSubmit = _ref.handleSubmit,
8950
+ handleSubmit = _ref$handleSubmit === void 0 ? _identity : _ref$handleSubmit,
8951
+ selectTicketTypeOptions = _ref.selectTicketTypeOptions,
8952
+ initialValues = _ref.initialValues;
8953
+ return React__default.createElement("div", {
8954
+ className: classNamePrefix + "-issue-form"
8955
+ }, React__default.createElement(formik.Formik, {
8956
+ initialValues: initialValues,
8957
+ onSubmit: function onSubmit(values, _ref2) {
8958
+ var resetForm = _ref2.resetForm,
8959
+ setSubmitting = _ref2.setSubmitting;
8960
+ delete values.confirm;
8961
+ handleSubmit(values, {
8962
+ resetForm: resetForm,
8963
+ setSubmitting: setSubmitting
8964
+ });
8965
+ }
8966
+ }, function (_ref3) {
8967
+ var isValid = _ref3.isValid,
8968
+ values = _ref3.values,
8969
+ isSubmitting = _ref3.isSubmitting;
8970
+ return React__default.createElement(formik.Form, null, React__default.createElement("div", {
8971
+ className: "body"
8972
+ }, React__default.createElement("div", {
8973
+ className: "field-item"
8974
+ }, React__default.createElement("div", {
8975
+ className: "field_label"
8976
+ }, "Ticket Type"), React__default.createElement(formik.Field, {
8977
+ name: "ticketTypeId",
8978
+ label: "Ticket Type",
8979
+ component: SelectField,
8980
+ validate: requiredValidator,
8981
+ options: selectTicketTypeOptions
8982
+ })), React__default.createElement("div", {
8983
+ className: "field-item"
8984
+ }, React__default.createElement("div", {
8985
+ className: "field_label"
8986
+ }, "Name"), React__default.createElement(formik.Field, {
8987
+ name: "firstName",
8988
+ label: "Name",
8989
+ component: CustomField,
8990
+ validate: requiredValidator
8991
+ })), React__default.createElement("div", {
8992
+ className: "field-item"
8993
+ }, React__default.createElement("div", {
8994
+ className: "field_label"
8995
+ }, "Last Name"), React__default.createElement(formik.Field, {
8996
+ name: "lastName",
8997
+ label: "Last Name",
8998
+ component: CustomField,
8999
+ validate: requiredValidator
9000
+ })), React__default.createElement("div", {
9001
+ className: "field-item"
9002
+ }, React__default.createElement("div", {
9003
+ className: "field_label"
9004
+ }, "Email"), React__default.createElement(formik.Field, {
9005
+ name: "email",
9006
+ label: "Email",
9007
+ component: CustomField,
9008
+ validate: requiredValidator
9009
+ })), React__default.createElement("div", {
9010
+ className: "field-item"
9011
+ }, React__default.createElement("div", {
9012
+ className: "field_label"
9013
+ }, "Confirm Email"), React__default.createElement(formik.Field, {
9014
+ name: "confirmEmail",
9015
+ label: "Confirm Email",
9016
+ component: CustomField,
9017
+ validate: getValidateFunctions$1({
9018
+ element: {
9019
+ name: 'confirmEmail',
9020
+ label: 'Confirm Email',
9021
+ required: true
9022
+ },
9023
+ values: values
9024
+ })
9025
+ }))), React__default.createElement("div", {
9026
+ className: "field-item checkbox_item"
9027
+ }, React__default.createElement(formik.Field, {
9028
+ name: "confirm",
9029
+ label: "I agree to ManaCommon's privacy policy",
9030
+ type: "checkbox",
9031
+ validate: requiredValidator,
9032
+ component: CheckboxField
9033
+ })), React__default.createElement("div", {
9034
+ className: "action-button"
9035
+ }, React__default.createElement("button", {
9036
+ type: "submit",
9037
+ disabled: !isValid
9038
+ }, isSubmitting ? React__default.createElement(material.CircularProgress, {
9039
+ size: "22px"
9040
+ }) : 'Issue Ticket')));
9041
+ }));
9042
+ };
9043
+
9044
+ var TicketsAssignedTable = function TicketsAssignedTable(_ref) {
9045
+ var _issuePageData$ticket, _issuePageData$ticket2;
9046
+ var _ref$tableTitle = _ref.tableTitle,
9047
+ tableTitle = _ref$tableTitle === void 0 ? 'Tickets assigned' : _ref$tableTitle,
9048
+ _ref$classNamePrefix = _ref.classNamePrefix,
9049
+ classNamePrefix = _ref$classNamePrefix === void 0 ? 'delegations' : _ref$classNamePrefix,
9050
+ issuePageData = _ref.issuePageData,
9051
+ _ref$noTicketsAssigne = _ref.noTicketsAssignedText,
9052
+ noTicketsAssignedText = _ref$noTicketsAssigne === void 0 ? "You haven't issued any tickets yet." : _ref$noTicketsAssigne;
9053
+ return React__default.createElement("div", {
9054
+ className: classNamePrefix + "-tables-block"
9055
+ }, React__default.createElement("div", {
9056
+ className: classNamePrefix + "-ticket-holder"
9057
+ }, tableTitle), (_issuePageData$ticket = issuePageData.tickets) != null && _issuePageData$ticket.length ? React__default.createElement(TableContainer, {
9058
+ className: "my-ticket-table"
9059
+ }, React__default.createElement(Table, {
9060
+ "aria-label": "collapsible table"
9061
+ }, React__default.createElement(TableHead, null, React__default.createElement(TableRow, null, React__default.createElement(TableCell, {
9062
+ key: 'Ticket Holder'
9063
+ }, 'Ticket Holder'), React__default.createElement(TableCell, {
9064
+ key: 'Ticket Type'
9065
+ }, 'Ticket Type'), React__default.createElement(TableCell, {
9066
+ key: 'Status'
9067
+ }, 'Status'))), React__default.createElement(TableBody, null, (_issuePageData$ticket2 = issuePageData.tickets) == null ? void 0 : _issuePageData$ticket2.map(function (ticket) {
9068
+ return React__default.createElement(TableRow, {
9069
+ key: ticket.id
9070
+ }, React__default.createElement(TableCell, {
9071
+ key: ticket.id + 'type'
9072
+ }, ticket.firstName + ' ' + ticket.lastName), React__default.createElement(TableCell, {
9073
+ key: ticket.id + 'ticketType'
9074
+ }, ticket.ticketType), React__default.createElement(TableCell, {
9075
+ key: ticket.id + 'status'
9076
+ }, ticket.status));
9077
+ })))) : noTicketsAssignedText);
9078
+ };
9079
+
9080
+ var TicketsAvailableTable = function TicketsAvailableTable(_ref) {
9081
+ var _ref$tableTitle = _ref.tableTitle,
9082
+ tableTitle = _ref$tableTitle === void 0 ? 'Tickets available' : _ref$tableTitle,
9083
+ _ref$classNamePrefix = _ref.classNamePrefix,
9084
+ classNamePrefix = _ref$classNamePrefix === void 0 ? 'delegations' : _ref$classNamePrefix,
9085
+ issuePageData = _ref.issuePageData;
9086
+ return React__default.createElement("div", {
9087
+ className: classNamePrefix + "-tables-block"
9088
+ }, React__default.createElement("div", {
9089
+ className: classNamePrefix + "-ticket-holder"
9090
+ }, tableTitle), React__default.createElement(TableContainer, {
9091
+ className: "my-ticket-table"
9092
+ }, React__default.createElement(Table, {
9093
+ "aria-label": "collapsible table"
9094
+ }, React__default.createElement(TableHead, null, React__default.createElement(TableRow, null, React__default.createElement(TableCell, {
9095
+ key: 1
9096
+ }, 'Ticket Type'), React__default.createElement(TableCell, {
9097
+ key: 2
9098
+ }, 'Total Quantity'), React__default.createElement(TableCell, {
9099
+ key: 3
9100
+ }, 'Quantity Issued'), React__default.createElement(TableCell, {
9101
+ key: 4
9102
+ }, 'Quantity Remaining'))), React__default.createElement(TableBody, null, _map(issuePageData.ticketTypes, function (val, key) {
9103
+ return React__default.createElement(TableRow, {
9104
+ key: key
9105
+ }, React__default.createElement(TableCell, {
9106
+ key: key + 'name'
9107
+ }, val.optionValue), React__default.createElement(TableCell, {
9108
+ key: key + 'maxQty'
9109
+ }, val.delegationMaxQuantity), React__default.createElement(TableCell, {
9110
+ key: key + 'issued'
9111
+ }, val.delegationQuantityIssued), React__default.createElement(TableCell, {
9112
+ key: key + 'remaining'
9113
+ }, Number(val.delegationMaxQuantity) - Number(val.delegationQuantityIssued)));
9114
+ })))));
9115
+ };
9116
+
9117
+ var IssueComponent = function IssueComponent(_ref) {
9118
+ var _ref$classNamePrefix = _ref.classNamePrefix,
9119
+ classNamePrefix = _ref$classNamePrefix === void 0 ? 'delegations' : _ref$classNamePrefix,
9120
+ _ref$headTitle = _ref.headTitle,
9121
+ headTitle = _ref$headTitle === void 0 ? 'Manage Your Guest Tickets' : _ref$headTitle,
9122
+ _ref$onGetIssuePageDa = _ref.onGetIssuePageDataSuccess,
9123
+ onGetIssuePageDataSuccess = _ref$onGetIssuePageDa === void 0 ? _identity : _ref$onGetIssuePageDa,
9124
+ _ref$onGetIssuePageDa2 = _ref.onGetIssuePageDataError,
9125
+ onGetIssuePageDataError = _ref$onGetIssuePageDa2 === void 0 ? _identity : _ref$onGetIssuePageDa2;
9126
+ var _useState = React.useState(true),
9127
+ loading = _useState[0],
9128
+ setLoading = _useState[1];
9129
+ var _useState2 = React.useState(false),
9130
+ showMaxQtyModal = _useState2[0],
9131
+ setShowMaxQtyModal = _useState2[1];
9132
+ var _useState3 = React.useState(false),
9133
+ showSuccessModal = _useState3[0],
9134
+ setShowSuccessModal = _useState3[1];
9135
+ var _useState4 = React.useState(''),
9136
+ error = _useState4[0],
9137
+ setError = _useState4[1];
9138
+ var accessHash = getQueryVariable('hash') || '';
9139
+ var _useState5 = React.useState({}),
9140
+ issuePageData = _useState5[0],
9141
+ setIssuePageData = _useState5[1];
9142
+ React.useEffect(function () {
9143
+ var fetchDelegationTickets = /*#__PURE__*/function () {
9144
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
9145
+ var _res$data, _res$data$data, res;
9146
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
9147
+ while (1) switch (_context.prev = _context.next) {
9148
+ case 0:
9149
+ _context.prev = 0;
9150
+ _context.next = 3;
9151
+ return getDelegationTickets(accessHash);
9152
+ case 3:
9153
+ res = _context.sent;
9154
+ setLoading(false);
9155
+ setIssuePageData((res == null ? void 0 : (_res$data = res.data) == null ? void 0 : (_res$data$data = _res$data.data) == null ? void 0 : _res$data$data.attributes) || {});
9156
+ onGetIssuePageDataSuccess();
9157
+ _context.next = 13;
9158
+ break;
9159
+ case 9:
9160
+ _context.prev = 9;
9161
+ _context.t0 = _context["catch"](0);
9162
+ setLoading(false);
9163
+ if (axios.isAxiosError(_context.t0)) {
9164
+ onGetIssuePageDataError(_context.t0);
9165
+ }
9166
+ case 13:
9167
+ case "end":
9168
+ return _context.stop();
9169
+ }
9170
+ }, _callee, null, [[0, 9]]);
9171
+ }));
9172
+ return function fetchDelegationTickets() {
9173
+ return _ref2.apply(this, arguments);
9174
+ };
9175
+ }();
9176
+ fetchDelegationTickets();
9177
+ }, [showSuccessModal]);
9178
+ var selectTicketTypeOptions = _map(issuePageData.ticketTypes || {}, function (val, key) {
9179
+ return {
9180
+ value: key,
9181
+ label: val.optionValue
9182
+ };
9183
+ });
9184
+ return React__default.createElement("div", {
9185
+ className: classNamePrefix + "-container"
9186
+ }, loading ? React__default.createElement(Loader, null) : React__default.createElement(React__default.Fragment, null, showMaxQtyModal && React__default.createElement(ConfirmModal, {
9187
+ hideCancelBtn: true,
9188
+ message: error,
9189
+ onClose: function onClose() {
9190
+ return error === DELEGATION_ACCESS_ERROR ? window.location.href = '/' : setShowMaxQtyModal(false);
9191
+ },
9192
+ onConfirm: function onConfirm() {
9193
+ return error === DELEGATION_ACCESS_ERROR ? window.location.href = '/' : setShowMaxQtyModal(false);
9194
+ }
9195
+ }), showSuccessModal && React__default.createElement(ConfirmModal, {
9196
+ hideCancelBtn: true,
9197
+ message: "Your ticket successfully issued.",
9198
+ onClose: function onClose() {
9199
+ return setShowSuccessModal(false);
9200
+ },
9201
+ onConfirm: function onConfirm() {
9202
+ return setShowSuccessModal(false);
9203
+ }
9204
+ }), React__default.createElement("div", {
9205
+ className: classNamePrefix + "-head-title"
9206
+ }, headTitle), React__default.createElement("div", {
9207
+ className: classNamePrefix + "-inner-blocks"
9208
+ }, React__default.createElement("div", {
9209
+ className: classNamePrefix + "-image-block"
9210
+ }, React__default.createElement("img", {
9211
+ src: "" + CONFIGS.BASE_URL + (issuePageData == null ? void 0 : issuePageData.eventImage),
9212
+ alt: "main_event_img",
9213
+ title: ""
9214
+ })), React__default.createElement("div", {
9215
+ className: classNamePrefix + "-tables"
9216
+ }, React__default.createElement(TicketsAvailableTable, {
9217
+ tableTitle: "Tickets available",
9218
+ issuePageData: issuePageData,
9219
+ classNamePrefix: "delegations"
9220
+ }), React__default.createElement(TicketsAssignedTable, {
9221
+ tableTitle: "Tickets assigned",
9222
+ issuePageData: issuePageData,
9223
+ classNamePrefix: "delegations"
9224
+ }), React__default.createElement("div", {
9225
+ className: classNamePrefix + "-issue-block"
9226
+ }, React__default.createElement("div", {
9227
+ className: classNamePrefix + "-issue-title"
9228
+ }, "Issue New Tickets"), React__default.createElement("div", {
9229
+ className: classNamePrefix + "-issue-subtitle"
9230
+ }, "Please select the type of tickets and enter recipient details:")), React__default.createElement(IssueTicketForm, {
9231
+ classNamePrefix: 'delegations',
9232
+ handleSubmit: function () {
9233
+ var _handleSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(values, _ref3) {
9234
+ var resetForm, setSubmitting, _e$response, _e$response$data, _error;
9235
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
9236
+ while (1) switch (_context2.prev = _context2.next) {
9237
+ case 0:
9238
+ resetForm = _ref3.resetForm, setSubmitting = _ref3.setSubmitting;
9239
+ _context2.prev = 1;
9240
+ _context2.next = 4;
9241
+ return issueTicket(accessHash, values);
9242
+ case 4:
9243
+ setShowSuccessModal(true);
9244
+ resetForm();
9245
+ _context2.next = 12;
9246
+ break;
9247
+ case 8:
9248
+ _context2.prev = 8;
9249
+ _context2.t0 = _context2["catch"](1);
9250
+ if (axios.isAxiosError(_context2.t0)) {
9251
+ _error = (_context2.t0 == null ? void 0 : (_e$response = _context2.t0.response) == null ? void 0 : (_e$response$data = _e$response.data) == null ? void 0 : _e$response$data.message) || 'Error';
9252
+ setError(_error);
9253
+ } else if (_context2.t0 instanceof Error) {
9254
+ setError((_context2.t0 == null ? void 0 : _context2.t0.message) || 'Error');
9255
+ }
9256
+ setShowMaxQtyModal(true);
9257
+ case 12:
9258
+ _context2.prev = 12;
9259
+ setLoading(false);
9260
+ setSubmitting(false);
9261
+ return _context2.finish(12);
9262
+ case 16:
9263
+ case "end":
9264
+ return _context2.stop();
9265
+ }
9266
+ }, _callee2, null, [[1, 8, 12, 16]]);
9267
+ }));
9268
+ function handleSubmit(_x, _x2) {
9269
+ return _handleSubmit.apply(this, arguments);
9270
+ }
9271
+ return handleSubmit;
9272
+ }(),
9273
+ selectTicketTypeOptions: selectTicketTypeOptions,
9274
+ initialValues: {
9275
+ ticketTypeId: '',
9276
+ firstName: '',
9277
+ lastName: '',
9278
+ email: '',
9279
+ confirmEmail: '',
9280
+ confirm: false
9281
+ }
9282
+ })))));
9283
+ };
9284
+
9285
+ var X_TF_ECOMMERCE$1 = 'X-TF-ECOMMERCE';
9286
+ var DelegationsContainer = function DelegationsContainer(_ref) {
9287
+ var registerFormFields = _ref.registerFormFields,
9288
+ _ref$classNamePrefix = _ref.classNamePrefix,
9289
+ classNamePrefix = _ref$classNamePrefix === void 0 ? 'guest-ticket-delegation' : _ref$classNamePrefix,
9290
+ _ref$issuePageErrorTe = _ref.issuePageErrorText,
9291
+ issuePageErrorText = _ref$issuePageErrorTe === void 0 ? 'You do not have access to manage these tickets.' : _ref$issuePageErrorTe,
9292
+ _ref$onCustomerExists = _ref.onCustomerExistsError,
9293
+ onCustomerExistsError = _ref$onCustomerExists === void 0 ? _identity : _ref$onCustomerExists,
9294
+ logo = _ref.logo;
9295
+ var _useState = React.useState(true),
9296
+ loading = _useState[0],
9297
+ setLoading = _useState[1];
9298
+ var _useState2 = React.useState(Boolean(getCookieByName(X_TF_ECOMMERCE$1))),
9299
+ isLoggedIn = _useState2[0],
9300
+ setIsLoggedIn = _useState2[1];
9301
+ var _useState3 = React.useState(false),
9302
+ isCustomerExsists = _useState3[0],
9303
+ setIsCustomerExsists = _useState3[1];
9304
+ var _useState4 = React.useState(false),
9305
+ issuePageError = _useState4[0],
9306
+ setIssuePageError = _useState4[1];
9307
+ var _useState5 = React.useState(''),
9308
+ customerEmail = _useState5[0],
9309
+ setCustomerEmail = _useState5[1];
9310
+ var accessHash = getQueryVariable('hash') || '';
9311
+ useCookieListener(X_TF_ECOMMERCE$1, function (value) {
9312
+ return setIsLoggedIn(Boolean(value));
9313
+ });
9314
+ var onGetIssuePageDataError = function onGetIssuePageDataError() {
9315
+ setIssuePageError(true);
9316
+ };
9317
+ React.useEffect(function () {
9318
+ var getCustomerData = /*#__PURE__*/function () {
9319
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
9320
+ var response, _isCustomerExsists;
9321
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
9322
+ while (1) switch (_context.prev = _context.next) {
9323
+ case 0:
9324
+ _context.prev = 0;
9325
+ _context.next = 3;
9326
+ return getCustomerExistsData(accessHash);
9327
+ case 3:
9328
+ response = _context.sent;
9329
+ _isCustomerExsists = _get(response, 'data.attributes.customerExists', false);
9330
+ setIsCustomerExsists(_isCustomerExsists);
9331
+ setCustomerEmail(_get(response, 'data.attributes.email', ''));
9332
+ setLoading(false);
9333
+ _context.next = 13;
9334
+ break;
9335
+ case 10:
9336
+ _context.prev = 10;
9337
+ _context.t0 = _context["catch"](0);
9338
+ onCustomerExistsError(_context.t0);
9339
+ case 13:
9340
+ case "end":
9341
+ return _context.stop();
9342
+ }
9343
+ }, _callee, null, [[0, 10]]);
9344
+ }));
9345
+ return function getCustomerData() {
9346
+ return _ref2.apply(this, arguments);
9347
+ };
9348
+ }();
9349
+ getCustomerData();
9350
+ }, []);
9351
+ return React__default.createElement("div", {
9352
+ className: classNamePrefix + "__container"
9353
+ }, loading ? React__default.createElement(Loader, null) : issuePageError ? React__default.createElement("div", {
9354
+ className: "issue_page_error"
9355
+ }, issuePageErrorText) : isLoggedIn ? React__default.createElement("div", null, React__default.createElement(IssueComponent, {
9356
+ classNamePrefix: classNamePrefix,
9357
+ onGetIssuePageDataError: onGetIssuePageDataError
9358
+ })) : isCustomerExsists ? React__default.createElement(LoginForm, {
9359
+ logo: logo
9360
+ }) : React__default.createElement(RegistrationForm, {
9361
+ customerEmail: customerEmail,
9362
+ formFields: registerFormFields,
9363
+ registrationType: "delegation"
9364
+ }));
9365
+ };
9366
+
9367
+ var addToCartFunc = /*#__PURE__*/function () {
9368
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
9369
+ var eventId, data, ticketQuantity, _ref$enableBillingInf, enableBillingInfoAutoCreate, isWindowDefined, result, pageConfigsDataResponse, pageConfigsData, _pageConfigsData$skip, skipBillingPage, _pageConfigsData$name, nameIsRequired, _pageConfigsData$age_, ageIsRequired, _pageConfigsData$phon, phoneIsRequired, _pageConfigsData$hide, hidePhoneField, _pageConfigsData$has_, hasAddOn, _pageConfigsData$free, freeTicket, _pageConfigsData$coll, collectOptionalWalletAddress, _pageConfigsData$coll2, collectMandatoryWalletAddress, hash, total, userData, checkoutBody, checkoutResult;
9370
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
9371
+ while (1) switch (_context.prev = _context.next) {
9372
+ case 0:
9373
+ eventId = _ref.eventId, data = _ref.data, ticketQuantity = _ref.ticketQuantity, _ref$enableBillingInf = _ref.enableBillingInfoAutoCreate, enableBillingInfoAutoCreate = _ref$enableBillingInf === void 0 ? true : _ref$enableBillingInf;
9374
+ isWindowDefined = typeof window !== 'undefined';
9375
+ _context.next = 4;
9376
+ return addToCart(eventId, data);
9377
+ case 4:
9378
+ result = _context.sent;
9379
+ _context.next = 7;
9380
+ return getCheckoutPageConfigs();
9381
+ case 7:
9382
+ pageConfigsDataResponse = _context.sent;
9383
+ if (!(result.status === 200 && pageConfigsDataResponse.status === 200)) {
9384
+ _context.next = 28;
9385
+ break;
9386
+ }
9387
+ pageConfigsData = _get(pageConfigsDataResponse, 'data.attributes') || {};
9388
+ _pageConfigsData$skip = pageConfigsData.skip_billing_page, skipBillingPage = _pageConfigsData$skip === void 0 ? false : _pageConfigsData$skip, _pageConfigsData$name = pageConfigsData.names_required, nameIsRequired = _pageConfigsData$name === void 0 ? false : _pageConfigsData$name, _pageConfigsData$age_ = pageConfigsData.age_required, ageIsRequired = _pageConfigsData$age_ === void 0 ? false : _pageConfigsData$age_, _pageConfigsData$phon = pageConfigsData.phone_required, phoneIsRequired = _pageConfigsData$phon === void 0 ? false : _pageConfigsData$phon, _pageConfigsData$hide = pageConfigsData.hide_phone_field, hidePhoneField = _pageConfigsData$hide === void 0 ? false : _pageConfigsData$hide, _pageConfigsData$has_ = pageConfigsData.has_add_on, hasAddOn = _pageConfigsData$has_ === void 0 ? false : _pageConfigsData$has_, _pageConfigsData$free = pageConfigsData.free_ticket, freeTicket = _pageConfigsData$free === void 0 ? false : _pageConfigsData$free, _pageConfigsData$coll = pageConfigsData.collect_optional_wallet_address, collectOptionalWalletAddress = _pageConfigsData$coll === void 0 ? false : _pageConfigsData$coll, _pageConfigsData$coll2 = pageConfigsData.collect_mandatory_wallet_address, collectMandatoryWalletAddress = _pageConfigsData$coll2 === void 0 ? false : _pageConfigsData$coll2;
9389
+ hash = '';
9390
+ total = '';
9391
+ isWindowDefined && window.localStorage.removeItem('add_ons');
9392
+ if (!(skipBillingPage && !hasAddOn)) {
9393
+ _context.next = 27;
9394
+ break;
9395
+ }
9396
+ // Get user data for checkout data
9397
+ userData = isWindowDefined && window.localStorage.getItem('user_data') ? JSON.parse(window.localStorage.getItem('user_data') || '') : {};
9398
+ checkoutBody = createCheckoutDataBodyWithDefaultHolder(ticketQuantity, userData);
9399
+ if (!enableBillingInfoAutoCreate) {
9400
+ _context.next = 23;
9401
+ break;
9402
+ }
9403
+ _context.next = 20;
9404
+ return postOnCheckout(checkoutBody, undefined, freeTicket);
9405
+ case 20:
9406
+ _context.t0 = _context.sent;
9407
+ _context.next = 24;
9408
+ break;
9409
+ case 23:
9410
+ _context.t0 = null;
9411
+ case 24:
9412
+ checkoutResult = _context.t0;
9413
+ hash = _get(checkoutResult, 'data.data.attributes.hash') || '';
9414
+ total = _get(checkoutResult, 'data.data.attributes.total') || '';
9415
+ case 27:
9416
+ return _context.abrupt("return", {
9417
+ skip_billing_page: skipBillingPage,
9418
+ names_required: nameIsRequired,
9419
+ phone_required: phoneIsRequired,
9420
+ age_required: ageIsRequired,
9421
+ hide_phone_field: hidePhoneField,
9422
+ free_ticket: freeTicket,
9423
+ collect_optional_wallet_address: collectOptionalWalletAddress,
9424
+ collect_mandatory_wallet_address: collectMandatoryWalletAddress,
9425
+ event_id: String(eventId),
9426
+ hash: hash,
9427
+ total: total,
9428
+ hasAddOn: hasAddOn
9429
+ });
9430
+ case 28:
9431
+ return _context.abrupt("return", null);
9432
+ case 29:
9433
+ case "end":
9434
+ return _context.stop();
9435
+ }
8294
9436
  }, _callee);
8295
9437
  }));
8296
9438
  return function addToCartFunc(_x) {
@@ -9135,20 +10277,6 @@ var SeatMapContainer = function SeatMapContainer(props) {
9135
10277
  }));
9136
10278
  };
9137
10279
 
9138
- /* eslint-disable max-len */
9139
- var VERIFICATION_STATUSES = {
9140
- PENDING: 'PENDING',
9141
- APPROVED: 'APPROVED_VERIFIED',
9142
- FAILED: 'FAILED',
9143
- WRONG_CUSTOMER: 'WRONG_CUSTOMER'
9144
- };
9145
- var VERIFICATION_MESSAGES = {
9146
- PENDING: 'Your ID verification is currently being processed. We will notify you as soon as it is completed. Thank you for your patience.',
9147
- APPROVED: 'Your ID verification is approved!',
9148
- FAILED: 'Unfortunately your ID verification has failed. Please try again.',
9149
- WRONG_CUSTOMER: 'The order does not belong to the customer.'
9150
- };
9151
-
9152
10280
  var IDVerification = function IDVerification(props) {
9153
10281
  var _props$onGetVerifyUrl = props.onGetVerifyUrlSuccess,
9154
10282
  onGetVerifyUrlSuccess = _props$onGetVerifyUrl === void 0 ? _identity : _props$onGetVerifyUrl,
@@ -9614,6 +10742,7 @@ var RsvpContainer = function RsvpContainer(_ref) {
9614
10742
  exports.AddonsContainter = AddonsContainter;
9615
10743
  exports.BillingInfoContainer = BillingInfoContainer;
9616
10744
  exports.ConfirmationContainer = ConfirmationContainer;
10745
+ exports.DelegationsContainer = DelegationsContainer;
9617
10746
  exports.ForgotPasswordModal = ForgotPasswordModal;
9618
10747
  exports.IDVerification = IDVerification;
9619
10748
  exports.LoginModal = LoginModal;
@@ -9631,4 +10760,5 @@ exports.VERIFICATION_STATUSES = VERIFICATION_STATUSES;
9631
10760
  exports.createFixedFloatNormalizer = createFixedFloatNormalizer;
9632
10761
  exports.currencyNormalizerCreator = currencyNormalizerCreator;
9633
10762
  exports.setConfigs = setConfigs;
10763
+ exports.useCookieListener = useCookieListener;
9634
10764
  //# sourceMappingURL=tf-checkout-react.cjs.development.js.map