@pelcro/react-pelcro-js 3.26.0-beta.40 → 3.26.0-beta.42

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
@@ -14459,14 +14459,37 @@ function LoginModal(_ref) {
14459
14459
  plan,
14460
14460
  order,
14461
14461
  switchToAddressView,
14462
- switchToPaymentView
14462
+ switchToPaymentView,
14463
+ giftCode,
14464
+ isGift
14463
14465
  } = usePelcro();
14464
14466
  const onSuccess = res => {
14465
14467
  var _props$onSuccess;
14466
14468
  (_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
14469
+ handleAfterLoginLogic();
14470
+ };
14471
+ const handleAfterLoginLogic = () => {
14467
14472
  if (window.Pelcro.paywall.isArticleRestricted()) {
14468
14473
  initPaywalls();
14469
14474
  }
14475
+ if (!product && !order && !giftCode) {
14476
+ // If product and plan are not selected
14477
+ return resetView();
14478
+ }
14479
+
14480
+ // If this is a redeem gift
14481
+ if (giftCode) {
14482
+ return switchView("gift-redeem");
14483
+ // return switchToAddressView();
14484
+ }
14485
+
14486
+ // Check if the subscription is meant as a gift (if so, gather recipients info)
14487
+ if (isGift) {
14488
+ return switchView("gift-create");
14489
+ }
14490
+ if (order) {
14491
+ return switchToAddressView();
14492
+ }
14470
14493
  if (product && plan) {
14471
14494
  if (product.address_required) {
14472
14495
  return switchToAddressView();
@@ -14477,15 +14500,12 @@ function LoginModal(_ref) {
14477
14500
  if (product && !plan) {
14478
14501
  return switchView("plan-select");
14479
14502
  }
14480
- if (order) {
14481
- return switchToAddressView();
14482
- }
14483
- resetView();
14484
14503
  const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
14485
14504
  const viewsURLs = ["invoice-details", "gift-redeem", "plan-select", "payment-method-update"];
14486
14505
  if (viewsURLs.includes(viewFromURL)) {
14487
- initViewFromURL();
14506
+ return initViewFromURL();
14488
14507
  }
14508
+ return resetView();
14489
14509
  };
14490
14510
  const onCreateAccountClick = () => {
14491
14511
  switchView("plan-select");
@@ -21499,7 +21519,7 @@ const TaxAmount = () => {
21499
21519
  const isTaxInclusive = (_window$Pelcro$site = window.Pelcro.site) === null || _window$Pelcro$site === void 0 ? void 0 : (_window$Pelcro$site$r = _window$Pelcro$site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tax_inclusive;
21500
21520
  if (taxAmount) {
21501
21521
  return /*#__PURE__*/React__default['default'].createElement("div", {
21502
- className: "plc-text-center pelcro-tax-amount"
21522
+ className: "plc-text-center pelcro-tax-amount plc-mt-10"
21503
21523
  }, isTaxInclusive && "(", isTaxInclusive ? `Includes ${t("labels.tax")}` : `+ ${t("labels.tax")}`, " ", /*#__PURE__*/React__default['default'].createElement("span", {
21504
21524
  className: "plc-font-bold"
21505
21525
  }, priceFormatted), isTaxInclusive && ")");
package/dist/index.esm.js CHANGED
@@ -14429,14 +14429,37 @@ function LoginModal(_ref) {
14429
14429
  plan,
14430
14430
  order,
14431
14431
  switchToAddressView,
14432
- switchToPaymentView
14432
+ switchToPaymentView,
14433
+ giftCode,
14434
+ isGift
14433
14435
  } = usePelcro();
14434
14436
  const onSuccess = res => {
14435
14437
  var _props$onSuccess;
14436
14438
  (_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
14439
+ handleAfterLoginLogic();
14440
+ };
14441
+ const handleAfterLoginLogic = () => {
14437
14442
  if (window.Pelcro.paywall.isArticleRestricted()) {
14438
14443
  initPaywalls();
14439
14444
  }
14445
+ if (!product && !order && !giftCode) {
14446
+ // If product and plan are not selected
14447
+ return resetView();
14448
+ }
14449
+
14450
+ // If this is a redeem gift
14451
+ if (giftCode) {
14452
+ return switchView("gift-redeem");
14453
+ // return switchToAddressView();
14454
+ }
14455
+
14456
+ // Check if the subscription is meant as a gift (if so, gather recipients info)
14457
+ if (isGift) {
14458
+ return switchView("gift-create");
14459
+ }
14460
+ if (order) {
14461
+ return switchToAddressView();
14462
+ }
14440
14463
  if (product && plan) {
14441
14464
  if (product.address_required) {
14442
14465
  return switchToAddressView();
@@ -14447,15 +14470,12 @@ function LoginModal(_ref) {
14447
14470
  if (product && !plan) {
14448
14471
  return switchView("plan-select");
14449
14472
  }
14450
- if (order) {
14451
- return switchToAddressView();
14452
- }
14453
- resetView();
14454
14473
  const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
14455
14474
  const viewsURLs = ["invoice-details", "gift-redeem", "plan-select", "payment-method-update"];
14456
14475
  if (viewsURLs.includes(viewFromURL)) {
14457
- initViewFromURL();
14476
+ return initViewFromURL();
14458
14477
  }
14478
+ return resetView();
14459
14479
  };
14460
14480
  const onCreateAccountClick = () => {
14461
14481
  switchView("plan-select");
@@ -21469,7 +21489,7 @@ const TaxAmount = () => {
21469
21489
  const isTaxInclusive = (_window$Pelcro$site = window.Pelcro.site) === null || _window$Pelcro$site === void 0 ? void 0 : (_window$Pelcro$site$r = _window$Pelcro$site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tax_inclusive;
21470
21490
  if (taxAmount) {
21471
21491
  return /*#__PURE__*/React__default.createElement("div", {
21472
- className: "plc-text-center pelcro-tax-amount"
21492
+ className: "plc-text-center pelcro-tax-amount plc-mt-10"
21473
21493
  }, isTaxInclusive && "(", isTaxInclusive ? `Includes ${t("labels.tax")}` : `+ ${t("labels.tax")}`, " ", /*#__PURE__*/React__default.createElement("span", {
21474
21494
  className: "plc-font-bold"
21475
21495
  }, priceFormatted), isTaxInclusive && ")");
package/dist/pelcro.css CHANGED
@@ -2384,6 +2384,10 @@ apple-pay-button {
2384
2384
  margin-bottom: 1.5rem;
2385
2385
  }
2386
2386
 
2387
+ .pelcro-root .plc-mt-10 {
2388
+ margin-top: 2.5rem;
2389
+ }
2390
+
2387
2391
  .pelcro-root .plc-mt-auto {
2388
2392
  margin-top: auto;
2389
2393
  }
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.40",
4
+ "version": "3.26.0-beta.42",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",