tf-checkout-react 1.0.92 → 1.0.96

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.
@@ -19,6 +19,7 @@ export declare const getAccessToken: (data: FormData) => Promise<import("axios")
19
19
  export declare const getPaymentData: (hash: string) => Promise<import("axios").AxiosResponse<any, any>>;
20
20
  export declare const handlePaymentData: (orderHash: string, data: any) => Promise<import("axios").AxiosResponse<any, any>>;
21
21
  export declare const handlePaymentSuccess: (orderHash: string) => Promise<import("axios").AxiosResponse<any, any>>;
22
+ export declare const handleFreeSuccess: (orderHash: string) => Promise<import("axios").AxiosResponse<any, any>>;
22
23
  export declare const getProfileData: (accessToken: any) => Promise<any>;
23
24
  export declare const getCountries: () => Promise<import("axios").AxiosResponse<any, any>>;
24
25
  export declare const getConfirmationData: (orderHash: string) => Promise<import("axios").AxiosResponse<any, any>>;
@@ -27,4 +28,5 @@ export declare const getOrders: (page: number, limit: number, eventSlug: string)
27
28
  export declare const getOrderDetails: (orderId: string) => Promise<import("axios").AxiosResponse<any, any>>;
28
29
  export declare const addToWaitingList: (id: number, data: any) => Promise<import("axios").AxiosResponse<any, any>>;
29
30
  export declare const getConditions: (eventId: string) => Promise<import("axios").AxiosResponse<any, any>>;
31
+ export declare const postReferralVisits: (eventId: string, referralId: string) => Promise<import("axios").AxiosResponse<any, any>>;
30
32
  export {};
@@ -1,4 +1,5 @@
1
1
  import { IGroupItem } from '../../types';
2
+ import { FormikValues } from 'formik';
2
3
  export interface ILoggedInValues {
3
4
  emailLogged?: string;
4
5
  firstNameLogged?: string;
@@ -48,6 +49,6 @@ export declare const setLoggedUserData: (data: IUserData) => {
48
49
  export declare const createCheckoutDataBody: (ticketsQuantity: number, values?: IValues, logedInValues?: ILoggedInValues, includeDob?: boolean) => ICheckoutBody;
49
50
  export declare const getValidateFunctions: (element: IGroupItem, states: {
50
51
  [key: string]: any;
51
- }[]) => (...value: any) => any;
52
+ }[], values: FormikValues) => (...value: any) => any;
52
53
  export declare const assingUniqueIds: (data: any) => any;
53
54
  export {};
@@ -0,0 +1,5 @@
1
+ interface IReferralLogicProps {
2
+ eventId: string | number;
3
+ }
4
+ export declare const ReferralLogic: (props: IReferralLogicProps) => null;
5
+ export {};
@@ -1275,6 +1275,12 @@ var handlePaymentSuccess = function handlePaymentSuccess(orderHash) {
1275
1275
  });
1276
1276
  return res;
1277
1277
  };
