tf-checkout-react 1.0.80 → 1.0.81
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/ticketsContainer/index.d.ts +2 -1
- package/dist/hooks/usePrevious.d.ts +1 -0
- package/dist/tf-checkout-react.cjs.development.js +65 -19
- 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 +66 -20
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/billing-info-container/index.tsx +18 -5
- package/src/components/ticketsContainer/PromoCodeSection.tsx +8 -3
- package/src/components/ticketsContainer/index.tsx +4 -1
- package/src/hooks/usePrevious.tsx +9 -0
- package/src/utils/downloadPDF.tsx +11 -3
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React, { Component, useState,
|
|
1
|
+
import React, { Component, useState, useRef, useEffect, useCallback, Fragment } from 'react';
|
|
2
2
|
import { connect, Formik, Form, Field } from 'formik';
|
|
3
3
|
import Button from '@mui/material/Button';
|
|
4
4
|
import _identity from 'lodash-es/identity';
|
|
5
5
|
import _map from 'lodash-es/map';
|
|
6
6
|
import _get from 'lodash-es/get';
|
|
7
7
|
import _includes from 'lodash-es/includes';
|
|
8
|
+
import _isEqual from 'lodash-es/isEqual';
|
|
8
9
|
import axios from 'axios';
|
|
9
10
|
import _forEach from 'lodash-es/forEach';
|
|
10
11
|
import { TextField, FormControl, FormHelperText, InputLabel, CircularProgress, createTheme as createTheme$1 } from '@mui/material';
|
|
@@ -999,7 +1000,7 @@ var downloadPDF = function downloadPDF(pdfUrl) {
|
|
|
999
1000
|
}
|
|
1000
1001
|
}).then( /*#__PURE__*/function () {
|
|
1001
1002
|
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(response) {
|
|
1002
|
-
var blobValue;
|
|
1003
|
+
var blobValue, fileNameHeader, fileName;
|
|
1003
1004
|
return runtime_1.wrap(function _callee$(_context) {
|
|
1004
1005
|
while (1) {
|
|
1005
1006
|
switch (_context.prev = _context.next) {
|
|
@@ -1009,9 +1010,14 @@ var downloadPDF = function downloadPDF(pdfUrl) {
|
|
|
1009
1010
|
|
|
1010
1011
|
case 2:
|
|
1011
1012
|
blobValue = _context.sent;
|
|
1012
|
-
|
|
1013
|
+
fileNameHeader = response.headers.get("content-disposition") || '';
|
|
1014
|
+
fileName = fileNameHeader.split('"')[1];
|
|
1015
|
+
return _context.abrupt("return", {
|
|
1016
|
+
blobValue: blobValue,
|
|
1017
|
+
fileName: fileName
|
|
1018
|
+
});
|
|
1013
1019
|
|
|
1014
|
-
case
|
|
1020
|
+
case 6:
|
|
1015
1021
|
case "end":
|
|
1016
1022
|
return _context.stop();
|
|
1017
1023
|
}
|
|
@@ -1022,12 +1028,20 @@ var downloadPDF = function downloadPDF(pdfUrl) {
|
|
|
1022
1028
|
return function (_x) {
|
|
1023
1029
|
return _ref.apply(this, arguments);
|
|
1024
1030
|
};
|
|
1025
|
-
}()).then(function (
|
|
1031
|
+
}()).then(function (_ref2) {
|
|
1032
|
+
var blobValue = _ref2.blobValue,
|
|
1033
|
+
fileName = _ref2.fileName;
|
|
1034
|
+
if (!fileName) return;
|
|
1026
1035
|
var file = new Blob([blobValue], {
|
|
1027
1036
|
type: 'application/pdf'
|
|
1028
1037
|
});
|
|
1029
1038
|
var fileURL = URL.createObjectURL(file);
|
|
1030
|
-
|
|
1039
|
+
var link = document.createElement('a');
|
|
1040
|
+
link.href = fileURL;
|
|
1041
|
+
link.setAttribute('download', fileName);
|
|
1042
|
+
document.body.appendChild(link);
|
|
1043
|
+
link.click();
|
|
1044
|
+
document.body.removeChild(link);
|
|
1031
1045
|
});
|
|
1032
1046
|
};
|
|
1033
1047
|
|
|
@@ -2080,6 +2094,14 @@ var FormikPhoneNumberField = function FormikPhoneNumberField(_ref) {
|
|
|
2080
2094
|
}, rest));
|
|
2081
2095
|
};
|
|
2082
2096
|
|
|
2097
|
+
var usePrevious = function usePrevious(value) {
|
|
2098
|
+
var ref = useRef();
|
|
2099
|
+
useEffect(function () {
|
|
2100
|
+
ref.current = value;
|
|
2101
|
+
});
|
|
2102
|
+
return ref.current;
|
|
2103
|
+
};
|
|
2104
|
+
|
|
2083
2105
|
var LogicRunner = function LogicRunner(_ref) {
|
|
2084
2106
|
var values = _ref.values,
|
|
2085
2107
|
setStates = _ref.setStates,
|
|
@@ -2217,7 +2239,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2217
2239
|
_ref3$onGetStatesErro = _ref3.onGetStatesError,
|
|
2218
2240
|
onGetStatesError = _ref3$onGetStatesErro === void 0 ? function () {} : _ref3$onGetStatesErro,
|
|
2219
2241
|
_ref3$onGetProfileDat = _ref3.onGetProfileDataSuccess,
|
|
2220
|
-
|
|
2242
|
+
_onGetProfileDataSuccess = _ref3$onGetProfileDat === void 0 ? function () {} : _ref3$onGetProfileDat,
|
|
2221
2243
|
_ref3$onGetProfileDat2 = _ref3.onGetProfileDataError,
|
|
2222
2244
|
onGetProfileDataError = _ref3$onGetProfileDat2 === void 0 ? function () {} : _ref3$onGetProfileDat2,
|
|
2223
2245
|
_ref3$onAuthorizeSucc = _ref3.onAuthorizeSuccess,
|
|
@@ -2233,6 +2255,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2233
2255
|
accountInfoTitle = _ref3$accountInfoTitl === void 0 ? '' : _ref3$accountInfoTitl,
|
|
2234
2256
|
hideLogo = _ref3.hideLogo,
|
|
2235
2257
|
themeOptions = _ref3.themeOptions;
|
|
2258
|
+
|
|
2236
2259
|
var themeMui = createTheme(themeOptions);
|
|
2237
2260
|
var isWindowDefined = typeof window !== 'undefined';
|
|
2238
2261
|
var userData = isWindowDefined && window.localStorage.getItem('user_data') ? JSON.parse(window.localStorage.getItem('user_data') || '') : {};
|
|
@@ -2307,9 +2330,14 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2307
2330
|
|
|
2308
2331
|
var optedInFieldValue = _get(cartInfoData, 'optedIn', false);
|
|
2309
2332
|
|
|
2310
|
-
var
|
|
2333
|
+
var ttfOptIn = _get(cartInfoData, 'ttfOptIn', false);
|
|
2334
|
+
|
|
2335
|
+
var hideTtfOptIn = _get(cartInfoData, 'hide_ttf_opt_in', true); // Get prevProps
|
|
2336
|
+
|
|
2311
2337
|
|
|
2312
|
-
|
|
2338
|
+
var prevData = usePrevious(data);
|
|
2339
|
+
|
|
2340
|
+
if (!_get(dataWithUniqueIds, '[0].uniqueId') || !_isEqual(prevData, data)) {
|
|
2313
2341
|
setDataWithUniqueIds(assingUniqueIds(data));
|
|
2314
2342
|
}
|
|
2315
2343
|
|
|
@@ -2464,7 +2492,8 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2464
2492
|
lastName: profileDataObj.last_name
|
|
2465
2493
|
}));
|
|
2466
2494
|
window.localStorage.setItem('user_data', JSON.stringify(profileDataObj));
|
|
2467
|
-
|
|
2495
|
+
|
|
2496
|
+
_onGetProfileDataSuccess(userDataResponse.data);
|
|
2468
2497
|
|
|
2469
2498
|
case 10:
|
|
2470
2499
|
_context4.next = 15;
|
|
@@ -2500,7 +2529,8 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2500
2529
|
initialValues: getInitialValues(dataWithUniqueIds, _extends({}, initialValues, {
|
|
2501
2530
|
country: _get(userData, 'country', '') || "1",
|
|
2502
2531
|
state: _get(userData, 'state', '') || "1",
|
|
2503
|
-
brand_opt_in: optedInFieldValue
|
|
2532
|
+
brand_opt_in: optedInFieldValue,
|
|
2533
|
+
ttf_opt_in: ttfOptIn
|
|
2504
2534
|
}), userValues),
|
|
2505
2535
|
enableReinitialize: true,
|
|
2506
2536
|
onSubmit: function () {
|
|
@@ -2744,13 +2774,13 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2744
2774
|
var groupClassname = group.groupClassname,
|
|
2745
2775
|
groupItems = group.groupItems;
|
|
2746
2776
|
return React.createElement("div", {
|
|
2747
|
-
key: group.
|
|
2777
|
+
key: group.id
|
|
2748
2778
|
}, React.createElement("div", {
|
|
2749
2779
|
className: groupClassname
|
|
2750
2780
|
}, _map(groupItems, function (element) {
|
|
2751
2781
|
return React.createElement("div", {
|
|
2752
2782
|
className: element.className,
|
|
2753
|
-
key: element.
|
|
2783
|
+
key: element.name
|
|
2754
2784
|
}, React.createElement(Field, {
|
|
2755
2785
|
name: element.name + "-" + index,
|
|
2756
2786
|
label: element.label,
|
|
@@ -2784,7 +2814,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2784
2814
|
userExpired: userExpired,
|
|
2785
2815
|
onAuthorizeSuccess: onAuthorizeSuccess,
|
|
2786
2816
|
onAuthorizeError: onAuthorizeError,
|
|
2787
|
-
onGetProfileDataSuccess: onGetProfileDataSuccess
|
|
2817
|
+
onGetProfileDataSuccess: function onGetProfileDataSuccess(data) {
|
|
2818
|
+
fetchCart();
|
|
2819
|
+
|
|
2820
|
+
_onGetProfileDataSuccess(data);
|
|
2821
|
+
},
|
|
2788
2822
|
onGetProfileDataError: onGetProfileDataError
|
|
2789
2823
|
}), showModalRegister && React.createElement(RegisterModal, {
|
|
2790
2824
|
onClose: function onClose() {
|
|
@@ -2793,7 +2827,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2793
2827
|
onRegister: function onRegister() {
|
|
2794
2828
|
setShowModalRegister(false);
|
|
2795
2829
|
},
|
|
2796
|
-
onGetProfileDataSuccess: onGetProfileDataSuccess
|
|
2830
|
+
onGetProfileDataSuccess: function onGetProfileDataSuccess(data) {
|
|
2831
|
+
fetchCart();
|
|
2832
|
+
|
|
2833
|
+
_onGetProfileDataSuccess(data);
|
|
2834
|
+
},
|
|
2797
2835
|
onGetProfileDataError: onGetProfileDataError
|
|
2798
2836
|
}));
|
|
2799
2837
|
};
|
|
@@ -4032,6 +4070,7 @@ var PromoCodeSection = function PromoCodeSection(_ref) {
|
|
|
4032
4070
|
setPromoCodeUpdated = _ref.setPromoCodeUpdated,
|
|
4033
4071
|
setShowPromoInput = _ref.setShowPromoInput,
|
|
4034
4072
|
isAccessCodeEnabled = _ref.isAccessCodeEnabled;
|
|
4073
|
+
var isPromoCodeHasValue = !!promoCode.trim();
|
|
4035
4074
|
|
|
4036
4075
|
var renderInputField = function renderInputField() {
|
|
4037
4076
|
return React.createElement("div", {
|
|
@@ -4047,14 +4086,18 @@ var PromoCodeSection = function PromoCodeSection(_ref) {
|
|
|
4047
4086
|
setPromoCode(e.target.value);
|
|
4048
4087
|
},
|
|
4049
4088
|
onKeyPress: function onKeyPress(event) {
|
|
4050
|
-
if (event.key === 'Enter') {
|
|
4089
|
+
if (event.key === 'Enter' && isPromoCodeHasValue) {
|
|
4051
4090
|
setPromoCodeUpdated(promoCode);
|
|
4091
|
+
setShowPromoInput(false);
|
|
4052
4092
|
}
|
|
4053
4093
|
}
|
|
4054
4094
|
}), React.createElement(Button$1, {
|
|
4055
4095
|
className: "promo-submit-button",
|
|
4056
4096
|
onClick: function onClick() {
|
|
4057
|
-
|
|
4097
|
+
if (isPromoCodeHasValue) {
|
|
4098
|
+
setPromoCodeUpdated(promoCode);
|
|
4099
|
+
setShowPromoInput(false);
|
|
4100
|
+
}
|
|
4058
4101
|
}
|
|
4059
4102
|
}, isAccessCodeEnabled ? 'ENTER' : 'APPLY'));
|
|
4060
4103
|
};
|
|
@@ -4068,7 +4111,7 @@ var PromoCodeSection = function PromoCodeSection(_ref) {
|
|
|
4068
4111
|
}
|
|
4069
4112
|
}), React.createElement("p", {
|
|
4070
4113
|
className: "promo-code-success"
|
|
4071
|
-
}, "PROMO CODE APPLIED SUCCESSFULLY")) : null, showPromoInput &&
|
|
4114
|
+
}, "PROMO CODE APPLIED SUCCESSFULLY")) : null, showPromoInput && renderInputField(), isPromotionsEnabled && !showPromoInput && !isAccessCodeEnabled ? React.createElement(Button$1, {
|
|
4072
4115
|
className: "promo-code-button",
|
|
4073
4116
|
placeholder: "Promo Codes",
|
|
4074
4117
|
onClick: function onClick() {
|
|
@@ -4182,7 +4225,9 @@ var TicketsContainer = function TicketsContainer(_ref) {
|
|
|
4182
4225
|
isPromotionsEnabled = _ref$isPromotionsEnab === void 0 ? true : _ref$isPromotionsEnab,
|
|
4183
4226
|
themeOptions = _ref.themeOptions,
|
|
4184
4227
|
_ref$isAccessCodeEnab = _ref.isAccessCodeEnabled,
|
|
4185
|
-
isAccessCodeEnabled = _ref$isAccessCodeEnab === void 0 ? false : _ref$isAccessCodeEnab
|
|
4228
|
+
isAccessCodeEnabled = _ref$isAccessCodeEnab === void 0 ? false : _ref$isAccessCodeEnab,
|
|
4229
|
+
_ref$hideSessionButto = _ref.hideSessionButtons,
|
|
4230
|
+
hideSessionButtons = _ref$hideSessionButto === void 0 ? false : _ref$hideSessionButto;
|
|
4186
4231
|
|
|
4187
4232
|
var _useState = useState({}),
|
|
4188
4233
|
selectedTickets = _useState[0],
|
|
@@ -4313,6 +4358,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
|
|
|
4313
4358
|
setTickets(_get(attributes, 'tickets'));
|
|
4314
4359
|
setShowWaitingList(attributes.showWaitingList);
|
|
4315
4360
|
onGetTicketsSuccess(response.data);
|
|
4361
|
+
setPromoCode('');
|
|
4316
4362
|
}
|
|
4317
4363
|
|
|
4318
4364
|
if (eventResponse.data.success) {
|
|
@@ -4521,7 +4567,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
|
|
|
4521
4567
|
"aria-hidden": true,
|
|
4522
4568
|
className: "book-button " + (handleBookIsLoading || _isEmpty(selectedTickets) || Object.values(selectedTickets)[0] === 0 ? 'disabled' : ''),
|
|
4523
4569
|
onClick: !handleBookIsLoading && !_isEmpty(selectedTickets) && Object.values(selectedTickets)[0] > 0 ? handleBook : function () {}
|
|
4524
|
-
}, getTicketsLabel || 'GET TICKETS'), isLogged ? React.createElement("div", {
|
|
4570
|
+
}, getTicketsLabel || 'GET TICKETS'), isLogged && !hideSessionButtons ? React.createElement("div", {
|
|
4525
4571
|
className: "session-wrapper"
|
|
4526
4572
|
}, React.createElement("span", {
|
|
4527
4573
|
className: "session-container"
|