@pelcro/react-pelcro-js 3.13.0-beta.1 → 3.13.0-beta.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 CHANGED
@@ -3252,7 +3252,8 @@ var validation$2 = {
3252
3252
  };
3253
3253
  var buttons$e = {
3254
3254
  account: "Accès abonné(e)s",
3255
- login: "Se connecter"
3255
+ login: "Se connecter",
3256
+ subscribe: "S'abonner"
3256
3257
  };
3257
3258
  var dashboard$3 = {
3258
3259
  labels: {
@@ -3344,7 +3345,8 @@ var validation$1 = {
3344
3345
  };
3345
3346
  var buttons$d = {
3346
3347
  account: "My account",
3347
- login: "Login"
3348
+ login: "Login",
3349
+ subscribe: "Subscribe"
3348
3350
  };
3349
3351
  var dashboard$2 = {
3350
3352
  labels: {
@@ -3435,7 +3437,8 @@ var validation = {
3435
3437
  };
3436
3438
  var buttons$c = {
3437
3439
  account: "내 계정",
3438
- login: "로그인"
3440
+ login: "로그인",
3441
+ subscribe: "구독하다"
3439
3442
  };
3440
3443
  var dashboard$1 = {
3441
3444
  labels: {
@@ -15409,7 +15412,7 @@ const PaymentMethodContainerWithoutStripe = ({
15409
15412
  onFailure = () => {},
15410
15413
  ...props
15411
15414
  }) => {
15412
- var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice;
15415
+ var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice, _window$Pelcro, _window$Pelcro$uiSett;
15413
15416
 
15414
15417
  const {
15415
15418
  t
@@ -15432,6 +15435,7 @@ const PaymentMethodContainerWithoutStripe = ({
15432
15435
  const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
15433
15436
  const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
15434
15437
  const invoice = (_props$invoice = props.invoice) !== null && _props$invoice !== void 0 ? _props$invoice : pelcroStore.invoice;
15438
+ const skipPayment = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.skipPaymentForFreePlans;
15435
15439
  const cardProcessor = getSiteCardProcessor();
15436
15440
  React.useEffect(() => {
15437
15441
  if (window.Pelcro.coupon.getFromUrl()) {
@@ -15978,6 +15982,8 @@ const PaymentMethodContainerWithoutStripe = ({
15978
15982
  }, [selectedPaymentMethodId]);
15979
15983
 
15980
15984
  const initPaymentRequest = (state, dispatch) => {
15985
+ if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
15986
+
15981
15987
  try {
15982
15988
  const paymentRequest = stripe.paymentRequest({
15983
15989
  country: window.Pelcro.user.location.countryCode || "US",
@@ -16049,6 +16055,7 @@ const PaymentMethodContainerWithoutStripe = ({
16049
16055
  const updateTotalAmountWithTax = () => {
16050
16056
  var _window$Pelcro$site$r4;
16051
16057
 
16058
+ if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16052
16059
  const taxesEnabled = (_window$Pelcro$site$r4 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.taxes_enabled;
16053
16060
 
16054
16061
  if (taxesEnabled && type === "createPayment") {
@@ -16375,8 +16382,8 @@ const PaymentMethodContainerWithoutStripe = ({
16375
16382
 
16376
16383
  if (!subscriptionIdToRenew) {
16377
16384
  window.Pelcro.subscription.create({
16378
- source_id: stripeSource.isExistingSource ? stripeSource.id : undefined,
16379
- stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
16385
+ source_id: stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
16386
+ stripe_token: !(stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource) ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
16380
16387
  auth_token: window.Pelcro.user.read().auth_token,
16381
16388
  plan_id: plan.id,
16382
16389
  campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
@@ -17934,6 +17941,41 @@ const IncludePhone = props => /*#__PURE__*/React__default['default'].createEleme
17934
17941
  store: store$j
17935
17942
  }, props));
17936
17943
 
17944
+ const SubscriptionCreateFreePlanButton = ({
17945
+ name,
17946
+ onClick,
17947
+ ...otherProps
17948
+ }) => {
17949
+ const {
17950
+ state: {
17951
+ disableSubmit
17952
+ },
17953
+ dispatch
17954
+ } = React.useContext(store$j);
17955
+ const {
17956
+ t
17957
+ } = useTranslation("common");
17958
+ const [isDisabled, setDisabled] = React.useState(true);
17959
+ React.useEffect(() => {
17960
+ setDisabled(disableSubmit);
17961
+ }, [disableSubmit]);
17962
+ return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
17963
+ className: "plc-w-full",
17964
+ onClick: () => {
17965
+ dispatch({
17966
+ type: DISABLE_SUBMIT,
17967
+ payload: true
17968
+ });
17969
+ dispatch({
17970
+ type: SUBSCRIBE
17971
+ });
17972
+ onClick === null || onClick === void 0 ? void 0 : onClick();
17973
+ },
17974
+ disabled: isDisabled,
17975
+ isLoading: disableSubmit
17976
+ }, otherProps), t("buttons.subscribe"));
17977
+ };
17978
+
17937
17979
  /**
17938
17980
  *
17939
17981
  */
@@ -17944,7 +17986,8 @@ function PaymentMethodView({
17944
17986
  onFailure,
17945
17987
  type,
17946
17988
  showCoupon,
17947
- showExternalPaymentMethods
17989
+ showExternalPaymentMethods,
17990
+ showSubscriptionButton
17948
17991
  }) {
17949
17992
  var _window$Pelcro$site$r, _window$Pelcro$site$r2;
17950
17993
 
@@ -17959,7 +18002,7 @@ function PaymentMethodView({
17959
18002
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
17960
18003
  return /*#__PURE__*/React__default['default'].createElement("div", {
17961
18004
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
17962
- }, cardProcessor === "stripe" && /*#__PURE__*/React__default['default'].createElement("div", {
18005
+ }, cardProcessor === "stripe" && !showSubscriptionButton && /*#__PURE__*/React__default['default'].createElement("div", {
17963
18006
  className: "plc-flex plc-items-center plc-w-full plc-px-4 plc-py-2 plc-text-center plc-text-green-600 plc-border plc-border-green-400 plc-rounded plc-bg-green-50"
17964
18007
  }, /*#__PURE__*/React__default['default'].createElement(SvgLock, {
17965
18008
  className: "plc-w-5 plc-h-5 plc-mr-1"
@@ -17976,9 +18019,9 @@ function PaymentMethodView({
17976
18019
  onSuccess: onSuccess,
17977
18020
  onGiftRenewalSuccess: onGiftRenewalSuccess,
17978
18021
  onFailure: onFailure
17979
- }, /*#__PURE__*/React__default['default'].createElement(BankRedirection, null), /*#__PURE__*/React__default['default'].createElement(BankAuthenticationSuccess, null), /*#__PURE__*/React__default['default'].createElement(AlertWithContext, {
18022
+ }, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, {
17980
18023
  className: "plc-mb-2"
17981
- }), /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(SelectedPaymentMethod, null), supportsTap && (!isUserFirstName || !isUserLastName || !isUserPhone) && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("div", {
18024
+ }), showSubscriptionButton ? /*#__PURE__*/React__default['default'].createElement(SubscriptionCreateFreePlanButton, null) : /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(BankRedirection, null), /*#__PURE__*/React__default['default'].createElement(BankAuthenticationSuccess, null), /*#__PURE__*/React__default['default'].createElement(SelectedPaymentMethod, null), supportsTap && (!isUserFirstName || !isUserLastName || !isUserPhone) && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("div", {
17982
18025
  className: "plc-flex plc-items-start"
17983
18026
  }, /*#__PURE__*/React__default['default'].createElement(IncludeFirstName, {
17984
18027
  id: "pelcro-input-first-name",
@@ -19391,7 +19434,7 @@ const SubscriptionCreateView = ({
19391
19434
  onSuccess = () => {},
19392
19435
  onFailure = () => {}
19393
19436
  }) => {
19394
- var _product$paywall$subs, _product$paywall, _window$Pelcro$paywal, _product$paywall$subs2, _product$paywall2, _window$Pelcro$paywal2;
19437
+ var _window$Pelcro, _window$Pelcro$uiSett, _product$paywall$subs, _product$paywall, _window$Pelcro$paywal, _product$paywall$subs2, _product$paywall2, _window$Pelcro$paywal2;
19395
19438
 
19396
19439
  const {
19397
19440
  t
@@ -19400,6 +19443,8 @@ const SubscriptionCreateView = ({
19400
19443
  product,
19401
19444
  plan
19402
19445
  } = usePelcro();
19446
+ const skipPayment = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.skipPaymentForFreePlans;
19447
+ const showSubscriptionButton = skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0;
19403
19448
 
19404
19449
  const getPricingText = plan => {
19405
19450
  var _plan$quantity;
@@ -19438,7 +19483,8 @@ const SubscriptionCreateView = ({
19438
19483
  showCoupon: true,
19439
19484
  showExternalPaymentMethods: true,
19440
19485
  onSuccess: onSuccess,
19441
- onFailure: onFailure
19486
+ onFailure: onFailure,
19487
+ showSubscriptionButton: showSubscriptionButton
19442
19488
  }));
19443
19489
  };
19444
19490
 
@@ -23678,13 +23724,12 @@ const AddressSelectContainer = ({
23678
23724
  className = "",
23679
23725
  onGiftRedemptionSuccess = () => {},
23680
23726
  onMembershipAdressUpdateSuccess = () => {},
23681
- onFreePlanSubscriptionSuccess = () => {},
23682
23727
  onSuccess = () => {},
23683
23728
  onFailure = () => {},
23684
23729
  children,
23685
23730
  ...props
23686
23731
  }) => {
23687
- var _props$giftCode, _ref, _props$subscriptionId, _window$Pelcro, _window$Pelcro$uiSett;
23732
+ var _props$giftCode, _ref, _props$subscriptionId;
23688
23733
 
23689
23734
  const {
23690
23735
  t
@@ -23694,13 +23739,10 @@ const AddressSelectContainer = ({
23694
23739
  giftCode: giftCodeFromStore,
23695
23740
  subscriptionIdToRenew: subscriptionIdToRenewFromStore,
23696
23741
  set,
23697
- selectedMembership,
23698
- plan,
23699
- product
23742
+ selectedMembership
23700
23743
  } = usePelcro();
23701
23744
  const giftCode = (_props$giftCode = props.giftCode) !== null && _props$giftCode !== void 0 ? _props$giftCode : giftCodeFromStore;
23702
23745
  const subscriptionIdToRenew = (_ref = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : subscriptionIdToRenewFromStore) !== null && _ref !== void 0 ? _ref : undefined;
23703
- const skipPayment = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.skipPaymentForFreePlans;
23704
23746
 
23705
23747
  const submitAddress = ({
23706
23748
  selectedAddressId
@@ -23772,39 +23814,6 @@ const AddressSelectContainer = ({
23772
23814
  });
23773
23815
  }
23774
23816
 
23775
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) {
23776
- dispatch({
23777
- type: LOADING,
23778
- payload: true
23779
- });
23780
- window.Pelcro.subscription.create({
23781
- auth_token: window.Pelcro.user.read().auth_token,
23782
- plan_id: plan.id,
23783
- campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
23784
- quantity: plan.quantity,
23785
- address_id: product.address_required ? selectedAddressId : null
23786
- }, (err, res) => {
23787
- dispatch({
23788
- type: LOADING,
23789
- payload: false
23790
- });
23791
-
23792
- if (err) {
23793
- dispatch({
23794
- type: SHOW_ALERT,
23795
- payload: {
23796
- type: "error",
23797
- content: getErrorMessages(err)
23798
- }
23799
- });
23800
- return notify.error(getErrorMessages(err));
23801
- }
23802
-
23803
- return onFreePlanSubscriptionSuccess(res);
23804
- });
23805
- return;
23806
- }
23807
-
23808
23817
  onSuccess(selectedAddressId);
23809
23818
  };
23810
23819
 
@@ -23991,7 +24000,8 @@ const AddressSelectModal = ({
23991
24000
 
23992
24001
  const onAddNewAddress = () => {
23993
24002
  switchView("address-create");
23994
- };
24003
+ }; // FIXME: implement me
24004
+
23995
24005
 
23996
24006
  const onMembershipAdressUpdateSuccess = () => {
23997
24007
  var _otherProps$onMembers;
@@ -24000,13 +24010,6 @@ const AddressSelectModal = ({
24000
24010
  resetView();
24001
24011
  };
24002
24012
 
24003
- const onFreePlanSubscriptionSuccess = () => {
24004
- var _otherProps$onFreePla;
24005
-
24006
- (_otherProps$onFreePla = otherProps.onFreePlanSubscriptionSuccess) === null || _otherProps$onFreePla === void 0 ? void 0 : _otherProps$onFreePla.call(otherProps);
24007
- switchView("subscription-success");
24008
- };
24009
-
24010
24013
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
24011
24014
  onDisplay: onDisplay,
24012
24015
  onClose: onClose,
@@ -24016,8 +24019,7 @@ const AddressSelectModal = ({
24016
24019
  }, otherProps, {
24017
24020
  onSuccess: onSuccess,
24018
24021
  onGiftRedemptionSuccess: onGiftRedemptionSuccess,
24019
- onMembershipAdressUpdateSuccess: onMembershipAdressUpdateSuccess,
24020
- onFreePlanSubscriptionSuccess: onFreePlanSubscriptionSuccess
24022
+ onMembershipAdressUpdateSuccess: onMembershipAdressUpdateSuccess
24021
24023
  }))), /*#__PURE__*/React__default['default'].createElement(ModalFooter, null, /*#__PURE__*/React__default['default'].createElement(Authorship, null)));
24022
24024
  };
24023
24025
  AddressSelectModal.viewId = "address-select";
@@ -24235,10 +24237,19 @@ const PaymentMethodSelectModal = ({
24235
24237
  onClose,
24236
24238
  ...otherProps
24237
24239
  }) => {
24240
+ var _window$Pelcro, _window$Pelcro$uiSett;
24241
+
24238
24242
  const {
24239
24243
  switchToCheckoutForm,
24240
- set
24244
+ set,
24245
+ plan
24241
24246
  } = usePelcro();
24247
+ const skipPayment = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.skipPaymentForFreePlans;
24248
+ React.useEffect(() => {
24249
+ if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) {
24250
+ switchToCheckoutForm();
24251
+ }
24252
+ }, []);
24242
24253
 
24243
24254
  const onSuccess = selectedPaymentMethodId => {
24244
24255
  var _otherProps$onSuccess;
@@ -31182,6 +31193,7 @@ exports.ShopView = ShopView;
31182
31193
  exports.SubmitPaymentMethod = SubmitPaymentMethod;
31183
31194
  exports.SubscriptionCancelModal = SubscriptionCancelModal;
31184
31195
  exports.SubscriptionCreateContainer = SubscriptionCreateContainer;
31196
+ exports.SubscriptionCreateFreePlanButton = SubscriptionCreateFreePlanButton;
31185
31197
  exports.SubscriptionCreateModal = SubscriptionCreateModal;
31186
31198
  exports.SubscriptionCreateView = SubscriptionCreateView;
31187
31199
  exports.SubscriptionRenewContainer = SubscriptionRenewContainer;
package/dist/index.esm.js CHANGED
@@ -3222,7 +3222,8 @@ var validation$2 = {
3222
3222
  };
3223
3223
  var buttons$e = {
3224
3224
  account: "Accès abonné(e)s",
3225
- login: "Se connecter"
3225
+ login: "Se connecter",
3226
+ subscribe: "S'abonner"
3226
3227
  };
3227
3228
  var dashboard$3 = {
3228
3229
  labels: {
@@ -3314,7 +3315,8 @@ var validation$1 = {
3314
3315
  };
3315
3316
  var buttons$d = {
3316
3317
  account: "My account",
3317
- login: "Login"
3318
+ login: "Login",
3319
+ subscribe: "Subscribe"
3318
3320
  };
3319
3321
  var dashboard$2 = {
3320
3322
  labels: {
@@ -3405,7 +3407,8 @@ var validation = {
3405
3407
  };
3406
3408
  var buttons$c = {
3407
3409
  account: "내 계정",
3408
- login: "로그인"
3410
+ login: "로그인",
3411
+ subscribe: "구독하다"
3409
3412
  };
3410
3413
  var dashboard$1 = {
3411
3414
  labels: {
@@ -15379,7 +15382,7 @@ const PaymentMethodContainerWithoutStripe = ({
15379
15382
  onFailure = () => {},
15380
15383
  ...props
15381
15384
  }) => {
15382
- var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice;
15385
+ var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice, _window$Pelcro, _window$Pelcro$uiSett;
15383
15386
 
15384
15387
  const {
15385
15388
  t
@@ -15402,6 +15405,7 @@ const PaymentMethodContainerWithoutStripe = ({
15402
15405
  const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
15403
15406
  const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
15404
15407
  const invoice = (_props$invoice = props.invoice) !== null && _props$invoice !== void 0 ? _props$invoice : pelcroStore.invoice;
15408
+ const skipPayment = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.skipPaymentForFreePlans;
15405
15409
  const cardProcessor = getSiteCardProcessor();
15406
15410
  useEffect(() => {
15407
15411
  if (window.Pelcro.coupon.getFromUrl()) {
@@ -15948,6 +15952,8 @@ const PaymentMethodContainerWithoutStripe = ({
15948
15952
  }, [selectedPaymentMethodId]);
15949
15953
 
15950
15954
  const initPaymentRequest = (state, dispatch) => {
15955
+ if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
15956
+
15951
15957
  try {
15952
15958
  const paymentRequest = stripe.paymentRequest({
15953
15959
  country: window.Pelcro.user.location.countryCode || "US",
@@ -16019,6 +16025,7 @@ const PaymentMethodContainerWithoutStripe = ({
16019
16025
  const updateTotalAmountWithTax = () => {
16020
16026
  var _window$Pelcro$site$r4;
16021
16027
 
16028
+ if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16022
16029
  const taxesEnabled = (_window$Pelcro$site$r4 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.taxes_enabled;
16023
16030
 
16024
16031
  if (taxesEnabled && type === "createPayment") {
@@ -16345,8 +16352,8 @@ const PaymentMethodContainerWithoutStripe = ({
16345
16352
 
16346
16353
  if (!subscriptionIdToRenew) {
16347
16354
  window.Pelcro.subscription.create({
16348
- source_id: stripeSource.isExistingSource ? stripeSource.id : undefined,
16349
- stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
16355
+ source_id: stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
16356
+ stripe_token: !(stripeSource !== null && stripeSource !== void 0 && stripeSource.isExistingSource) ? stripeSource === null || stripeSource === void 0 ? void 0 : stripeSource.id : undefined,
16350
16357
  auth_token: window.Pelcro.user.read().auth_token,
16351
16358
  plan_id: plan.id,
16352
16359
  campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
@@ -17904,6 +17911,41 @@ const IncludePhone = props => /*#__PURE__*/React__default.createElement(Phone, O
17904
17911
  store: store$j
17905
17912
  }, props));
17906
17913
 
17914
+ const SubscriptionCreateFreePlanButton = ({
17915
+ name,
17916
+ onClick,
17917
+ ...otherProps
17918
+ }) => {
17919
+ const {
17920
+ state: {
17921
+ disableSubmit
17922
+ },
17923
+ dispatch
17924
+ } = useContext(store$j);
17925
+ const {
17926
+ t
17927
+ } = useTranslation("common");
17928
+ const [isDisabled, setDisabled] = useState(true);
17929
+ useEffect(() => {
17930
+ setDisabled(disableSubmit);
17931
+ }, [disableSubmit]);
17932
+ return /*#__PURE__*/React__default.createElement(Button, Object.assign({
17933
+ className: "plc-w-full",
17934
+ onClick: () => {
17935
+ dispatch({
17936
+ type: DISABLE_SUBMIT,
17937
+ payload: true
17938
+ });
17939
+ dispatch({
17940
+ type: SUBSCRIBE
17941
+ });
17942
+ onClick === null || onClick === void 0 ? void 0 : onClick();
17943
+ },
17944
+ disabled: isDisabled,
17945
+ isLoading: disableSubmit
17946
+ }, otherProps), t("buttons.subscribe"));
17947
+ };
17948
+
17907
17949
  /**
17908
17950
  *
17909
17951
  */
@@ -17914,7 +17956,8 @@ function PaymentMethodView({
17914
17956
  onFailure,
17915
17957
  type,
17916
17958
  showCoupon,
17917
- showExternalPaymentMethods
17959
+ showExternalPaymentMethods,
17960
+ showSubscriptionButton
17918
17961
  }) {
17919
17962
  var _window$Pelcro$site$r, _window$Pelcro$site$r2;
17920
17963
 
@@ -17929,7 +17972,7 @@ function PaymentMethodView({
17929
17972
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
17930
17973
  return /*#__PURE__*/React__default.createElement("div", {
17931
17974
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
17932
- }, cardProcessor === "stripe" && /*#__PURE__*/React__default.createElement("div", {
17975
+ }, cardProcessor === "stripe" && !showSubscriptionButton && /*#__PURE__*/React__default.createElement("div", {
17933
17976
  className: "plc-flex plc-items-center plc-w-full plc-px-4 plc-py-2 plc-text-center plc-text-green-600 plc-border plc-border-green-400 plc-rounded plc-bg-green-50"
17934
17977
  }, /*#__PURE__*/React__default.createElement(SvgLock, {
17935
17978
  className: "plc-w-5 plc-h-5 plc-mr-1"
@@ -17946,9 +17989,9 @@ function PaymentMethodView({
17946
17989
  onSuccess: onSuccess,
17947
17990
  onGiftRenewalSuccess: onGiftRenewalSuccess,
17948
17991
  onFailure: onFailure
17949
- }, /*#__PURE__*/React__default.createElement(BankRedirection, null), /*#__PURE__*/React__default.createElement(BankAuthenticationSuccess, null), /*#__PURE__*/React__default.createElement(AlertWithContext, {
17992
+ }, /*#__PURE__*/React__default.createElement(AlertWithContext, {
17950
17993
  className: "plc-mb-2"
17951
- }), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(SelectedPaymentMethod, null), supportsTap && (!isUserFirstName || !isUserLastName || !isUserPhone) && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
17994
+ }), showSubscriptionButton ? /*#__PURE__*/React__default.createElement(SubscriptionCreateFreePlanButton, null) : /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(BankRedirection, null), /*#__PURE__*/React__default.createElement(BankAuthenticationSuccess, null), /*#__PURE__*/React__default.createElement(SelectedPaymentMethod, null), supportsTap && (!isUserFirstName || !isUserLastName || !isUserPhone) && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
17952
17995
  className: "plc-flex plc-items-start"
17953
17996
  }, /*#__PURE__*/React__default.createElement(IncludeFirstName, {
17954
17997
  id: "pelcro-input-first-name",
@@ -19361,7 +19404,7 @@ const SubscriptionCreateView = ({
19361
19404
  onSuccess = () => {},
19362
19405
  onFailure = () => {}
19363
19406
  }) => {
19364
- var _product$paywall$subs, _product$paywall, _window$Pelcro$paywal, _product$paywall$subs2, _product$paywall2, _window$Pelcro$paywal2;
19407
+ var _window$Pelcro, _window$Pelcro$uiSett, _product$paywall$subs, _product$paywall, _window$Pelcro$paywal, _product$paywall$subs2, _product$paywall2, _window$Pelcro$paywal2;
19365
19408
 
19366
19409
  const {
19367
19410
  t
@@ -19370,6 +19413,8 @@ const SubscriptionCreateView = ({
19370
19413
  product,
19371
19414
  plan
19372
19415
  } = usePelcro();
19416
+ const skipPayment = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.skipPaymentForFreePlans;
19417
+ const showSubscriptionButton = skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0;
19373
19418
 
19374
19419
  const getPricingText = plan => {
19375
19420
  var _plan$quantity;
@@ -19408,7 +19453,8 @@ const SubscriptionCreateView = ({
19408
19453
  showCoupon: true,
19409
19454
  showExternalPaymentMethods: true,
19410
19455
  onSuccess: onSuccess,
19411
- onFailure: onFailure
19456
+ onFailure: onFailure,
19457
+ showSubscriptionButton: showSubscriptionButton
19412
19458
  }));
19413
19459
  };
19414
19460
 
@@ -23648,13 +23694,12 @@ const AddressSelectContainer = ({
23648
23694
  className = "",
23649
23695
  onGiftRedemptionSuccess = () => {},
23650
23696
  onMembershipAdressUpdateSuccess = () => {},
23651
- onFreePlanSubscriptionSuccess = () => {},
23652
23697
  onSuccess = () => {},
23653
23698
  onFailure = () => {},
23654
23699
  children,
23655
23700
  ...props
23656
23701
  }) => {
23657
- var _props$giftCode, _ref, _props$subscriptionId, _window$Pelcro, _window$Pelcro$uiSett;
23702
+ var _props$giftCode, _ref, _props$subscriptionId;
23658
23703
 
23659
23704
  const {
23660
23705
  t
@@ -23664,13 +23709,10 @@ const AddressSelectContainer = ({
23664
23709
  giftCode: giftCodeFromStore,
23665
23710
  subscriptionIdToRenew: subscriptionIdToRenewFromStore,
23666
23711
  set,
23667
- selectedMembership,
23668
- plan,
23669
- product
23712
+ selectedMembership
23670
23713
  } = usePelcro();
23671
23714
  const giftCode = (_props$giftCode = props.giftCode) !== null && _props$giftCode !== void 0 ? _props$giftCode : giftCodeFromStore;
23672
23715
  const subscriptionIdToRenew = (_ref = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : subscriptionIdToRenewFromStore) !== null && _ref !== void 0 ? _ref : undefined;
23673
- const skipPayment = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.skipPaymentForFreePlans;
23674
23716
 
23675
23717
  const submitAddress = ({
23676
23718
  selectedAddressId
@@ -23742,39 +23784,6 @@ const AddressSelectContainer = ({
23742
23784
  });
23743
23785
  }
23744
23786
 
23745
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) {
23746
- dispatch({
23747
- type: LOADING,
23748
- payload: true
23749
- });
23750
- window.Pelcro.subscription.create({
23751
- auth_token: window.Pelcro.user.read().auth_token,
23752
- plan_id: plan.id,
23753
- campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
23754
- quantity: plan.quantity,
23755
- address_id: product.address_required ? selectedAddressId : null
23756
- }, (err, res) => {
23757
- dispatch({
23758
- type: LOADING,
23759
- payload: false
23760
- });
23761
-
23762
- if (err) {
23763
- dispatch({
23764
- type: SHOW_ALERT,
23765
- payload: {
23766
- type: "error",
23767
- content: getErrorMessages(err)
23768
- }
23769
- });
23770
- return notify.error(getErrorMessages(err));
23771
- }
23772
-
23773
- return onFreePlanSubscriptionSuccess(res);
23774
- });
23775
- return;
23776
- }
23777
-
23778
23787
  onSuccess(selectedAddressId);
23779
23788
  };
23780
23789
 
@@ -23961,7 +23970,8 @@ const AddressSelectModal = ({
23961
23970
 
23962
23971
  const onAddNewAddress = () => {
23963
23972
  switchView("address-create");
23964
- };
23973
+ }; // FIXME: implement me
23974
+
23965
23975
 
23966
23976
  const onMembershipAdressUpdateSuccess = () => {
23967
23977
  var _otherProps$onMembers;
@@ -23970,13 +23980,6 @@ const AddressSelectModal = ({
23970
23980
  resetView();
23971
23981
  };
23972
23982
 
23973
- const onFreePlanSubscriptionSuccess = () => {
23974
- var _otherProps$onFreePla;
23975
-
23976
- (_otherProps$onFreePla = otherProps.onFreePlanSubscriptionSuccess) === null || _otherProps$onFreePla === void 0 ? void 0 : _otherProps$onFreePla.call(otherProps);
23977
- switchView("subscription-success");
23978
- };
23979
-
23980
23983
  return /*#__PURE__*/React__default.createElement(Modal, {
23981
23984
  onDisplay: onDisplay,
23982
23985
  onClose: onClose,
@@ -23986,8 +23989,7 @@ const AddressSelectModal = ({
23986
23989
  }, otherProps, {
23987
23990
  onSuccess: onSuccess,
23988
23991
  onGiftRedemptionSuccess: onGiftRedemptionSuccess,
23989
- onMembershipAdressUpdateSuccess: onMembershipAdressUpdateSuccess,
23990
- onFreePlanSubscriptionSuccess: onFreePlanSubscriptionSuccess
23992
+ onMembershipAdressUpdateSuccess: onMembershipAdressUpdateSuccess
23991
23993
  }))), /*#__PURE__*/React__default.createElement(ModalFooter, null, /*#__PURE__*/React__default.createElement(Authorship, null)));
23992
23994
  };
23993
23995
  AddressSelectModal.viewId = "address-select";
@@ -24205,10 +24207,19 @@ const PaymentMethodSelectModal = ({
24205
24207
  onClose,
24206
24208
  ...otherProps
24207
24209
  }) => {
24210
+ var _window$Pelcro, _window$Pelcro$uiSett;
24211
+
24208
24212
  const {
24209
24213
  switchToCheckoutForm,
24210
- set
24214
+ set,
24215
+ plan
24211
24216
  } = usePelcro();
24217
+ const skipPayment = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.skipPaymentForFreePlans;
24218
+ useEffect(() => {
24219
+ if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) {
24220
+ switchToCheckoutForm();
24221
+ }
24222
+ }, []);
24212
24223
 
24213
24224
  const onSuccess = selectedPaymentMethodId => {
24214
24225
  var _otherProps$onSuccess;
@@ -30962,4 +30973,4 @@ const QrCodeModal = ({
30962
30973
  };
30963
30974
  QrCodeModal.viewId = "qrcode";
30964
30975
 
30965
- 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, 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, SubscriptionCreateModal, SubscriptionCreateView, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, SubscriptionSuspendContainer, SubscriptionSuspendModal, SubscriptionSuspendView, TaxAmount, TextArea, Tooltip, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateTin, UserUpdateView, VerifyLinkTokenContainer, VerifyLinkTokenLoader, VerifyLinkTokenModal, VerifyLinkTokenView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, invoicePaymentSubmitButton, notify, unauthenticatedButtons, usePelcro };
30976
+ 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, 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, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, SubscriptionSuspendContainer, SubscriptionSuspendModal, SubscriptionSuspendView, TaxAmount, TextArea, Tooltip, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateTin, UserUpdateView, VerifyLinkTokenContainer, VerifyLinkTokenLoader, VerifyLinkTokenModal, VerifyLinkTokenView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, invoicePaymentSubmitButton, notify, unauthenticatedButtons, 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.1",
4
+ "version": "3.13.0-beta.2",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",