@pelcro/react-pelcro-js 3.2.0-beta.40 → 3.2.0-beta.43

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
@@ -6994,6 +6994,8 @@ class PelcroActions {
6994
6994
  });
6995
6995
 
6996
6996
  _defineProperty$3(this, "switchView", view => {
6997
+ var _window$Pelcro$site$r;
6998
+
6997
6999
  // view switching guards
6998
7000
  if (userMustVerifyEmail() && !["dashboard", "meter", "login", null].includes(view)) {
6999
7001
  return this.set({
@@ -7013,7 +7015,9 @@ class PelcroActions {
7013
7015
  });
7014
7016
  }
7015
7017
 
7016
- if (["passwordless-request"].includes(view) && this.get().isAuthenticated()) {
7018
+ console.log(this.get().isAuthenticated());
7019
+
7020
+ if (["passwordless-request"].includes(view) && (this.get().isAuthenticated() || !((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.passwordless_enabled))) {
7017
7021
  return this.set({
7018
7022
  view: null
7019
7023
  });
@@ -10159,18 +10163,19 @@ const verifyEmailTokenFromUrl = () => {
10159
10163
  };
10160
10164
 
10161
10165
  const verifyLinkTokenFromUrl = () => {
10162
- var _window$Pelcro$user$i, _window$Pelcro$user;
10166
+ var _window$Pelcro$site$r7;
10163
10167
 
10164
10168
  const {
10165
10169
  whenSiteReady,
10166
- resetView
10170
+ resetView,
10171
+ isAuthenticated
10167
10172
  } = usePelcro.getStore();
10168
10173
  const translations = i18next.t("verifyLinkToken:messages", {
10169
10174
  returnObjects: true
10170
10175
  });
10171
- const isAlreadyLoggedIn = (_window$Pelcro$user$i = (_window$Pelcro$user = window.Pelcro.user) === null || _window$Pelcro$user === void 0 ? void 0 : _window$Pelcro$user.isAuthenticated()) !== null && _window$Pelcro$user$i !== void 0 ? _window$Pelcro$user$i : false;
10172
10176
  const loginToken = window.Pelcro.helpers.getURLParameter("token");
10173
- if (isAlreadyLoggedIn || !loginToken) return;
10177
+ const passwordlessEnabled = (_window$Pelcro$site$r7 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r7 === void 0 ? void 0 : _window$Pelcro$site$r7.passwordless_enabled;
10178
+ if (isAuthenticated() || !loginToken || !passwordlessEnabled) return;
10174
10179
  whenSiteReady(() => {
10175
10180
  window.Pelcro.user.verifyLoginToken({
10176
10181
  token: loginToken
@@ -10199,11 +10204,13 @@ const verifyLinkTokenFromUrl = () => {
10199
10204
  };
10200
10205
 
10201
10206
  const showPasswordlessRequestFromUrl = () => {
10202
- var _window$Pelcro$site$r7, _window$Pelcro$user$i2, _window$Pelcro$user2;
10207
+ var _window$Pelcro$site$r8;
10203
10208
 
10204
- const passwordlessEnabled = (_window$Pelcro$site$r7 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r7 === void 0 ? void 0 : _window$Pelcro$site$r7.passwordless_enabled;
10205
- const isAlreadyLoggedIn = (_window$Pelcro$user$i2 = (_window$Pelcro$user2 = window.Pelcro.user) === null || _window$Pelcro$user2 === void 0 ? void 0 : _window$Pelcro$user2.isAuthenticated()) !== null && _window$Pelcro$user$i2 !== void 0 ? _window$Pelcro$user$i2 : false;
10206
- if (!passwordlessEnabled || isAlreadyLoggedIn) return;
10209
+ const {
10210
+ isAuthenticated
10211
+ } = usePelcro.getStore();
10212
+ const passwordlessEnabled = (_window$Pelcro$site$r8 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r8 === void 0 ? void 0 : _window$Pelcro$site$r8.passwordless_enabled;
10213
+ if (!passwordlessEnabled || isAuthenticated()) return;
10207
10214
  const {
10208
10215
  switchView
10209
10216
  } = usePelcro.getStore();
@@ -11647,13 +11654,23 @@ const Auth0LoginButton = ({
11647
11654
  }
11648
11655
 
11649
11656
  const {
11650
- email
11657
+ email,
11658
+ first_name,
11659
+ last_name,
11660
+ given_name,
11661
+ family_name
11651
11662
  } = user;
11652
11663
  loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
11653
11664
  type: HANDLE_SOCIAL_LOGIN,
11654
11665
  payload: {
11655
11666
  idpName: "auth0",
11656
11667
  idpToken: accessToken,
11668
+ ...((first_name || given_name) && {
11669
+ firstName: first_name || given_name
11670
+ }),
11671
+ ...((last_name || family_name) && {
11672
+ lastName: last_name || family_name
11673
+ }),
11657
11674
  email
11658
11675
  }
11659
11676
  });
@@ -11662,6 +11679,12 @@ const Auth0LoginButton = ({
11662
11679
  payload: {
11663
11680
  idpName: "auth0",
11664
11681
  idpToken: accessToken,
11682
+ ...((first_name || given_name) && {
11683
+ firstName: first_name || given_name
11684
+ }),
11685
+ ...((last_name || family_name) && {
11686
+ lastName: last_name || family_name
11687
+ }),
11665
11688
  email
11666
11689
  }
11667
11690
  });
@@ -17101,6 +17124,7 @@ const SubscriptionCancelView = props => {
17101
17124
  const {
17102
17125
  subscriptionToCancel
17103
17126
  } = usePelcro();
17127
+ console.log(subscriptionToCancel);
17104
17128
  const {
17105
17129
  t
17106
17130
  } = useTranslation("subscriptionCancel");
@@ -17118,14 +17142,14 @@ const SubscriptionCancelView = props => {
17118
17142
  className: "plc-w-32 plc-h-32"
17119
17143
  }), /*#__PURE__*/React__default['default'].createElement("p", {
17120
17144
  className: "plc-mb-3 plc-text-gray-900 plc-text-center plc-whitespace-pre-line"
17121
- }, t("messages.subscriptionEnd"), " ", new Date(subscriptionToCancel === null || subscriptionToCancel === void 0 ? void 0 : subscriptionToCancel.current_period_end).toLocaleDateString('en-CA', {
17145
+ }, t("messages.subscriptionEnd"), " ", new Date(subscriptionToCancel === null || subscriptionToCancel === void 0 ? void 0 : subscriptionToCancel.current_period_end).toLocaleDateString("en-CA", {
17122
17146
  year: "numeric",
17123
17147
  month: "short",
17124
17148
  day: "numeric"
17125
17149
  }), "."), /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelReason, null), /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelNowButton, {
17126
17150
  className: "plc-mb-2",
17127
17151
  subscription: subscriptionToCancel
17128
- }), /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelLaterButton, {
17152
+ }), subscriptionToCancel.cancel_at_period_end === 0 && /*#__PURE__*/React__default['default'].createElement(SubscriptionCancelLaterButton, {
17129
17153
  subscription: subscriptionToCancel
17130
17154
  }))));
17131
17155
  };
@@ -24058,14 +24082,7 @@ const SubscriptionsItems = ({
24058
24082
  className: "plc-inline-block plc-mt-1 plc-underline"
24059
24083
  }, getSubscriptionStatus(sub).content), /*#__PURE__*/React__default['default'].createElement("br", null), sub.shipments_remaining ? /*#__PURE__*/React__default['default'].createElement("span", {
24060
24084
  className: "plc-inline-block plc-mt-1"
24061
- }, sub.shipments_remaining, " ", t("labels.shipments")) : null)), /*#__PURE__*/React__default['default'].createElement("td", null, sub.cancel_at_period_end === 0 && /*#__PURE__*/React__default['default'].createElement(Button, {
24062
- variant: "ghost",
24063
- className: "plc-text-red-500 focus:plc-ring-red-500 pelcro-dashboard-sub-cancel-button",
24064
- icon: /*#__PURE__*/React__default['default'].createElement(SvgXIconSolid, null),
24065
- onClick: onCancelClick,
24066
- disabled: disableSubmit,
24067
- "data-key": sub.id
24068
- }, t("labels.unsubscribe")), sub.cancel_at_period_end === 1 && sub.plan.auto_renew && !sub.is_gift_recipient && /*#__PURE__*/React__default['default'].createElement(Button, {
24085
+ }, sub.shipments_remaining, " ", t("labels.shipments")) : null)), /*#__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, {
24069
24086
  variant: "ghost",
24070
24087
  className: "plc-text-green-400 focus:plc-ring-green-300 pelcro-dashboard-sub-reactivate-button",
24071
24088
  icon: /*#__PURE__*/React__default['default'].createElement(SvgRefresh, null),
@@ -24079,7 +24096,14 @@ const SubscriptionsItems = ({
24079
24096
  onClick: onRenewClick,
24080
24097
  disabled: disableSubmit,
24081
24098
  "data-key": sub.id
24082
- }, t("labels.renew"))), /*#__PURE__*/React__default['default'].createElement("td", null, hasPhases && /*#__PURE__*/React__default['default'].createElement("div", {
24099
+ }, t("labels.renew")), /*#__PURE__*/React__default['default'].createElement(Button, {
24100
+ variant: "ghost",
24101
+ className: "plc-text-red-500 focus:plc-ring-red-500 pelcro-dashboard-sub-cancel-button",
24102
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgXIconSolid, null),
24103
+ onClick: onCancelClick,
24104
+ disabled: disableSubmit,
24105
+ "data-key": sub.id
24106
+ }, t("labels.unsubscribe"))), /*#__PURE__*/React__default['default'].createElement("td", null, hasPhases && /*#__PURE__*/React__default['default'].createElement("div", {
24083
24107
  className: `plc-flex plc-items-center plc-justify-center plc-transition-transform plc-ease-out plc-transform plc-rounded-full plc-w-7 plc-h-7 ${isActive ? "plc-flex plc-place-items-center plc-w-7 plc-h-7 plc-p-1 plc-bg-primary-400 plc-rounded-full" : "accordion-chevron"}`
24084
24108
  }, /*#__PURE__*/React__default['default'].createElement("span", {
24085
24109
  className: `plc-transition plc-ease-out ${isActive && "plc-text-white plc-transform plc-rotate-90"}`
package/dist/index.esm.js CHANGED
@@ -6964,6 +6964,8 @@ class PelcroActions {
6964
6964
  });
6965
6965
 
6966
6966
  _defineProperty$3(this, "switchView", view => {
6967
+ var _window$Pelcro$site$r;
6968
+
6967
6969
  // view switching guards
6968
6970
  if (userMustVerifyEmail() && !["dashboard", "meter", "login", null].includes(view)) {
6969
6971
  return this.set({
@@ -6983,7 +6985,9 @@ class PelcroActions {
6983
6985
  });
6984
6986
  }
6985
6987
 
6986
- if (["passwordless-request"].includes(view) && this.get().isAuthenticated()) {
6988
+ console.log(this.get().isAuthenticated());
6989
+
6990
+ if (["passwordless-request"].includes(view) && (this.get().isAuthenticated() || !((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.passwordless_enabled))) {
6987
6991
  return this.set({
6988
6992
  view: null
6989
6993
  });
@@ -10129,18 +10133,19 @@ const verifyEmailTokenFromUrl = () => {
10129
10133
  };
10130
10134
 
10131
10135
  const verifyLinkTokenFromUrl = () => {
10132
- var _window$Pelcro$user$i, _window$Pelcro$user;
10136
+ var _window$Pelcro$site$r7;
10133
10137
 
10134
10138
  const {
10135
10139
  whenSiteReady,
10136
- resetView
10140
+ resetView,
10141
+ isAuthenticated
10137
10142
  } = usePelcro.getStore();
10138
10143
  const translations = i18next.t("verifyLinkToken:messages", {
10139
10144
  returnObjects: true
10140
10145
  });
10141
- const isAlreadyLoggedIn = (_window$Pelcro$user$i = (_window$Pelcro$user = window.Pelcro.user) === null || _window$Pelcro$user === void 0 ? void 0 : _window$Pelcro$user.isAuthenticated()) !== null && _window$Pelcro$user$i !== void 0 ? _window$Pelcro$user$i : false;
10142
10146
  const loginToken = window.Pelcro.helpers.getURLParameter("token");
10143
- if (isAlreadyLoggedIn || !loginToken) return;
10147
+ const passwordlessEnabled = (_window$Pelcro$site$r7 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r7 === void 0 ? void 0 : _window$Pelcro$site$r7.passwordless_enabled;
10148
+ if (isAuthenticated() || !loginToken || !passwordlessEnabled) return;
10144
10149
  whenSiteReady(() => {
10145
10150
  window.Pelcro.user.verifyLoginToken({
10146
10151
  token: loginToken
@@ -10169,11 +10174,13 @@ const verifyLinkTokenFromUrl = () => {
10169
10174
  };
10170
10175
 
10171
10176
  const showPasswordlessRequestFromUrl = () => {
10172
- var _window$Pelcro$site$r7, _window$Pelcro$user$i2, _window$Pelcro$user2;
10177
+ var _window$Pelcro$site$r8;
10173
10178
 
10174
- const passwordlessEnabled = (_window$Pelcro$site$r7 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r7 === void 0 ? void 0 : _window$Pelcro$site$r7.passwordless_enabled;
10175
- const isAlreadyLoggedIn = (_window$Pelcro$user$i2 = (_window$Pelcro$user2 = window.Pelcro.user) === null || _window$Pelcro$user2 === void 0 ? void 0 : _window$Pelcro$user2.isAuthenticated()) !== null && _window$Pelcro$user$i2 !== void 0 ? _window$Pelcro$user$i2 : false;
10176
- if (!passwordlessEnabled || isAlreadyLoggedIn) return;
10179
+ const {
10180
+ isAuthenticated
10181
+ } = usePelcro.getStore();
10182
+ const passwordlessEnabled = (_window$Pelcro$site$r8 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r8 === void 0 ? void 0 : _window$Pelcro$site$r8.passwordless_enabled;
10183
+ if (!passwordlessEnabled || isAuthenticated()) return;
10177
10184
  const {
10178
10185
  switchView
10179
10186
  } = usePelcro.getStore();
@@ -11617,13 +11624,23 @@ const Auth0LoginButton = ({
11617
11624
  }
11618
11625
 
11619
11626
  const {
11620
- email
11627
+ email,
11628
+ first_name,
11629
+ last_name,
11630
+ given_name,
11631
+ family_name
11621
11632
  } = user;
11622
11633
  loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
11623
11634
  type: HANDLE_SOCIAL_LOGIN,
11624
11635
  payload: {
11625
11636
  idpName: "auth0",
11626
11637
  idpToken: accessToken,
11638
+ ...((first_name || given_name) && {
11639
+ firstName: first_name || given_name
11640
+ }),
11641
+ ...((last_name || family_name) && {
11642
+ lastName: last_name || family_name
11643
+ }),
11627
11644
  email
11628
11645
  }
11629
11646
  });
@@ -11632,6 +11649,12 @@ const Auth0LoginButton = ({
11632
11649
  payload: {
11633
11650
  idpName: "auth0",
11634
11651
  idpToken: accessToken,
11652
+ ...((first_name || given_name) && {
11653
+ firstName: first_name || given_name
11654
+ }),
11655
+ ...((last_name || family_name) && {
11656
+ lastName: last_name || family_name
11657
+ }),
11635
11658
  email
11636
11659
  }
11637
11660
  });
@@ -17071,6 +17094,7 @@ const SubscriptionCancelView = props => {
17071
17094
  const {
17072
17095
  subscriptionToCancel
17073
17096
  } = usePelcro();
17097
+ console.log(subscriptionToCancel);
17074
17098
  const {
17075
17099
  t
17076
17100
  } = useTranslation("subscriptionCancel");
@@ -17088,14 +17112,14 @@ const SubscriptionCancelView = props => {
17088
17112
  className: "plc-w-32 plc-h-32"
17089
17113
  }), /*#__PURE__*/React__default.createElement("p", {
17090
17114
  className: "plc-mb-3 plc-text-gray-900 plc-text-center plc-whitespace-pre-line"
17091
- }, t("messages.subscriptionEnd"), " ", new Date(subscriptionToCancel === null || subscriptionToCancel === void 0 ? void 0 : subscriptionToCancel.current_period_end).toLocaleDateString('en-CA', {
17115
+ }, t("messages.subscriptionEnd"), " ", new Date(subscriptionToCancel === null || subscriptionToCancel === void 0 ? void 0 : subscriptionToCancel.current_period_end).toLocaleDateString("en-CA", {
17092
17116
  year: "numeric",
17093
17117
  month: "short",
17094
17118
  day: "numeric"
17095
17119
  }), "."), /*#__PURE__*/React__default.createElement(SubscriptionCancelReason, null), /*#__PURE__*/React__default.createElement(SubscriptionCancelNowButton, {
17096
17120
  className: "plc-mb-2",
17097
17121
  subscription: subscriptionToCancel
17098
- }), /*#__PURE__*/React__default.createElement(SubscriptionCancelLaterButton, {
17122
+ }), subscriptionToCancel.cancel_at_period_end === 0 && /*#__PURE__*/React__default.createElement(SubscriptionCancelLaterButton, {
17099
17123
  subscription: subscriptionToCancel
17100
17124
  }))));
17101
17125
  };
@@ -24028,14 +24052,7 @@ const SubscriptionsItems = ({
24028
24052
  className: "plc-inline-block plc-mt-1 plc-underline"
24029
24053
  }, getSubscriptionStatus(sub).content), /*#__PURE__*/React__default.createElement("br", null), sub.shipments_remaining ? /*#__PURE__*/React__default.createElement("span", {
24030
24054
  className: "plc-inline-block plc-mt-1"
24031
- }, sub.shipments_remaining, " ", t("labels.shipments")) : null)), /*#__PURE__*/React__default.createElement("td", null, sub.cancel_at_period_end === 0 && /*#__PURE__*/React__default.createElement(Button, {
24032
- variant: "ghost",
24033
- className: "plc-text-red-500 focus:plc-ring-red-500 pelcro-dashboard-sub-cancel-button",
24034
- icon: /*#__PURE__*/React__default.createElement(SvgXIconSolid, null),
24035
- onClick: onCancelClick,
24036
- disabled: disableSubmit,
24037
- "data-key": sub.id
24038
- }, t("labels.unsubscribe")), sub.cancel_at_period_end === 1 && sub.plan.auto_renew && !sub.is_gift_recipient && /*#__PURE__*/React__default.createElement(Button, {
24055
+ }, sub.shipments_remaining, " ", t("labels.shipments")) : null)), /*#__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, {
24039
24056
  variant: "ghost",
24040
24057
  className: "plc-text-green-400 focus:plc-ring-green-300 pelcro-dashboard-sub-reactivate-button",
24041
24058
  icon: /*#__PURE__*/React__default.createElement(SvgRefresh, null),
@@ -24049,7 +24066,14 @@ const SubscriptionsItems = ({
24049
24066
  onClick: onRenewClick,
24050
24067
  disabled: disableSubmit,
24051
24068
  "data-key": sub.id
24052
- }, t("labels.renew"))), /*#__PURE__*/React__default.createElement("td", null, hasPhases && /*#__PURE__*/React__default.createElement("div", {
24069
+ }, t("labels.renew")), /*#__PURE__*/React__default.createElement(Button, {
24070
+ variant: "ghost",
24071
+ className: "plc-text-red-500 focus:plc-ring-red-500 pelcro-dashboard-sub-cancel-button",
24072
+ icon: /*#__PURE__*/React__default.createElement(SvgXIconSolid, null),
24073
+ onClick: onCancelClick,
24074
+ disabled: disableSubmit,
24075
+ "data-key": sub.id
24076
+ }, t("labels.unsubscribe"))), /*#__PURE__*/React__default.createElement("td", null, hasPhases && /*#__PURE__*/React__default.createElement("div", {
24053
24077
  className: `plc-flex plc-items-center plc-justify-center plc-transition-transform plc-ease-out plc-transform plc-rounded-full plc-w-7 plc-h-7 ${isActive ? "plc-flex plc-place-items-center plc-w-7 plc-h-7 plc-p-1 plc-bg-primary-400 plc-rounded-full" : "accordion-chevron"}`
24054
24078
  }, /*#__PURE__*/React__default.createElement("span", {
24055
24079
  className: `plc-transition plc-ease-out ${isActive && "plc-text-white plc-transform plc-rotate-90"}`
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.2.0-beta.40",
4
+ "version": "3.2.0-beta.43",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",