@pelcro/react-pelcro-js 3.13.0-beta.13 → 3.13.0-beta.15

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
@@ -8313,7 +8313,7 @@ class PelcroActions {
8313
8313
  return console.error("invalid subscription id");
8314
8314
  }
8315
8315
 
8316
- if ((subscriptionToManageMembers === null || subscriptionToManageMembers === void 0 ? void 0 : (_subscriptionToManage = subscriptionToManageMembers.plan) === null || _subscriptionToManage === void 0 ? void 0 : _subscriptionToManage.type) !== 'membership') {
8316
+ if ((subscriptionToManageMembers === null || subscriptionToManageMembers === void 0 ? void 0 : (_subscriptionToManage = subscriptionToManageMembers.plan) === null || _subscriptionToManage === void 0 ? void 0 : _subscriptionToManage.type) !== "membership") {
8317
8317
  return console.error("subscription is not from type membership");
8318
8318
  }
8319
8319
 
@@ -13482,7 +13482,7 @@ function LoginModal({
13482
13482
  resetView();
13483
13483
  const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
13484
13484
 
13485
- if (viewFromURL === "invoice-details") {
13485
+ if (viewFromURL === "invoice-details" || viewFromURL === "gift-redeem") {
13486
13486
  initViewFromURL();
13487
13487
  }
13488
13488
  };
@@ -14066,7 +14066,7 @@ function RegisterModal(props) {
14066
14066
 
14067
14067
 
14068
14068
  if (giftCode) {
14069
- return switchToAddressView();
14069
+ return switchView("gift-redeem"); // return switchToAddressView();
14070
14070
  } // Check if the subscription is meant as a gift (if so, gather recipients info)
14071
14071
 
14072
14072
 
@@ -21060,8 +21060,8 @@ function SubscriptionManageMembersList(props) {
21060
21060
  return {
21061
21061
  title: sub.status,
21062
21062
  content: sub.status,
21063
- textColor: "plc-text-red-500",
21064
- bgColor: "plc-bg-red-100",
21063
+ textColor: "plc-text-yellow-500",
21064
+ bgColor: "plc-bg-yellow-100",
21065
21065
  icon: /*#__PURE__*/React__default['default'].createElement(SvgExclamation, null)
21066
21066
  };
21067
21067
  }
@@ -21117,7 +21117,8 @@ function SubscriptionManageMembersList(props) {
21117
21117
  key: member.id,
21118
21118
  className: `plc-w-full plc-align-middle plc-cursor-pointer accordion-header hover:plc-bg-gray-50 plc-text-center`
21119
21119
  }, /*#__PURE__*/React__default['default'].createElement("td", {
21120
- className: "plc-truncate"
21120
+ className: "plc-truncate plc-text-left",
21121
+ title: member === null || member === void 0 ? void 0 : member.invitation_email
21121
21122
  }, /*#__PURE__*/React__default['default'].createElement("span", {
21122
21123
  className: "plc-font-semibold plc-text-gray-500"
21123
21124
  }, member === null || member === void 0 ? void 0 : member.invitation_email)), /*#__PURE__*/React__default['default'].createElement("td", {
@@ -21171,8 +21172,10 @@ function SubscriptionManageMembersView(props) {
21171
21172
  className: "plc-flex-shrink-0 plc-p-2 plc-text-xs plc-text-gray-400 plc-uppercase"
21172
21173
  }, t("labels.listOfMembers")), /*#__PURE__*/React__default['default'].createElement("hr", {
21173
21174
  className: "plc-w-full plc-border-gray-300"
21174
- })), /*#__PURE__*/React__default['default'].createElement("table", {
21175
- className: "plc-w-full plc-table-fixed plc-text-center"
21175
+ })), /*#__PURE__*/React__default['default'].createElement("div", {
21176
+ className: "plc-max-h-48 plc-overflow-x-hidden plc-overflow-y-auto"
21177
+ }, /*#__PURE__*/React__default['default'].createElement("table", {
21178
+ className: "plc-w-full plc-table-fixed plc-text-center plc-p-2 plc-m-1"
21176
21179
  }, /*#__PURE__*/React__default['default'].createElement("thead", {
21177
21180
  className: "plc-text-xs plc-font-semibold plc-tracking-wider plc-text-gray-400 plc-uppercase "
21178
21181
  }, /*#__PURE__*/React__default['default'].createElement("tr", null, /*#__PURE__*/React__default['default'].createElement("th", {
@@ -21181,7 +21184,7 @@ function SubscriptionManageMembersView(props) {
21181
21184
  className: "plc-w-3/12 "
21182
21185
  }, t("labels.status")), /*#__PURE__*/React__default['default'].createElement("th", {
21183
21186
  className: "plc-w-3/12 "
21184
- }, t("labels.actions")))), /*#__PURE__*/React__default['default'].createElement("tbody", null, /*#__PURE__*/React__default['default'].createElement(SubscriptionManageMembersList, null)))))));
21187
+ }, t("labels.actions")))), /*#__PURE__*/React__default['default'].createElement("tbody", null, /*#__PURE__*/React__default['default'].createElement(SubscriptionManageMembersList, null))))))));
21185
21188
  }
