@pelcro/react-pelcro-js 3.13.0-beta.16 → 3.13.0-beta.18

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
@@ -10337,7 +10337,7 @@ toast.confirm = (onConfirm, {
10337
10337
  ...options
10338
10338
  });
10339
10339
  setTimeout(() => {
10340
- notify.dismiss(id);
10340
+ notify$1.dismiss(id);
10341
10341
  }, 3000);
10342
10342
  };
10343
10343
 
@@ -10347,12 +10347,12 @@ toast.confirm = (onConfirm, {
10347
10347
  ...options
10348
10348
  });
10349
10349
  setTimeout(() => {
10350
- notify.dismiss(id);
10350
+ notify$1.dismiss(id);
10351
10351
  }, 3000);
10352
10352
  };
10353
10353
  };
10354
10354
 
10355
- const notify = toast;
10355
+ const notify$1 = toast;
10356
10356
 
10357
10357
  const translations = i18next.t("common:buttons", {
10358
10358
  returnObjects: true
@@ -10423,7 +10423,7 @@ const init$1 = () => {
10423
10423
  const errorMessage = i18next.t("messages:invalidSubscription", {
10424
10424
  returnObjects: true
10425
10425
  });
10426
- return notify.error(errorMessage);
10426
+ return notify$1.error(errorMessage);
10427
10427
  }
10428
10428
 
10429
10429
  switchView("manage-members");
@@ -10432,7 +10432,7 @@ const init$1 = () => {
10432
10432
  const errorMessage = i18next.t("messages:invalidSubscription", {
10433
10433
  returnObjects: true
10434
10434
  });
10435
- return notify.error(errorMessage);
10435
+ return notify$1.error(errorMessage);
10436
10436
  }
10437
10437
  }
10438
10438
  }
@@ -10602,7 +10602,7 @@ const init$1 = () => {
10602
10602
  const errorMsg = i18next.t("shop:messages.currencyMismatch", {
10603
10603
  currency: userCurrency
10604
10604
  });
10605
- notify.error(errorMsg);
10605
+ notify$1.error(errorMsg);
10606
10606
  }
10607
10607
  });
10608
10608
  }
