@pelcro/react-pelcro-js 3.26.0-beta.57 → 3.26.0-beta.59

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/index.cjs.js CHANGED
@@ -9926,6 +9926,19 @@ function generatePassword() {
9926
9926
  }
9927
9927
  return retVal;
9928
9928
  }
9929
+ const refreshUser = () => {
9930
+ var _window$Pelcro6, _window$Pelcro6$user, _window$Pelcro6$user$;
9931
+ window.Pelcro.user.refresh({
9932
+ auth_token: (_window$Pelcro6 = window.Pelcro) === null || _window$Pelcro6 === void 0 ? void 0 : (_window$Pelcro6$user = _window$Pelcro6.user) === null || _window$Pelcro6$user === void 0 ? void 0 : (_window$Pelcro6$user$ = _window$Pelcro6$user.read()) === null || _window$Pelcro6$user$ === void 0 ? void 0 : _window$Pelcro6$user$.auth_token
9933
+ }, (err, res) => {
9934
+ if (err) {
9935
+ console.error(err);
9936
+ }
9937
+ if (res) {
9938
+ return res.data;
9939
+ }
9940
+ });
9941
+ };
9929
9942
 
9930
9943
  const resources = {
9931
9944
  en: {
@@ -12651,6 +12664,9 @@ const defaultOptions = {
12651
12664
  enableTheme: true,
12652
12665
  enablePaywalls: true,
12653
12666
  loadSecuritySDK: true,
12667
+ enableNativeButtons: true,
12668
+ enableAuthenticatedButtons: true,
12669
+ enableUnAuthenticatedButtons: true,
12654
12670
  enableGoogleAnalytics: false
12655
12671
  };
12656
12672
  const PelcroModalController = _ref => {
@@ -12674,8 +12690,16 @@ const PelcroModalController = _ref => {
12674
12690
  }
12675
12691
  }
12676
12692
  }, [isDonation]);
12693
+
12694
+ // default options are overridable by consumer's options
12695
+ const mergedOptions = {
12696
+ ...defaultOptions,
12697
+ ...options
12698
+ };
12677
12699
  React__default['default'].useEffect(() => {
12678
- init$1();
12700
+ if (mergedOptions.enableNativeButtons) {
12701
+ init$1();
12702
+ }
12679
12703
  renderShopView(React__default['default'].Children.map(children, child => child).find(_ref2 => {
12680
12704
  let {
12681
12705
  type
@@ -12683,12 +12707,6 @@ const PelcroModalController = _ref => {
12683
12707
  return (type === null || type === void 0 ? void 0 : type.viewId) === "shop";
12684
12708
  }));
12685
12709
  }, []);
12686
-
12687
- // default options are overridable by consumer's options
12688
- const mergedOptions = {
12689
- ...defaultOptions,
12690
- ...options
12691
- };
12692
12710
  React__default['default'].useEffect(() => {
12693
12711
  whenSiteReady(() => {
12694
12712
  optionsController(mergedOptions);
@@ -12696,9 +12714,13 @@ const PelcroModalController = _ref => {
12696
12714
  }, [options]);
12697
12715
  React__default['default'].useEffect(() => {
12698
12716
  if (window.Pelcro.user.isAuthenticated()) {
12699
- authenticatedButtons();
12717
+ if (mergedOptions.enableAuthenticatedButtons) {
12718
+ authenticatedButtons();
12719
+ }
12700
12720
  } else {
12701
- unauthenticatedButtons();
12721
+ if (mergedOptions.enableUnAuthenticatedButtons) {
12722
+ unauthenticatedButtons();
12723
+ }
12702
12724
  }
12703
12725
  }, [window.Pelcro.user.isAuthenticated()]);
12704
12726
  React__default['default'].useEffect(() => {
@@ -19655,6 +19677,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19655
19677
  content: t("messages.sourceCreated")
19656
19678
  }
19657
19679
  });
19680
+ refreshUser();
19658
19681
  onSuccess(res);
19659
19682
  });
19660
19683
  }
@@ -19709,6 +19732,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19709
19732
  }
19710
19733
  });
19711
19734
  }
19735
+ refreshUser();
19712
19736
  onSuccess(res);