21186
21189
 
21187
21190
  /**
@@ -25272,6 +25275,7 @@ const GiftCreateModal = ({
25272
25275
  GiftCreateModal.viewId = "gift-create";
25273
25276
 
25274
25277
  const initialState$6 = {
25278
+ isSubmitting: false,
25275
25279
  giftCode: "",
25276
25280
  buttonDisabled: true,
25277
25281
  alert: {
@@ -25290,14 +25294,24 @@ const GiftRedeemContainer = ({
25290
25294
  onSuccess = () => {},
25291
25295
  onFailure = () => {},
25292
25296
  onDisplay = () => {},
25293
- children
25297
+ children,
25298
+ ...props
25294
25299
  }) => {
25300
+ var _ref, _props$subscriptionId;
25301
+
25295
25302
  const {
25296
25303
  t
25297
25304
  } = useTranslation("register");
25298
25305
  const {
25299
25306
  set
25300
25307
  } = usePelcro();
25308
+ const {
25309
+ switchView,
25310
+ switchToAddressView,
25311
+ isAuthenticated,
25312
+ subscriptionIdToRenew: subscriptionIdToRenewFromStore
25313
+ } = usePelcro();
25314
+ const subscriptionIdToRenew = (_ref = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : subscriptionIdToRenewFromStore) !== null && _ref !== void 0 ? _ref : undefined;
25301
25315
  React.useEffect(() => {
25302
25316
  onDisplay();
25303
25317
  }, []);
@@ -25318,7 +25332,41 @@ const GiftRedeemContainer = ({
25318
25332
  set({
25319
25333
  giftCode
25320
25334
  });
25321
- onSuccess(giftCode);
25335
+
25336
+ if (!isAuthenticated()) {
25337
+ switchView("register");
25338
+ } else {
25339
+ console.log("Shaker");
25340
+ window.Pelcro.subscription.redeemGift({
25341
+ auth_token: window.Pelcro.user.read().auth_token,
25342
+ gift_code: giftCode,
25343
+ // redeem gift as a future phase of an existing subscription
25344
+ subscription_id: subscriptionIdToRenew
25345
+ }, (err, res) => {
25346
+ dispatch({
25347
+ type: LOADING,
25348
+ payload: false
25349
+ });
25350
+
25351
+ if (err) {
25352
+ dispatch({
25353
+ type: SHOW_ALERT,
25354
+ payload: {
25355
+ type: "error",
25356
+ content: getErrorMessages(err)
25357
+ }
25358
+ });
25359
+
25360
+ if (getErrorMessages(err) === "Address ID is required") {
25361
+ switchToAddressView();
25362
+ } else {
25363
+ return onFailure(err);
25364
+ }
25365
+ } else {
25366
+ return onSuccess(giftCode);
25367
+ }
25368
+ });
25369
+ }
25322
25370
  }
25323
25371
  };
25324
25372
 
@@ -25339,8 +25387,14 @@ const GiftRedeemContainer = ({
25339
25387
  buttonDisabled: action.payload
25340
25388
  });
25341
25389
 
25390
+ case LOADING:
25391
+ return lib_7({ ...state,
25392
+ isSubmitting: action.payload
25393
+ });
25394
+
25342
25395
  case HANDLE_SUBMIT:
25343
25396
  return lib_5({ ...state,
25397
+ isSubmitting: true,
25344
25398
  buttonDisabled: true
25345
25399
  }, (state, dispatch) => handleRedeem(state, dispatch));
25346
25400
 
@@ -25409,7 +25463,8 @@ const GiftRedeemSubmitButton = ({
25409
25463
  const {
25410
25464
  dispatch,
25411
25465
  state: {
25412
- disableSubmit
25466
+ disableSubmit,
25467
+ isSubmitting
25413
25468
  }
25414
25469
  } = React.useContext(store$6);
25415
25470
  const {
@@ -25422,7 +25477,8 @@ const GiftRedeemSubmitButton = ({
25422
25477
  });
25423
25478
  onClick === null || onClick === void 0 ? void 0 : onClick();
25424
25479
  },
25425
- disabled: disableSubmit
25480
+ disabled: disableSubmit,
25481
+ isLoading: isSubmitting
25426
25482
  }, otherProps), name !== null && name !== void 0 ? name : t("redeem.buttons.redeem"));
25427
25483
  };
25428
25484
 
@@ -25473,12 +25529,7 @@ const GiftRedeemModal = ({
25473
25529
  var _otherProps$onSuccess;
25474
25530
 
25475
25531
  (_otherProps$onSuccess = otherProps.onSuccess) === null || _otherProps$onSuccess === void 0 ? void 0 : _otherProps$onSuccess.call(otherProps, giftCode);
25476
-
25477
- if (isAuthenticated()) {
25478
- switchToAddressView();
25479
- } else {
25480
- switchView("register");
25481
- }
25532
+ switchView("subscription-success");
25482
25533
  };
25483
25534
 
25484
25535
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
package/dist/index.esm.js CHANGED
@@ -8283,7 +8283,7 @@ class PelcroActions {
8283
8283
  return console.error("invalid subscription id");
8284
8284
  }
8285
8285
 
8286
- if ((subscriptionToManageMembers === null || subscriptionToManageMembers === void 0 ? void 0 : (_subscriptionToManage = subscriptionToManageMembers.plan) === null || _subscriptionToManage === void 0 ? void 0 : _subscriptionToManage.type) !== 'membership') {
8286
+ if ((subscriptionToManageMembers === null || subscriptionToManageMembers === void 0 ? void 0 : (_subscriptionToManage = subscriptionToManageMembers.plan) === null || _subscriptionToManage === void 0 ? void 0 : _subscriptionToManage.type) !== "membership") {
8287
8287
  return console.error("subscription is not from type membership");
8288
8288
  }
8289
8289
 
@@ -13452,7 +13452,7 @@ function LoginModal({
13452
13452
  resetView();
13453
13453
  const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
13454
13454
 
13455
- if (viewFromURL === "invoice-details") {
13455
+ if (viewFromURL === "invoice-details" || viewFromURL === "gift-redeem") {
13456
13456
  initViewFromURL();
13457
13457
  }
13458
13458
  };
@@ -14036,7 +14036,7 @@ function RegisterModal(props) {
14036
14036
 
14037
14037
 
14038
14038
  if (giftCode) {
14039
- return switchToAddressView();
14039
+ return switchView("gift-redeem"); // return switchToAddressView();
14040
14040
  } // Check if the subscription is meant as a gift (if so, gather recipients info)
14041
14041
 
14042
14042
 
@@ -21030,8 +21030,8 @@ function SubscriptionManageMembersList(props) {
21030
21030
  return {
21031
21031
  title: sub.status,
21032
21032
  content: sub.status,
21033
- textColor: "plc-text-red-500",
21034
- bgColor: "plc-bg-red-100",
21033
+ textColor: "plc-text-yellow-500",
21034
+ bgColor: "plc-bg-yellow-100",
21035
21035
  icon: /*#__PURE__*/React__default.createElement(SvgExclamation, null)