1278
+ var handleFreeSuccess = function handleFreeSuccess(orderHash) {
1279
+ var res = publicRequest.post("v1/order/" + orderHash + "/complete_free_registration")["catch"](function (error) {
1280
+ throw error;
1281
+ });
1282
+ return res;
1283
+ };
1278
1284
  var getProfileData = function getProfileData(accessToken) {
1279
1285
  return publicRequest.get('/customer/profile/', {
1280
1286
  headers: _extends({}, ttfHeaders, {
@@ -1305,6 +1311,11 @@ var addToWaitingList = function addToWaitingList(id, data) {
1305
1311
  var getConditions = function getConditions(eventId) {
1306
1312
  return publicRequest.get("v1/event/" + eventId + "/conditions");
1307
1313
  };
1314
+ var postReferralVisits = function postReferralVisits(eventId, referralId) {
1315
+ return publicRequest.post("/v1/event/" + eventId + "/referrer/", {
1316
+ referrer: "" + referralId
1317
+ });
1318
+ };
1308
1319
 
1309
1320
  var style = {
1310
1321
  position: 'absolute',
@@ -1866,7 +1877,7 @@ var createCheckoutDataBody = function createCheckoutDataBody(ticketsQuantity, va
1866
1877
 
1867
1878
  return body;
1868
1879
  };
1869
- var getValidateFunctions = function getValidateFunctions(element, states) {
1880
+ var getValidateFunctions = function getValidateFunctions(element, states, values) {
1870
1881
  var validationFunctions = [];
1871
1882
 
1872
1883
  if (element.required) {
@@ -1879,6 +1890,14 @@ var getValidateFunctions = function getValidateFunctions(element, states) {
1879
1890
  validationFunctions.push(element.onValidate);
1880
1891
  }
1881
1892
 
1893
+ if (element.name === 'confirmEmail') {
1894
+ var isSameEmail = function isSameEmail(confirmEmail) {
1895
+ return values.email !== confirmEmail ? 'Please confirm your email address correctly' : null;
1896
+ };
1897
+
1898
+ validationFunctions.push(isSameEmail);
1899
+ }
1900
+
1882
1901
  return combineValidators.apply(void 0, validationFunctions);
1883
1902
  };
1884
1903
  var assingUniqueIds = function assingUniqueIds(data) {
@@ -2379,7 +2398,9 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2379
2398
 
2380
2399
  var ttfOptIn = Boolean(_get(cartInfoData, 'ttfOptIn', false));
2381
2400
 
2382
- var hideTtfOptIn = _get(cartInfoData, 'hide_ttf_opt_in', true); // Get prevProps
2401
+ var hideTtfOptIn = _get(cartInfoData, 'hide_ttf_opt_in', true);
2402
+
2403
+ var flagRequirePhone = _get(cartInfoData, 'flagRequirePhone', false); // Get prevProps
2383
2404
 
2384
2405
 
2385
2406
  var prevData = React.useRef(data);
@@ -2673,7 +2694,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2673
2694
  _context6.prev = 0;
2674
2695
 
2675
2696
  if (!isLoggedIn) {
2676
- _context6.next = 17;
2697
+ _context6.next = 15;
2677
2698
  break;
2678
2699
  }
2679
2700
 
@@ -2701,14 +2722,10 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2701
2722
 
2702
2723
  case 12:
2703
2724
  _res = _context6.sent;
2704
- _context6.next = 15;
2705
- return getPaymentData(_res.data.data.attributes.hash);
2706
-
2707
- case 15:
2708
2725
  handleSubmit(values, formikHelpers, eventId, _res);
2709
2726
  return _context6.abrupt("return");
2710
2727
 
2711
- case 17:
2728
+ case 15:
2712
2729
  checkoutBodyForRegistration = createCheckoutDataBody(ticketsQuantity.length, values, {
2713
2730
  emailLogged: emailLogged,
2714
2731
  firstNameLogged: firstNameLogged,
@@ -2716,11 +2733,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2716
2733
  }, showDOB);
2717
2734
  bodyFormData = createRegisterFormData(values, checkoutBodyForRegistration);
2718
2735
  access_token_register = null;
2719
- _context6.prev = 20;
2720
- _context6.next = 23;
2736
+ _context6.prev = 18;
2737
+ _context6.next = 21;
2721
2738
  return register(bodyFormData);
2722
2739
 
2723
- case 23:
2740
+ case 21:
2724
2741
  resRegister = _context6.sent;
2725
2742
  access_token_register = _get(resRegister, 'data.data.attributes.access_token');
2726
2743
  refreshToken = _get(resRegister, 'data.data.attributes.refresh_token');
@@ -2730,12 +2747,12 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2730
2747
  refreshToken: refreshToken
2731
2748
  };
2732
2749
  onRegisterSuccess(tokens);
2733
- _context6.next = 35;
2750
+ _context6.next = 33;
2734
2751
  break;
2735
2752
 
2736
- case 31:
2737
- _context6.prev = 31;
2738
- _context6.t0 = _context6["catch"](20);
2753
+ case 29:
2754
+ _context6.prev = 29;
2755
+ _context6.t0 = _context6["catch"](18);
2739
2756
 
2740
2757
  if (axios.isAxiosError(_context6.t0)) {
2741
2758
  _error = _context6.t0 == null ? void 0 : (_e$response = _context6.t0.response) == null ? void 0 : (_e$response$data = _e$response.data) == null ? void 0 : _e$response$data.message;
@@ -2760,11 +2777,11 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2760
2777
 
2761
2778
  return _context6.abrupt("return");
2762
2779
 
2763
- case 35:
2764
- _context6.next = 37;
2780
+ case 33:
2781
+ _context6.next = 35;
2765
2782
  return getProfileData(access_token_register);
2766
2783
 
2767
- case 37:
2784
+ case 35:
2768
2785
  profileData = _context6.sent;
2769
2786
  profileSpecifiedData = _get(profileData, 'data.data');
2770
2787
  profileDataObj = setLoggedUserData(profileSpecifiedData);
@@ -2774,21 +2791,17 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2774
2791
  }
2775
2792
 
2776
2793
  checkoutBody = collectCheckoutBody(values);
2777
- _context6.next = 44;
2794
+ _context6.next = 42;
2778
2795
  return postOnCheckout(checkoutBody, access_token_register);
2779
2796
 
2780
- case 44:
2797
+ case 42:
2781
2798
  res = _context6.sent;
2782
- _context6.next = 47;
2783
- return getPaymentData(res.data.data.attributes.hash);
2784
-
2785
- case 47:
2786
2799
  handleSubmit(values, formikHelpers, eventId, res);
2787
- _context6.next = 53;
2800
+ _context6.next = 49;
2788
2801
  break;
2789
2802
 
2790
- case 50:
2791
- _context6.prev = 50;
2803
+ case 46:
2804
+ _context6.prev = 46;
2792
2805
  _context6.t1 = _context6["catch"](0);
2793
2806
 
2794
2807
  if (axios.isAxiosError(_context6.t1)) {
@@ -2812,12 +2825,12 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2812
2825
  onSubmitError(_context6.t1);
2813
2826
  }
2814
2827
 
2815
- case 53:
2828
+ case 49:
2816
2829
  case "end":
2817
2830
  return _context6.stop();
2818
2831
  }
2819
2832
  }
2820
- }, _callee6, null, [[0, 50], [20, 31]]);
2833
+ }, _callee6, null, [[0, 46], [18, 29]]);
2821
2834
  }));
