@pelcro/react-pelcro-js 3.21.5 → 3.21.7

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
@@ -3457,7 +3457,8 @@ var labels$10 = {
3457
3457
  removeCoupon: "REMOVE",
3458
3458
  firstName: "First name",
3459
3459
  lastName: "Last name",
3460
- phone: "Phone"
3460
+ phone: "Phone",
3461
+ freeItems: "Free Items"
3461
3462
  };
3462
3463
  var checkoutForm_en = {
3463
3464
  messages: messages$14,
@@ -4398,7 +4399,8 @@ var labels$H = {
4398
4399
  removeCoupon: "RETIRER",
4399
4400
  firstName: "Prénom",
4400
4401
  lastName: "Nom de famille",
4401
- phone: "Téléphoner"
4402
+ phone: "Téléphoner",
4403
+ freeItems: "Articles gratuits"
4402
4404
  };
4403
4405
  var checkoutForm_fr = {
4404
4406
  messages: messages$M,
@@ -5225,7 +5227,8 @@ var labels$s = {
5225
5227
  removeCoupon: "제거",
5226
5228
  firstName: "이름",
5227
5229
  lastName: "성",
5228
- phone: "핸드폰"
5230
+ phone: "핸드폰",
5231
+ freeItems: "무료 아이템"
5229
5232
  };
5230
5233
  var checkoutForm_ko = {
5231
5234
  messages: messages$v,
@@ -6156,7 +6159,8 @@ var labels$d = {
6156
6159
  removeCoupon: "ELIMINAR",
6157
6160
  firstName: "Nombre",
6158
6161
  lastName: "Apellido",
6159
- phone: "Teléfono"
6162
+ phone: "Teléfono",
6163
+ freeItems: "Artículos gratis"
6160
6164
  };
6161
6165
  var checkoutForm_es = {
6162
6166
  messages: messages$e,
@@ -8707,7 +8711,7 @@ const calcAndFormatItemsTotal = (items, currency) => {
8707
8711
  if (!Array.isArray(items)) return;
8708
8712
  let totalWithoutDividingBy100 = 0;
8709
8713
  for (const item of items) {
8710
- totalWithoutDividingBy100 += parseFloat(item.price ? isCurrencyZeroDecimal(currency) ? item.price * item.quantity : (item.price * item.quantity).toFixed(2) : isCurrencyZeroDecimal(currency) ? item.amount : item.amount.toFixed(2));
8714
+ totalWithoutDividingBy100 += parseFloat(item !== null && item !== void 0 && item.price || (item === null || item === void 0 ? void 0 : item.price) === 0 ? isCurrencyZeroDecimal(currency) ? item.price * item.quantity : (item.price * item.quantity).toFixed(2) : isCurrencyZeroDecimal(currency) ? item.amount : item.amount.toFixed(2));
8711
8715
  }
8712
8716
  return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
8713
8717
  };
@@ -11141,6 +11145,9 @@ const initViewFromURL = () => {
11141
11145
  if (view === "manage-members") {
11142
11146
  return showSubscriptionManageMembersFromUrl();
11143
11147
  }
11148
+ if (view === "payment-method-update") {
11149
+ return showPaymentMethodUpdateFromUrl();
11150
+ }
11144
11151
  switchView(view);
11145
11152
  });
11146
11153
  }
@@ -11349,6 +11356,43 @@ const showPasswordlessRequestFromUrl = () => {
11349
11356
  } = usePelcro.getStore();
11350
11357
  return switchView("passwordless-request");
11351
11358
  };
11359
+ const showPaymentMethodUpdateFromUrl = () => {
11360
+ const {
11361
+ isAuthenticated,
11362
+ whenSiteReady,
11363
+ whenUserReady,
11364
+ switchView
11365
+ } = usePelcro.getStore();
11366
+ whenSiteReady(() => {
11367
+ if (!isAuthenticated()) {
11368
+ return switchView("login");
11369
+ }
11370
+ whenUserReady(() => {
11371
+ const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_gateway_settings);
11372
+ const supportsTap = Boolean(window.Pelcro.site.read().tap_gateway_settings);
11373
+ if (!window.Stripe && !supportsVantiv && !supportsTap) {
11374
+ document.querySelector('script[src="https://js.stripe.com/v3"]').addEventListener("load", () => {
11375
+ return switchView("payment-method-update");
11376
+ });
11377
+ return;
11378
+ }
11379
+
11380
+ //vantiv
11381
+ if (supportsVantiv) {
11382
+ document.querySelector("#vantiv-eprotect-sdk").addEventListener("load", () => {
11383
+ return switchView("payment-method-update");
11384
+ });
11385
+ return;
11386
+ }
11387
+
11388
+ //Tap
11389
+ if (supportsTap && document.querySelector("#tap-sdk")) {
11390
+ return switchView("payment-method-update");
11391
+ }
11392
+ return switchView("payment-method-update");
11393
+ });
11394
+ });
11395
+ };
11352
11396
  const showInvoiceDetailsFromUrl = () => {
11353
11397
  const {
11354
11398
  isAuthenticated,
@@ -13261,7 +13305,7 @@ function LoginModal(_ref) {
13261
13305
  }
13262
13306
  resetView();
13263
13307
  const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
13264
- const viewsURLs = ["invoice-details", "gift-redeem", "plan-select"];
13308
+ const viewsURLs = ["invoice-details", "gift-redeem", "plan-select", "payment-method-update"];
13265
13309
  if (viewsURLs.includes(viewFromURL)) {
13266
13310
  initViewFromURL();
13267
13311
  }
@@ -16802,7 +16846,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16802
16846
  const tapInstanceRef = React__default['default'].useRef(null);
16803
16847
  const tapInstanceCard = React__default['default'].useRef(null);
16804
16848
  React.useEffect(() => {
16805
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16849
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
16806
16850
  if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
16807
16851
  var _window$Pelcro$site$r2, _window$Pelcro$site$r3;
16808
16852
  const payPageId = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.vantiv_gateway_settings.pay_page_id;
@@ -16838,7 +16882,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16838
16882
  }, [vantivPaymentRequest]);
16839
16883
  React.useEffect(() => {
16840
16884
  whenUserReady(() => {
16841
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16885
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
16842
16886
  if (cardProcessor === "tap" && !window.Tapjsli) {
16843
16887
  window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
16844
16888
  window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
@@ -16852,7 +16896,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16852
16896
  });
16853
16897
  }, [selectedPaymentMethodId]);
16854
16898
  const initPaymentRequest = (state, dispatch) => {
16855
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16899
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
16856
16900
  try {
16857
16901
  const paymentRequest = stripe.paymentRequest({
16858
16902
  country: window.Pelcro.user.location.countryCode || "US",
@@ -16921,7 +16965,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16921
16965
  */
16922
16966
  const updateTotalAmountWithTax = () => {
16923
16967
  var _window$Pelcro$site$r4;
16924
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16968
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
16925
16969
  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;
16926
16970
  if (taxesEnabled && type === "createPayment") {
16927
16971
  dispatch({
@@ -17418,16 +17462,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17418
17462
  items: mappedOrderItems,
17419
17463
  addressId: selectedAddressId,
17420
17464
  couponCode
17421
- }, (err, res) => {
17422
- dispatch({
17423
- type: DISABLE_SUBMIT,
17424
- payload: false
17425
- });
17426
- dispatch({
17427
- type: LOADING,
17428
- payload: false
17429
- });
17465
+ }, (err, orderResponse) => {
17466
+ var _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro2$user$;
17430
17467
  if (err) {
17468
+ toggleAuthenticationSuccessPendingView(false);
17469
+ dispatch({
17470
+ type: DISABLE_SUBMIT,
17471
+ payload: false
17472
+ });
17473
+ dispatch({
17474
+ type: LOADING,
17475
+ payload: false
17476
+ });
17431
17477
  onFailure(err);
17432
17478
  return dispatch({
17433
17479
  type: SHOW_ALERT,
@@ -17447,7 +17493,30 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17447
17493
  cartItems: []
17448
17494
  });
17449
17495
  }
17450
- onSuccess(res);
17496
+ window.Pelcro.user.refresh({
17497
+ auth_token: (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$user = _window$Pelcro2.user) === null || _window$Pelcro2$user === void 0 ? void 0 : (_window$Pelcro2$user$ = _window$Pelcro2$user.read()) === null || _window$Pelcro2$user$ === void 0 ? void 0 : _window$Pelcro2$user$.auth_token
17498
+ }, (err, res) => {
17499
+ dispatch({
17500
+ type: DISABLE_SUBMIT,
17501
+ payload: false
17502
+ });
17503
+ dispatch({
17504
+ type: LOADING,
17505
+ payload: false
17506
+ });
17507
+ toggleAuthenticationSuccessPendingView(false);
17508
+ if (err) {
17509
+ onFailure(err);
17510
+ return dispatch({
17511
+ type: SHOW_ALERT,
17512
+ payload: {
17513
+ type: "error",
17514
+ content: getErrorMessages(err)
17515
+ }
17516
+ });
17517
+ }
17518
+ onSuccess(orderResponse);
17519
+ });
17451
17520
  });
17452
17521
  };
17453
17522
  const payInvoice = (gatewayService, gatewayToken, dispatch) => {
@@ -17525,6 +17594,29 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17525
17594
  });
17526
17595
  };
17527
17596
  const submitPayment = (state, dispatch) => {
17597
+ if (skipPayment && props !== null && props !== void 0 && props.freeOrders) {
17598
+ const isQuickPurchase = !Array.isArray(order);
17599
+ const mappedOrderItems = isQuickPurchase ? [{
17600
+ sku_id: order.id,
17601
+ quantity: order.quantity
17602
+ }] : order.map(item => ({
17603
+ sku_id: item.id,
17604
+ quantity: item.quantity
17605
+ }));
17606
+ window.Pelcro.ecommerce.order.create({
17607
+ items: mappedOrderItems,
17608
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
17609
+ ...(selectedAddressId && {
17610
+ address_id: selectedAddressId
17611
+ })
17612
+ }, (err, res) => {
17613
+ if (err) {
17614
+ return handlePaymentError(err);
17615
+ }
17616
+ return onSuccess(res);
17617
+ });
17618
+ return;
17619
+ }
17528
17620
  stripe.createSource({
17529
17621
  type: "card"
17530
17622
  }).then(_ref8 => {
@@ -17758,6 +17850,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17758
17850
  disableSubmit: true,
17759
17851
  isLoading: true
17760
17852
  }, (state, dispatch) => {
17853
+ if (skipPayment && props !== null && props !== void 0 && props.freeOrders) {
17854
+ return submitPayment(state);
17855
+ }
17761
17856
  if (getSiteCardProcessor() === "vantiv") {
17762
17857
  return submitUsingVantiv(state);
17763
17858
  }
@@ -17886,10 +17981,14 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17886
17981
  state,
17887
17982
  dispatch
17888
17983
  }
17889
- }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
17890
- store: store$k,
17891
- key: i
17892
- })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
17984
+ }, children.length ? children.map((child, i) => {
17985
+ if (child) {
17986
+ return /*#__PURE__*/React__default['default'].cloneElement(child, {
17987
+ store: store$k,
17988
+ key: i
17989
+ });
17990
+ }
17991
+ }) : /*#__PURE__*/React__default['default'].cloneElement(children, {
17893
17992
  store: store$k
17894
17993
  })));
17895
17994
  };
@@ -18712,11 +18811,47 @@ const SubscriptionCreateFreePlanButton = _ref => {
18712
18811
  }, otherProps), t("buttons.subscribe"));