19713
19737
  });
19714
19738
  }, 2000);
@@ -19770,6 +19794,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19770
19794
  content: t("messages.sourceUpdated")
19771
19795
  }
19772
19796
  });
19797
+ refreshUser();
19773
19798
  onSuccess(res);
19774
19799
  });
19775
19800
  }
@@ -20356,6 +20381,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20356
20381
  type: LOADING,
20357
20382
  payload: false
20358
20383
  });
20384
+ refreshUser();
20359
20385
  onSuccess(res);
20360
20386
  return;
20361
20387
  }
@@ -20371,6 +20397,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20371
20397
  content: t("messages.sourceCreated")
20372
20398
  }
20373
20399
  });
20400
+ refreshUser();
20374
20401
  onSuccess(res);
20375
20402
  return;
20376
20403
  }
@@ -20390,6 +20417,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20390
20417
  content: t("messages.sourceUpdated")
20391
20418
  }
20392
20419
  });
20420
+ refreshUser();
20393
20421
  onSuccess(res);
20394
20422
  return;
20395
20423
  }
@@ -20417,6 +20445,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20417
20445
  }
20418
20446
  });
20419
20447
  }
20448
+ refreshUser();
20420
20449
  onSuccess(res);
20421
20450
  });
20422
20451
  }, 2000);
@@ -20771,6 +20800,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20771
20800
  content: t("messages.sourceCreated")
20772
20801
  }
20773
20802
  });
20803
+ refreshUser();
20774
20804
  onSuccess(res);
20775
20805
  }
20776
20806
  });
@@ -20822,6 +20852,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20822
20852
  content: t("messages.sourceUpdated")
20823
20853
  }
20824
20854
  });
20855
+ refreshUser();
20825
20856
  onSuccess(res);
20826
20857
  }
20827
20858
  });
@@ -20891,6 +20922,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20891
20922
  }
20892
20923
  });
20893
20924
  }
20925
+ refreshUser();
20894
20926
  onSuccess(res);
20895
20927
  });
20896
20928
  }, 2000);
package/dist/index.esm.js CHANGED
@@ -9896,6 +9896,19 @@ function generatePassword() {
9896
9896
  }
9897
9897
  return retVal;
9898
9898
  }
9899
+ const refreshUser = () => {
9900
+ var _window$Pelcro6, _window$Pelcro6$user, _window$Pelcro6$user$;
9901
+ window.Pelcro.user.refresh({
9902
+ auth_token: (_window$Pelcro6 = window.Pelcro) === null || _window$Pelcro6 === void 0 ? void 0 : (_window$Pelcro6$user = _window$Pelcro6.user) === null || _window$Pelcro6$user === void 0 ? void 0 : (_window$Pelcro6$user$ = _window$Pelcro6$user.read()) === null || _window$Pelcro6$user$ === void 0 ? void 0 : _window$Pelcro6$user$.auth_token
9903
+ }, (err, res) => {
9904
+ if (err) {
9905
+ console.error(err);
9906
+ }
9907
+ if (res) {
9908
+ return res.data;
9909
+ }
9910
+ });
9911
+ };
9899
9912
 
9900
9913
  const resources = {
9901
9914
  en: {
@@ -12621,6 +12634,9 @@ const defaultOptions = {
12621
12634
  enableTheme: true,
12622
12635
  enablePaywalls: true,
12623
12636
  loadSecuritySDK: true,
12637
+ enableNativeButtons: true,
12638
+ enableAuthenticatedButtons: true,
12639
+ enableUnAuthenticatedButtons: true,
12624
12640
  enableGoogleAnalytics: false
12625
12641
  };
12626
12642
  const PelcroModalController = _ref => {
@@ -12644,8 +12660,16 @@ const PelcroModalController = _ref => {
12644
12660
  }
12645
12661
  }
12646
12662
  }, [isDonation]);
