@pelcro/react-pelcro-js 3.0.0-beta.4 → 3.0.0-beta.7

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
@@ -9106,22 +9106,26 @@ const showInvoiceDetailsFromUrl = () => {
9106
9106
  const {
9107
9107
  isAuthenticated,
9108
9108
  setInvoice,
9109
+ whenSiteReady,
9109
9110
  switchView
9110
9111
  } = usePelcro.getStore();
9112
+ whenSiteReady(() => {
9113
+ if (!isAuthenticated()) {
9114
+ return switchView("login");
9115
+ }
9111
9116
 
9112
- if (!isAuthenticated()) {
9113
- return switchView("login");
9114
- }
9117
+ const invoiceId = window.Pelcro.helpers.getURLParameter("id");
9118
+ const wasSetSuccessfully = setInvoice(invoiceId);
9115
9119
 
9116
- const invoiceId = window.Pelcro.helpers.getURLParameter("id");
9117
- const wasSetSuccessfully = setInvoice(invoiceId);
9120
+ if (!wasSetSuccessfully) {
9121
+ const errorMessage = i18next.t("messages:invalidInvoice", {
9122
+ returnObjects: true
9123
+ });
9124
+ return notify.error(errorMessage);
9125
+ }
9118
9126
 
9119
- if (!wasSetSuccessfully) {
9120
- const translations = i18next.t("messages", {
9121
- returnObjects: true
9122
- });
9123
- notify.error(translations.invalidInvoice);
9124
- }
9127
+ return switchView("invoice-details");
9128
+ });
9125
9129
  };
9126
9130
 