18713
18812
  };
18714
18813
 
18814
+ const OrderCreateFreeButton = _ref => {
18815
+ let {
18816
+ name,
18817
+ onClick,
18818
+ ...otherProps
18819
+ } = _ref;
18820
+ const {
18821
+ state: {
18822
+ disableSubmit
18823
+ },
18824
+ dispatch
18825
+ } = React.useContext(store$k);
18826
+ const {
18827
+ t
18828
+ } = useTranslation("checkoutForm");
18829
+ const [isDisabled, setDisabled] = React.useState(true);
18830
+ React.useEffect(() => {
18831
+ setDisabled(disableSubmit);
18832
+ }, [disableSubmit]);
18833
+ return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
18834
+ className: "plc-w-full",
18835
+ onClick: () => {
18836
+ dispatch({
18837
+ type: DISABLE_SUBMIT,
18838
+ payload: true
18839
+ });
18840
+ dispatch({
18841
+ type: SUBMIT_PAYMENT
18842
+ });
18843
+ onClick === null || onClick === void 0 ? void 0 : onClick();
18844
+ },
18845
+ disabled: isDisabled,
18846
+ isLoading: disableSubmit
18847
+ }, otherProps), t("labels.submit"));
18848
+ };
18849
+
18715
18850
  /**
18716
18851
  *
18717
18852
  */