21036
21036
  };
21037
21037
  }
@@ -21087,7 +21087,8 @@ function SubscriptionManageMembersList(props) {
21087
21087
  key: member.id,
21088
21088
  className: `plc-w-full plc-align-middle plc-cursor-pointer accordion-header hover:plc-bg-gray-50 plc-text-center`
21089
21089
  }, /*#__PURE__*/React__default.createElement("td", {
21090
- className: "plc-truncate"
21090
+ className: "plc-truncate plc-text-left",
21091
+ title: member === null || member === void 0 ? void 0 : member.invitation_email
21091
21092
  }, /*#__PURE__*/React__default.createElement("span", {
21092
21093
  className: "plc-font-semibold plc-text-gray-500"
21093
21094
  }, member === null || member === void 0 ? void 0 : member.invitation_email)), /*#__PURE__*/React__default.createElement("td", {
@@ -21141,8 +21142,10 @@ function SubscriptionManageMembersView(props) {
21141
21142
  className: "plc-flex-shrink-0 plc-p-2 plc-text-xs plc-text-gray-400 plc-uppercase"
21142
21143
  }, t("labels.listOfMembers")), /*#__PURE__*/React__default.createElement("hr", {
21143
21144
  className: "plc-w-full plc-border-gray-300"
21144
- })), /*#__PURE__*/React__default.createElement("table", {
21145
- className: "plc-w-full plc-table-fixed plc-text-center"
21145
+ })), /*#__PURE__*/React__default.createElement("div", {
21146
+ className: "plc-max-h-48 plc-overflow-x-hidden plc-overflow-y-auto"
21147
+ }, /*#__PURE__*/React__default.createElement("table", {
21148
+ className: "plc-w-full plc-table-fixed plc-text-center plc-p-2 plc-m-1"
21146
21149
  }, /*#__PURE__*/React__default.createElement("thead", {
21147
21150
  className: "plc-text-xs plc-font-semibold plc-tracking-wider plc-text-gray-400 plc-uppercase "
21148
21151
  }, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
@@ -21151,7 +21154,7 @@ function SubscriptionManageMembersView(props) {
21151
21154
  className: "plc-w-3/12 "
21152
21155
  }, t("labels.status")), /*#__PURE__*/React__default.createElement("th", {
21153
21156
  className: "plc-w-3/12 "
21154
- }, t("labels.actions")))), /*#__PURE__*/React__default.createElement("tbody", null, /*#__PURE__*/React__default.createElement(SubscriptionManageMembersList, null)))))));
21157
+ }, t("labels.actions")))), /*#__PURE__*/React__default.createElement("tbody", null, /*#__PURE__*/React__default.createElement(SubscriptionManageMembersList, null))))))));
21155
21158
  }