9127
9131
  const defaultOptions = {
@@ -22186,9 +22190,11 @@ const DonationsMenu = () => {
22186
22190
  };
22187
22191
 
22188
22192
  function getDonationSubs() {
22189
- var _window$Pelcro$subscr, _window$Pelcro$subscr2, _window$Pelcro$subscr3;
22193
+ var _window$Pelcro$subscr, _window$Pelcro$subscr2, _window$Pelcro$subscr3, _window$Pelcro$user$r, _window$Pelcro$user$r2;
22190
22194
 
22191
- return (_window$Pelcro$subscr = (_window$Pelcro$subscr2 = window.Pelcro.subscription) === null || _window$Pelcro$subscr2 === void 0 ? void 0 : (_window$Pelcro$subscr3 = _window$Pelcro$subscr2.list()) === null || _window$Pelcro$subscr3 === void 0 ? void 0 : _window$Pelcro$subscr3.filter(sub => sub.plan.is_donation)) !== null && _window$Pelcro$subscr !== void 0 ? _window$Pelcro$subscr : [];
22195
+ const donations = (_window$Pelcro$subscr = (_window$Pelcro$subscr2 = window.Pelcro.subscription) === null || _window$Pelcro$subscr2 === void 0 ? void 0 : (_window$Pelcro$subscr3 = _window$Pelcro$subscr2.list()) === null || _window$Pelcro$subscr3 === void 0 ? void 0 : _window$Pelcro$subscr3.filter(sub => sub.plan.is_donation)) !== null && _window$Pelcro$subscr !== void 0 ? _window$Pelcro$subscr : [];
22196
+ const canceledDonations = (_window$Pelcro$user$r = (_window$Pelcro$user$r2 = window.Pelcro.user.read().expired_subscriptions) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : _window$Pelcro$user$r2.filter(sub => sub.plan.is_donation)) !== null && _window$Pelcro$user$r !== void 0 ? _window$Pelcro$user$r : [];
22197
+ return [...donations, ...canceledDonations];
22192
22198
  }
22193
22199
 
22194
22200
  function formatStartDate(date) {
@@ -22900,10 +22906,11 @@ function hasInvoices() {
22900
22906
  }
22901
22907
 
22902
22908
  function hasDonationSubs() {
22903
- var _window$Pelcro$subscr, _window$Pelcro$subscr2, _window$Pelcro$subscr3;
22909
+ var _window$Pelcro$subscr, _window$Pelcro$subscr2, _window$Pelcro$subscr3, _window$Pelcro$user$r4;
22904
22910
 
22905
22911
  const donations = (_window$Pelcro$subscr = (_window$Pelcro$subscr2 = window.Pelcro.subscription) === null || _window$Pelcro$subscr2 === void 0 ? void 0 : (_window$Pelcro$subscr3 = _window$Pelcro$subscr2.list()) === null || _window$Pelcro$subscr3 === void 0 ? void 0 : _window$Pelcro$subscr3.filter(sub => sub.plan.is_donation)) !== null && _window$Pelcro$subscr !== void 0 ? _window$Pelcro$subscr : [];
22906
- return donations.length > 0;
22912
+ const canceledDonations = (_window$Pelcro$user$r4 = window.Pelcro.user.read().expired_subscriptions) !== null && _window$Pelcro$user$r4 !== void 0 ? _window$Pelcro$user$r4 : [];
22913
+ return donations.length > 0 || canceledDonations.length > 0;
22907
22914
  }
22908
22915
 
22909
22916
  const DashboardWithTrans = withTranslation("dashboard")(Dashboard);
package/dist/index.esm.js CHANGED
@@ -9076,22 +9076,26 @@ const showInvoiceDetailsFromUrl = () => {
9076
9076
  const {
9077
9077
  isAuthenticated,
9078
9078
  setInvoice,
9079
+ whenSiteReady,
9079
9080
  switchView
9080
9081
  } = usePelcro.getStore();
9082
+ whenSiteReady(() => {
9083
+ if (!isAuthenticated()) {
9084
+ return switchView("login");
9085
+ }
9081
9086
 
9082
- if (!isAuthenticated()) {
9083
- return switchView("login");
9084
- }
9087
+ const invoiceId = window.Pelcro.helpers.getURLParameter("id");
9088
+ const wasSetSuccessfully = setInvoice(invoiceId);
9085
9089
 
9086
- const invoiceId = window.Pelcro.helpers.getURLParameter("id");
9087
- const wasSetSuccessfully = setInvoice(invoiceId);
9090
+ if (!wasSetSuccessfully) {
9091
+ const errorMessage = i18next.t("messages:invalidInvoice", {
9092
+ returnObjects: true
9093
+ });
9094
+ return notify.error(errorMessage);
9095
+ }
9088
9096
 
9089
- if (!wasSetSuccessfully) {
9090
- const translations = i18next.t("messages", {
9091
- returnObjects: true
9092
- });
9093
- notify.error(translations.invalidInvoice);
9094
- }
9097
+ return switchView("invoice-details");
9098
+ });
9095
9099
  };
9096
9100
 
9097
9101
  const defaultOptions = {
@@ -22156,9 +22160,11 @@ const DonationsMenu = () => {
22156
22160
  };
22157
22161
 
22158
22162
  function getDonationSubs() {
22159
- var _window$Pelcro$subscr, _window$Pelcro$subscr2, _window$Pelcro$subscr3;
22163
+ var _window$Pelcro$subscr, _window$Pelcro$subscr2, _window$Pelcro$subscr3, _window$Pelcro$user$r, _window$Pelcro$user$r2;
22160
22164
 
22161
- return (_window$Pelcro$subscr = (_window$Pelcro$subscr2 = window.Pelcro.subscription) === null || _window$Pelcro$subscr2 === void 0 ? void 0 : (_window$Pelcro$subscr3 = _window$Pelcro$subscr2.list()) === null || _window$Pelcro$subscr3 === void 0 ? void 0 : _window$Pelcro$subscr3.filter(sub => sub.plan.is_donation)) !== null && _window$Pelcro$subscr !== void 0 ? _window$Pelcro$subscr : [];
22165
+ const donations = (_window$Pelcro$subscr = (_window$Pelcro$subscr2 = window.Pelcro.subscription) === null || _window$Pelcro$subscr2 === void 0 ? void 0 : (_window$Pelcro$subscr3 = _window$Pelcro$subscr2.list()) === null || _window$Pelcro$subscr3 === void 0 ? void 0 : _window$Pelcro$subscr3.filter(sub => sub.plan.is_donation)) !== null && _window$Pelcro$subscr !== void 0 ? _window$Pelcro$subscr : [];
22166
+ const canceledDonations = (_window$Pelcro$user$r = (_window$Pelcro$user$r2 = window.Pelcro.user.read().expired_subscriptions) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : _window$Pelcro$user$r2.filter(sub => sub.plan.is_donation)) !== null && _window$Pelcro$user$r !== void 0 ? _window$Pelcro$user$r : [];
22167
+ return [...donations, ...canceledDonations];
22162
22168
  }
22163
22169
 
22164
22170
  function formatStartDate(date) {
@@ -22870,10 +22876,11 @@ function hasInvoices() {
22870
22876
  }
22871
22877
 
22872
22878
  function hasDonationSubs() {
22873
- var _window$Pelcro$subscr, _window$Pelcro$subscr2, _window$Pelcro$subscr3;
22879
+ var _window$Pelcro$subscr, _window$Pelcro$subscr2, _window$Pelcro$subscr3, _window$Pelcro$user$r4;
22874
22880
 
22875
22881
  const donations = (_window$Pelcro$subscr = (_window$Pelcro$subscr2 = window.Pelcro.subscription) === null || _window$Pelcro$subscr2 === void 0 ? void 0 : (_window$Pelcro$subscr3 = _window$Pelcro$subscr2.list()) === null || _window$Pelcro$subscr3 === void 0 ? void 0 : _window$Pelcro$subscr3.filter(sub => sub.plan.is_donation)) !== null && _window$Pelcro$subscr !== void 0 ? _window$Pelcro$subscr : [];
22876
- return donations.length > 0;
22882
+ const canceledDonations = (_window$Pelcro$user$r4 = window.Pelcro.user.read().expired_subscriptions) !== null && _window$Pelcro$user$r4 !== void 0 ? _window$Pelcro$user$r4 : [];
22883
+ return donations.length > 0 || canceledDonations.length > 0;
22877
22884
  }
22878
22885
 
22879
22886
  const DashboardWithTrans = withTranslation("dashboard")(Dashboard);
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.0.0-beta.4",
4
+ "version": "3.0.0-beta.7",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",