tf-checkout-react 1.2.25 → 1.2.28

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.
@@ -1,11 +1,4 @@
1
- import { AxiosInstance, AxiosResponse } from 'axios';
2
- interface IPublicRequest extends AxiosInstance {
3
- setGuestToken: (token: string) => void;
4
- setAccessToken: (token: string) => void;
5
- setBaseUrl: (baseUrl: string) => void;
6
- }
7
- export declare const publicRequest: IPublicRequest;
8
- export declare const setXSourceOrigin: (sourceOrigin: string) => void;
1
+ import { AxiosResponse } from 'axios';
9
2
  export declare const setCustomHeader: (response: any) => void;
10
3
  export declare const handleSetAccessToken: (token: string) => void;
11
4
  export declare function getEvent(id: string | number, pk?: string): Promise<AxiosResponse<any, any>>;
@@ -17,6 +17,7 @@ export interface ITicketTypes {
17
17
  resale_fee_amount: number | string;
18
18
  ticket_type_hash: string;
19
19
  ticket_type_is_active?: boolean;
20
+ retain_amount_on_sale: number | string;
20
21
  }
21
22
  export interface IActionColumns {
22
23
  download?: boolean;
@@ -911,7 +911,18 @@ try {
911
911
  }
912
912
  });
913
913
 
914
+ var ttfHeaders = {
915
+ Accept: 'application/vnd.api+json',
916
+ 'Content-Type': 'application/vnd.api+json'
917
+ };
914
918
  var CONFIGS = {};