21156
21159
 
21157
21160
  /**
@@ -25242,6 +25245,7 @@ const GiftCreateModal = ({
25242
25245
  GiftCreateModal.viewId = "gift-create";
25243
25246
 
25244
25247
  const initialState$6 = {
25248
+ isSubmitting: false,
25245
25249
  giftCode: "",
25246
25250
  buttonDisabled: true,
25247
25251
  alert: {
@@ -25260,14 +25264,24 @@ const GiftRedeemContainer = ({
25260
25264
  onSuccess = () => {},
25261
25265
  onFailure = () => {},
25262
25266
  onDisplay = () => {},
25263
- children
25267
+ children,
25268
+ ...props
25264
25269
  }) => {
25270
+ var _ref, _props$subscriptionId;
25271
+
25265
25272
  const {
25266
25273
  t
25267
25274
  } = useTranslation("register");
25268
25275
  const {
25269
25276
  set
25270
25277
  } = usePelcro();
25278
+ const {
25279
+ switchView,
25280
+ switchToAddressView,
25281
+ isAuthenticated,
25282
+ subscriptionIdToRenew: subscriptionIdToRenewFromStore
25283
+ } = usePelcro();
25284
+ const subscriptionIdToRenew = (_ref = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : subscriptionIdToRenewFromStore) !== null && _ref !== void 0 ? _ref : undefined;
25271
25285
  useEffect(() => {
25272
25286
  onDisplay();
25273
25287
  }, []);
@@ -25288,7 +25302,41 @@ const GiftRedeemContainer = ({
25288
25302
  set({
25289
25303
  giftCode
25290
25304
  });
25291
- onSuccess(giftCode);
25305
+
25306
+ if (!isAuthenticated()) {
25307
+ switchView("register");
25308
+ } else {
25309
+ console.log("Shaker");
25310
+ window.Pelcro.subscription.redeemGift({
25311
+ auth_token: window.Pelcro.user.read().auth_token,
25312
+ gift_code: giftCode,
25313
+ // redeem gift as a future phase of an existing subscription
25314
+ subscription_id: subscriptionIdToRenew
25315
+ }, (err, res) => {
25316
+ dispatch({
25317
+ type: LOADING,
25318
+ payload: false
25319
+ });
25320
+
25321
+ if (err) {
25322
+ dispatch({
25323
+ type: SHOW_ALERT,
25324
+ payload: {
25325
+ type: "error",
25326
+ content: getErrorMessages(err)
25327
+ }
25328
+ });
25329
+
25330
+ if (getErrorMessages(err) === "Address ID is required") {
25331
+ switchToAddressView();
25332
+ } else {
25333
+ return onFailure(err);
25334
+ }
25335
+ } else {
25336
+ return onSuccess(giftCode);
25337
+ }
25338
+ });
25339
+ }
25292
25340
  }
25293
25341
  };
25294
25342
 
@@ -25309,8 +25357,14 @@ const GiftRedeemContainer = ({
25309
25357
  buttonDisabled: action.payload
25310
25358
  });
25311
25359
 
25360
+ case LOADING:
25361
+ return lib_7({ ...state,
25362
+ isSubmitting: action.payload
25363
+ });
25364
+
25312
25365
  case HANDLE_SUBMIT:
25313
25366
  return lib_5({ ...state,
25367
+ isSubmitting: true,
25314
25368
  buttonDisabled: true
25315
25369
  }, (state, dispatch) => handleRedeem(state, dispatch));
25316
25370
 
@@ -25379,7 +25433,8 @@ const GiftRedeemSubmitButton = ({
25379
25433
  const {
25380
25434
  dispatch,
25381
25435
  state: {
25382
- disableSubmit
25436
+ disableSubmit,
25437
+ isSubmitting
25383
25438
  }
25384
25439
  } = useContext(store$6);
25385
25440
  const {
@@ -25392,7 +25447,8 @@ const GiftRedeemSubmitButton = ({
25392
25447
  });
25393
25448
  onClick === null || onClick === void 0 ? void 0 : onClick();
25394
25449
  },
25395
- disabled: disableSubmit
25450
+ disabled: disableSubmit,
25451
+ isLoading: isSubmitting
25396
25452
  }, otherProps), name !== null && name !== void 0 ? name : t("redeem.buttons.redeem"));
25397
25453
  };
25398
25454
 
@@ -25443,12 +25499,7 @@ const GiftRedeemModal = ({
25443
25499
  var _otherProps$onSuccess;
25444
25500
 
25445
25501
  (_otherProps$onSuccess = otherProps.onSuccess) === null || _otherProps$onSuccess === void 0 ? void 0 : _otherProps$onSuccess.call(otherProps, giftCode);
25446
-
25447
- if (isAuthenticated()) {
25448
- switchToAddressView();
25449
- } else {
25450
- switchView("register");
25451
- }
25502
+ switchView("subscription-success");
25452
25503
  };
25453
25504
 
25454
25505
  return /*#__PURE__*/React__default.createElement(Modal, {
package/dist/pelcro.css CHANGED
@@ -2217,6 +2217,10 @@ in order to scope selectors under pelcro-root
2217
2217
  margin: 0px;
2218
2218
  }
2219
2219
 
2220
+ .pelcro-root .plc-m-1 {
2221
+ margin: 0.25rem;
2222
+ }
2223
+
2220
2224
  .pelcro-root .plc-m-3 {
2221
2225
  margin: 0.75rem;
2222
2226
  }
@@ -2337,6 +2341,10 @@ in order to scope selectors under pelcro-root
2337
2341
  max-height: 3.5rem;
2338
2342
  }
