tf-checkout-react 1.0.99-beta.5 → 1.0.99-beta.9
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/tf-checkout-react.cjs.development.js +38 -17
- 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 +38 -17
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/dist/utils/getDomain.d.ts +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/api/index.ts +3 -1
- package/src/components/billing-info-container/index.tsx +14 -14
- package/src/utils/cookies.ts +37 -28
- package/src/utils/getDomain.ts +15 -0
- package/src/utils/index.ts +1 -0
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
|
@@ -1001,6 +1001,21 @@ var ErrorFocusInternal = /*#__PURE__*/function (_Component) {
|
|
|
1001
1001
|
|
|
1002
1002
|
var ErrorFocus = /*#__PURE__*/formik.connect(ErrorFocusInternal);
|
|
1003
1003
|
|
|
1004
|
+
function getDomain(url, subdomain) {
|
|
1005
|
+
var updatedUrl = url.replace(/(https?:\/\/)?(www.)?/i, '');
|
|
1006
|
+
|
|
1007
|
+
if (!subdomain) {
|
|
1008
|
+
updatedUrl = updatedUrl.split('.');
|
|
1009
|
+
updatedUrl = updatedUrl.slice(updatedUrl.length - 2).join('.');
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
if (updatedUrl.indexOf('/') !== -1) {
|
|
1013
|
+
return updatedUrl.split('/')[0];
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
return updatedUrl;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1004
1019
|
function setCustomCookie(name, value, days) {
|
|
1005
1020
|
var expires = '';
|
|
1006
1021
|
|
|
@@ -1011,7 +1026,8 @@ function setCustomCookie(name, value, days) {
|
|
|
1011
1026
|
}
|
|
1012
1027
|
|
|
1013
1028
|
if (typeof window !== 'undefined') {
|
|
1014
|
-
|
|
1029
|
+
var domain = getDomain(window.location.hostname);
|
|
1030
|
+
document.cookie = name + '=' + (value || '') + expires + '; path=/' + ("; domain=" + domain);
|
|
1015
1031
|
}
|
|
1016
1032
|
}
|
|
1017
1033
|
function getCookieByName(cname) {
|
|
@@ -1035,7 +1051,8 @@ function getCookieByName(cname) {
|
|
|
1035
1051
|
}
|
|
1036
1052
|
function deleteCookieByName(name) {
|
|
1037
1053
|
if (typeof window !== 'undefined') {
|
|
1038
|
-
|
|
1054
|
+
var domain = getDomain(window.location.hostname);
|
|
1055
|
+
document.cookie = name + '=; Path=/' + ("; domain=" + domain) + '; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
|
|
1039
1056
|
}
|
|
1040
1057
|
}
|
|
1041
1058
|
|
|
@@ -1250,7 +1267,11 @@ publicRequest.interceptors.request.use(function (config) {
|
|
|
1250
1267
|
publicRequest.interceptors.response.use(function (response) {
|
|
1251
1268
|
var xtfCookie = _get(response, 'headers.x-tf-ecommerce');
|
|
1252
1269
|
|
|
1253
|
-
|
|
1270
|
+
var url = _get(response, 'config.url');
|
|
1271
|
+
|
|
1272
|
+
var method = _get(response, 'config.method');
|
|
1273
|
+
|
|
1274
|
+
if (xtfCookie && !(url === '/auth' && method === 'delete')) {
|
|
1254
1275
|
setCustomCookie('X-TF-ECOMMERCE', xtfCookie);
|
|
1255
1276
|
}
|
|
1256
1277
|
|
|
@@ -2269,8 +2290,8 @@ var LogicRunner = function LogicRunner(_ref) {
|
|
|
2269
2290
|
try {
|
|
2270
2291
|
var parsedData = JSON.parse(userDataEncoded);
|
|
2271
2292
|
var mappedValues = {
|
|
2272
|
-
firstName: (parsedData == null ? void 0 : parsedData.first_name) || '',
|
|
2273
|
-
lastName: (parsedData == null ? void 0 : parsedData.last_name) || '',
|
|
2293
|
+
firstName: (parsedData == null ? void 0 : parsedData.first_name) || (parsedData == null ? void 0 : parsedData.firstName) || '',
|
|
2294
|
+
lastName: (parsedData == null ? void 0 : parsedData.last_name) || (parsedData == null ? void 0 : parsedData.lastName) || '',
|
|
2274
2295
|
email: (parsedData == null ? void 0 : parsedData.email) || '',
|
|
2275
2296
|
phone: (parsedData == null ? void 0 : parsedData.phone) || '',
|
|
2276
2297
|
confirmEmail: (parsedData == null ? void 0 : parsedData.email) || '',
|
|
@@ -2278,15 +2299,15 @@ var LogicRunner = function LogicRunner(_ref) {
|
|
|
2278
2299
|
street_address: (parsedData == null ? void 0 : parsedData.street_address) || '',
|
|
2279
2300
|
country: (parsedData == null ? void 0 : parsedData.country) || '1',
|
|
2280
2301
|
zip: (parsedData == null ? void 0 : parsedData.zip) || '',
|
|
2281
|
-
brand_opt_in: (parsedData == null ? void 0 : parsedData.brand_opt_in) ||
|
|
2302
|
+
brand_opt_in: (parsedData == null ? void 0 : parsedData.brand_opt_in) || false,
|
|
2282
2303
|
city: (parsedData == null ? void 0 : parsedData.city) || '',
|
|
2283
2304
|
confirmPassword: '',
|
|
2284
2305
|
password: '',
|
|
2285
|
-
'holderFirstName-0': (parsedData == null ? void 0 : parsedData.first_name) || '',
|
|
2286
|
-
'holderLastName-0': (parsedData == null ? void 0 : parsedData.last_name) || '',
|
|
2306
|
+
'holderFirstName-0': (parsedData == null ? void 0 : parsedData.first_name) || (parsedData == null ? void 0 : parsedData.firstName) || '',
|
|
2307
|
+
'holderLastName-0': (parsedData == null ? void 0 : parsedData.last_name) || (parsedData == null ? void 0 : parsedData.lastName) || '',
|
|
2287
2308
|
'holderEmail-0': (parsedData == null ? void 0 : parsedData.email) || ''
|
|
2288
2309
|
};
|
|
2289
|
-
setValues(mappedValues);
|
|
2310
|
+
setValues(_extends({}, values, mappedValues));
|
|
2290
2311
|
setUserValues(mappedValues);
|
|
2291
2312
|
} catch (e) {}
|
|
2292
2313
|
}
|
|
@@ -2373,7 +2394,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2373
2394
|
|
|
2374
2395
|
var xtfCookie = getCookieByName('X-TF-ECOMMERCE');
|
|
2375
2396
|
|
|
2376
|
-
var _useState2 = React.useState(!!
|
|
2397
|
+
var _useState2 = React.useState(!!(pIsLoggedIn || xtfCookie)),
|
|
2377
2398
|
isLoggedIn = _useState2[0],
|
|
2378
2399
|
setIsLoggedIn = _useState2[1];
|
|
2379
2400
|
|
|
@@ -2482,10 +2503,10 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2482
2503
|
};
|
|
2483
2504
|
|
|
2484
2505
|
React.useEffect(function () {
|
|
2485
|
-
if (
|
|
2486
|
-
setIsLoggedIn(
|
|
2506
|
+
if (pIsLoggedIn !== isLoggedIn || xtfCookie) {
|
|
2507
|
+
setIsLoggedIn(!!(pIsLoggedIn || xtfCookie));
|
|
2487
2508
|
}
|
|
2488
|
-
}, [pIsLoggedIn, isLoggedIn,
|
|
2509
|
+
}, [pIsLoggedIn, isLoggedIn, xtfCookie]); //just once
|
|
2489
2510
|
|
|
2490
2511
|
React.useEffect(function () {
|
|
2491
2512
|
// fetch countries data
|
|
@@ -2708,8 +2729,8 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2708
2729
|
} else {
|
|
2709
2730
|
checkoutBody = createCheckoutDataBody(ticketsQuantity.length, values, {
|
|
2710
2731
|
emailLogged: emailLogged || profileData.email,
|
|
2711
|
-
firstNameLogged: firstNameLogged || profileData.first_name,
|
|
2712
|
-
lastNameLogged: lastNameLogged || profileData.
|
|
2732
|
+
firstNameLogged: firstNameLogged || profileData.first_name || profileData.firstName,
|
|
2733
|
+
lastNameLogged: lastNameLogged || profileData.last_nam || profileData.lastName
|
|
2713
2734
|
}, showDOB);
|
|
2714
2735
|
}
|
|
2715
2736
|
|
|
@@ -2734,7 +2755,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2734
2755
|
brand_opt_in: optedInFieldValue,
|
|
2735
2756
|
ttf_opt_in: ttfOptIn
|
|
2736
2757
|
}), userValues),
|
|
2737
|
-
enableReinitialize:
|
|
2758
|
+
enableReinitialize: false,
|
|
2738
2759
|
onSubmit: function () {
|
|
2739
2760
|
var _onSubmit = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(values, formikHelpers) {
|
|
2740
2761
|
var updatedUserData, _profileSpecifiedData, _profileDataObj, _checkoutBody, _res, checkoutBodyForRegistration, bodyFormData, resRegister, _xtfCookie, accessToken, refreshToken, userProfile, _e$response, _e$response$data, _error, profileData, profileSpecifiedData, profileDataObj, checkoutBody, res, _e$response2, _e$response3;
|
|
@@ -2768,7 +2789,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
|
|
|
2768
2789
|
}
|
|
2769
2790
|
|
|
2770
2791
|
case 9:
|
|
2771
|
-
_checkoutBody = collectCheckoutBody(values);
|
|
2792
|
+
_checkoutBody = collectCheckoutBody(values, userData);
|
|
2772
2793
|
_context6.next = 12;
|
|
2773
2794
|
return postOnCheckout(_checkoutBody, access_token);
|
|
2774
2795
|
|