2822
2835
 
2823
2836
  function onSubmit(_x2, _x3) {
@@ -2887,6 +2900,10 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2887
2900
  return false;
2888
2901
  }
2889
2902
 
2903
+ if (el.name === 'phone' && !flagRequirePhone) {
2904
+ el.required = true;
2905
+ }
2906
+
2890
2907
  return true;
2891
2908
  }), function (element) {
2892
2909
  return ['password', 'confirmPassword', 'password-info'].includes(element.name) && isLoggedIn ? null : React__default.createElement(React__default.Fragment, {
@@ -2897,7 +2914,7 @@ var BillingInfoContainer = function BillingInfoContainer(_ref3) {
2897
2914
  name: element.name,
2898
2915
  label: element.label,
2899
2916
  type: element.type,
2900
- validate: getValidateFunctions(element, states),
2917
+ validate: getValidateFunctions(element, states, props.values),
2901
2918
  setFieldValue: props.setFieldValue,
2902
2919
  onBlur: props.handleBlur,
2903
2920
  component: element.type === 'checkbox' ? CheckboxField : element.type === 'select' ? SelectField : element.type === 'phone' ? FormikPhoneNumberField : CustomField,
@@ -3395,9 +3412,9 @@ var PaymentContainer = function PaymentContainer(_ref) {
3395
3412
  var showFormTitle = Boolean(formTitle);
3396
3413
  var showErrorText = Boolean(errorText);
3397
3414
  var eventId = getQueryVariable('event_id');
3415
+ var hash = checkoutData.hash,
3416
+ total = checkoutData.total;
3398
3417
  React.useEffect(function () {
3399
- var hash = checkoutData.hash;
3400
-
3401
3418
  _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
3402
3419
  var response, _cart$, attributes, cart, order_details, _order_details$ticket, ticket, _orderData;
3403
3420
 
@@ -3517,32 +3534,50 @@ var PaymentContainer = function PaymentContainer(_ref) {
3517
3534
 
3518
3535
  case 4:
3519
3536
  order_hash = reviewData.order_details.order_hash;
3520
- _context3.next = 7;
3537
+
3538
+ if (!(total === "0.00")) {
3539
+ _context3.next = 11;
3540
+ break;
3541
+ }
3542
+
3543
+ _context3.next = 8;
3544
+ return handleFreeSuccess(order_hash);
3545
+
3546
+ case 8:
3547
+ _context3.t0 = _context3.sent;
3548
+ _context3.next = 14;
3549
+ break;
3550
+
3551
+ case 11:
3552
+ _context3.next = 13;
3521
3553
  return handlePaymentSuccess(order_hash);
3522
3554
 
3523
- case 7:
3524
- paymentSuccessResponse = _context3.sent;
3555
+ case 13:
3556
+ _context3.t0 = _context3.sent;
3557
+
3558
+ case 14:
3559
+ paymentSuccessResponse = _context3.t0;
3525
3560
 
3526
3561
  if (paymentSuccessResponse.status === 200) {
3527
3562
  handlePayment(paymentSuccessResponse);
3528
3563
  setPaymentIsLoading(false);
3529
3564
  }
3530
3565
 
3531
- _context3.next = 15;
3566
+ _context3.next = 22;
3532
3567
  break;
3533
3568
 
3534
- case 11:
3535
- _context3.prev = 11;
3536
- _context3.t0 = _context3["catch"](0);
3537
- setError(_get(_context3.t0, 'response.data.message'));
3538
- onPaymentError(_context3.t0.response);
3569
+ case 18:
3570
+ _context3.prev = 18;
3571
+ _context3.t1 = _context3["catch"](0);
3572
+ setError(_get(_context3.t1, 'response.data.message'));
3573
+ onPaymentError(_context3.t1.response);
3539
3574
 
3540
- case 15:
3575
+ case 22:
3541
3576
  case "end":
3542
3577
  return _context3.stop();
3543
3578
  }
3544
3579
  }
3545
- }, _callee3, null, [[0, 11]]);
3580
+ }, _callee3, null, [[0, 18]]);
3546
3581
  }));