2339
2343
 
2344
+ .pelcro-root .plc-max-h-48 {
2345
+ max-height: 12rem;
2346
+ }
2347
+
2340
2348
  .pelcro-root .plc-max-h-72 {
2341
2349
  max-height: 18rem;
2342
2350
  }
@@ -2383,6 +2391,10 @@ in order to scope selectors under pelcro-root
2383
2391
  overflow-y: auto;
2384
2392
  }
2385
2393
 
2394
+ .pelcro-root .plc-overflow-x-hidden {
2395
+ overflow-x: hidden;
2396
+ }
2397
+
2386
2398
  .pelcro-root .plc-overflow-y-scroll {
2387
2399
  overflow-y: scroll;
2388
2400
  }
@@ -2740,6 +2752,11 @@ in order to scope selectors under pelcro-root
2740
2752
  color: rgba(98, 26, 23, var(--tw-text-opacity));
2741
2753
  }
2742
2754
 
2755
+ .pelcro-root .plc-text-yellow-500 {
2756
+ --tw-text-opacity: 1;
2757
+ color: rgba(245, 158, 11, var(--tw-text-opacity));
2758
+ }
2759
+
2743
2760
  .pelcro-root .plc-text-yellow-700 {
2744
2761
  --tw-text-opacity: 1;
2745
2762
  color: rgba(180, 83, 9, var(--tw-text-opacity));
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.13",
4
+ "version": "3.13.0-beta.15",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",