919
+ var publicRequest = /*#__PURE__*/axios.create({
920
+ baseURL: CONFIGS.BASE_URL || "https://www.ticketfairy.com/api",
921
+ headers: ttfHeaders
922
+ });
923
+ var setXSourceOrigin = function setXSourceOrigin(sourceOrigin) {
924
+ ttfHeaders['X-Source-Origin'] = sourceOrigin;
925
+ };
915
926
  var setConfigs = function setConfigs(configs) {
916
927
  _forEach(configs, function (value, key) {
917
928
  CONFIGS[key] = value;
@@ -1168,19 +1179,11 @@ var createCheckoutDataBodyWithDefaultHolder = function createCheckoutDataBodyWit
1168
1179
 
1169
1180
  var isWindowDefined = typeof window !== 'undefined';
1170
1181
  var isDocumentDefined = typeof document !== 'undefined';
1171
- var ttfHeaders = {
1172
- Accept: 'application/vnd.api+json',
1173
- 'Content-Type': 'application/vnd.api+json'
1174
- };
1175
1182
 
1176
1183
  if (isWindowDefined && localStorage.getItem('auth_guest_token')) {
1177
1184
  ttfHeaders['Authorization-Guest'] = /*#__PURE__*/localStorage.getItem('auth_guest_token');
1178
1185
  }
1179
1186
 
1180
- var publicRequest = /*#__PURE__*/axios.create({
1181
- baseURL: CONFIGS.BASE_URL || "https://www.ticketfairy.com/api",
1182
- headers: ttfHeaders
1183
- });
1184
1187
  publicRequest.interceptors.response.use(function (response) {
1185
1188
  var authGuestToken = _get(response, 'headers.authorization-guest');
1186
1189
 
@@ -1287,9 +1290,6 @@ publicRequest.setAccessToken = function (token) {
1287
1290
  return publicRequest.defaults.headers.common.Authorization = token;
1288
1291
  };
1289
1292
 
1290
- var setXSourceOrigin = function setXSourceOrigin(sourceOrigin) {
1291
- ttfHeaders['X-Source-Origin'] = sourceOrigin;
1292
- };
1293
1293
  var setCustomHeader = function setCustomHeader(response) {
1294
1294
  var guestHeaderResponseValue = _get(response, 'headers.authorization-guest');
1295
1295
 
@@ -3241,7 +3241,7 @@ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref3) {
3241
3241
  enableReinitialize: false,
3242
3242
  onSubmit: function () {
3243
3243
  var _onSubmit = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(values, formikHelpers) {
3244
- 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;
3244
+ 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;
3245
3245
 
3246
3246
  return runtime_1.wrap(function _callee6$(_context6) {
3247
3247
  while (1) {
@@ -3254,31 +3254,29 @@ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref3) {
3254
3254
  break;
3255
3255
  }
3256
3256
 
3257
- if (!access_token) {
3258
- _context6.next = 9;
3257
+ _checkoutBody = collectCheckoutBody(values, userData);
3258
+ _context6.next = 5;
3259
+ return postOnCheckout(_checkoutBody, access_token);
3260
+
3261
+ case 5:
3262
+ _res = _context6.sent;
3263
+ removeReferralKey(); // After checkout is successful recover updated profile and store it on local storage if needed
3264
+
3265
+ if (!isWindowDefined) {
3266
+ _context6.next = 14;
3259
3267
  break;
3260
3268
  }
3261
3269
 
3262
- _context6.next = 5;
3270
+ _context6.next = 10;
3263
3271
  return getProfileData(access_token);
3264
3272
 
3265
- case 5:
3273
+ case 10:
3266
3274
  updatedUserData = _context6.sent;
3267
3275
  _profileSpecifiedData = _get(updatedUserData, 'data.data');
3268
3276
  _profileDataObj = setLoggedUserData$1(_profileSpecifiedData);
3277
+ window.localStorage.setItem('user_data', JSON.stringify(_profileDataObj));
3269
3278
 
3270
- if (isWindowDefined) {
3271
- window.localStorage.setItem('user_data', JSON.stringify(_profileDataObj));
3272
- }
3273
-
3274
- case 9:
3275
- _checkoutBody = collectCheckoutBody(values, userData);
3276
- _context6.next = 12;
3277
- return postOnCheckout(_checkoutBody, access_token);
3278
-
3279
- case 12:
3280
- _res = _context6.sent;
3281
- removeReferralKey();
3279
+ case 14:
3282
3280
  handleSubmit(values, formikHelpers, eventId, _res);
3283
3281
  return _context6.abrupt("return");
3284
3282
 
@@ -4571,9 +4569,11 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
4571
4569
  className: "title"
4572
4570
  }, "Your Tickets are Confirmed!"), React__default.createElement("div", {
4573
4571
  className: "share-message-section"
4574
- }, React__default.createElement("span", {
4572
+ }, data.attach_tickets ? React__default.createElement("span", {
4573
+ className: "main"
4574
+ }, "Your tickets have been emailed to you") : React__default.createElement("span", {
4575
4575
  className: "main"
4576
- }, "Your tickets have been emailed to you"), React__default.createElement("span", {
4576
+ }, "Your tickets are available in My Tickets section"), React__default.createElement("span", {
4577
4577
  className: "helper"
4578
4578
  }, "Please bring them with you to the event")))), data.disable_referral === false && isReferralEnabled && React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
4579
4579
  className: "referral_text_image_section"
@@ -5277,6 +5277,10 @@ var TicketsContainer = function TicketsContainer(_ref) {
5277
5277
  showPromoCodeSection = _useState14[0],
5278
5278
  setShowPromoCodeSection = _useState14[1];
5279
5279
 
5280
+ var _useState15 = React.useState(null),
5281
+ error = _useState15[0],
5282
+ setError = _useState15[1];
5283
+
5280
5284
  var ticketsContainerRef = React.useRef(null);
5281
5285
  React.useEffect(function () {
5282
5286
  if (typeof window !== 'undefined') {
@@ -5445,6 +5449,10 @@ var TicketsContainer = function TicketsContainer(_ref) {
5445
5449
  }
5446
5450
  };
5447
5451
 
5452
+ var onErrorClose = function onErrorClose() {
5453
+ setError(null);
5454
+ };
5455
+
5448
5456
  var handleBook = /*#__PURE__*/function () {
5449
5457
  var _ref4 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
5450
5458
  var _product_options, _product_options2, _ticket_types;
@@ -5546,6 +5554,7 @@ var TicketsContainer = function TicketsContainer(_ref) {
5546
5554
 
5547
5555
  if (axios.isAxiosError(_context2.t1)) {
5548
5556
  onAddToCartError(_context2.t1);
5557
+ setError(_get(_context2.t1, 'response.data.message'));
5549
5558
  }
5550
5559
 
5551
5560
  case 38:
@@ -5620,7 +5629,14 @@ var TicketsContainer = function TicketsContainer(_ref) {
5620
5629
  }), React__default.createElement("div", {
5621
5630
  className: "get-tickets-page " + theme,
5622
5631
  style: contentStyle
5623
- }, isLoading ? React__default.createElement(Loader, null) : React__default.createElement("div", {
5632
+ }, error && React__default.createElement(Alert, {
5633
+ severity: "error",
5634
+ onClose: onErrorClose,
5635
+ variant: "filled",
5636
+ style: {
5637
+ width: '350px'
5638
+ }
5639
+ }, error), isLoading ? React__default.createElement(Loader, null) : React__default.createElement("div", {
5624
5640
  ref: ticketsContainerRef
5625
5641
  }, !isSalesClosed && React__default.createElement(TicketsSection, {
5626
5642
  ticketsList: tickets,
@@ -6061,6 +6077,7 @@ var TicketResaleModal = function TicketResaleModal(_ref) {
6061
6077
  event_name = ticket.event_name,
6062
6078
  currency = ticket.currency,
6063
6079
  resale_fee_amount = ticket.resale_fee_amount,
6080
+ retain_amount_on_sale = ticket.retain_amount_on_sale,
6064
6081
  ticket_type_is_active = ticket.ticket_type_is_active;
6065
6082
  return React__default.createElement(Modal, {
6066
6083
  open: true,
@@ -6140,7 +6157,7 @@ var TicketResaleModal = function TicketResaleModal(_ref) {
6140
6157
  type: "radio",
6141
6158
  value: "anyone",
6142
6159
  component: RadioField
6143
- })), React__default.createElement("div", null, React__default.createElement("h4", null, "Terms of Resale"), React__default.createElement("p", null, "I confirm that I want to sell this ticket and that, if someone chooses to buy it, I will no longer own it or have the right to ask for it back."), React__default.createElement("p", null, "I also understand that, if no one chooses to buy it, it remains my property, is valid for entry to ", React__default.createElement("strong", null, event_name), " and I will not receive any refund."), React__default.createElement("p", null, "If my ticket is sold, the original card I used to buy my ticket will be refunded with the original amount paid, minus a small handling fee of ", React__default.createElement("strong", null, (currency || '') + " " + (resale_fee_amount || '')), ", and that any existing refunds due to me for referring sales for this event are no longer valid."), React__default.createElement(formik.Field, {
6160
+ })), React__default.createElement("div", null, React__default.createElement("h4", null, "Terms of Resale"), React__default.createElement("p", null, "I confirm that I want to sell this ticket and that, if someone chooses to buy it, I will no longer own it or have the right to ask for it back."), React__default.createElement("p", null, "I also understand that, if no one chooses to buy it, it remains my property, is valid for entry to ", React__default.createElement("strong", null, event_name), " and I will not receive any refund."), React__default.createElement("p", null, "If my ticket is sold, the original card I used to buy my ticket will be refunded with the original amount paid, minus a small handling fee of ", React__default.createElement("strong", null, (currency != null ? currency : '') + " " + (retain_amount_on_sale != null ? retain_amount_on_sale : '0')), ", and that any existing refunds due to me for referring sales for this event are no longer valid."), React__default.createElement("p", null, "In order to receive the refund, I agree to pay a fee of ", React__default.createElement("strong", null, (currency != null ? currency : '') + " " + (resale_fee_amount != null ? resale_fee_amount : '0')), "."), React__default.createElement(formik.Field, {
6144
6161
  name: 'confirm',
6145
6162
  label: 'I agree',
6146
6163
  type: 'checkbox',