3547
3582
 
3548
3583
  return function handlePaymentMiddleWare(_x) {
@@ -3584,7 +3619,7 @@ var PaymentContainer = function PaymentContainer(_ref) {
3584
3619
  }, label), React__default.createElement("div", {
3585
3620
  className: className + " order_info_text"
3586
3621
  }, normalizer(orderData[id], orderData.currency)));
3587
- })), React__default.createElement("div", {
3622
+ })), total !== "0.00" ? React__default.createElement("div", {
3588
3623
  className: "payment_info"
3589
3624
  }, React__default.createElement("div", {
3590
3625
  className: "payment_info_label"
@@ -3607,7 +3642,17 @@ var PaymentContainer = function PaymentContainer(_ref) {
3607
3642
  conditions: conditions,
3608
3643
  stripeCardOptions: stripeCardOptions,
3609
3644
  disableZipSection: disableZipSection
3610
- })))))));
3645
+ })))) : React__default.createElement("div", {
3646
+ className: "payment_button " + (paymentIsLoading ? 'disabled-payment-button' : '')
3647
+ }, React__default.createElement("button", {
3648
+ disabled: paymentIsLoading,
3649
+ type: "button",
3650
+ onClick: function onClick() {
3651
+ handlePaymentMiddleWare(null);
3652
+ }
3653
+ }, paymentIsLoading ? React__default.createElement(CircularProgress, {
3654
+ size: 26
3655
+ }) : "Complete Registration")))));
3611
3656
  };
