tf-checkout-react 1.0.51 → 1.0.55
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/dist/components/billing-info-container/utils.d.ts +5 -1
- package/dist/components/common/CustomField.d.ts +1 -1
- package/dist/tf-checkout-react.cjs.development.js +78 -53
- package/dist/tf-checkout-react.cjs.development.js.map +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
- package/dist/tf-checkout-react.esm.js +78 -53
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/billing-info-container/index.tsx +58 -80
- package/src/components/billing-info-container/utils.ts +9 -1
- package/src/components/common/CustomField.tsx +2 -4
- package/src/components/common/SelectField.tsx +1 -1
- package/src/components/paymentContainer/index.tsx +1 -0
- package/src/components/stripePayment/index.tsx +31 -3
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
|
@@ -1555,7 +1555,7 @@ var getInitialValues = function getInitialValues(data, propsInitialValues, userV
|
|
|
1555
1555
|
|
|
1556
1556
|
return initialValues;
|
|
1557
1557
|
};
|
|
1558
|
-
var createRegisterFormData = function createRegisterFormData(values) {
|
|
1558
|
+
var createRegisterFormData = function createRegisterFormData(values, checkoutBody) {
|
|
1559
1559
|
if (values === void 0) {
|
|
1560
1560
|
values = {};
|
|
1561
1561
|
}
|
|
@@ -1568,6 +1568,11 @@ var createRegisterFormData = function createRegisterFormData(values) {
|
|
|
1568
1568
|
bodyFormData.append('password_confirmation', values.confirmPassword);
|
|
1569
1569
|
bodyFormData.append('client_id', ENV.CLIENT_ID );
|
|
1570
1570
|
bodyFormData.append('client_secret', ENV.CLIENT_SECRET );
|
|
1571
|
+
|
|
1572
|
+
_forEach(checkoutBody.attributes, function (item, key) {
|
|
1573
|
+
bodyFormData.append(key, item);
|
|
1574
|
+
});
|
|
1575
|
+
|
|
1571
1576
|
return bodyFormData;
|
|
1572
1577
|
};
|
|
1573
1578
|
var setLoggedUserData = function setLoggedUserData(data) {
|
|
@@ -1707,13 +1712,13 @@ var CustomField = function CustomField(_ref) {
|
|
|
1707
1712
|
_ref$form = _ref.form,
|
|
1708
1713
|
touched = _ref$form.touched,
|
|
1709
1714
|
errors = _ref$form.errors,
|
|
1715
|
+
submitCount = _ref$form.submitCount,
|
|
1710
1716
|
theme = _ref.theme;
|
|
1711
1717
|
var isSelectField = type === 'select';
|
|
1712
|
-
var isShrink = Boolean(field.value) || type === 'date' || type === 'select';
|
|
1713
1718
|
|
|
1714
1719
|
var error = _get(errors, field.name);
|
|
1715
1720
|
|
|
1716
|
-
var isTouched = Boolean(_get(touched, field.name)) || _includes(field.name, 'holder') && !!error;
|
|
1721
|
+
var isTouched = Boolean(_get(touched, field.name)) || _includes(field.name, 'holder') && !!error && !!submitCount;
|
|
1717
1722
|
var classes = useStyles();
|
|
1718
1723
|
return React.createElement(TextField$1, Object.assign({
|
|
1719
1724
|
id: field.name,
|
|
@@ -1723,9 +1728,6 @@ var CustomField = function CustomField(_ref) {
|
|
|
1723
1728
|
fullWidth: true,
|
|
1724
1729
|
error: !!error && isTouched,
|
|
1725
1730
|
helperText: isTouched && error,
|
|
1726
|
-
InputLabelProps: {
|
|
1727
|
-
shrink: isShrink
|
|
1728
|
-
},
|
|
1729
1731
|
InputProps: {
|
|
1730
1732
|
classes: {
|
|
1731
1733
|
input: classes.input
|
|
@@ -1803,7 +1805,8 @@ var SelectField = function SelectField(_ref) {
|
|
|
1803
1805
|
fullWidth: true
|
|
1804
1806
|
}, React.createElement(InputLabel, {
|
|
1805
1807
|
htmlFor: field.name,
|
|
1806
|
-
error: !!error && isTouched
|
|
1808
|
+
error: !!error && isTouched,
|
|
1809
|
+
shrink: true
|
|
1807
1810
|
}, label), React.createElement(Select, Object.assign({
|
|
1808
1811
|
id: field.name,
|
|
1809
1812
|
label: label,
|
|
@@ -2074,7 +2077,6 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2074
2077
|
var lastNameLogged = _get(userData, 'last_name', '') || _get(userValues, 'last_name', '');
|
|
2075
2078
|
|
|
2076
2079
|
var showDOB = getQueryVariable('age_required') === 'true';
|
|
2077
|
-
var showTicketHolderName = getQueryVariable('names_required') === 'true';
|
|
2078
2080
|
var eventId = getQueryVariable('event_id');
|
|
2079
2081
|
|
|
2080
2082
|
var optedInFieldValue = _get(cartInfoData, 'optedIn', false);
|
|
@@ -2260,7 +2262,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2260
2262
|
enableReinitialize: true,
|
|
2261
2263
|
onSubmit: function () {
|
|
2262
2264
|
var _onSubmit = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(values, formikHelpers) {
|
|
2263
|
-
var updatedUserData, _profileSpecifiedData, _profileDataObj, _checkoutBody, _res, bodyFormData, access_token_register, resRegister, refreshToken, tokens, _e$response, _e$response$data, error, profileData, profileSpecifiedData, profileDataObj, checkoutBody, res, _e$response2;
|
|
2265
|
+
var updatedUserData, _profileSpecifiedData, _profileDataObj, _checkoutBody, _res, checkoutBodyForRegistration, bodyFormData, access_token_register, resRegister, refreshToken, tokens, _e$response, _e$response$data, error, profileData, profileSpecifiedData, profileDataObj, checkoutBody, res, _e$response2;
|
|
2264
2266
|
|
|
2265
2267
|
return runtime_1.wrap(function _callee5$(_context5) {
|
|
2266
2268
|
while (1) {
|
|
@@ -2305,13 +2307,18 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2305
2307
|
return _context5.abrupt("return");
|
|
2306
2308
|
|
|
2307
2309
|
case 15:
|
|
2308
|
-
|
|
2310
|
+
checkoutBodyForRegistration = createCheckoutDataBody(ticketsQuantity.length, values, {
|
|
2311
|
+
emailLogged: emailLogged,
|
|
2312
|
+
firstNameLogged: firstNameLogged,
|
|
2313
|
+
lastNameLogged: lastNameLogged
|
|
2314
|
+
}, showDOB);
|
|
2315
|
+
bodyFormData = createRegisterFormData(values, checkoutBodyForRegistration);
|
|
2309
2316
|
access_token_register = null;
|
|
2310
|
-
_context5.prev =
|
|
2311
|
-
_context5.next =
|
|
2317
|
+
_context5.prev = 18;
|
|
2318
|
+
_context5.next = 21;
|
|
2312
2319
|
return register(bodyFormData);
|
|
2313
2320
|
|
|
2314
|
-
case
|
|
2321
|
+
case 21:
|
|
2315
2322
|
resRegister = _context5.sent;
|
|
2316
2323
|
access_token_register = _get(resRegister, 'data.data.attributes.access_token');
|
|
2317
2324
|
refreshToken = _get(resRegister, 'data.data.attributes.refresh_token');
|
|
@@ -2321,12 +2328,12 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2321
2328
|
refreshToken: refreshToken
|
|
2322
2329
|
};
|
|
2323
2330
|
onRegisterSuccess(tokens);
|
|
2324
|
-
_context5.next =
|
|
2331
|
+
_context5.next = 33;
|
|
2325
2332
|
break;
|
|
2326
2333
|
|
|
2327
|
-
case
|
|
2328
|
-
_context5.prev =
|
|
2329
|
-
_context5.t0 = _context5["catch"](
|
|
2334
|
+
case 29:
|
|
2335
|
+
_context5.prev = 29;
|
|
2336
|
+
_context5.t0 = _context5["catch"](18);
|
|
2330
2337
|
|
|
2331
2338
|
if (axios.isAxiosError(_context5.t0)) {
|
|
2332
2339
|
error = _context5.t0 == null ? void 0 : (_e$response = _context5.t0.response) == null ? void 0 : (_e$response$data = _e$response.data) == null ? void 0 : _e$response$data.message;
|
|
@@ -2350,11 +2357,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2350
2357
|
|
|
2351
2358
|
return _context5.abrupt("return");
|
|
2352
2359
|
|
|
2353
|
-
case
|
|
2354
|
-
_context5.next =
|
|
2360
|
+
case 33:
|
|
2361
|
+
_context5.next = 35;
|
|
2355
2362
|
return getProfileData(access_token_register);
|
|
2356
2363
|
|
|
2357
|
-
case
|
|
2364
|
+
case 35:
|
|
2358
2365
|
profileData = _context5.sent;
|
|
2359
2366
|
profileSpecifiedData = _get(profileData, 'data.data');
|
|
2360
2367
|
profileDataObj = setLoggedUserData(profileSpecifiedData);
|
|
@@ -2368,17 +2375,17 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2368
2375
|
firstNameLogged: firstNameLogged,
|
|
2369
2376
|
lastNameLogged: lastNameLogged
|
|
2370
2377
|
}, showDOB);
|
|
2371
|
-
_context5.next =
|
|
2378
|
+
_context5.next = 42;
|
|
2372
2379
|
return postOnCheckout(checkoutBody, access_token_register);
|
|
2373
2380
|
|
|
2374
|
-
case
|
|
2381
|
+
case 42:
|
|
2375
2382
|
res = _context5.sent;
|
|
2376
2383
|
handleSubmit(values, formikHelpers, eventId, res);
|
|
2377
|
-
_context5.next =
|
|
2384
|
+
_context5.next = 49;
|
|
2378
2385
|
break;
|
|
2379
2386
|
|
|
2380
|
-
case
|
|
2381
|
-
_context5.prev =
|
|
2387
|
+
case 46:
|
|
2388
|
+
_context5.prev = 46;
|
|
2382
2389
|
_context5.t1 = _context5["catch"](0);
|
|
2383
2390
|
|
|
2384
2391
|
if (axios.isAxiosError(_context5.t1)) {
|
|
@@ -2394,12 +2401,12 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2394
2401
|
onSubmitError(_context5.t1);
|
|
2395
2402
|
}
|
|
2396
2403
|
|
|
2397
|
-
case
|
|
2404
|
+
case 49:
|
|
2398
2405
|
case "end":
|
|
2399
2406
|
return _context5.stop();
|
|
2400
2407
|
}
|
|
2401
2408
|
}
|
|
2402
|
-
}, _callee5, null, [[0,
|
|
2409
|
+
}, _callee5, null, [[0, 46], [18, 29]]);
|
|
2403
2410
|
}));
|
|
2404
2411
|
|
|
2405
2412
|
function onSubmit(_x2, _x3) {
|
|
@@ -2436,35 +2443,18 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2436
2443
|
var label = item.label,
|
|
2437
2444
|
labelClassName = item.labelClassName,
|
|
2438
2445
|
fields = item.fields;
|
|
2439
|
-
|
|
2440
|
-
if (label === 'Ticket Holders' && !showTicketHolderName && !showDOB) {
|
|
2441
|
-
return null;
|
|
2442
|
-
}
|
|
2443
|
-
|
|
2444
2446
|
return React.createElement(React.Fragment, {
|
|
2445
2447
|
key: item.uniqueId
|
|
2446
2448
|
}, React.createElement("p", {
|
|
2447
2449
|
className: labelClassName
|
|
2448
2450
|
}, label), _map(fields, function (group) {
|
|
2449
2451
|
var groupClassname = group.groupClassname,
|
|
2450
|
-
groupItems = group.groupItems
|
|
2451
|
-
groupLabel = group.groupLabel,
|
|
2452
|
-
groupLabelClassName = group.groupLabelClassName;
|
|
2452
|
+
groupItems = group.groupItems;
|
|
2453
2453
|
return React.createElement(React.Fragment, {
|
|
2454
2454
|
key: group.uniqueId
|
|
2455
|
-
},
|
|
2456
|
-
className: groupLabelClassName
|
|
2457
|
-
}, groupLabel), React.createElement("div", {
|
|
2455
|
+
}, React.createElement("div", {
|
|
2458
2456
|
className: groupClassname
|
|
2459
2457
|
}, _map(groupItems.filter(function (el) {
|
|
2460
|
-
if (el.name === 'holderFirstName' && !showTicketHolderName) {
|
|
2461
|
-
return false;
|
|
2462
|
-
}
|
|
2463
|
-
|
|
2464
|
-
if (el.name === 'holderLastName' && !showTicketHolderName) {
|
|
2465
|
-
return false;
|
|
2466
|
-
}
|
|
2467
|
-
|
|
2468
2458
|
if (el.name === 'holderAge' && !showDOB) {
|
|
2469
2459
|
return false;
|
|
2470
2460
|
}
|
|
@@ -2475,7 +2465,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2475
2465
|
|
|
2476
2466
|
return true;
|
|
2477
2467
|
}), function (element) {
|
|
2478
|
-
return ['password', 'confirmPassword'].includes(element.name) && isLoggedIn ? null : React.createElement(React.Fragment, {
|
|
2468
|
+
return ['password', 'confirmPassword', 'password-info'].includes(element.name) && isLoggedIn ? null : React.createElement(React.Fragment, {
|
|
2479
2469
|
key: element.uniqueId
|
|
2480
2470
|
}, element.name === 'email' ? React.createElement("div", {
|
|
2481
2471
|
className: "email-checking"
|
|
@@ -2492,7 +2482,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2492
2482
|
})));
|
|
2493
2483
|
})));
|
|
2494
2484
|
}));
|
|
2495
|
-
}),
|
|
2485
|
+
}), React.createElement("div", {
|
|
2496
2486
|
className: "ticket-holders-fields"
|
|
2497
2487
|
}, React.createElement("p", null, ticketHoldersFields.label), _map(ticketsQuantity, function (_item, index) {
|
|
2498
2488
|
return React.createElement("div", {
|
|
@@ -2518,7 +2508,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2518
2508
|
}));
|
|
2519
2509
|
})));
|
|
2520
2510
|
}));
|
|
2521
|
-
}))
|
|
2511
|
+
})), React.createElement("div", {
|
|
2522
2512
|
className: "button-container"
|
|
2523
2513
|
}, React.createElement(LoadingButton, {
|
|
2524
2514
|
type: "submit",
|
|
@@ -2675,6 +2665,14 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
2675
2665
|
stripeError = _useState2[0],
|
|
2676
2666
|
setStripeError = _useState2[1];
|
|
2677
2667
|
|
|
2668
|
+
var _useState3 = useState([]),
|
|
2669
|
+
checkboxes = _useState3[0],
|
|
2670
|
+
setCheckboxes = _useState3[1];
|
|
2671
|
+
|
|
2672
|
+
var _useState4 = useState(false),
|
|
2673
|
+
allowSubmit = _useState4[0],
|
|
2674
|
+
setAllowSubmit = _useState4[1];
|
|
2675
|
+
|
|
2678
2676
|
var handleSubmit = /*#__PURE__*/function () {
|
|
2679
2677
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(event) {
|
|
2680
2678
|
var card, address, paymentMethodReq, _yield$stripe$confirm, _error;
|
|
@@ -2780,6 +2778,17 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
2780
2778
|
};
|
|
2781
2779
|
}();
|
|
2782
2780
|
|
|
2781
|
+
var handleCheckboxes = function handleCheckboxes(e) {
|
|
2782
|
+
var checkbox = e.target;
|
|
2783
|
+
var updatedCheckedState = checkboxes.map(function (item) {
|
|
2784
|
+
var value = item.id === checkbox.name ? !item.checked : item.checked;
|
|
2785
|
+
return _extends({}, item, {
|
|
2786
|
+
checked: value
|
|
2787
|
+
});
|
|
2788
|
+
});
|
|
2789
|
+
setCheckboxes(updatedCheckedState);
|
|
2790
|
+
};
|
|
2791
|
+
|
|
2783
2792
|
var onChangePostalCode = function onChangePostalCode(e) {
|
|
2784
2793
|
setPostalCode(e.target.value);
|
|
2785
2794
|
};
|
|
@@ -2793,6 +2802,19 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
2793
2802
|
zipCode && setPostalCode(zipCode);
|
|
2794
2803
|
}
|
|
2795
2804
|
}, []);
|
|
2805
|
+
useEffect(function () {
|
|
2806
|
+
if (conditions.length) {
|
|
2807
|
+
setCheckboxes(conditions);
|
|
2808
|
+
}
|
|
2809
|
+
}, [conditions]);
|
|
2810
|
+
useEffect(function () {
|
|
2811
|
+
if (checkboxes.length) {
|
|
2812
|
+
var allChecked = checkboxes.every(function (item) {
|
|
2813
|
+
return (item == null ? void 0 : item.checked) === true;
|
|
2814
|
+
});
|
|
2815
|
+
setAllowSubmit(allChecked);
|
|
2816
|
+
}
|
|
2817
|
+
}, [checkboxes]);
|
|
2796
2818
|
var buttonIsDiabled = !stripe || !!error || isLoading;
|
|
2797
2819
|
return React.createElement("div", {
|
|
2798
2820
|
className: "stripe_payment_container"
|
|
@@ -2833,7 +2855,7 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
2833
2855
|
value: postalCode,
|
|
2834
2856
|
onChange: onChangePostalCode,
|
|
2835
2857
|
placeholder: "ZIP"
|
|
2836
|
-
}))),
|
|
2858
|
+
}))), checkboxes == null ? void 0 : checkboxes.map(function (checkbox) {
|
|
2837
2859
|
return React.createElement("div", {
|
|
2838
2860
|
className: 'billing-info-container__singleField',
|
|
2839
2861
|
key: checkbox.id
|
|
@@ -2842,10 +2864,12 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
2842
2864
|
}, React.createElement(CheckboxField, {
|
|
2843
2865
|
name: checkbox.id,
|
|
2844
2866
|
label: checkbox.text,
|
|
2845
|
-
required: true
|
|
2867
|
+
required: true,
|
|
2868
|
+
onChange: handleCheckboxes,
|
|
2869
|
+
checked: checkbox.checked
|
|
2846
2870
|
})));
|
|
2847
2871
|
}), React.createElement("div", {
|
|
2848
|
-
className: "payment_button " + (buttonIsDiabled ? 'disabled-payment-button' : '')
|
|
2872
|
+
className: "payment_button " + (buttonIsDiabled || !allowSubmit ? 'disabled-payment-button' : '')
|
|
2849
2873
|
}, React.createElement("button", {
|
|
2850
2874
|
disabled: buttonIsDiabled,
|
|
2851
2875
|
type: "submit"
|
|
@@ -2987,7 +3011,8 @@ var PaymentContainer = function PaymentContainer(_ref) {
|
|
|
2987
3011
|
setConditions(conditionsInfo ? conditionsInfo.map(function (item) {
|
|
2988
3012
|
return {
|
|
2989
3013
|
id: nanoid(),
|
|
2990
|
-
text: item
|
|
3014
|
+
text: item,
|
|
3015
|
+
checked: false
|
|
2991
3016
|
};
|
|
2992
3017
|
}) : []);
|
|
2993
3018
|
|