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
|
@@ -8,7 +8,11 @@ export interface IValues {
|
|
|
8
8
|
[key: string]: any;
|
|
9
9
|
}
|
|
10
10
|
export declare const getInitialValues: (data?: any, propsInitialValues?: IValues, userValues?: any) => IValues;
|
|
11
|
-
export declare const createRegisterFormData: (values
|
|
11
|
+
export declare const createRegisterFormData: (values: IValues | undefined, checkoutBody: {
|
|
12
|
+
attributes: {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
};
|
|
15
|
+
}) => FormData;
|
|
12
16
|
interface ICheckoutBody {
|
|
13
17
|
attributes: {
|
|
14
18
|
[key: string]: any;
|
|
@@ -16,5 +16,5 @@ export interface ICustomField {
|
|
|
16
16
|
interface IOtherProps {
|
|
17
17
|
[key: string]: any;
|
|
18
18
|
}
|
|
19
|
-
export declare const CustomField: ({ label, type, field, selectOptions, form: { touched, errors }, theme, }: ICustomField & IOtherProps) => JSX.Element;
|
|
19
|
+
export declare const CustomField: ({ label, type, field, selectOptions, form: { touched, errors, submitCount }, theme, }: ICustomField & IOtherProps) => JSX.Element;
|
|
20
20
|
export {};
|
|
@@ -1526,7 +1526,7 @@ var getInitialValues = function getInitialValues(data, propsInitialValues, userV
|
|
|
1526
1526
|
|
|
1527
1527
|
return initialValues;
|
|
1528
1528
|
};
|
|
1529
|
-
var createRegisterFormData = function createRegisterFormData(values) {
|
|
1529
|
+
var createRegisterFormData = function createRegisterFormData(values, checkoutBody) {
|
|
1530
1530
|
if (values === void 0) {
|
|
1531
1531
|
values = {};
|
|
1532
1532
|
}
|
|
@@ -1539,6 +1539,11 @@ var createRegisterFormData = function createRegisterFormData(values) {
|
|
|
1539
1539
|
bodyFormData.append('password_confirmation', values.confirmPassword);
|
|
1540
1540
|
bodyFormData.append('client_id', ENV.CLIENT_ID );
|
|
1541
1541
|
bodyFormData.append('client_secret', ENV.CLIENT_SECRET );
|
|
1542
|
+
|
|
1543
|
+
_forEach(checkoutBody.attributes, function (item, key) {
|
|
1544
|
+
bodyFormData.append(key, item);
|
|
1545
|
+
});
|
|
1546
|
+
|
|
1542
1547
|
return bodyFormData;
|
|
1543
1548
|
};
|
|
1544
1549
|
var setLoggedUserData = function setLoggedUserData(data) {
|
|
@@ -1678,13 +1683,13 @@ var CustomField = function CustomField(_ref) {
|
|
|
1678
1683
|
_ref$form = _ref.form,
|
|
1679
1684
|
touched = _ref$form.touched,
|
|
1680
1685
|
errors = _ref$form.errors,
|
|
1686
|
+
submitCount = _ref$form.submitCount,
|
|
1681
1687
|
theme = _ref.theme;
|
|
1682
1688
|
var isSelectField = type === 'select';
|
|
1683
|
-
var isShrink = Boolean(field.value) || type === 'date' || type === 'select';
|
|
1684
1689
|
|
|
1685
1690
|
var error = _get(errors, field.name);
|
|
1686
1691
|
|
|
1687
|
-
var isTouched = Boolean(_get(touched, field.name)) || _includes(field.name, 'holder') && !!error;
|
|
1692
|
+
var isTouched = Boolean(_get(touched, field.name)) || _includes(field.name, 'holder') && !!error && !!submitCount;
|
|
1688
1693
|
var classes = useStyles();
|
|
1689
1694
|
return React__default.createElement(TextField, Object.assign({
|
|
1690
1695
|
id: field.name,
|
|
@@ -1694,9 +1699,6 @@ var CustomField = function CustomField(_ref) {
|
|
|
1694
1699
|
fullWidth: true,
|
|
1695
1700
|
error: !!error && isTouched,
|
|
1696
1701
|
helperText: isTouched && error,
|
|
1697
|
-
InputLabelProps: {
|
|
1698
|
-
shrink: isShrink
|
|
1699
|
-
},
|
|
1700
1702
|
InputProps: {
|
|
1701
1703
|
classes: {
|
|
1702
1704
|
input: classes.input
|
|
@@ -1774,7 +1776,8 @@ var SelectField = function SelectField(_ref) {
|
|
|
1774
1776
|
fullWidth: true
|
|
1775
1777
|
}, React__default.createElement(material.InputLabel, {
|
|
1776
1778
|
htmlFor: field.name,
|
|
1777
|
-
error: !!error && isTouched
|
|
1779
|
+
error: !!error && isTouched,
|
|
1780
|
+
shrink: true
|
|
1778
1781
|
}, label), React__default.createElement(Select, Object.assign({
|
|
1779
1782
|
id: field.name,
|
|
1780
1783
|
label: label,
|
|
@@ -2045,7 +2048,6 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2045
2048
|
var lastNameLogged = _get(userData, 'last_name', '') || _get(userValues, 'last_name', '');
|
|
2046
2049
|
|
|
2047
2050
|
var showDOB = getQueryVariable('age_required') === 'true';
|
|
2048
|
-
var showTicketHolderName = getQueryVariable('names_required') === 'true';
|
|
2049
2051
|
var eventId = getQueryVariable('event_id');
|
|
2050
2052
|
|
|
2051
2053
|
var optedInFieldValue = _get(cartInfoData, 'optedIn', false);
|
|
@@ -2231,7 +2233,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2231
2233
|
enableReinitialize: true,
|
|
2232
2234
|
onSubmit: function () {
|
|
2233
2235
|
var _onSubmit = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(values, formikHelpers) {
|
|
2234
|
-
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;
|
|
2236
|
+
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;
|
|
2235
2237
|
|
|
2236
2238
|
return runtime_1.wrap(function _callee5$(_context5) {
|
|
2237
2239
|
while (1) {
|
|
@@ -2276,13 +2278,18 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2276
2278
|
return _context5.abrupt("return");
|
|
2277
2279
|
|
|
2278
2280
|
case 15:
|
|
2279
|
-
|
|
2281
|
+
checkoutBodyForRegistration = createCheckoutDataBody(ticketsQuantity.length, values, {
|
|
2282
|
+
emailLogged: emailLogged,
|
|
2283
|
+
firstNameLogged: firstNameLogged,
|
|
2284
|
+
lastNameLogged: lastNameLogged
|
|
2285
|
+
}, showDOB);
|
|
2286
|
+
bodyFormData = createRegisterFormData(values, checkoutBodyForRegistration);
|
|
2280
2287
|
access_token_register = null;
|
|
2281
|
-
_context5.prev =
|
|
2282
|
-
_context5.next =
|
|
2288
|
+
_context5.prev = 18;
|
|
2289
|
+
_context5.next = 21;
|
|
2283
2290
|
return register(bodyFormData);
|
|
2284
2291
|
|
|
2285
|
-
case
|
|
2292
|
+
case 21:
|
|
2286
2293
|
resRegister = _context5.sent;
|
|
2287
2294
|
access_token_register = _get(resRegister, 'data.data.attributes.access_token');
|
|
2288
2295
|
refreshToken = _get(resRegister, 'data.data.attributes.refresh_token');
|
|
@@ -2292,12 +2299,12 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2292
2299
|
refreshToken: refreshToken
|
|
2293
2300
|
};
|
|
2294
2301
|
onRegisterSuccess(tokens);
|
|
2295
|
-
_context5.next =
|
|
2302
|
+
_context5.next = 33;
|
|
2296
2303
|
break;
|
|
2297
2304
|
|
|
2298
|
-
case
|
|
2299
|
-
_context5.prev =
|
|
2300
|
-
_context5.t0 = _context5["catch"](
|
|
2305
|
+
case 29:
|
|
2306
|
+
_context5.prev = 29;
|
|
2307
|
+
_context5.t0 = _context5["catch"](18);
|
|
2301
2308
|
|
|
2302
2309
|
if (axios.isAxiosError(_context5.t0)) {
|
|
2303
2310
|
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;
|
|
@@ -2321,11 +2328,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2321
2328
|
|
|
2322
2329
|
return _context5.abrupt("return");
|
|
2323
2330
|
|
|
2324
|
-
case
|
|
2325
|
-
_context5.next =
|
|
2331
|
+
case 33:
|
|
2332
|
+
_context5.next = 35;
|
|
2326
2333
|
return getProfileData(access_token_register);
|
|
2327
2334
|
|
|
2328
|
-
case
|
|
2335
|
+
case 35:
|
|
2329
2336
|
profileData = _context5.sent;
|
|
2330
2337
|
profileSpecifiedData = _get(profileData, 'data.data');
|
|
2331
2338
|
profileDataObj = setLoggedUserData(profileSpecifiedData);
|
|
@@ -2339,17 +2346,17 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2339
2346
|
firstNameLogged: firstNameLogged,
|
|
2340
2347
|
lastNameLogged: lastNameLogged
|
|
2341
2348
|
}, showDOB);
|
|
2342
|
-
_context5.next =
|
|
2349
|
+
_context5.next = 42;
|
|
2343
2350
|
return postOnCheckout(checkoutBody, access_token_register);
|
|
2344
2351
|
|
|
2345
|
-
case
|
|
2352
|
+
case 42:
|
|
2346
2353
|
res = _context5.sent;
|
|
2347
2354
|
handleSubmit(values, formikHelpers, eventId, res);
|
|
2348
|
-
_context5.next =
|
|
2355
|
+
_context5.next = 49;
|
|
2349
2356
|
break;
|
|
2350
2357
|
|
|
2351
|
-
case
|
|
2352
|
-
_context5.prev =
|
|
2358
|
+
case 46:
|
|
2359
|
+
_context5.prev = 46;
|
|
2353
2360
|
_context5.t1 = _context5["catch"](0);
|
|
2354
2361
|
|
|
2355
2362
|
if (axios.isAxiosError(_context5.t1)) {
|
|
@@ -2365,12 +2372,12 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2365
2372
|
onSubmitError(_context5.t1);
|
|
2366
2373
|
}
|
|
2367
2374
|
|
|
2368
|
-
case
|
|
2375
|
+
case 49:
|
|
2369
2376
|
case "end":
|
|
2370
2377
|
return _context5.stop();
|
|
2371
2378
|
}
|
|
2372
2379
|
}
|
|
2373
|
-
}, _callee5, null, [[0,
|
|
2380
|
+
}, _callee5, null, [[0, 46], [18, 29]]);
|
|
2374
2381
|
}));
|
|
2375
2382
|
|
|
2376
2383
|
function onSubmit(_x2, _x3) {
|
|
@@ -2407,35 +2414,18 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2407
2414
|
var label = item.label,
|
|
2408
2415
|
labelClassName = item.labelClassName,
|
|
2409
2416
|
fields = item.fields;
|
|
2410
|
-
|
|
2411
|
-
if (label === 'Ticket Holders' && !showTicketHolderName && !showDOB) {
|
|
2412
|
-
return null;
|
|
2413
|
-
}
|
|
2414
|
-
|
|
2415
2417
|
return React__default.createElement(React__default.Fragment, {
|
|
2416
2418
|
key: item.uniqueId
|
|
2417
2419
|
}, React__default.createElement("p", {
|
|
2418
2420
|
className: labelClassName
|
|
2419
2421
|
}, label), _map(fields, function (group) {
|
|
2420
2422
|
var groupClassname = group.groupClassname,
|
|
2421
|
-
groupItems = group.groupItems
|
|
2422
|
-
groupLabel = group.groupLabel,
|
|
2423
|
-
groupLabelClassName = group.groupLabelClassName;
|
|
2423
|
+
groupItems = group.groupItems;
|
|
2424
2424
|
return React__default.createElement(React__default.Fragment, {
|
|
2425
2425
|
key: group.uniqueId
|
|
2426
|
-
},
|
|
2427
|
-
className: groupLabelClassName
|
|
2428
|
-
}, groupLabel), React__default.createElement("div", {
|
|
2426
|
+
}, React__default.createElement("div", {
|
|
2429
2427
|
className: groupClassname
|
|
2430
2428
|
}, _map(groupItems.filter(function (el) {
|
|
2431
|
-
if (el.name === 'holderFirstName' && !showTicketHolderName) {
|
|
2432
|
-
return false;
|
|
2433
|
-
}
|
|
2434
|
-
|
|
2435
|
-
if (el.name === 'holderLastName' && !showTicketHolderName) {
|
|
2436
|
-
return false;
|
|
2437
|
-
}
|
|
2438
|
-
|
|
2439
2429
|
if (el.name === 'holderAge' && !showDOB) {
|
|
2440
2430
|
return false;
|
|
2441
2431
|
}
|
|
@@ -2446,7 +2436,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2446
2436
|
|
|
2447
2437
|
return true;
|
|
2448
2438
|
}), function (element) {
|
|
2449
|
-
return ['password', 'confirmPassword'].includes(element.name) && isLoggedIn ? null : React__default.createElement(React__default.Fragment, {
|
|
2439
|
+
return ['password', 'confirmPassword', 'password-info'].includes(element.name) && isLoggedIn ? null : React__default.createElement(React__default.Fragment, {
|
|
2450
2440
|
key: element.uniqueId
|
|
2451
2441
|
}, element.name === 'email' ? React__default.createElement("div", {
|
|
2452
2442
|
className: "email-checking"
|
|
@@ -2463,7 +2453,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2463
2453
|
})));
|
|
2464
2454
|
})));
|
|
2465
2455
|
}));
|
|
2466
|
-
}),
|
|
2456
|
+
}), React__default.createElement("div", {
|
|
2467
2457
|
className: "ticket-holders-fields"
|
|
2468
2458
|
}, React__default.createElement("p", null, ticketHoldersFields.label), _map(ticketsQuantity, function (_item, index) {
|
|
2469
2459
|
return React__default.createElement("div", {
|
|
@@ -2489,7 +2479,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2489
2479
|
}));
|
|
2490
2480
|
})));
|
|
2491
2481
|
}));
|
|
2492
|
-
}))
|
|
2482
|
+
})), React__default.createElement("div", {
|
|
2493
2483
|
className: "button-container"
|
|
2494
2484
|
}, React__default.createElement(LoadingButton, {
|
|
2495
2485
|
type: "submit",
|
|
@@ -2640,6 +2630,14 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
2640
2630
|
stripeError = _useState2[0],
|
|
2641
2631
|
setStripeError = _useState2[1];
|
|
2642
2632
|
|
|
2633
|
+
var _useState3 = React.useState([]),
|
|
2634
|
+
checkboxes = _useState3[0],
|
|
2635
|
+
setCheckboxes = _useState3[1];
|
|
2636
|
+
|
|
2637
|
+
var _useState4 = React.useState(false),
|
|
2638
|
+
allowSubmit = _useState4[0],
|
|
2639
|
+
setAllowSubmit = _useState4[1];
|
|
2640
|
+
|
|
2643
2641
|
var handleSubmit = /*#__PURE__*/function () {
|
|
2644
2642
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(event) {
|
|
2645
2643
|
var card, address, paymentMethodReq, _yield$stripe$confirm, _error;
|
|
@@ -2745,6 +2743,17 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
2745
2743
|
};
|
|
2746
2744
|
}();
|
|
2747
2745
|
|
|
2746
|
+
var handleCheckboxes = function handleCheckboxes(e) {
|
|
2747
|
+
var checkbox = e.target;
|
|
2748
|
+
var updatedCheckedState = checkboxes.map(function (item) {
|
|
2749
|
+
var value = item.id === checkbox.name ? !item.checked : item.checked;
|
|
2750
|
+
return _extends({}, item, {
|
|
2751
|
+
checked: value
|
|
2752
|
+
});
|
|
2753
|
+
});
|
|
2754
|
+
setCheckboxes(updatedCheckedState);
|
|
2755
|
+
};
|
|
2756
|
+
|
|
2748
2757
|
var onChangePostalCode = function onChangePostalCode(e) {
|
|
2749
2758
|
setPostalCode(e.target.value);
|
|
2750
2759
|
};
|
|
@@ -2758,6 +2767,19 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
2758
2767
|
zipCode && setPostalCode(zipCode);
|
|
2759
2768
|
}
|
|
2760
2769
|
}, []);
|
|
2770
|
+
React.useEffect(function () {
|
|
2771
|
+
if (conditions.length) {
|
|
2772
|
+
setCheckboxes(conditions);
|
|
2773
|
+
}
|
|
2774
|
+
}, [conditions]);
|
|
2775
|
+
React.useEffect(function () {
|
|
2776
|
+
if (checkboxes.length) {
|
|
2777
|
+
var allChecked = checkboxes.every(function (item) {
|
|
2778
|
+
return (item == null ? void 0 : item.checked) === true;
|
|
2779
|
+
});
|
|
2780
|
+
setAllowSubmit(allChecked);
|
|
2781
|
+
}
|
|
2782
|
+
}, [checkboxes]);
|
|
2761
2783
|
var buttonIsDiabled = !stripe || !!error || isLoading;
|
|
2762
2784
|
return React__default.createElement("div", {
|
|
2763
2785
|
className: "stripe_payment_container"
|
|
@@ -2798,7 +2820,7 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
2798
2820
|
value: postalCode,
|
|
2799
2821
|
onChange: onChangePostalCode,
|
|
2800
2822
|
placeholder: "ZIP"
|
|
2801
|
-
}))),
|
|
2823
|
+
}))), checkboxes == null ? void 0 : checkboxes.map(function (checkbox) {
|
|
2802
2824
|
return React__default.createElement("div", {
|
|
2803
2825
|
className: 'billing-info-container__singleField',
|
|
2804
2826
|
key: checkbox.id
|
|
@@ -2807,10 +2829,12 @@ var CheckoutForm = function CheckoutForm(_ref) {
|
|
|
2807
2829
|
}, React__default.createElement(CheckboxField, {
|
|
2808
2830
|
name: checkbox.id,
|
|
2809
2831
|
label: checkbox.text,
|
|
2810
|
-
required: true
|
|
2832
|
+
required: true,
|
|
2833
|
+
onChange: handleCheckboxes,
|
|
2834
|
+
checked: checkbox.checked
|
|
2811
2835
|
})));
|
|
2812
2836
|
}), React__default.createElement("div", {
|
|
2813
|
-
className: "payment_button " + (buttonIsDiabled ? 'disabled-payment-button' : '')
|
|
2837
|
+
className: "payment_button " + (buttonIsDiabled || !allowSubmit ? 'disabled-payment-button' : '')
|
|
2814
2838
|
}, React__default.createElement("button", {
|
|
2815
2839
|
disabled: buttonIsDiabled,
|
|
2816
2840
|
type: "submit"
|
|
@@ -2952,7 +2976,8 @@ var PaymentContainer = function PaymentContainer(_ref) {
|
|
|
2952
2976
|
setConditions(conditionsInfo ? conditionsInfo.map(function (item) {
|
|
2953
2977
|
return {
|
|
2954
2978
|
id: nanoid.nanoid(),
|
|
2955
|
-
text: item
|
|
2979
|
+
text: item,
|
|
2980
|
+
checked: false
|
|
2956
2981
|
};
|
|
2957
2982
|
}) : []);
|
|
2958
2983
|
|