3612
3657
 
3613
3658
  var config = {
@@ -3767,7 +3812,7 @@ var SocialButtons = function SocialButtons(_ref2) {
3767
3812
  return React__default.createElement(SocialComponent, Object.assign({
3768
3813
  key: index
3769
3814
  }, shareButton));
3770
- })));
3815
+ })), (showDefaultShareButtons || shareButtons.length) && React__default.createElement("p", null, "We ", React__default.createElement("strong", null, "never"), " post on Facebook without your permission!"));
3771
3816
  };
3772
3817
 
3773
3818
  var ConfirmationContainer = function ConfirmationContainer(_ref) {
@@ -4069,7 +4114,7 @@ var TicketsSection = function TicketsSection(_ref) {
4069
4114
  className: "old-price"
4070
4115
  }, "$ ", (+ticket.oldPrice).toFixed(2)), React__default.createElement("p", null, ticketPrice), !isSoldOut && !ticketIsFree && React__default.createElement("p", {
4071
4116
  className: "fees"
4072
- }, ticket.taxesIncluded ? '(incl. Fees)' : '(excl. Fees)')), React__default.createElement("div", {
4117
+ }, ticket.feeIncluded ? '(incl. Fees)' : '(excl. Fees)')), React__default.createElement("div", {
4073
4118
  className: "event-detail__tier-state",
4074
4119
  style: {
4075
4120
  minWidth: 55
@@ -4398,6 +4443,47 @@ function Countdown(_ref) {
4398
4443
  }, message)));
4399
4444
  }
4400
4445
 
4446
+ var ReferralLogic = function ReferralLogic(props) {
4447
+ var eventId = props.eventId;
4448
+ var isWindowDefined = typeof window !== 'undefined';
4449
+ React.useEffect(function () {
4450
+ if (isWindowDefined) {
4451
+ var params = new URL("" + window.location).searchParams;
4452
+ var referralId = params.get('ttf_r') || '';
4453
+ var isAlreadyCounted = !!localStorage.getItem('referral_key');
4454
+
4455
+ if (referralId && eventId && !isAlreadyCounted) {
4456
+ _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
4457
+ return runtime_1.wrap(function _callee$(_context) {
4458
+ while (1) {
4459
+ switch (_context.prev = _context.next) {
4460
+ case 0:
4461
+ _context.prev = 0;
4462
+ _context.next = 3;
4463
+ return postReferralVisits("" + eventId, referralId);
4464
+
4465
+ case 3:
4466
+ localStorage.setItem('referral_key', [eventId, '.', referralId].join(''));
4467
+ _context.next = 8;
4468
+ break;
4469
+
4470
+ case 6:
4471
+ _context.prev = 6;
4472
+ _context.t0 = _context["catch"](0);
4473
+
4474
+ case 8:
4475
+ case "end":
4476
+ return _context.stop();
4477
+ }
4478
+ }
4479
+ }, _callee, null, [[0, 6]]);
4480
+ }))();
4481
+ }
4482
+ }
4483
+ }, []);
4484
+ return null;
4485
+ };
4486
+
4401
4487
  function Loader$1() {
4402
4488
  return React__default.createElement("div", {
4403
4489
  className: "loader-container"
@@ -4742,7 +4828,9 @@ var TicketsContainer = function TicketsContainer(_ref) {
4742
4828
  }, []);
4743
4829
  return React__default.createElement(privateTheming.ThemeProvider, {
4744
4830
  theme: themeMui
4745
- }, React__default.createElement("div", {
4831
+ }, React__default.createElement(ReferralLogic, {
4832
+ eventId: eventId
4833
+ }), React__default.createElement("div", {
4746
4834
  className: "get-tickets-page " + theme,
4747
4835
  style: contentStyle
4748
4836
  }, isLoading ? React__default.createElement(Loader$1, null) : React__default.createElement("div", null, React__default.createElement(TicketsSection, {