tf-checkout-react 1.2.25 → 1.2.26

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.
@@ -904,7 +904,18 @@ try {
904
904
  }
905
905
  });
906
906
 
907
+ var ttfHeaders = {
908
+ Accept: 'application/vnd.api+json',
909
+ 'Content-Type': 'application/vnd.api+json'
910
+ };
907
911
  var CONFIGS = {};
912
+ var publicRequest = /*#__PURE__*/axios.create({
913
+ baseURL: CONFIGS.BASE_URL || "https://www.ticketfairy.com/api",
914
+ headers: ttfHeaders
915
+ });
916
+ var setXSourceOrigin = function setXSourceOrigin(sourceOrigin) {
917
+ ttfHeaders['X-Source-Origin'] = sourceOrigin;
918
+ };
908
919
  var setConfigs = function setConfigs(configs) {
909
920
  _forEach(configs, function (value, key) {
910
921
  CONFIGS[key] = value;
@@ -1161,19 +1172,11 @@ var createCheckoutDataBodyWithDefaultHolder = function createCheckoutDataBodyWit
1161
1172
 
1162
1173
  var isWindowDefined = typeof window !== 'undefined';
1163
1174
  var isDocumentDefined = typeof document !== 'undefined';
1164
- var ttfHeaders = {
1165
- Accept: 'application/vnd.api+json',
1166
- 'Content-Type': 'application/vnd.api+json'
1167
- };
1168
1175
 
1169
1176
  if (isWindowDefined && localStorage.getItem('auth_guest_token')) {
1170
1177
  ttfHeaders['Authorization-Guest'] = /*#__PURE__*/localStorage.getItem('auth_guest_token');
1171
1178
  }
1172
1179
 
1173
- var publicRequest = /*#__PURE__*/axios.create({
1174
- baseURL: CONFIGS.BASE_URL || "https://www.ticketfairy.com/api",
1175
- headers: ttfHeaders
1176
- });
1177
1180
  publicRequest.interceptors.response.use(function (response) {
1178
1181
  var authGuestToken = _get(response, 'headers.authorization-guest');
1179
1182
 
@@ -1280,9 +1283,6 @@ publicRequest.setAccessToken = function (token) {
1280
1283
  return publicRequest.defaults.headers.common.Authorization = token;
1281
1284
  };
1282
1285
 
1283
- var setXSourceOrigin = function setXSourceOrigin(sourceOrigin) {
1284
- ttfHeaders['X-Source-Origin'] = sourceOrigin;
1285
- };
1286
1286
  var setCustomHeader = function setCustomHeader(response) {
1287
1287
  var guestHeaderResponseValue = _get(response, 'headers.authorization-guest');
1288
1288
 
@@ -3239,7 +3239,7 @@ var BillingInfoContainer = /*#__PURE__*/React.memo(function (_ref3) {
3239
3239
  enableReinitialize: false,
3240
3240
  onSubmit: function () {
3241
3241
  var _onSubmit = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(values, formikHelpers) {
3242
- 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;
3242
+ var _checkoutBody, _res, updatedUserData, _profileSpecifiedData, _profileDataObj, checkoutBodyForRegistration, bodyFormData, resRegister, _xtfCookie, accessToken, refreshToken, userProfile, _e$response, _e$response$data, _error, profileData, profileSpecifiedData, profileDataObj, checkoutBody, res, _e$response2, _e$response3;
3243
3243
 
3244
3244
  return runtime_1.wrap(function _callee6$(_context6) {
3245
3245
  while (1) {
@@ -3252,31 +3252,29 @@ var BillingInfoContainer = /*#__PURE__*/React.memo(function (_ref3) {
3252
3252
  break;
3253
3253
  }
3254
3254
 
3255
- if (!access_token) {
3256
- _context6.next = 9;
3255
+ _checkoutBody = collectCheckoutBody(values, userData);
3256
+ _context6.next = 5;
3257
+ return postOnCheckout(_checkoutBody, access_token);
3258
+
3259
+ case 5:
3260
+ _res = _context6.sent;
3261
+ removeReferralKey(); // After checkout is successful recover updated profile and store it on local storage if needed
3262
+
3263
+ if (!isWindowDefined) {
3264
+ _context6.next = 14;
3257
3265
  break;
3258
3266
  }
3259
3267
 
3260
- _context6.next = 5;
3268
+ _context6.next = 10;
3261
3269
  return getProfileData(access_token);
3262
3270
 
3263
- case 5:
3271
+ case 10:
3264
3272
  updatedUserData = _context6.sent;
3265
3273
  _profileSpecifiedData = _get(updatedUserData, 'data.data');
3266
3274
  _profileDataObj = setLoggedUserData$1(_profileSpecifiedData);
3275
+ window.localStorage.setItem('user_data', JSON.stringify(_profileDataObj));
3267
3276
 
3268
- if (isWindowDefined) {
3269
- window.localStorage.setItem('user_data', JSON.stringify(_profileDataObj));
3270
- }
3271
-
3272
- case 9:
3273
- _checkoutBody = collectCheckoutBody(values, userData);
3274
- _context6.next = 12;
3275
- return postOnCheckout(_checkoutBody, access_token);
3276
-
3277
- case 12:
3278
- _res = _context6.sent;
3279
- removeReferralKey();
3277
+ case 14:
3280
3278
  handleSubmit(values, formikHelpers, eventId, _res);
3281
3279
  return _context6.abrupt("return");
3282
3280