@@ -10704,7 +10704,7 @@ const init = () => {
10704
10704
  elemDeepClone.setAttribute("style", "filter:blur(3px) !important; pointer-events:none !important; user-select:none !important");
10705
10705
  unblurElemWhenUserSubscribes(elemDeepClone, entitlements);
10706
10706
  const NOTIFICATION_ID = "entitlement";
10707
- notify( /*#__PURE__*/React__default['default'].createElement("p", null, /*#__PURE__*/React__default['default'].createElement(Trans, {
10707
+ notify$1( /*#__PURE__*/React__default['default'].createElement("p", null, /*#__PURE__*/React__default['default'].createElement(Trans, {
10708
10708
  i18nKey: "messages:entitlement"
10709
10709
  }, "Some of the content on this page is available with one or more of our plans.", /*#__PURE__*/React__default['default'].createElement(Link, {
10710
10710
  onClick: () => {
@@ -10721,7 +10721,7 @@ const init = () => {
10721
10721
  });
10722
10722
  }
10723
10723
 
10724
- notify.dismiss(NOTIFICATION_ID);
10724
+ notify$1.dismiss(NOTIFICATION_ID);
10725
10725
  switchView("_plan-select-entitlements");
10726
10726
  }
10727
10727
  }, "Subscribe"), "now to get full page access.")), {
@@ -11481,10 +11481,10 @@ const verifyEmailTokenFromUrl = () => {
11481
11481
  token: emailToken
11482
11482
  }, (err, res) => {
11483
11483
  if (err) {
11484
- return notify.error(getErrorMessages(err));
11484
+ return notify$1.error(getErrorMessages(err));
11485
11485
  }
11486
11486
 
11487
- return notify.success(translations.success);
11487
+ return notify$1.success(translations.success);
11488
11488
  });
11489
11489
  }, {
11490
11490
  once: true
@@ -11510,7 +11510,7 @@ const verifyLinkTokenFromUrl = () => {
11510
11510
  token: loginToken
11511
11511
  }, (err, res) => {
11512
11512
  if (err) {
11513
- return notify.error(getErrorMessages(err));
11513
+ return notify$1.error(getErrorMessages(err));
11514
11514
  }
11515
11515
 
11516
11516
  const {
@@ -11520,11 +11520,11 @@ const verifyLinkTokenFromUrl = () => {
11520
11520
  auth_token
11521
11521
  }, (err, res) => {
11522
11522
  if (err) {
11523
- return notify.error(getErrorMessages(err));
11523
+ return notify$1.error(getErrorMessages(err));
11524
11524
  }
11525
11525
 
11526
11526
  resetView();
11527
- return notify.success(translations.success);
11527
+ return notify$1.success(translations.success);
11528
11528
  });
11529
11529
  });
11530
11530
  }, {
@@ -11567,7 +11567,7 @@ const showInvoiceDetailsFromUrl = () => {
11567
11567
  const errorMessage = i18next.t("messages:invalidInvoice", {
11568
11568
  returnObjects: true
11569
11569
  });
11570
- return notify.error(errorMessage);
11570
+ return notify$1.error(errorMessage);
11571
11571
  }
11572
11572
 
11573
11573
  const {
@@ -11578,7 +11578,7 @@ const showInvoiceDetailsFromUrl = () => {
11578
11578
  const errorMessage = i18next.t("messages:zeroTotalInvoice", {
11579
11579
  returnObjects: true
11580
11580
  });
11581
- return notify.error(errorMessage);
11581
+ return notify$1.error(errorMessage);
11582
11582
  }
11583
11583
 
11584
11584
  return switchView("invoice-details");
@@ -11607,7 +11607,7 @@ const showSubscriptionManageMembersFromUrl = () => {
11607
11607
  const errorMessage = i18next.t("messages:invalidSubscription", {
11608
11608
  returnObjects: true
11609
11609
  });
11610
- return notify.error(errorMessage);
11610
+ return notify$1.error(errorMessage);
11611
11611
  }
11612
11612
 
11613
11613
  return switchView("manage-members");
@@ -13468,7 +13468,7 @@ function LoginModal({
13468
13468
  switchView,
13469
13469
  resetView,
13470
13470
  product,
13471
- plan,
13471
+ order,
13472
13472
  switchToAddressView,
13473
13473
  switchToPaymentView
13474
13474
  } = usePelcro$1();
@@ -13482,7 +13482,7 @@ function LoginModal({
13482
13482
  initPaywalls();
13483
13483
  }
13484
13484
 
13485
- if (product && plan) {
13485
+ if (product) {
13486
13486
  if (product.address_required) {
13487
13487
  return switchToAddressView();
13488
13488
  } else {
@@ -13490,10 +13490,15 @@ function LoginModal({
13490
13490
  }
13491
13491
  }
13492
13492
 
13493
+ if (order) {
13494
+ return switchToAddressView();
13495
+ }
13496
+
13493
13497
  resetView();
13494
13498
  const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
13499
+ const viewsURLs = ["invoice-details", "gift-redeem", "plan-select"];
13495
13500
 
13496
- if (viewFromURL === "invoice-details" || viewFromURL === "gift-redeem") {
13501
+ if (viewsURLs.includes(viewFromURL)) {
13497
13502
  initViewFromURL();
13498
13503
  }
13499
13504
  };
@@ -19593,7 +19598,7 @@ const SubscriptionCancelNowButton = ({
19593
19598
 
19594
19599
  switchView(null); //Show confirmation alert after closing the modal
19595
19600
 
19596
- notify.confirm((onSuccess, onFailure) => {
19601
+ notify$1.confirm((onSuccess, onFailure) => {
19597
19602
  cancelSubscription(payload, onSuccess, onFailure);
19598
19603
  }, {
19599
19604
  confirmMessage: t("messages.subCancellation.isSureToCancelNow"),
@@ -19665,7 +19670,7 @@ const SubscriptionCancelLaterButton = ({
19665
19670
 
19666
19671
  switchView(null); //Show confirmation alert after closing the modal
19667
19672
 
19668
- notify.confirm((onSuccess, onFailure) => {
19673
+ notify$1.confirm((onSuccess, onFailure) => {
19669
19674
  cancelSubscription(payload, onSuccess, onFailure);
19670
19675
  }, {
19671
19676
  confirmMessage: t("messages.subCancellation.isSureToCancel"),
@@ -19902,7 +19907,7 @@ const SubscriptionSuspendButton = ({
19902
19907
 
19903
19908
  switchView(null); //Show confirmation alert after closing the modal
19904
19909
 
19905
- notify.confirm((onSuccess, onFailure) => {
19910
+ notify$1.confirm((onSuccess, onFailure) => {
19906
19911
  suspendSubscription(payload, onSuccess, onFailure);
19907
19912
  }, {
19908
19913
  confirmMessage: t("messages.subCancellation.isSureToSuspendNow"),
@@ -22034,7 +22039,7 @@ const AddressCreateContainer = ({
22034
22039
  return onFailure(err);
22035
22040
  }
22036
22041
 
22037
- notify.success(t("messages.addressUpdated"));
22042
+ notify$1.success(t("messages.addressUpdated"));
22038
22043
  return onMembershipAdressUpdateSuccess(res);
22039
22044
  });
22040
22045
  }
@@ -24804,7 +24809,7 @@ const ShopView = () => {
24804
24809
  className: "plc-mt-2"
24805
24810
  }), /*#__PURE__*/React__default['default'].createElement(ShopPurchaseButton, {
24806
24811
  itemId: item.id,
24807
- className: "plc-mt-2"
24812
+ className: "plc-mt-2 pelcro-purchase-button"
24808
24813
  })));
24809
24814
  })));
24810
24815
  };
@@ -25638,7 +25643,7 @@ const AddressSelectContainer = ({
25638
25643
  return onFailure(err);
25639
25644
  }
25640
25645
 
25641
- notify.success(t("messages.addressUpdated"));
25646
+ notify$1.success(t("messages.addressUpdated"));
25642
25647
  return onMembershipAdressUpdateSuccess(res);
25643
25648
  });
25644
25649
  }
@@ -27632,7 +27637,7 @@ const SubscriptionsItems = ({
27632
27637
  }
27633
27638
 
27634
27639
  onClose === null || onClose === void 0 ? void 0 : onClose();
27635
- notify.confirm((onSuccess, onFailure) => {
27640
+ notify$1.confirm((onSuccess, onFailure) => {
27636
27641
  cancelSubscription(sub.id, onSuccess, onFailure);
27637
27642
  }, {
27638
27643
  confirmMessage: t("messages.subCancellation.isSureToCancel"),
@@ -27690,7 +27695,7 @@ const SubscriptionsItems = ({
27690
27695
  }
27691
27696
 
27692
27697
  onClose === null || onClose === void 0 ? void 0 : onClose();
27693
- notify.confirm((onSuccess, onFailure) => {
27698
+ notify$1.confirm((onSuccess, onFailure) => {
27694
27699
  unSuspendSubscription(sub.id, onSuccess, onFailure);
27695
27700
  }, {
27696
27701
  confirmMessage: t("messages.subUnSuspend.isSureToUnSuspend"),
@@ -28136,11 +28141,56 @@ function SvgQrcode(props) {
28136
28141
  })));
28137
28142
  }
28138
28143
 
28139
- const DonationsMenu = () => {
28144
+ const DonationsMenu = ({
28145
+ reactivateSubscription,
28146
+ disableSubmit,
28147
+ cancelSubscription
28148
+ }) => {
28140
28149
  const {
28141
28150
  t
28142
28151
  } = useTranslation("dashboard");
28152
+ const {
28153
+ switchView,
28154
+ setSubscriptionToCancel
28155
+ } = usePelcro$1();
28143
28156
  const subscriptions = getDonationSubs().sort((a, b) => a.expires_at - b.expires_at).sort((a, b) => a.renews_at - b.renews_at).map(sub => {
28157
+ // Cancel button click handlers
28158
+ const onCancelClick = () => {
28159
+ var _onClose;
28160
+
28161
+ const isImmediateCancelationEnabled = window.Pelcro.site.read().cancel_settings.status;
28162
+
28163
+ if (isImmediateCancelationEnabled) {
28164
+ setSubscriptionToCancel(sub.id);
28165
+ return switchView("subscription-cancel");
28166
+ }
28167
+
28168
+ if (userMustVerifyEmail()) {
28169
+ return switchView("email-verify");
28170
+ }
28171
+
28172
+ (_onClose = onClose) === null || _onClose === void 0 ? void 0 : _onClose();
28173
+ notify.confirm((onSuccess, onFailure) => {
28174
+ cancelSubscription(sub.id, onSuccess, onFailure);
28175
+ }, {
28176
+ confirmMessage: t("messages.subCancellation.isSureToCancel"),
28177
+ loadingMessage: t("messages.subCancellation.loading"),
28178
+ successMessage: t("messages.subCancellation.success"),
28179
+ errorMessage: t("messages.subCancellation.error")
28180
+ }, {
28181
+ closeButtonLabel: t("labels.subCancellation.goBack")
28182
+ });
28183
+ }; // Reactivate button click handlers
28184
+
28185
+
28186
+ const onReactivateClick = () => {
28187
+ if (userMustVerifyEmail()) {
28188
+ return switchView("email-verify");
28189
+ }
28190
+
28191
+ reactivateSubscription(sub.id);
28192
+ };
28193
+
28144
28194
  return /*#__PURE__*/React__default['default'].createElement("tr", {
28145
28195
  key: sub.id,
28146
28196
  className: "plc-w-full plc-align-top pelcro-donation-row"
@@ -28152,7 +28202,21 @@ const DonationsMenu = () => {
28152
28202
  className: "plc-text-xs plc-text-gray-400 pelcro-donation-price"
28153
28203
  }, getFormattedPriceByLocal(sub.plan.amount * sub.quantity, sub.plan.currency, getPageOrDefaultLanguage())))), /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement("div", {
28154
28204
  className: "plc-mb-4 plc-text-gray-500 pelcro-donation-date"
28155
- }, sub.status && /*#__PURE__*/React__default['default'].createElement("span", null, formatStartDate(sub.start)))));
28205
+ }, sub.status && /*#__PURE__*/React__default['default'].createElement("span", null, formatStartDate(sub.start)))), /*#__PURE__*/React__default['default'].createElement("td", null, sub.cancel_at_period_end === 1 && sub.plan.auto_renew && !sub.is_gift_recipient && /*#__PURE__*/React__default['default'].createElement(Button, {
28206
+ variant: "ghost",
28207
+ className: "plc-text-green-400 focus:plc-ring-green-300 pelcro-dashboard-sub-reactivate-button",
28208
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgRefresh, null),
28209
+ onClick: onReactivateClick,
28210
+ disabled: disableSubmit,
28211
+ "data-key": sub.id
28212
+ }, t("labels.reactivate")), !sub.plan.auto_renew || sub.plan.auto_renew && sub.cancel_at_period_end === 0 ? /*#__PURE__*/React__default['default'].createElement(Button, {
28213
+ variant: "ghost",
28214
+ className: "plc-text-red-500 focus:plc-ring-red-500 pelcro-dashboard-sub-cancel-button",
28215
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgXIconSolid, null),
28216
+ onClick: onCancelClick,
28217
+ disabled: disableSubmit,
28218
+ "data-key": sub.id
28219
+ }, t("labels.unsubscribe")) : ""));
28156
28220
  });
28157
28221
  return /*#__PURE__*/React__default['default'].createElement("table", {
28158
28222
  className: "plc-w-full plc-table-fixed pelcro-donations-table"
@@ -28162,7 +28226,9 @@ const DonationsMenu = () => {
28162
28226
  className: "plc-w-6/12 "
28163
28227
  }, t("labels.plan")), /*#__PURE__*/React__default['default'].createElement("th", {
28164
28228
  className: "plc-w-6/12 "
28165
- }, t("labels.startDate")))), /*#__PURE__*/React__default['default'].createElement("tbody", null, /*#__PURE__*/React__default['default'].createElement("tr", {
28229
+ }, t("labels.startDate")), /*#__PURE__*/React__default['default'].createElement("th", {
28230
+ className: "plc-w-3/12 "
28231
+ }, t("labels.actions")))), /*#__PURE__*/React__default['default'].createElement("tbody", null, /*#__PURE__*/React__default['default'].createElement("tr", {
28166
28232
  className: "plc-h-4"
28167
28233
  }), subscriptions));
28168
28234
  };
@@ -28995,7 +29061,11 @@ class Dashboard extends React.Component {
28995
29061
  className: "plc-transform plc-scale-120 plc-w-7 plc-h-8 plc-mr-1 plc-pt-1"
28996
29062
  }),
28997
29063
  title: this.locale("labels.donations"),
28998
- content: /*#__PURE__*/React__default['default'].createElement(DonationsMenu, null)
29064
+ content: /*#__PURE__*/React__default['default'].createElement(DonationsMenu, {
29065
+ reactivateSubscription: this.reactivateSubscription,
29066
+ disableSubmit: this.state.disableSubmit,
29067
+ cancelSubscription: this.cancelSubscription
29068
+ })
28999
29069
  }), /*#__PURE__*/React__default['default'].createElement(Accordion.item, {
29000
29070
  name: SUB_MENUS.GIFTS,
29001
29071
  icon: /*#__PURE__*/React__default['default'].createElement(SvgGift, null),
@@ -31056,7 +31126,7 @@ const EmailVerifyModal = ({
31056
31126
 
31057
31127
  (_props$onSuccess = (_props = props).onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(_props, res);
31058
31128
 
31059
- if (product && plan) {
31129
+ if (product) {
31060
31130
  if (product.address_required) {
31061
31131
  return switchToAddressView();
31062
31132
  } else {
@@ -31226,7 +31296,7 @@ function VerifyLinkTokenModal({
31226
31296
 
31227
31297
  (_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
31228
31298
  resetView();
31229
- notify.success(t("messages.success"));
31299
+ notify$1.success(t("messages.success"));
31230
31300
  };
31231
31301
 
31232
31302
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
@@ -33120,6 +33190,6 @@ exports.i18n = i18next;
33120
33190
  exports.initButtons = init$1;
33121
33191
  exports.initContentEntitlement = init;
33122
33192
  exports.invoicePaymentSubmitButton = invoicePaymentSubmitButton;
33123
- exports.notify = notify;
33193
+ exports.notify = notify$1;
33124
33194
  exports.unauthenticatedButtons = unauthenticatedButtons;
33125
33195
  exports.usePelcro = usePelcro$1;
package/dist/index.esm.js CHANGED
@@ -10307,7 +10307,7 @@ toast.confirm = (onConfirm, {
10307
10307
  ...options
10308
10308
  });
10309
10309
  setTimeout(() => {
10310
- notify.dismiss(id);
10310
+ notify$1.dismiss(id);
10311
10311
  }, 3000);
10312
10312
  };
10313
10313
 
@@ -10317,12 +10317,12 @@ toast.confirm = (onConfirm, {
10317
10317
  ...options
10318
10318
  });
10319
10319
  setTimeout(() => {
10320
- notify.dismiss(id);
10320
+ notify$1.dismiss(id);
10321
10321
  }, 3000);
10322
10322
  };
10323
10323
  };
10324
10324
 
10325
- const notify = toast;
10325
+ const notify$1 = toast;
10326
10326
 
10327
10327
  const translations = i18next.t("common:buttons", {
10328
10328
  returnObjects: true
@@ -10393,7 +10393,7 @@ const init$1 = () => {
10393
10393
  const errorMessage = i18next.t("messages:invalidSubscription", {
10394
10394
  returnObjects: true
10395
10395
  });
10396
- return notify.error(errorMessage);
10396
+ return notify$1.error(errorMessage);
10397
10397
  }
10398
10398
 
10399
10399
  switchView("manage-members");
@@ -10402,7 +10402,7 @@ const init$1 = () => {
10402
10402
  const errorMessage = i18next.t("messages:invalidSubscription", {
10403
10403
  returnObjects: true
10404
10404
  });
10405
- return notify.error(errorMessage);
10405
+ return notify$1.error(errorMessage);
10406
10406
  }
10407
10407
  }
10408
10408
  }
@@ -10572,7 +10572,7 @@ const init$1 = () => {
10572
10572
  const errorMsg = i18next.t("shop:messages.currencyMismatch", {
10573
10573
  currency: userCurrency
10574
10574
  });
10575
- notify.error(errorMsg);
10575
+ notify$1.error(errorMsg);
10576
10576
  }
10577
10577
  });
10578
10578
  }
@@ -10674,7 +10674,7 @@ const init = () => {
10674
10674
  elemDeepClone.setAttribute("style", "filter:blur(3px) !important; pointer-events:none !important; user-select:none !important");
10675
10675
  unblurElemWhenUserSubscribes(elemDeepClone, entitlements);
10676
10676
  const NOTIFICATION_ID = "entitlement";
10677
- notify( /*#__PURE__*/React__default.createElement("p", null, /*#__PURE__*/React__default.createElement(Trans, {
10677
+ notify$1( /*#__PURE__*/React__default.createElement("p", null, /*#__PURE__*/React__default.createElement(Trans, {
10678
10678
  i18nKey: "messages:entitlement"
10679
10679
  }, "Some of the content on this page is available with one or more of our plans.", /*#__PURE__*/React__default.createElement(Link, {
10680
10680
  onClick: () => {
@@ -10691,7 +10691,7 @@ const init = () => {
10691
10691
  });
10692
10692
  }
10693
10693
 
10694
- notify.dismiss(NOTIFICATION_ID);
10694
+ notify$1.dismiss(NOTIFICATION_ID);
10695
10695
  switchView("_plan-select-entitlements");
10696
10696
  }
10697
10697
  }, "Subscribe"), "now to get full page access.")), {
@@ -11451,10 +11451,10 @@ const verifyEmailTokenFromUrl = () => {
11451
11451
  token: emailToken
11452
11452
  }, (err, res) => {
11453
11453
  if (err) {
11454
- return notify.error(getErrorMessages(err));
11454
+ return notify$1.error(getErrorMessages(err));
11455
11455
  }
11456
11456
 
11457
- return notify.success(translations.success);
11457
+ return notify$1.success(translations.success);
11458
11458
  });
11459
11459
  }, {
11460
11460
  once: true
@@ -11480,7 +11480,7 @@ const verifyLinkTokenFromUrl = () => {
11480
11480
  token: loginToken
11481
11481
  }, (err, res) => {
11482
11482
  if (err) {
11483
- return notify.error(getErrorMessages(err));
11483
+ return notify$1.error(getErrorMessages(err));
11484
11484
  }
11485
11485
 
11486
11486
  const {
@@ -11490,11 +11490,11 @@ const verifyLinkTokenFromUrl = () => {
11490
11490
  auth_token
11491
11491
  }, (err, res) => {
11492
11492
  if (err) {
11493
- return notify.error(getErrorMessages(err));
11493
+ return notify$1.error(getErrorMessages(err));
11494
11494
  }
11495
11495
 
11496
11496
  resetView();
11497
- return notify.success(translations.success);
11497
+ return notify$1.success(translations.success);
11498
11498
  });
11499
11499
  });
11500
11500
  }, {
@@ -11537,7 +11537,7 @@ const showInvoiceDetailsFromUrl = () => {
11537
11537
  const errorMessage = i18next.t("messages:invalidInvoice", {
11538
11538
  returnObjects: true
11539
11539
  });
11540
- return notify.error(errorMessage);
11540
+ return notify$1.error(errorMessage);
11541
11541
  }
11542
11542
 
11543
11543
  const {
@@ -11548,7 +11548,7 @@ const showInvoiceDetailsFromUrl = () => {
11548
11548
  const errorMessage = i18next.t("messages:zeroTotalInvoice", {
11549
11549
  returnObjects: true
11550
11550
  });
11551
- return notify.error(errorMessage);
11551
+ return notify$1.error(errorMessage);
11552
11552
  }
11553
11553
 
11554
11554
  return switchView("invoice-details");
@@ -11577,7 +11577,7 @@ const showSubscriptionManageMembersFromUrl = () => {
11577
11577
  const errorMessage = i18next.t("messages:invalidSubscription", {
11578
11578
  returnObjects: true
11579
11579
  });
11580
- return notify.error(errorMessage);
11580
+ return notify$1.error(errorMessage);
11581
11581
  }
11582
11582
 
11583
11583
  return switchView("manage-members");
@@ -13438,7 +13438,7 @@ function LoginModal({
13438
13438
  switchView,
13439
13439
  resetView,
13440
13440
  product,
13441
- plan,
13441
+ order,
13442
13442
  switchToAddressView,
13443
13443
  switchToPaymentView
13444
13444
  } = usePelcro$1();
@@ -13452,7 +13452,7 @@ function LoginModal({
13452
13452
  initPaywalls();
13453
13453
  }
13454
13454
 
13455
- if (product && plan) {
13455
+ if (product) {
13456
13456
  if (product.address_required) {
13457
13457
  return switchToAddressView();
13458
13458
  } else {
@@ -13460,10 +13460,15 @@ function LoginModal({
13460
13460
  }
13461
13461
  }
13462
13462
 
13463
+ if (order) {
13464
+ return switchToAddressView();
13465
+ }
13466
+
13463
13467
  resetView();
13464
13468
  const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
13469
+ const viewsURLs = ["invoice-details", "gift-redeem", "plan-select"];
13465
13470
 
13466
- if (viewFromURL === "invoice-details" || viewFromURL === "gift-redeem") {
13471
+ if (viewsURLs.includes(viewFromURL)) {
13467
13472
  initViewFromURL();
13468
13473
  }
13469
13474
  };
@@ -19563,7 +19568,7 @@ const SubscriptionCancelNowButton = ({
19563
19568
 
19564
19569
  switchView(null); //Show confirmation alert after closing the modal
19565
19570
 
19566
- notify.confirm((onSuccess, onFailure) => {
19571
+ notify$1.confirm((onSuccess, onFailure) => {
19567
19572
  cancelSubscription(payload, onSuccess, onFailure);
19568
19573
  }, {
19569
19574
  confirmMessage: t("messages.subCancellation.isSureToCancelNow"),
@@ -19635,7 +19640,7 @@ const SubscriptionCancelLaterButton = ({
19635
19640
 
19636
19641
  switchView(null); //Show confirmation alert after closing the modal
19637
19642
 
19638
- notify.confirm((onSuccess, onFailure) => {
19643
+ notify$1.confirm((onSuccess, onFailure) => {
19639
19644
  cancelSubscription(payload, onSuccess, onFailure);
19640
19645
  }, {
19641
19646
  confirmMessage: t("messages.subCancellation.isSureToCancel"),
@@ -19872,7 +19877,7 @@ const SubscriptionSuspendButton = ({
19872
19877
 
19873
19878
  switchView(null); //Show confirmation alert after closing the modal
19874
19879
 
19875
- notify.confirm((onSuccess, onFailure) => {
19880
+ notify$1.confirm((onSuccess, onFailure) => {
19876
19881
  suspendSubscription(payload, onSuccess, onFailure);
19877
19882
  }, {
19878
19883
  confirmMessage: t("messages.subCancellation.isSureToSuspendNow"),
@@ -22004,7 +22009,7 @@ const AddressCreateContainer = ({
22004
22009
  return onFailure(err);
22005
22010
  }
22006
22011
 
22007
- notify.success(t("messages.addressUpdated"));
22012
+ notify$1.success(t("messages.addressUpdated"));
22008
22013
  return onMembershipAdressUpdateSuccess(res);
22009
22014
  });
22010
22015
  }
@@ -24774,7 +24779,7 @@ const ShopView = () => {
24774
24779
  className: "plc-mt-2"
24775
24780
  }), /*#__PURE__*/React__default.createElement(ShopPurchaseButton, {
24776
24781
  itemId: item.id,
24777
- className: "plc-mt-2"
24782
+ className: "plc-mt-2 pelcro-purchase-button"
24778
24783
  })));
24779
24784
  })));
24780
24785
  };
@@ -25608,7 +25613,7 @@ const AddressSelectContainer = ({
25608
25613
  return onFailure(err);
25609
25614
  }
25610
25615
 
25611
- notify.success(t("messages.addressUpdated"));
25616
+ notify$1.success(t("messages.addressUpdated"));
25612
25617
  return onMembershipAdressUpdateSuccess(res);
25613
25618
  });
25614
25619
  }
@@ -27602,7 +27607,7 @@ const SubscriptionsItems = ({
27602
27607
  }
27603
27608
 
27604
27609
  onClose === null || onClose === void 0 ? void 0 : onClose();
27605
- notify.confirm((onSuccess, onFailure) => {
27610
+ notify$1.confirm((onSuccess, onFailure) => {
27606
27611
  cancelSubscription(sub.id, onSuccess, onFailure);
27607
27612
  }, {
27608
27613
  confirmMessage: t("messages.subCancellation.isSureToCancel"),
@@ -27660,7 +27665,7 @@ const SubscriptionsItems = ({
27660
27665
  }
27661
27666
 
27662
27667
  onClose === null || onClose === void 0 ? void 0 : onClose();
27663
- notify.confirm((onSuccess, onFailure) => {
27668
+ notify$1.confirm((onSuccess, onFailure) => {
27664
27669
  unSuspendSubscription(sub.id, onSuccess, onFailure);
27665
27670
  }, {
27666
27671
  confirmMessage: t("messages.subUnSuspend.isSureToUnSuspend"),
@@ -28106,11 +28111,56 @@ function SvgQrcode(props) {
28106
28111
  })));
28107
28112
  }
28108
28113
 
28109
- const DonationsMenu = () => {
28114
+ const DonationsMenu = ({
28115
+ reactivateSubscription,
28116
+ disableSubmit,
28117
+ cancelSubscription
28118
+ }) => {
28110
28119
  const {
28111
28120
  t
28112
28121
  } = useTranslation("dashboard");
28122
+ const {
28123
+ switchView,
28124
+ setSubscriptionToCancel
28125
+ } = usePelcro$1();
28113
28126
  const subscriptions = getDonationSubs().sort((a, b) => a.expires_at - b.expires_at).sort((a, b) => a.renews_at - b.renews_at).map(sub => {
28127
+ // Cancel button click handlers
28128
+ const onCancelClick = () => {
28129
+ var _onClose;
28130
+
28131
+ const isImmediateCancelationEnabled = window.Pelcro.site.read().cancel_settings.status;
28132
+
28133
+ if (isImmediateCancelationEnabled) {
28134
+ setSubscriptionToCancel(sub.id);
28135
+ return switchView("subscription-cancel");
28136
+ }
28137
+
28138
+ if (userMustVerifyEmail()) {
28139
+ return switchView("email-verify");
28140
+ }
28141
+
28142
+ (_onClose = onClose) === null || _onClose === void 0 ? void 0 : _onClose();
28143
+ notify.confirm((onSuccess, onFailure) => {
28144
+ cancelSubscription(sub.id, onSuccess, onFailure);
28145
+ }, {
28146
+ confirmMessage: t("messages.subCancellation.isSureToCancel"),
28147
+ loadingMessage: t("messages.subCancellation.loading"),
28148
+ successMessage: t("messages.subCancellation.success"),
28149
+ errorMessage: t("messages.subCancellation.error")
28150
+ }, {
28151
+ closeButtonLabel: t("labels.subCancellation.goBack")
28152
+ });
28153
+ }; // Reactivate button click handlers
28154
+
28155
+
28156
+ const onReactivateClick = () => {
28157
+ if (userMustVerifyEmail()) {
28158
+ return switchView("email-verify");
28159
+ }
28160
+
28161
+ reactivateSubscription(sub.id);
28162
+ };
28163
+
28114
28164
  return /*#__PURE__*/React__default.createElement("tr", {
28115
28165
  key: sub.id,
28116
28166
  className: "plc-w-full plc-align-top pelcro-donation-row"
@@ -28122,7 +28172,21 @@ const DonationsMenu = () => {
28122
28172
  className: "plc-text-xs plc-text-gray-400 pelcro-donation-price"
28123
28173
  }, getFormattedPriceByLocal(sub.plan.amount * sub.quantity, sub.plan.currency, getPageOrDefaultLanguage())))), /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("div", {
28124
28174
  className: "plc-mb-4 plc-text-gray-500 pelcro-donation-date"
28125
- }, sub.status && /*#__PURE__*/React__default.createElement("span", null, formatStartDate(sub.start)))));
28175
+ }, sub.status && /*#__PURE__*/React__default.createElement("span", null, formatStartDate(sub.start)))), /*#__PURE__*/React__default.createElement("td", null, sub.cancel_at_period_end === 1 && sub.plan.auto_renew && !sub.is_gift_recipient && /*#__PURE__*/React__default.createElement(Button, {
28176
+ variant: "ghost",
28177
+ className: "plc-text-green-400 focus:plc-ring-green-300 pelcro-dashboard-sub-reactivate-button",
28178
+ icon: /*#__PURE__*/React__default.createElement(SvgRefresh, null),
28179
+ onClick: onReactivateClick,
28180
+ disabled: disableSubmit,
28181
+ "data-key": sub.id
28182
+ }, t("labels.reactivate")), !sub.plan.auto_renew || sub.plan.auto_renew && sub.cancel_at_period_end === 0 ? /*#__PURE__*/React__default.createElement(Button, {
28183
+ variant: "ghost",
28184
+ className: "plc-text-red-500 focus:plc-ring-red-500 pelcro-dashboard-sub-cancel-button",
28185
+ icon: /*#__PURE__*/React__default.createElement(SvgXIconSolid, null),
28186
+ onClick: onCancelClick,
28187
+ disabled: disableSubmit,
28188
+ "data-key": sub.id
28189
+ }, t("labels.unsubscribe")) : ""));
28126
28190
  });
28127
28191
  return /*#__PURE__*/React__default.createElement("table", {
28128
28192
  className: "plc-w-full plc-table-fixed pelcro-donations-table"
@@ -28132,7 +28196,9 @@ const DonationsMenu = () => {
28132
28196
  className: "plc-w-6/12 "
28133
28197
  }, t("labels.plan")), /*#__PURE__*/React__default.createElement("th", {
28134
28198
  className: "plc-w-6/12 "
28135
- }, t("labels.startDate")))), /*#__PURE__*/React__default.createElement("tbody", null, /*#__PURE__*/React__default.createElement("tr", {
28199
+ }, t("labels.startDate")), /*#__PURE__*/React__default.createElement("th", {
28200
+ className: "plc-w-3/12 "
28201
+ }, t("labels.actions")))), /*#__PURE__*/React__default.createElement("tbody", null, /*#__PURE__*/React__default.createElement("tr", {
28136
28202
  className: "plc-h-4"
28137
28203
  }), subscriptions));
28138
28204
  };
@@ -28965,7 +29031,11 @@ class Dashboard extends Component {
28965
29031
  className: "plc-transform plc-scale-120 plc-w-7 plc-h-8 plc-mr-1 plc-pt-1"
28966
29032
  }),
28967
29033
  title: this.locale("labels.donations"),
28968
- content: /*#__PURE__*/React__default.createElement(DonationsMenu, null)
29034
+ content: /*#__PURE__*/React__default.createElement(DonationsMenu, {
29035
+ reactivateSubscription: this.reactivateSubscription,
29036
+ disableSubmit: this.state.disableSubmit,
29037
+ cancelSubscription: this.cancelSubscription
29038
+ })
28969
29039
  }), /*#__PURE__*/React__default.createElement(Accordion.item, {
28970
29040
  name: SUB_MENUS.GIFTS,
28971
29041
  icon: /*#__PURE__*/React__default.createElement(SvgGift, null),
@@ -31026,7 +31096,7 @@ const EmailVerifyModal = ({
31026
31096
 
31027
31097
  (_props$onSuccess = (_props = props).onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(_props, res);
31028
31098
 
31029
- if (product && plan) {
31099
+ if (product) {
31030
31100
  if (product.address_required) {
31031
31101
  return switchToAddressView();
31032
31102
  } else {
@@ -31196,7 +31266,7 @@ function VerifyLinkTokenModal({
31196
31266
 
31197
31267
  (_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
31198
31268
  resetView();
31199
- notify.success(t("messages.success"));
31269
+ notify$1.success(t("messages.success"));
31200
31270
  };
31201
31271
 
31202
31272
  return /*#__PURE__*/React__default.createElement(Modal, {
@@ -32858,4 +32928,4 @@ const QrCodeModal = ({
32858
32928
  };
32859
32929
  QrCodeModal.viewId = "qrcode";
32860
32930
 
32861
- export { AddressCreateCity, AddressCreateContainer, AddressCreateCountrySelect, AddressCreateFirstName, AddressCreateLastName, AddressCreateLine1, AddressCreateLine2, AddressCreateModal, AddressCreatePostalCode, AddressCreateSetDefault, AddressCreateStateSelect, AddressCreateSubmit, AddressCreateTextInput, AddressCreateView, AddressSelectContainer, AddressSelectList, AddressSelectModal, AddressSelectSubmit, AddressSelectView, AddressUpdateCity, AddressUpdateContainer, AddressUpdateCountrySelect, AddressUpdateFirstName, AddressUpdateLastName, AddressUpdateLine1, AddressUpdateLine2, AddressUpdateModal, AddressUpdatePostalCode, AddressUpdateSetDefault, AddressUpdateStateSelect, AddressUpdateSubmit, AddressUpdateTextInput, AddressUpdateView, AlertWithContext as Alert, Alert as AlertElement, ApplyCouponButton, Auth0LoginButton, Badge, BankAuthenticationSuccess, BankRedirection, Button, CartContainer, CartModal, CartRemoveItemButton, CartSubmit, CartTotalPrice, CartView, Checkbox, CheckoutForm, ConfirmPassword, CouponCode, CouponCodeField, DashboardWithHook as Dashboard, DashboardOpenButton, DatePicker, DiscountedPrice, Email, EmailVerifyContainer, EmailVerifyModal, EmailVerifyResendButton, EmailVerifyView, FacebookLoginButton, GiftCreateContainer, GiftCreateEmail, GiftCreateFirstName, GiftCreateLastName, GiftCreateMessage, GiftCreateModal, GiftCreateStartDate, GiftCreateSubmitButton, GiftCreateView, GiftRedeemCode, GiftRedeemContainer, GiftRedeemModal, GiftRedeemSubmitButton, GiftRedeemView, GoogleLoginButton, IncludeFirstName, IncludeLastName, IncludePhone, Input, InvoiceDetailsContainer, InvoiceDetailsDownloadButton, InvoiceDetailsModal, InvoiceDetailsPayButton, InvoiceDetailsView, InvoicePaymentContainer, InvoicePaymentModal, InvoicePaymentView, Link, LoginButton, LoginContainer, LoginEmail, LoginModal, LoginPassword, LoginRequestLoginToken, LoginUsername, LoginView, Logout, MeterModal, MeterView, Modal, ModalBody, ModalFooter, NewsletterWithHook as NewsLetter, NewsletterUpdateButton, NewsletterUpdateContainer, NewsletterUpdateList, NewsletterUpdateModal, NewsletterUpdateView, Notification, OrderConfirmModal, OrderCreateContainer, OrderCreateModal, OrderCreateSubmitButton, OrderCreateView, Password, PasswordChangeButton, PasswordChangeConfirmNewPassword, PasswordChangeContainer, PasswordChangeCurrentPassword, PasswordChangeModal, PasswordChangeNewPassword, PasswordChangeView, PasswordForgotButton, PasswordForgotContainer, PasswordForgotEmail, PasswordForgotModal, PasswordForgotView, PasswordResetButton, PasswordResetConfirmPassword, PasswordResetContainer, PasswordResetEmail, PasswordResetModal, PasswordResetPassword, PasswordResetView, PasswordlessRequestContainer, PasswordlessRequestEmail, PasswordlessRequestModal, PasswordlessRequestView, PasswordlessRequestViewButton, PaymentCreateContainer, PaymentCreateView, PaymentMethodContainer, PaymentMethodSelectContainer, PaymentMethodSelectList, PaymentMethodSelectModal, PaymentMethodSelectSubmit, PaymentMethodSelectView, PaymentMethodUpdateContainer, PaymentMethodUpdateModal, PaymentMethodUpdateView, PaymentMethodView, PaymentSuccessModal, PaymentSuccessView, PaypalSubscribeButton, PelcroCardCVC, PelcroCardExpiry, PelcroCardNumber, PelcroModalController, PelcroPaymentRequestButton, ProfilePicChangeButton, ProfilePicChangeContainer, ProfilePicChangeCropper, ProfilePicChangeModal, ProfilePicChangeRemoveButton, ProfilePicChangeSelectButton, ProfilePicChangeView, ProfilePicChangeZoom, QrCodeModal, QrCodeView, Radio, RegisterButton, RegisterCompany, RegisterContainer, RegisterEmail, RegisterFirstName, RegisterJobTitle, RegisterLastName, RegisterModal, RegisterPassword, RegisterView, Select, SelectModalWithHook as SelectModal, SelectedPaymentMethod, ShopPurchaseButton, ShopSelectProductButton, ShopView, SubmitPaymentMethod, SubscriptionCancelModal, SubscriptionCreateContainer, SubscriptionCreateFreePlanButton, SubscriptionCreateModal, SubscriptionCreateView, SubscriptionManageMembersButton, SubscriptionManageMembersContainer, SubscriptionManageMembersEmails, SubscriptionManageMembersList, SubscriptionManageMembersModal, SubscriptionManageMembersView, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, SubscriptionSuspendContainer, SubscriptionSuspendModal, SubscriptionSuspendView, TaxAmount, TextArea, Tooltip, UserNameInput, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateTin, UserUpdateUsername, UserUpdateView, VerifyLinkTokenContainer, VerifyLinkTokenLoader, VerifyLinkTokenModal, VerifyLinkTokenView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, invoicePaymentSubmitButton, notify, unauthenticatedButtons, usePelcro$1 as usePelcro };
32931
+ export { AddressCreateCity, AddressCreateContainer, AddressCreateCountrySelect, AddressCreateFirstName, AddressCreateLastName, AddressCreateLine1, AddressCreateLine2, AddressCreateModal, AddressCreatePostalCode, AddressCreateSetDefault, AddressCreateStateSelect, AddressCreateSubmit, AddressCreateTextInput, AddressCreateView, AddressSelectContainer, AddressSelectList, AddressSelectModal, AddressSelectSubmit, AddressSelectView, AddressUpdateCity, AddressUpdateContainer, AddressUpdateCountrySelect, AddressUpdateFirstName, AddressUpdateLastName, AddressUpdateLine1, AddressUpdateLine2, AddressUpdateModal, AddressUpdatePostalCode, AddressUpdateSetDefault, AddressUpdateStateSelect, AddressUpdateSubmit, AddressUpdateTextInput, AddressUpdateView, AlertWithContext as Alert, Alert as AlertElement, ApplyCouponButton, Auth0LoginButton, Badge, BankAuthenticationSuccess, BankRedirection, Button, CartContainer, CartModal, CartRemoveItemButton, CartSubmit, CartTotalPrice, CartView, Checkbox, CheckoutForm, ConfirmPassword, CouponCode, CouponCodeField, DashboardWithHook as Dashboard, DashboardOpenButton, DatePicker, DiscountedPrice, Email, EmailVerifyContainer, EmailVerifyModal, EmailVerifyResendButton, EmailVerifyView, FacebookLoginButton, GiftCreateContainer, GiftCreateEmail, GiftCreateFirstName, GiftCreateLastName, GiftCreateMessage, GiftCreateModal, GiftCreateStartDate, GiftCreateSubmitButton, GiftCreateView, GiftRedeemCode, GiftRedeemContainer, GiftRedeemModal, GiftRedeemSubmitButton, GiftRedeemView, GoogleLoginButton, IncludeFirstName, IncludeLastName, IncludePhone, Input, InvoiceDetailsContainer, InvoiceDetailsDownloadButton, InvoiceDetailsModal, InvoiceDetailsPayButton, InvoiceDetailsView, InvoicePaymentContainer, InvoicePaymentModal, InvoicePaymentView, Link, LoginButton, LoginContainer, LoginEmail, LoginModal, LoginPassword, LoginRequestLoginToken, LoginUsername, LoginView, Logout, MeterModal, MeterView, Modal, ModalBody, ModalFooter, NewsletterWithHook as NewsLetter, NewsletterUpdateButton, NewsletterUpdateContainer, NewsletterUpdateList, NewsletterUpdateModal, NewsletterUpdateView, Notification, OrderConfirmModal, OrderCreateContainer, OrderCreateModal, OrderCreateSubmitButton, OrderCreateView, Password, PasswordChangeButton, PasswordChangeConfirmNewPassword, PasswordChangeContainer, PasswordChangeCurrentPassword, PasswordChangeModal, PasswordChangeNewPassword, PasswordChangeView, PasswordForgotButton, PasswordForgotContainer, PasswordForgotEmail, PasswordForgotModal, PasswordForgotView, PasswordResetButton, PasswordResetConfirmPassword, PasswordResetContainer, PasswordResetEmail, PasswordResetModal, PasswordResetPassword, PasswordResetView, PasswordlessRequestContainer, PasswordlessRequestEmail, PasswordlessRequestModal, PasswordlessRequestView, PasswordlessRequestViewButton, PaymentCreateContainer, PaymentCreateView, PaymentMethodContainer, PaymentMethodSelectContainer, PaymentMethodSelectList, PaymentMethodSelectModal, PaymentMethodSelectSubmit, PaymentMethodSelectView, PaymentMethodUpdateContainer, PaymentMethodUpdateModal, PaymentMethodUpdateView, PaymentMethodView, PaymentSuccessModal, PaymentSuccessView, PaypalSubscribeButton, PelcroCardCVC, PelcroCardExpiry, PelcroCardNumber, PelcroModalController, PelcroPaymentRequestButton, ProfilePicChangeButton, ProfilePicChangeContainer, ProfilePicChangeCropper, ProfilePicChangeModal, ProfilePicChangeRemoveButton, ProfilePicChangeSelectButton, ProfilePicChangeView, ProfilePicChangeZoom, QrCodeModal, QrCodeView, Radio, RegisterButton, RegisterCompany, RegisterContainer, RegisterEmail, RegisterFirstName, RegisterJobTitle, RegisterLastName, RegisterModal, RegisterPassword, RegisterView, Select, SelectModalWithHook as SelectModal, SelectedPaymentMethod, ShopPurchaseButton, ShopSelectProductButton, ShopView, SubmitPaymentMethod, SubscriptionCancelModal, SubscriptionCreateContainer, SubscriptionCreateFreePlanButton, SubscriptionCreateModal, SubscriptionCreateView, SubscriptionManageMembersButton, SubscriptionManageMembersContainer, SubscriptionManageMembersEmails, SubscriptionManageMembersList, SubscriptionManageMembersModal, SubscriptionManageMembersView, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, SubscriptionSuspendContainer, SubscriptionSuspendModal, SubscriptionSuspendView, TaxAmount, TextArea, Tooltip, UserNameInput, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateTin, UserUpdateUsername, UserUpdateView, VerifyLinkTokenContainer, VerifyLinkTokenLoader, VerifyLinkTokenModal, VerifyLinkTokenView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, invoicePaymentSubmitButton, notify$1 as notify, unauthenticatedButtons, usePelcro$1 as usePelcro };
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.13.0-beta.16",
4
+ "version": "3.13.0-beta.18",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",