@pelcro/react-pelcro-js 3.33.0 → 3.33.2
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 +38 -18
- package/dist/index.esm.js +38 -18
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -14100,14 +14100,37 @@ function LoginModal(_ref) {
|
|
|
14100
14100
|
plan,
|
|
14101
14101
|
order,
|
|
14102
14102
|
switchToAddressView,
|
|
14103
|
-
switchToPaymentView
|
|
14103
|
+
switchToPaymentView,
|
|
14104
|
+
giftCode,
|
|
14105
|
+
isGift
|
|
14104
14106
|
} = usePelcro();
|
|
14105
14107
|
const onSuccess = res => {
|
|
14106
14108
|
var _props$onSuccess;
|
|
14107
14109
|
(_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
|
|
14110
|
+
handleAfterLoginLogic();
|
|
14111
|
+
};
|
|
14112
|
+
const handleAfterLoginLogic = () => {
|
|
14108
14113
|
if (window.Pelcro.paywall.isArticleRestricted()) {
|
|
14109
14114
|
initPaywalls();
|
|
14110
14115
|
}
|
|
14116
|
+
if (!product && !order && !giftCode) {
|
|
14117
|
+
// If product and plan are not selected
|
|
14118
|
+
return resetView();
|
|
14119
|
+
}
|
|
14120
|
+
|
|
14121
|
+
// If this is a redeem gift
|
|
14122
|
+
if (giftCode) {
|
|
14123
|
+
return switchView("gift-redeem");
|
|
14124
|
+
// return switchToAddressView();
|
|
14125
|
+
}
|
|
14126
|
+
|
|
14127
|
+
// Check if the subscription is meant as a gift (if so, gather recipients info)
|
|
14128
|
+
if (isGift) {
|
|
14129
|
+
return switchView("gift-create");
|
|
14130
|
+
}
|
|
14131
|
+
if (order) {
|
|
14132
|
+
return switchToAddressView();
|
|
14133
|
+
}
|
|
14111
14134
|
if (product && plan) {
|
|
14112
14135
|
if (product.address_required) {
|
|
14113
14136
|
return switchToAddressView();
|
|
@@ -14118,15 +14141,12 @@ function LoginModal(_ref) {
|
|
|
14118
14141
|
if (product && !plan) {
|
|
14119
14142
|
return switchView("plan-select");
|
|
14120
14143
|
}
|
|
14121
|
-
if (order) {
|
|
14122
|
-
return switchToAddressView();
|
|
14123
|
-
}
|
|
14124
|
-
resetView();
|
|
14125
14144
|
const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
|
|
14126
14145
|
const viewsURLs = ["invoice-details", "gift-redeem", "plan-select", "payment-method-update"];
|
|
14127
14146
|
if (viewsURLs.includes(viewFromURL)) {
|
|
14128
|
-
initViewFromURL();
|
|
14147
|
+
return initViewFromURL();
|
|
14129
14148
|
}
|
|
14149
|
+
return resetView();
|
|
14130
14150
|
};
|
|
14131
14151
|
const onCreateAccountClick = () => {
|
|
14132
14152
|
switchView("plan-select");
|
|
@@ -20083,7 +20103,7 @@ const CouponCodeField = props => {
|
|
|
20083
20103
|
};
|
|
20084
20104
|
return /*#__PURE__*/React__default['default'].createElement(Input, Object.assign({
|
|
20085
20105
|
className: "plc-h-12",
|
|
20086
|
-
wrapperClassName: "plc-mb-
|
|
20106
|
+
wrapperClassName: "plc-mb-6",
|
|
20087
20107
|
errorClassName: "plc-h-12 sm:plc-h-8",
|
|
20088
20108
|
error: couponError,
|
|
20089
20109
|
"aria-label": t("labels.code"),
|
|
@@ -20735,7 +20755,7 @@ const ApplePayButton = _ref => {
|
|
|
20735
20755
|
total: {
|
|
20736
20756
|
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
20737
20757
|
type: "final",
|
|
20738
|
-
amount: updatedPrice / 100
|
|
20758
|
+
amount: (updatedPrice / 100).toFixed(2)
|
|
20739
20759
|
}
|
|
20740
20760
|
};
|
|
20741
20761
|
|
|
@@ -20779,12 +20799,12 @@ const ApplePayButton = _ref => {
|
|
|
20779
20799
|
const newTotal = {
|
|
20780
20800
|
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
20781
20801
|
type: "final",
|
|
20782
|
-
amount: updatedPrice / 100
|
|
20802
|
+
amount: (updatedPrice / 100).toFixed(2)
|
|
20783
20803
|
};
|
|
20784
20804
|
const newLineItems = [{
|
|
20785
20805
|
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
20786
20806
|
type: "final",
|
|
20787
|
-
amount: updatedPrice / 100
|
|
20807
|
+
amount: (updatedPrice / 100).toFixed(2)
|
|
20788
20808
|
}];
|
|
20789
20809
|
session.completePaymentMethodSelection(newTotal, newLineItems);
|
|
20790
20810
|
};
|
|
@@ -20796,14 +20816,14 @@ const ApplePayButton = _ref => {
|
|
|
20796
20816
|
// const newTotal = {
|
|
20797
20817
|
// label: plan?.nickname || orderLabel || `invoice #${invoice?.id}`,
|
|
20798
20818
|
// type: "final",
|
|
20799
|
-
// amount: updatedPrice / 100
|
|
20819
|
+
// amount: (updatedPrice / 100).toFixed(2)
|
|
20800
20820
|
// };
|
|
20801
20821
|
|
|
20802
20822
|
// const newLineItems = [
|
|
20803
20823
|
// {
|
|
20804
20824
|
// label: plan?.nickname || orderLabel || `invoice #${invoice?.id}`,
|
|
20805
20825
|
// type: "final",
|
|
20806
|
-
// amount: updatedPrice / 100
|
|
20826
|
+
// amount: (updatedPrice / 100).toFixed(2)
|
|
20807
20827
|
// }
|
|
20808
20828
|
// ];
|
|
20809
20829
|
|
|
@@ -30436,9 +30456,7 @@ const MembershipsItems = () => {
|
|
|
30436
30456
|
};
|
|
30437
30457
|
if (memberships.length === 0) return null;
|
|
30438
30458
|
return memberships.sort((a, b) => a.created_at - b.created_at).map(membership => {
|
|
30439
|
-
|
|
30440
|
-
(_window$Pelcro$addres = window.Pelcro.address.list()) === null || _window$Pelcro$addres === void 0 ? void 0 : _window$Pelcro$addres.find(address => address.id === membership.address_id);
|
|
30441
|
-
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, membership.subscription.ended_at === null && /*#__PURE__*/React__default['default'].createElement("tr", {
|
|
30459
|
+
return /*#__PURE__*/React__default['default'].createElement("tr", {
|
|
30442
30460
|
key: membership.id,
|
|
30443
30461
|
className: `plc-w-full plc-align-top pelcro-membership-row`
|
|
30444
30462
|
}, /*#__PURE__*/React__default['default'].createElement("td", {
|
|
@@ -30454,12 +30472,13 @@ const MembershipsItems = () => {
|
|
|
30454
30472
|
}),
|
|
30455
30473
|
className: "plc-text-blue-400 focus:plc-ring-blue-500 pelcro-dashboard-membership-address-button",
|
|
30456
30474
|
onClick: () => onChangeAddressClick(membership.id)
|
|
30457
|
-
}, `${t("labels.editAddress")}`)))
|
|
30475
|
+
}, `${t("labels.editAddress")}`)));
|
|
30458
30476
|
});
|
|
30459
30477
|
};
|
|
30460
30478
|
function getActiveMemberships() {
|
|
30461
30479
|
var _window$Pelcro$user$r, _window$Pelcro$user$r2;
|
|
30462
|
-
|
|
30480
|
+
const subsStatuses = ["active", "extended", "trialing"];
|
|
30481
|
+
return (_window$Pelcro$user$r = (_window$Pelcro$user$r2 = window.Pelcro.user.read().memberships) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : _window$Pelcro$user$r2.filter(membership => membership.status === "active" && subsStatuses.includes(membership.subscription.status))) !== null && _window$Pelcro$user$r !== void 0 ? _window$Pelcro$user$r : [];
|
|
30463
30482
|
}
|
|
30464
30483
|
function getMemberShipStatus(status) {
|
|
30465
30484
|
return {
|
|
@@ -31184,7 +31203,8 @@ function hasDonationSubs() {
|
|
|
31184
31203
|
}
|
|
31185
31204
|
function hasActiveMemberships() {
|
|
31186
31205
|
var _window$Pelcro$user$r6, _window$Pelcro$user$r7;
|
|
31187
|
-
|
|
31206
|
+
const subsStatuses = ["active", "extended", "trialing"];
|
|
31207
|
+
return (_window$Pelcro$user$r6 = (_window$Pelcro$user$r7 = window.Pelcro.user.read().memberships) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.some(membership => membership.status === "active" && subsStatuses.includes(membership.subscription.status))) !== null && _window$Pelcro$user$r6 !== void 0 ? _window$Pelcro$user$r6 : false;
|
|
31188
31208
|
}
|
|
31189
31209
|
const DashboardWithTrans = withTranslation("dashboard")(Dashboard);
|
|
31190
31210
|
|
package/dist/index.esm.js
CHANGED
|
@@ -14070,14 +14070,37 @@ function LoginModal(_ref) {
|
|
|
14070
14070
|
plan,
|
|
14071
14071
|
order,
|
|
14072
14072
|
switchToAddressView,
|
|
14073
|
-
switchToPaymentView
|
|
14073
|
+
switchToPaymentView,
|
|
14074
|
+
giftCode,
|
|
14075
|
+
isGift
|
|
14074
14076
|
} = usePelcro();
|
|
14075
14077
|
const onSuccess = res => {
|
|
14076
14078
|
var _props$onSuccess;
|
|
14077
14079
|
(_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
|
|
14080
|
+
handleAfterLoginLogic();
|
|
14081
|
+
};
|
|
14082
|
+
const handleAfterLoginLogic = () => {
|
|
14078
14083
|
if (window.Pelcro.paywall.isArticleRestricted()) {
|
|
14079
14084
|
initPaywalls();
|
|
14080
14085
|
}
|
|
14086
|
+
if (!product && !order && !giftCode) {
|
|
14087
|
+
// If product and plan are not selected
|
|
14088
|
+
return resetView();
|
|
14089
|
+
}
|
|
14090
|
+
|
|
14091
|
+
// If this is a redeem gift
|
|
14092
|
+
if (giftCode) {
|
|
14093
|
+
return switchView("gift-redeem");
|
|
14094
|
+
// return switchToAddressView();
|
|
14095
|
+
}
|
|
14096
|
+
|
|
14097
|
+
// Check if the subscription is meant as a gift (if so, gather recipients info)
|
|
14098
|
+
if (isGift) {
|
|
14099
|
+
return switchView("gift-create");
|
|
14100
|
+
}
|
|
14101
|
+
if (order) {
|
|
14102
|
+
return switchToAddressView();
|
|
14103
|
+
}
|
|
14081
14104
|
if (product && plan) {
|
|
14082
14105
|
if (product.address_required) {
|
|
14083
14106
|
return switchToAddressView();
|
|
@@ -14088,15 +14111,12 @@ function LoginModal(_ref) {
|
|
|
14088
14111
|
if (product && !plan) {
|
|
14089
14112
|
return switchView("plan-select");
|
|
14090
14113
|
}
|
|
14091
|
-
if (order) {
|
|
14092
|
-
return switchToAddressView();
|
|
14093
|
-
}
|
|
14094
|
-
resetView();
|
|
14095
14114
|
const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
|
|
14096
14115
|
const viewsURLs = ["invoice-details", "gift-redeem", "plan-select", "payment-method-update"];
|
|
14097
14116
|
if (viewsURLs.includes(viewFromURL)) {
|
|
14098
|
-
initViewFromURL();
|
|
14117
|
+
return initViewFromURL();
|
|
14099
14118
|
}
|
|
14119
|
+
return resetView();
|
|
14100
14120
|
};
|
|
14101
14121
|
const onCreateAccountClick = () => {
|
|
14102
14122
|
switchView("plan-select");
|
|
@@ -20053,7 +20073,7 @@ const CouponCodeField = props => {
|
|
|
20053
20073
|
};
|
|
20054
20074
|
return /*#__PURE__*/React__default.createElement(Input, Object.assign({
|
|
20055
20075
|
className: "plc-h-12",
|
|
20056
|
-
wrapperClassName: "plc-mb-
|
|
20076
|
+
wrapperClassName: "plc-mb-6",
|
|
20057
20077
|
errorClassName: "plc-h-12 sm:plc-h-8",
|
|
20058
20078
|
error: couponError,
|
|
20059
20079
|
"aria-label": t("labels.code"),
|
|
@@ -20705,7 +20725,7 @@ const ApplePayButton = _ref => {
|
|
|
20705
20725
|
total: {
|
|
20706
20726
|
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
20707
20727
|
type: "final",
|
|
20708
|
-
amount: updatedPrice / 100
|
|
20728
|
+
amount: (updatedPrice / 100).toFixed(2)
|
|
20709
20729
|
}
|
|
20710
20730
|
};
|
|
20711
20731
|
|
|
@@ -20749,12 +20769,12 @@ const ApplePayButton = _ref => {
|
|
|
20749
20769
|
const newTotal = {
|
|
20750
20770
|
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
20751
20771
|
type: "final",
|
|
20752
|
-
amount: updatedPrice / 100
|
|
20772
|
+
amount: (updatedPrice / 100).toFixed(2)
|
|
20753
20773
|
};
|
|
20754
20774
|
const newLineItems = [{
|
|
20755
20775
|
label: (plan === null || plan === void 0 ? void 0 : plan.nickname) || orderLabel || `invoice #${invoice === null || invoice === void 0 ? void 0 : invoice.id}`,
|
|
20756
20776
|
type: "final",
|
|
20757
|
-
amount: updatedPrice / 100
|
|
20777
|
+
amount: (updatedPrice / 100).toFixed(2)
|
|
20758
20778
|
}];
|
|
20759
20779
|
session.completePaymentMethodSelection(newTotal, newLineItems);
|
|
20760
20780
|
};
|
|
@@ -20766,14 +20786,14 @@ const ApplePayButton = _ref => {
|
|
|
20766
20786
|
// const newTotal = {
|
|
20767
20787
|
// label: plan?.nickname || orderLabel || `invoice #${invoice?.id}`,
|
|
20768
20788
|
// type: "final",
|
|
20769
|
-
// amount: updatedPrice / 100
|
|
20789
|
+
// amount: (updatedPrice / 100).toFixed(2)
|
|
20770
20790
|
// };
|
|
20771
20791
|
|
|
20772
20792
|
// const newLineItems = [
|
|
20773
20793
|
// {
|
|
20774
20794
|
// label: plan?.nickname || orderLabel || `invoice #${invoice?.id}`,
|
|
20775
20795
|
// type: "final",
|
|
20776
|
-
// amount: updatedPrice / 100
|
|
20796
|
+
// amount: (updatedPrice / 100).toFixed(2)
|
|
20777
20797
|
// }
|
|
20778
20798
|
// ];
|
|
20779
20799
|
|
|
@@ -30406,9 +30426,7 @@ const MembershipsItems = () => {
|
|
|
30406
30426
|
};
|
|
30407
30427
|
if (memberships.length === 0) return null;
|
|
30408
30428
|
return memberships.sort((a, b) => a.created_at - b.created_at).map(membership => {
|
|
30409
|
-
|
|
30410
|
-
(_window$Pelcro$addres = window.Pelcro.address.list()) === null || _window$Pelcro$addres === void 0 ? void 0 : _window$Pelcro$addres.find(address => address.id === membership.address_id);
|
|
30411
|
-
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, membership.subscription.ended_at === null && /*#__PURE__*/React__default.createElement("tr", {
|
|
30429
|
+
return /*#__PURE__*/React__default.createElement("tr", {
|
|
30412
30430
|
key: membership.id,
|
|
30413
30431
|
className: `plc-w-full plc-align-top pelcro-membership-row`
|
|
30414
30432
|
}, /*#__PURE__*/React__default.createElement("td", {
|
|
@@ -30424,12 +30442,13 @@ const MembershipsItems = () => {
|
|
|
30424
30442
|
}),
|
|
30425
30443
|
className: "plc-text-blue-400 focus:plc-ring-blue-500 pelcro-dashboard-membership-address-button",
|
|
30426
30444
|
onClick: () => onChangeAddressClick(membership.id)
|
|
30427
|
-
}, `${t("labels.editAddress")}`)))
|
|
30445
|
+
}, `${t("labels.editAddress")}`)));
|
|
30428
30446
|
});
|
|
30429
30447
|
};
|
|
30430
30448
|
function getActiveMemberships() {
|
|
30431
30449
|
var _window$Pelcro$user$r, _window$Pelcro$user$r2;
|
|
30432
|
-
|
|
30450
|
+
const subsStatuses = ["active", "extended", "trialing"];
|
|
30451
|
+
return (_window$Pelcro$user$r = (_window$Pelcro$user$r2 = window.Pelcro.user.read().memberships) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : _window$Pelcro$user$r2.filter(membership => membership.status === "active" && subsStatuses.includes(membership.subscription.status))) !== null && _window$Pelcro$user$r !== void 0 ? _window$Pelcro$user$r : [];
|
|
30433
30452
|
}
|
|
30434
30453
|
function getMemberShipStatus(status) {
|
|
30435
30454
|
return {
|
|
@@ -31154,7 +31173,8 @@ function hasDonationSubs() {
|
|
|
31154
31173
|
}
|
|
31155
31174
|
function hasActiveMemberships() {
|
|
31156
31175
|
var _window$Pelcro$user$r6, _window$Pelcro$user$r7;
|
|
31157
|
-
|
|
31176
|
+
const subsStatuses = ["active", "extended", "trialing"];
|
|
31177
|
+
return (_window$Pelcro$user$r6 = (_window$Pelcro$user$r7 = window.Pelcro.user.read().memberships) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.some(membership => membership.status === "active" && subsStatuses.includes(membership.subscription.status))) !== null && _window$Pelcro$user$r6 !== void 0 ? _window$Pelcro$user$r6 : false;
|
|
31158
31178
|
}
|
|
31159
31179
|
const DashboardWithTrans = withTranslation("dashboard")(Dashboard);
|
|
31160
31180
|
|