tf-checkout-react 1.3.15 → 1.3.17

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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.15",
2
+ "version": "1.3.17",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -311,10 +311,13 @@ export const BillingInfoContainer = React.memo(
311
311
  const hideTtfOptIn: boolean = _get(cartInfoData, 'hide_ttf_opt_in', true)
312
312
  const expirationTime = _get(cartInfoData, 'expiresAt')
313
313
  const flagRequirePhone = getQueryVariable('phone_required') === 'true'
314
- const collectOptionalWalletAddress = getQueryVariable('collect_optional_wallet_address') === 'true'
315
- const collectMandatoryWalletAddress = getQueryVariable('collect_mandatory_wallet_address') === 'true'
314
+ const collectMandatoryWalletAddress =
315
+ getQueryVariable('collect_mandatory_wallet_address') === 'true'
316
+ const collectOptionalWalletAddress =
317
+ getQueryVariable('collect_optional_wallet_address') === 'true'
316
318
  const flagFreeTicket = getQueryVariable('free_ticket') === 'true'
317
319
  const hidePhoneField = getQueryVariable('hide_phone_field') === 'true'
320
+ const hideWalletAddressField = !collectOptionalWalletAddress && !collectMandatoryWalletAddress;
318
321
 
319
322
  // Get prevProps
320
323
  const prevData = useRef(data)
@@ -570,7 +573,8 @@ export const BillingInfoContainer = React.memo(
570
573
  )
571
574
  const bodyFormData = createRegisterFormData(
572
575
  values,
573
- checkoutBodyForRegistration
576
+ checkoutBodyForRegistration,
577
+ flagFreeTicket,
574
578
  )
575
579
  try {
576
580
  setLoading(true)
@@ -769,15 +773,22 @@ export const BillingInfoContainer = React.memo(
769
773
  return false
770
774
  }
771
775
  }
772
- if (el.name === 'data_capture[wallet_address]') {
773
- if (collectOptionalWalletAddress) {
774
- el.required = false
775
- }
776
+ if (
777
+ el.name === 'data_capture[wallet_address]'
778
+ ) {
776
779
  if (collectMandatoryWalletAddress) {
777
780
  el.required = true
778
781
  }
779
782
  }
780
- if (['street_address', 'country', 'state', 'city', 'zip'].includes(el.name)) {
783
+ if (
784
+ [
785
+ 'street_address',
786
+ 'country',
787
+ 'state',
788
+ 'city',
789
+ 'zip',
790
+ ].includes(el.name)
791
+ ) {
781
792
  if (flagFreeTicket) {
782
793
  el.required = false
783
794
  return false
@@ -791,7 +802,10 @@ export const BillingInfoContainer = React.memo(
791
802
  'confirmPassword',
792
803
  'password-info',
793
804
  ].includes(element.name) &&
794
- isLoggedIn ? null : (
805
+ isLoggedIn ? null : [
806
+ 'data_capture[wallet_address]',
807
+ ].includes(element.name) &&
808
+ hideWalletAddressField ? null : (
795
809
  <React.Fragment key={element.uniqueId}>
796
810
  <div
797
811
  className={`${element.className} ${
@@ -815,13 +829,14 @@ export const BillingInfoContainer = React.memo(
815
829
  ? ''
816
830
  : ' (optional)'
817
831
  } `
818
- : element.name === 'data_capture[wallet_address]'
819
- ? `${element.label}${
820
- collectOptionalWalletAddress
832
+ : element.name ===
833
+ 'data_capture[wallet_address]'
834
+ ? `${element.label}${
835
+ !collectMandatoryWalletAddress
821
836
  ? ' (optional)'
822
837
  : ''
823
838
  } `
824
- : element.label
839
+ : element.label
825
840
  }
826
841
  type={element.type}
827
842
  fill={element.fill}
@@ -1,14 +1,14 @@
1
- import _map from 'lodash/map'
2
- import _get from 'lodash/get'
3
- import _forEach from 'lodash/forEach'
1
+ import { FormikErrors, FormikValues } from 'formik'
4
2
  import _flatMapDeep from 'lodash/flatMapDeep'
3
+ import _forEach from 'lodash/forEach'
4
+ import _get from 'lodash/get'
5
5
  import _isArray from 'lodash/isArray'
6
+ import _map from 'lodash/map'
7
+ import { nanoid } from 'nanoid'
6
8
 
7
- import { CONFIGS } from '../../utils'
8
9
  import { IGroupItem } from '../../types'
10
+ import { CONFIGS } from '../../utils'
9
11
  import { combineValidators, requiredValidator } from '../../validators'
10
- import { nanoid } from 'nanoid'
11
- import { FormikErrors, FormikValues } from 'formik'
12
12
 
13
13
  export interface ILoggedInValues {
14
14
  emailLogged?: string;
@@ -47,7 +47,8 @@ export const getInitialValues = (
47
47
 
48
48
  export const createRegisterFormData = (
49
49
  values: IValues = {},
50
- checkoutBody: { attributes: { [key: string]: any } }
50
+ checkoutBody: { attributes: { [key: string]: any } },
51
+ flagFreeTicket = false
51
52
  ): FormData => {
52
53
  const bodyFormData = new FormData()
53
54
  bodyFormData.append('first_name', values.firstName)
@@ -66,7 +67,9 @@ export const createRegisterFormData = (
66
67
  bodyFormData.append('check_cart_expiration', 'true')
67
68
 
68
69
  _forEach(checkoutBody.attributes, (item: any, key: string) => {
69
- bodyFormData.append(key, item)
70
+ if (!(flagFreeTicket && ['country', 'state', 'city', 'street_address', 'zip'].includes(key))) {
71
+ bodyFormData.append(key, item)
72
+ }
70
73
  })
71
74
 
72
75
  return bodyFormData
@@ -119,7 +122,7 @@ export const createCheckoutDataBody = (
119
122
  ticketsQuantity: number,
120
123
  values: IValues = {},
121
124
  logedInValues: ILoggedInValues = {},
122
- includeDob: boolean = false
125
+ includeDob = false
123
126
  ): ICheckoutBody => {
124
127
  const {
125
128
  firstName,
package/src/.DS_Store DELETED
Binary file
Binary file
@@ -1,96 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- exports.__esModule = true;
50
- exports.PhoneNumberField = void 0;
51
- var TextField_1 = require("@mui/material/TextField");
52
- var debounce_1 = require("lodash/debounce");
53
- var get_1 = require("lodash/get");
54
- var react_1 = require("react");
55
- var api_1 = require("../../api");
56
- exports.PhoneNumberField = function (_a) {
57
- var label = _a.label, _b = _a.type, type = _b === void 0 ? 'text' : _b, field = _a.field, _c = _a.form, errors = _c.errors, setFieldError = _c.setFieldError, setStatus = _c.setStatus;
58
- var error = get_1["default"](errors, field.name);
59
- // eslint-disable-next-line react-hooks/exhaustive-deps
60
- var debounceCb = react_1.useCallback(debounce_1["default"](function (cb) { return void cb(); }, 1000), []);
61
- react_1.useEffect(function () {
62
- var _a;
63
- if (field.value) {
64
- setStatus((_a = {}, _a[field.name] = true, _a));
65
- }
66
- debounceCb(function () { return __awaiter(void 0, void 0, void 0, function () {
67
- var error_1, message;
68
- var _a;
69
- return __generator(this, function (_b) {
70
- switch (_b.label) {
71
- case 0:
72
- _b.trys.push([0, 3, 4, 5]);
73
- if (!field.value) return [3 /*break*/, 2];
74
- return [4 /*yield*/, api_1.validatePhoneNumber(field.value)];
75
- case 1:
76
- _b.sent();
77
- _b.label = 2;
78
- case 2:
79
- setFieldError(field.name, '');
80
- return [3 /*break*/, 5];
81
- case 3:
82
- error_1 = _b.sent();
83
- message = get_1["default"](error_1, 'response.data.message', 'Invalid phone number');
84
- setFieldError(field.name, message);
85
- return [3 /*break*/, 5];
86
- case 4:
87
- setStatus((_a = {}, _a[field.name] = false, _a));
88
- return [7 /*endfinally*/];
89
- case 5: return [2 /*return*/];
90
- }
91
- });
92
- }); });
93
- // eslint-disable-next-line
94
- }, [field.value]);
95
- return (react_1["default"].createElement(TextField_1["default"], __assign({}, field, { id: field.name, label: label, type: type, fullWidth: true, error: !!error, helperText: error, value: field.value || '', inputProps: { pattern: '[+0-9]/d+' } })));
96
- };