12663
+
12664
+ // default options are overridable by consumer's options
12665
+ const mergedOptions = {
12666
+ ...defaultOptions,
12667
+ ...options
12668
+ };
12647
12669
  React__default.useEffect(() => {
12648
- init$1();
12670
+ if (mergedOptions.enableNativeButtons) {
12671
+ init$1();
12672
+ }
12649
12673
  renderShopView(React__default.Children.map(children, child => child).find(_ref2 => {
12650
12674
  let {
12651
12675
  type
@@ -12653,12 +12677,6 @@ const PelcroModalController = _ref => {
12653
12677
  return (type === null || type === void 0 ? void 0 : type.viewId) === "shop";
12654
12678
  }));
12655
12679
  }, []);
12656
-
12657
- // default options are overridable by consumer's options
12658
- const mergedOptions = {
12659
- ...defaultOptions,
12660
- ...options
12661
- };
12662
12680
  React__default.useEffect(() => {
12663
12681
  whenSiteReady(() => {
12664
12682
  optionsController(mergedOptions);
@@ -12666,9 +12684,13 @@ const PelcroModalController = _ref => {
12666
12684
  }, [options]);
12667
12685
  React__default.useEffect(() => {
12668
12686
  if (window.Pelcro.user.isAuthenticated()) {
12669
- authenticatedButtons();
12687
+ if (mergedOptions.enableAuthenticatedButtons) {
12688
+ authenticatedButtons();
12689
+ }
12670
12690
  } else {
12671
- unauthenticatedButtons();
12691
+ if (mergedOptions.enableUnAuthenticatedButtons) {
12692
+ unauthenticatedButtons();
12693
+ }
12672
12694
  }
12673
12695
  }, [window.Pelcro.user.isAuthenticated()]);
12674
12696
  React__default.useEffect(() => {
@@ -19625,6 +19647,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19625
19647
  content: t("messages.sourceCreated")
19626
19648
  }
19627
19649
  });
19650
+ refreshUser();
19628
19651
  onSuccess(res);
19629
19652
  });
19630
19653
  }
@@ -19679,6 +19702,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19679
19702
  }
19680
19703
  });
19681
19704
  }
19705
+ refreshUser();
19682
19706
  onSuccess(res);
19683
19707
  });
19684
19708
  }, 2000);
@@ -19740,6 +19764,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19740
19764
  content: t("messages.sourceUpdated")
19741
19765
  }
19742
19766
  });
19767
+ refreshUser();
19743
19768
  onSuccess(res);
19744
19769
  });
19745
19770
  }
@@ -20326,6 +20351,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20326
20351
  type: LOADING,
20327
20352
  payload: false
20328
20353
  });
20354
+ refreshUser();
20329
20355
  onSuccess(res);
20330
20356
  return;
20331
20357
  }
@@ -20341,6 +20367,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20341
20367
  content: t("messages.sourceCreated")
20342
20368
  }
20343
20369
  });
20370
+ refreshUser();
20344
20371
  onSuccess(res);
20345
20372
  return;
20346
20373
  }
@@ -20360,6 +20387,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20360
20387
  content: t("messages.sourceUpdated")
20361
20388
  }
20362
20389
  });
20390
+ refreshUser();
20363
20391
  onSuccess(res);
20364
20392
  return;
20365
20393
  }
@@ -20387,6 +20415,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20387
20415
  }
20388
20416
  });
20389
20417
  }
20418
+ refreshUser();
20390
20419
  onSuccess(res);
20391
20420
  });
20392
20421
  }, 2000);
@@ -20741,6 +20770,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20741
20770
  content: t("messages.sourceCreated")
20742
20771
  }
20743
20772
  });
20773
+ refreshUser();
20744
20774
  onSuccess(res);
20745
20775
  }
20746
20776
  });
@@ -20792,6 +20822,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20792
20822
  content: t("messages.sourceUpdated")
20793
20823
  }
20794
20824
  });
20825
+ refreshUser();
20795
20826
  onSuccess(res);
20796
20827
  }
20797
20828
  });
@@ -20861,6 +20892,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20861
20892
  }
20862
20893
  });
20863
20894
  }
20895
+ refreshUser();
20864
20896
  onSuccess(res);
20865
20897
  });
20866
20898
  }, 2000);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pelcro/react-pelcro-js",
3
3
  "description": "Pelcro's React UI Elements",
4
- "version": "3.26.0-beta.57",
4
+ "version": "3.26.0-beta.59",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",