18718
18853
  function PaymentMethodView(_ref) {
18719
- var _window$Pelcro$site$r, _window$Pelcro$site$r2;
18854
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2, _calcAndFormatItemsTo, _order$;
18720
18855
  let {
18721
18856
  onSuccess,
18722
18857
  onGiftRenewalSuccess,
@@ -18724,7 +18859,9 @@ function PaymentMethodView(_ref) {
18724
18859
  type,
18725
18860
  showCoupon,
18726
18861
  showExternalPaymentMethods,
18727
- showSubscriptionButton
18862
+ showSubscriptionButton,
18863
+ showOrderButton,
18864
+ order
18728
18865
  } = _ref;
18729
18866
  const {
18730
18867
  t
@@ -18737,7 +18874,17 @@ function PaymentMethodView(_ref) {
18737
18874
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
18738
18875
  return /*#__PURE__*/React__default['default'].createElement("div", {
18739
18876
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
18740
- }, cardProcessor === "stripe" && !showSubscriptionButton && /*#__PURE__*/React__default['default'].createElement("div", {
18877
+ }, order && /*#__PURE__*/React__default['default'].createElement("div", {
18878
+ className: "plc-w-full plc-p-2 plc-mb-4 plc-font-semibold plc-text-center plc-text-gray-900 plc-bg-gray-100 plc-border plc-border-gray-200"
18879
+ }, /*#__PURE__*/React__default['default'].createElement("p", {
18880
+ className: "plc-text-gray-600"
18881
+ }, !Array.isArray(order) ? /*#__PURE__*/React__default['default'].createElement("span", {
18882
+ className: "plc-tracking-wider plc-uppercase"
18883
+ }, order === null || order === void 0 ? void 0 : order.name) : /*#__PURE__*/React__default['default'].createElement("span", {
18884
+ className: "plc-tracking-wider plc-uppercase"
18885
+ }, t("labels.freeItems")), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("span", {
18886
+ className: "plc-text-xl plc-font-semibold plc-text-primary-600"
18887
+ }, (_calcAndFormatItemsTo = calcAndFormatItemsTotal(order, (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency)) !== null && _calcAndFormatItemsTo !== void 0 ? _calcAndFormatItemsTo : getFormattedPriceByLocal(order === null || order === void 0 ? void 0 : order.price, order === null || order === void 0 ? void 0 : order.currency, getPageOrDefaultLanguage())))), cardProcessor === "stripe" && !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default['default'].createElement("div", {
18741
18888
  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"
18742
18889
  }, /*#__PURE__*/React__default['default'].createElement(SvgLock, {
18743
18890
  className: "plc-w-5 plc-h-5 plc-mr-1"
@@ -18753,10 +18900,11 @@ function PaymentMethodView(_ref) {
18753
18900
  type: type,
18754
18901
  onSuccess: onSuccess,
18755
18902
  onGiftRenewalSuccess: onGiftRenewalSuccess,
18756
- onFailure: onFailure
18903
+ onFailure: onFailure,
18904
+ freeOrders: showOrderButton
18757
18905
  }, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, {
18758
18906
  className: "plc-mb-2"
18759
- }), 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", {
18907
+ }), showSubscriptionButton && /*#__PURE__*/React__default['default'].createElement(SubscriptionCreateFreePlanButton, null), showOrderButton && /*#__PURE__*/React__default['default'].createElement(OrderCreateFreeButton, null), !showSubscriptionButton && !showOrderButton && /*#__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", {
18760
18908
  className: "plc-flex plc-items-start"
18761
18909
  }, /*#__PURE__*/React__default['default'].createElement(IncludeFirstName, {
18762
18910
  id: "pelcro-input-first-name",
@@ -20511,6 +20659,16 @@ function SubscriptionManageMembersList(props) {
20511
20659
  icon: /*#__PURE__*/React__default['default'].createElement(SvgCheckMark, null)
20512
20660
  };
20513
20661
  }, []);
20662
+ const showMemberData = React.useCallback(member => {
20663
+ var _member$customer, _member$customer2, _member$customer3, _member$customer4;
20664
+ let data;
20665
+ if ((member === null || member === void 0 ? void 0 : member.status) !== "active") {
20666
+ data = member === null || member === void 0 ? void 0 : member.invitation_email;
20667
+ return data;
20668
+ }
20669
+ data = (member === null || member === void 0 ? void 0 : (_member$customer = member.customer) === null || _member$customer === void 0 ? void 0 : _member$customer.email) || (member === null || member === void 0 ? void 0 : (_member$customer2 = member.customer) === null || _member$customer2 === void 0 ? void 0 : _member$customer2.first_name) + " " + (member === null || member === void 0 ? void 0 : (_member$customer3 = member.customer) === null || _member$customer3 === void 0 ? void 0 : _member$customer3.last_name) || (member === null || member === void 0 ? void 0 : (_member$customer4 = member.customer) === null || _member$customer4 === void 0 ? void 0 : _member$customer4.username) || "-----";
20670
+ return data;
20671
+ }, []);
20514
20672
  if (loading) {
20515
20673
  return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("tr", null, /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement("div", {
20516
20674
  className: "plc-animate-pulse"
@@ -20552,10 +20710,10 @@ function SubscriptionManageMembersList(props) {
20552
20710
  className: `plc-w-full plc-align-middle plc-cursor-pointer accordion-header hover:plc-bg-gray-50 plc-text-center`
20553
20711
  }, /*#__PURE__*/React__default['default'].createElement("td", {
20554
20712
  className: "plc-truncate plc-text-left",
20555
- title: member === null || member === void 0 ? void 0 : member.invitation_email
20713
+ title: showMemberData(member)
20556
20714
  }, /*#__PURE__*/React__default['default'].createElement("span", {
20557
20715
  className: "plc-font-semibold plc-text-gray-500"
20558
- }, member === null || member === void 0 ? void 0 : member.invitation_email)), /*#__PURE__*/React__default['default'].createElement("td", {
20716
+ }, showMemberData(member))), /*#__PURE__*/React__default['default'].createElement("td", {
20559
20717
  className: "plc-py-2"
20560
20718
  }, /*#__PURE__*/React__default['default'].createElement("span", {
20561
20719
  className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${getMemberStatus(member).bgColor} plc-uppercase ${getMemberStatus(member).textColor} plc-rounded-lg`
@@ -24163,9 +24321,15 @@ const OrderCreateContainer = props => /*#__PURE__*/React__default['default'].cre
24163
24321
  }, props));
24164
24322
 
24165
24323
  const OrderCreateView = props => {
24324
+ var _window$Pelcro, _window$Pelcro$uiSett;
24166
24325
  const {
24167
24326
  t
24168
24327
  } = useTranslation("payment");
24328
+ const {
24329
+ order
24330
+ } = usePelcro();
24331
+ 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;
24332
+ const showOrderButton = skipPayment && ((order === null || order === void 0 ? void 0 : order.price) === 0 || (order === null || order === void 0 ? void 0 : order.length) > 0 && order.every(item => (item === null || item === void 0 ? void 0 : item.price) === 0));
24169
24333
  return /*#__PURE__*/React__default['default'].createElement("div", {
24170
24334
  id: "pelcro-order-create-view"
24171
24335
  }, /*#__PURE__*/React__default['default'].createElement("div", {
@@ -24176,7 +24340,9 @@ const OrderCreateView = props => {
24176
24340
  }, /*#__PURE__*/React__default['default'].createElement(PaymentMethodView, Object.assign({
24177
24341
  type: "orderCreate",
24178
24342
  showCoupon: true,
24179
- showExternalPaymentMethods: false
24343
+ showExternalPaymentMethods: false,
24344
+ showOrderButton: showOrderButton,
24345
+ order: order
24180
24346
  }, props))));
24181
24347
  };
24182
24348
 
@@ -25384,11 +25550,12 @@ const PaymentMethodSelectModal = _ref => {
25384
25550
  const {
25385
25551
  switchToCheckoutForm,
25386
25552
  set,
25387
- plan
25553
+ plan,
25554
+ order
25388
25555
  } = usePelcro();
25389
25556
  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;
25390
25557
  React.useEffect(() => {
25391
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) {
25558
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) {
25392
25559
  switchToCheckoutForm();
25393
25560
  }
25394
25561
  }, []);
@@ -27496,7 +27663,7 @@ const InvoicesItems = () => {
27496
27663
  setInvoice,
27497
27664
  switchView
27498
27665
  } = usePelcro();
27499
- const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
27666
+ const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.order_id || invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
27500
27667
  const showInvoiceDetails = event => {
27501
27668
  if (setInvoice(event.target.dataset.id)) {
27502
27669
  switchView("invoice-details");
@@ -28264,7 +28431,7 @@ class Dashboard extends React.Component {
28264
28431
  }
28265
28432
  function hasInvoices() {
28266
28433
  var _window$Pelcro$invoic, _window$Pelcro$invoic2;
28267
- const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
28434
+ const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.order_id || invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
28268
28435
  return invoices.length > 0;
28269
28436
  }
28270
28437
  function hasDonationSubs() {
@@ -32206,6 +32373,7 @@ exports.NewsletterUpdateView = NewsletterUpdateView;
32206
32373
  exports.Notification = Notification;
32207
32374
  exports.OrderConfirmModal = OrderConfirmModal;
32208
32375
  exports.OrderCreateContainer = OrderCreateContainer;
32376
+ exports.OrderCreateFreeButton = OrderCreateFreeButton;
32209
32377
  exports.OrderCreateModal = OrderCreateModal;
32210
32378
  exports.OrderCreateSubmitButton = OrderCreateSubmitButton;
32211
32379
  exports.OrderCreateView = OrderCreateView;
package/dist/index.esm.js CHANGED
@@ -3427,7 +3427,8 @@ var labels$10 = {
3427
3427
  removeCoupon: "REMOVE",
3428
3428
  firstName: "First name",
3429
3429
  lastName: "Last name",
3430
- phone: "Phone"
3430
+ phone: "Phone",
3431
+ freeItems: "Free Items"
3431
3432
  };
3432
3433
  var checkoutForm_en = {
3433
3434
  messages: messages$14,
@@ -4368,7 +4369,8 @@ var labels$H = {
4368
4369
  removeCoupon: "RETIRER",
4369
4370
  firstName: "Prénom",
4370
4371
  lastName: "Nom de famille",
4371
- phone: "Téléphoner"
4372
+ phone: "Téléphoner",
4373
+ freeItems: "Articles gratuits"
4372
4374
  };
4373
4375
  var checkoutForm_fr = {
4374
4376
  messages: messages$M,
@@ -5195,7 +5197,8 @@ var labels$s = {
5195
5197
  removeCoupon: "제거",
5196
5198
  firstName: "이름",
5197
5199
  lastName: "성",
5198
- phone: "핸드폰"
5200
+ phone: "핸드폰",
5201
+ freeItems: "무료 아이템"
5199
5202
  };
5200
5203
  var checkoutForm_ko = {
5201
5204
  messages: messages$v,
@@ -6126,7 +6129,8 @@ var labels$d = {
6126
6129
  removeCoupon: "ELIMINAR",
6127
6130
  firstName: "Nombre",
6128
6131
  lastName: "Apellido",
6129
- phone: "Teléfono"
6132
+ phone: "Teléfono",
6133
+ freeItems: "Artículos gratis"
6130
6134
  };
6131
6135
  var checkoutForm_es = {
6132
6136
  messages: messages$e,
@@ -8677,7 +8681,7 @@ const calcAndFormatItemsTotal = (items, currency) => {
8677
8681
  if (!Array.isArray(items)) return;
8678
8682
  let totalWithoutDividingBy100 = 0;
8679
8683
  for (const item of items) {
8680
- totalWithoutDividingBy100 += parseFloat(item.price ? isCurrencyZeroDecimal(currency) ? item.price * item.quantity : (item.price * item.quantity).toFixed(2) : isCurrencyZeroDecimal(currency) ? item.amount : item.amount.toFixed(2));
8684
+ totalWithoutDividingBy100 += parseFloat(item !== null && item !== void 0 && item.price || (item === null || item === void 0 ? void 0 : item.price) === 0 ? isCurrencyZeroDecimal(currency) ? item.price * item.quantity : (item.price * item.quantity).toFixed(2) : isCurrencyZeroDecimal(currency) ? item.amount : item.amount.toFixed(2));
8681
8685
  }
8682
8686
  return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
8683
8687
  };
@@ -11111,6 +11115,9 @@ const initViewFromURL = () => {
11111
11115
  if (view === "manage-members") {
11112
11116
  return showSubscriptionManageMembersFromUrl();
11113
11117
  }
11118
+ if (view === "payment-method-update") {
11119
+ return showPaymentMethodUpdateFromUrl();
11120
+ }
11114
11121
  switchView(view);
11115
11122
  });
11116
11123
  }
@@ -11319,6 +11326,43 @@ const showPasswordlessRequestFromUrl = () => {
11319
11326
  } = usePelcro.getStore();
11320
11327
  return switchView("passwordless-request");
11321
11328
  };
11329
+ const showPaymentMethodUpdateFromUrl = () => {
11330
+ const {
11331
+ isAuthenticated,
11332
+ whenSiteReady,
11333
+ whenUserReady,
11334
+ switchView
11335
+ } = usePelcro.getStore();
11336
+ whenSiteReady(() => {
11337
+ if (!isAuthenticated()) {
11338
+ return switchView("login");
11339
+ }
11340
+ whenUserReady(() => {
11341
+ const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_gateway_settings);
11342
+ const supportsTap = Boolean(window.Pelcro.site.read().tap_gateway_settings);
11343
+ if (!window.Stripe && !supportsVantiv && !supportsTap) {
11344
+ document.querySelector('script[src="https://js.stripe.com/v3"]').addEventListener("load", () => {
11345
+ return switchView("payment-method-update");
11346
+ });
11347
+ return;
11348
+ }
11349
+
11350
+ //vantiv
11351
+ if (supportsVantiv) {
11352
+ document.querySelector("#vantiv-eprotect-sdk").addEventListener("load", () => {
11353
+ return switchView("payment-method-update");
11354
+ });
11355
+ return;
11356
+ }
11357
+
11358
+ //Tap
11359
+ if (supportsTap && document.querySelector("#tap-sdk")) {
11360
+ return switchView("payment-method-update");
11361
+ }
11362
+ return switchView("payment-method-update");
11363
+ });
11364
+ });
11365
+ };
11322
11366
  const showInvoiceDetailsFromUrl = () => {
11323
11367
  const {
11324
11368
  isAuthenticated,
@@ -13231,7 +13275,7 @@ function LoginModal(_ref) {
13231
13275
  }
13232
13276
  resetView();
13233
13277
  const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
13234
- const viewsURLs = ["invoice-details", "gift-redeem", "plan-select"];
13278
+ const viewsURLs = ["invoice-details", "gift-redeem", "plan-select", "payment-method-update"];
13235
13279
  if (viewsURLs.includes(viewFromURL)) {
13236
13280
  initViewFromURL();
13237
13281
  }
@@ -16772,7 +16816,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16772
16816
  const tapInstanceRef = React__default.useRef(null);
16773
16817
  const tapInstanceCard = React__default.useRef(null);
16774
16818
  useEffect(() => {
16775
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16819
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
16776
16820
  if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
16777
16821
  var _window$Pelcro$site$r2, _window$Pelcro$site$r3;
16778
16822
  const payPageId = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.vantiv_gateway_settings.pay_page_id;
@@ -16808,7 +16852,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16808
16852
  }, [vantivPaymentRequest]);
16809
16853
  useEffect(() => {
16810
16854
  whenUserReady(() => {
16811
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16855
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
16812
16856
  if (cardProcessor === "tap" && !window.Tapjsli) {
16813
16857
  window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
16814
16858
  window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
@@ -16822,7 +16866,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16822
16866
  });
16823
16867
  }, [selectedPaymentMethodId]);
16824
16868
  const initPaymentRequest = (state, dispatch) => {
16825
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16869
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
16826
16870
  try {
16827
16871
  const paymentRequest = stripe.paymentRequest({
16828
16872
  country: window.Pelcro.user.location.countryCode || "US",
@@ -16891,7 +16935,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16891
16935
  */
16892
16936
  const updateTotalAmountWithTax = () => {
16893
16937
  var _window$Pelcro$site$r4;
16894
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16938
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
16895
16939
  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;
16896
16940
  if (taxesEnabled && type === "createPayment") {
16897
16941
  dispatch({
@@ -17388,16 +17432,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17388
17432
  items: mappedOrderItems,
17389
17433
  addressId: selectedAddressId,
17390
17434
  couponCode
17391
- }, (err, res) => {
17392
- dispatch({
17393
- type: DISABLE_SUBMIT,
17394
- payload: false
17395
- });
17396
- dispatch({
17397
- type: LOADING,
17398
- payload: false
17399
- });
17435
+ }, (err, orderResponse) => {
17436
+ var _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro2$user$;
17400
17437
  if (err) {
17438
+ toggleAuthenticationSuccessPendingView(false);
17439
+ dispatch({
17440
+ type: DISABLE_SUBMIT,
17441
+ payload: false
17442
+ });
17443
+ dispatch({
17444
+ type: LOADING,
17445
+ payload: false
17446
+ });
17401
17447
  onFailure(err);
17402
17448
  return dispatch({
17403
17449
  type: SHOW_ALERT,
@@ -17417,7 +17463,30 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17417
17463
  cartItems: []
17418
17464
  });
17419
17465
  }
17420
- onSuccess(res);
17466
+ window.Pelcro.user.refresh({
17467
+ auth_token: (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$user = _window$Pelcro2.user) === null || _window$Pelcro2$user === void 0 ? void 0 : (_window$Pelcro2$user$ = _window$Pelcro2$user.read()) === null || _window$Pelcro2$user$ === void 0 ? void 0 : _window$Pelcro2$user$.auth_token
17468
+ }, (err, res) => {
17469
+ dispatch({
17470
+ type: DISABLE_SUBMIT,
17471
+ payload: false
17472
+ });
17473
+ dispatch({
17474
+ type: LOADING,
17475
+ payload: false
17476
+ });
17477
+ toggleAuthenticationSuccessPendingView(false);
17478
+ if (err) {
17479
+ onFailure(err);
17480
+ return dispatch({
17481
+ type: SHOW_ALERT,
17482
+ payload: {
17483
+ type: "error",
17484
+ content: getErrorMessages(err)
17485
+ }
17486
+ });
17487
+ }
17488
+ onSuccess(orderResponse);
17489
+ });
17421
17490
  });
17422
17491
  };
17423
17492
  const payInvoice = (gatewayService, gatewayToken, dispatch) => {
@@ -17495,6 +17564,29 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17495
17564
  });
17496
17565
  };
17497
17566
  const submitPayment = (state, dispatch) => {
17567
+ if (skipPayment && props !== null && props !== void 0 && props.freeOrders) {
17568
+ const isQuickPurchase = !Array.isArray(order);
17569
+ const mappedOrderItems = isQuickPurchase ? [{
17570
+ sku_id: order.id,
17571
+ quantity: order.quantity
17572
+ }] : order.map(item => ({
17573
+ sku_id: item.id,
17574
+ quantity: item.quantity
17575
+ }));
17576
+ window.Pelcro.ecommerce.order.create({
17577
+ items: mappedOrderItems,
17578
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
17579
+ ...(selectedAddressId && {
17580
+ address_id: selectedAddressId
17581
+ })
17582
+ }, (err, res) => {
17583
+ if (err) {
17584
+ return handlePaymentError(err);
17585
+ }
17586
+ return onSuccess(res);
17587
+ });
17588
+ return;
17589
+ }
17498
17590
  stripe.createSource({
17499
17591
  type: "card"
17500
17592
  }).then(_ref8 => {
@@ -17728,6 +17820,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17728
17820
  disableSubmit: true,
17729
17821
  isLoading: true
17730
17822
  }, (state, dispatch) => {
17823
+ if (skipPayment && props !== null && props !== void 0 && props.freeOrders) {
17824
+ return submitPayment(state);
17825
+ }
17731
17826
  if (getSiteCardProcessor() === "vantiv") {
17732
17827
  return submitUsingVantiv(state);
17733
17828
  }
@@ -17856,10 +17951,14 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17856
17951
  state,
17857
17952
  dispatch
17858
17953
  }
17859
- }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
17860
- store: store$k,
17861
- key: i
17862
- })) : /*#__PURE__*/React__default.cloneElement(children, {
17954
+ }, children.length ? children.map((child, i) => {
17955
+ if (child) {
17956
+ return /*#__PURE__*/React__default.cloneElement(child, {
17957
+ store: store$k,
17958
+ key: i
17959
+ });
17960
+ }
17961
+ }) : /*#__PURE__*/React__default.cloneElement(children, {
17863
17962
  store: store$k
17864
17963
  })));
17865
17964
  };
@@ -18682,11 +18781,47 @@ const SubscriptionCreateFreePlanButton = _ref => {
18682
18781
  }, otherProps), t("buttons.subscribe"));
18683
18782
  };
18684
18783
 
18784
+ const OrderCreateFreeButton = _ref => {
18785
+ let {
18786
+ name,
18787
+ onClick,
18788
+ ...otherProps
18789
+ } = _ref;
18790
+ const {
18791
+ state: {
18792
+ disableSubmit
18793
+ },
18794
+ dispatch
18795
+ } = useContext(store$k);
18796
+ const {
18797
+ t
18798
+ } = useTranslation("checkoutForm");
18799
+ const [isDisabled, setDisabled] = useState(true);
18800
+ useEffect(() => {
18801
+ setDisabled(disableSubmit);
18802
+ }, [disableSubmit]);
18803
+ return /*#__PURE__*/React__default.createElement(Button, Object.assign({
18804
+ className: "plc-w-full",
18805
+ onClick: () => {
18806
+ dispatch({
18807
+ type: DISABLE_SUBMIT,
18808
+ payload: true
18809
+ });
18810
+ dispatch({
18811
+ type: SUBMIT_PAYMENT
18812
+ });
18813
+ onClick === null || onClick === void 0 ? void 0 : onClick();
18814
+ },
18815
+ disabled: isDisabled,
18816
+ isLoading: disableSubmit
18817
+ }, otherProps), t("labels.submit"));
18818
+ };
18819
+
18685
18820
  /**
18686
18821
  *
18687
18822
  */
18688
18823
  function PaymentMethodView(_ref) {
18689
- var _window$Pelcro$site$r, _window$Pelcro$site$r2;
18824
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2, _calcAndFormatItemsTo, _order$;
18690
18825
  let {
18691
18826
  onSuccess,
18692
18827
  onGiftRenewalSuccess,
@@ -18694,7 +18829,9 @@ function PaymentMethodView(_ref) {
18694
18829
  type,
18695
18830
  showCoupon,
18696
18831
  showExternalPaymentMethods,
18697
- showSubscriptionButton
18832
+ showSubscriptionButton,
18833
+ showOrderButton,
18834
+ order
18698
18835
  } = _ref;
18699
18836
  const {
18700
18837
  t
@@ -18707,7 +18844,17 @@ function PaymentMethodView(_ref) {
18707
18844
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
18708
18845
  return /*#__PURE__*/React__default.createElement("div", {
18709
18846
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
18710
- }, cardProcessor === "stripe" && !showSubscriptionButton && /*#__PURE__*/React__default.createElement("div", {
18847
+ }, order && /*#__PURE__*/React__default.createElement("div", {
18848
+ className: "plc-w-full plc-p-2 plc-mb-4 plc-font-semibold plc-text-center plc-text-gray-900 plc-bg-gray-100 plc-border plc-border-gray-200"
18849
+ }, /*#__PURE__*/React__default.createElement("p", {
18850
+ className: "plc-text-gray-600"
18851
+ }, !Array.isArray(order) ? /*#__PURE__*/React__default.createElement("span", {
18852
+ className: "plc-tracking-wider plc-uppercase"
18853
+ }, order === null || order === void 0 ? void 0 : order.name) : /*#__PURE__*/React__default.createElement("span", {
18854
+ className: "plc-tracking-wider plc-uppercase"
18855
+ }, t("labels.freeItems")), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
18856
+ className: "plc-text-xl plc-font-semibold plc-text-primary-600"
18857
+ }, (_calcAndFormatItemsTo = calcAndFormatItemsTotal(order, (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency)) !== null && _calcAndFormatItemsTo !== void 0 ? _calcAndFormatItemsTo : getFormattedPriceByLocal(order === null || order === void 0 ? void 0 : order.price, order === null || order === void 0 ? void 0 : order.currency, getPageOrDefaultLanguage())))), cardProcessor === "stripe" && !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default.createElement("div", {
18711
18858
  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"
18712
18859
  }, /*#__PURE__*/React__default.createElement(SvgLock, {
18713
18860
  className: "plc-w-5 plc-h-5 plc-mr-1"
@@ -18723,10 +18870,11 @@ function PaymentMethodView(_ref) {
18723
18870
  type: type,
18724
18871
  onSuccess: onSuccess,
18725
18872
  onGiftRenewalSuccess: onGiftRenewalSuccess,
18726
- onFailure: onFailure
18873
+ onFailure: onFailure,
18874
+ freeOrders: showOrderButton
18727
18875
  }, /*#__PURE__*/React__default.createElement(AlertWithContext, {
18728
18876
  className: "plc-mb-2"
18729
- }), 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", {
18877
+ }), showSubscriptionButton && /*#__PURE__*/React__default.createElement(SubscriptionCreateFreePlanButton, null), showOrderButton && /*#__PURE__*/React__default.createElement(OrderCreateFreeButton, null), !showSubscriptionButton && !showOrderButton && /*#__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", {
18730
18878
  className: "plc-flex plc-items-start"
18731
18879
  }, /*#__PURE__*/React__default.createElement(IncludeFirstName, {
18732
18880
  id: "pelcro-input-first-name",
@@ -20481,6 +20629,16 @@ function SubscriptionManageMembersList(props) {
20481
20629
  icon: /*#__PURE__*/React__default.createElement(SvgCheckMark, null)
20482
20630
  };
20483
20631
  }, []);
20632
+ const showMemberData = useCallback(member => {
20633
+ var _member$customer, _member$customer2, _member$customer3, _member$customer4;
20634
+ let data;
20635
+ if ((member === null || member === void 0 ? void 0 : member.status) !== "active") {
20636
+ data = member === null || member === void 0 ? void 0 : member.invitation_email;
20637
+ return data;
20638
+ }
20639
+ data = (member === null || member === void 0 ? void 0 : (_member$customer = member.customer) === null || _member$customer === void 0 ? void 0 : _member$customer.email) || (member === null || member === void 0 ? void 0 : (_member$customer2 = member.customer) === null || _member$customer2 === void 0 ? void 0 : _member$customer2.first_name) + " " + (member === null || member === void 0 ? void 0 : (_member$customer3 = member.customer) === null || _member$customer3 === void 0 ? void 0 : _member$customer3.last_name) || (member === null || member === void 0 ? void 0 : (_member$customer4 = member.customer) === null || _member$customer4 === void 0 ? void 0 : _member$customer4.username) || "-----";
20640
+ return data;
20641
+ }, []);
20484
20642
  if (loading) {
20485
20643
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement("div", {
20486
20644
  className: "plc-animate-pulse"
@@ -20522,10 +20680,10 @@ function SubscriptionManageMembersList(props) {
20522
20680
  className: `plc-w-full plc-align-middle plc-cursor-pointer accordion-header hover:plc-bg-gray-50 plc-text-center`
20523
20681
  }, /*#__PURE__*/React__default.createElement("td", {
20524
20682
  className: "plc-truncate plc-text-left",
20525
- title: member === null || member === void 0 ? void 0 : member.invitation_email
20683
+ title: showMemberData(member)
20526
20684
  }, /*#__PURE__*/React__default.createElement("span", {
20527
20685
  className: "plc-font-semibold plc-text-gray-500"
20528
- }, member === null || member === void 0 ? void 0 : member.invitation_email)), /*#__PURE__*/React__default.createElement("td", {
20686
+ }, showMemberData(member))), /*#__PURE__*/React__default.createElement("td", {
20529
20687
  className: "plc-py-2"
20530
20688
  }, /*#__PURE__*/React__default.createElement("span", {
20531
20689
  className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${getMemberStatus(member).bgColor} plc-uppercase ${getMemberStatus(member).textColor} plc-rounded-lg`
@@ -24133,9 +24291,15 @@ const OrderCreateContainer = props => /*#__PURE__*/React__default.createElement(
24133
24291
  }, props));
24134
24292
 
24135
24293
  const OrderCreateView = props => {
24294
+ var _window$Pelcro, _window$Pelcro$uiSett;
24136
24295
  const {
24137
24296
  t
24138
24297
  } = useTranslation("payment");
24298
+ const {
24299
+ order
24300
+ } = usePelcro();
24301
+ 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;
24302
+ const showOrderButton = skipPayment && ((order === null || order === void 0 ? void 0 : order.price) === 0 || (order === null || order === void 0 ? void 0 : order.length) > 0 && order.every(item => (item === null || item === void 0 ? void 0 : item.price) === 0));
24139
24303
  return /*#__PURE__*/React__default.createElement("div", {
24140
24304
  id: "pelcro-order-create-view"
24141
24305
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -24146,7 +24310,9 @@ const OrderCreateView = props => {
24146
24310
  }, /*#__PURE__*/React__default.createElement(PaymentMethodView, Object.assign({
24147
24311
  type: "orderCreate",
24148
24312
  showCoupon: true,
24149
- showExternalPaymentMethods: false
24313
+ showExternalPaymentMethods: false,
24314
+ showOrderButton: showOrderButton,
24315
+ order: order
24150
24316
  }, props))));
24151
24317
  };
24152
24318
 
@@ -25354,11 +25520,12 @@ const PaymentMethodSelectModal = _ref => {
25354
25520
  const {
25355
25521
  switchToCheckoutForm,
25356
25522
  set,
25357
- plan
25523
+ plan,
25524
+ order
25358
25525
  } = usePelcro();
25359
25526
  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;
25360
25527
  useEffect(() => {
25361
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) {
25528
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) {
25362
25529
  switchToCheckoutForm();
25363
25530
  }
25364
25531
  }, []);
@@ -27466,7 +27633,7 @@ const InvoicesItems = () => {
27466
27633
  setInvoice,
27467
27634
  switchView
27468
27635
  } = usePelcro();
27469
- const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
27636
+ const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.order_id || invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
27470
27637
  const showInvoiceDetails = event => {
27471
27638
  if (setInvoice(event.target.dataset.id)) {
27472
27639
  switchView("invoice-details");
@@ -28234,7 +28401,7 @@ class Dashboard extends Component {
28234
28401
  }
28235
28402
  function hasInvoices() {
28236
28403
  var _window$Pelcro$invoic, _window$Pelcro$invoic2;
28237
- const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
28404
+ const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.order_id || invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
28238
28405
  return invoices.length > 0;
28239
28406
  }
28240
28407
  function hasDonationSubs() {
@@ -32063,4 +32230,4 @@ const QrCodeModal = _ref => {
32063
32230
  };
32064
32231
  QrCodeModal.viewId = "qrcode";
32065
32232
 
32066
- 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, LoginUsername, 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, SubscriptionManageMembersButton, SubscriptionManageMembersContainer, SubscriptionManageMembersEmails, SubscriptionManageMembersList, SubscriptionManageMembersModal, SubscriptionManageMembersView, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, SubscriptionSuspendContainer, SubscriptionSuspendModal, SubscriptionSuspendView, TaxAmount, TextArea, Tooltip, UserNameInput, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateTin, UserUpdateUsername, UserUpdateView, VerifyLinkTokenContainer, VerifyLinkTokenLoader, VerifyLinkTokenModal, VerifyLinkTokenView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, invoicePaymentSubmitButton, notify$1 as notify, unauthenticatedButtons, usePelcro };
32233
+ 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, LoginUsername, LoginView, Logout, MeterModal, MeterView, Modal, ModalBody, ModalFooter, NewsletterWithHook as NewsLetter, NewsletterUpdateButton, NewsletterUpdateContainer, NewsletterUpdateList, NewsletterUpdateModal, NewsletterUpdateView, Notification, OrderConfirmModal, OrderCreateContainer, OrderCreateFreeButton, 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, SubscriptionManageMembersButton, SubscriptionManageMembersContainer, SubscriptionManageMembersEmails, SubscriptionManageMembersList, SubscriptionManageMembersModal, SubscriptionManageMembersView, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, SubscriptionSuspendContainer, SubscriptionSuspendModal, SubscriptionSuspendView, TaxAmount, TextArea, Tooltip, UserNameInput, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateTin, UserUpdateUsername, UserUpdateView, VerifyLinkTokenContainer, VerifyLinkTokenLoader, VerifyLinkTokenModal, VerifyLinkTokenView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, invoicePaymentSubmitButton, notify$1 as 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.21.5",
4
+ "version": "3.21.7",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",