@stigg/react-sdk 4.4.0-beta.4 → 4.4.0-beta.5
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/components/checkout/hooks/usePreviewSubscription.d.ts +3 -0
- package/dist/components/checkout/steps/plan/CheckoutChargeList.d.ts +2 -1
- package/dist/components/customerPortal/subscriptionOverview/subscriptionView/SubscriptionView.style.d.ts +1 -1
- package/dist/react-sdk.cjs.development.js +54 -37
- package/dist/react-sdk.cjs.development.js.map +1 -1
- package/dist/react-sdk.cjs.production.min.js +1 -1
- package/dist/react-sdk.cjs.production.min.js.map +1 -1
- package/dist/react-sdk.esm.js +54 -37
- package/dist/react-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/checkout/hooks/usePreviewSubscription.ts +8 -1
- package/src/components/checkout/steps/plan/CheckoutChargeList.tsx +12 -13
package/dist/react-sdk.esm.js
CHANGED
|
@@ -7005,7 +7005,7 @@ var usePreviewSubscriptionAction = function usePreviewSubscriptionAction() {
|
|
|
7005
7005
|
|
|
7006
7006
|
var previewSubscriptionAction = useCallback( /*#__PURE__*/function () {
|
|
7007
7007
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_temp) {
|
|
7008
|
-
var _ref4, promotionCode, estimateAddons, subscriptionPreview, errorMessage, previewSubscriptionProps, _error$message,
|
|
7008
|
+
var _ref4, promotionCode, estimateAddons, subscriptionPreview, errorMessage, isValid, previewSubscriptionProps, _error$message, _ref7, errorMsg;
|
|
7009
7009
|
|
|
7010
7010
|
return runtime_1.wrap(function _callee$(_context) {
|
|
7011
7011
|
while (1) {
|
|
@@ -7022,10 +7022,25 @@ var usePreviewSubscriptionAction = function usePreviewSubscriptionAction() {
|
|
|
7022
7022
|
});
|
|
7023
7023
|
subscriptionPreview = null;
|
|
7024
7024
|
errorMessage = null;
|
|
7025
|
-
|
|
7025
|
+
isValid = !subscription.billableFeatures.some(function (_ref6) {
|
|
7026
|
+
var quantity = _ref6.quantity;
|
|
7027
|
+
return quantity === null;
|
|
7028
|
+
});
|
|
7029
|
+
|
|
7030
|
+
if (isValid) {
|
|
7031
|
+
_context.next = 7;
|
|
7032
|
+
break;
|
|
7033
|
+
}
|
|
7034
|
+
|
|
7035
|
+
return _context.abrupt("return", {
|
|
7036
|
+
subscriptionPreview: subscriptionPreview
|
|
7037
|
+
});
|
|
7038
|
+
|
|
7039
|
+
case 7:
|
|
7040
|
+
_context.prev = 7;
|
|
7026
7041
|
|
|
7027
7042
|
if (!(customer != null && customer.id && plan != null && plan.id)) {
|
|
7028
|
-
_context.next =
|
|
7043
|
+
_context.next = 13;
|
|
7029
7044
|
break;
|
|
7030
7045
|
}
|
|
7031
7046
|
|
|
@@ -7042,34 +7057,34 @@ var usePreviewSubscriptionAction = function usePreviewSubscriptionAction() {
|
|
|
7042
7057
|
billingAddress: subscription.billingAddress,
|
|
7043
7058
|
taxPercentage: subscription.taxPercentage
|
|
7044
7059
|
}));
|
|
7045
|
-
_context.next =
|
|
7060
|
+
_context.next = 12;
|
|
7046
7061
|
return stigg.previewSubscription(previewSubscriptionProps);
|
|
7047
7062
|
|
|
7048
|
-
case
|
|
7063
|
+
case 12:
|
|
7049
7064
|
subscriptionPreview = _context.sent;
|
|
7050
7065
|
|
|
7051
|
-
case
|
|
7052
|
-
_context.next =
|
|
7066
|
+
case 13:
|
|
7067
|
+
_context.next = 19;
|
|
7053
7068
|
break;
|
|
7054
7069
|
|
|
7055
|
-
case
|
|
7056
|
-
_context.prev =
|
|
7057
|
-
_context.t0 = _context["catch"](
|
|
7058
|
-
|
|
7070
|
+
case 15:
|
|
7071
|
+
_context.prev = 15;
|
|
7072
|
+
_context.t0 = _context["catch"](7);
|
|
7073
|
+
_ref7 = (_context.t0 == null ? void 0 : (_error$message = _context.t0.message) == null ? void 0 : _error$message.split('Error:')) || [], errorMsg = _ref7[1];
|
|
7059
7074
|
errorMessage = errorMsg == null ? void 0 : errorMsg.trim();
|
|
7060
7075
|
|
|
7061
|
-
case
|
|
7076
|
+
case 19:
|
|
7062
7077
|
return _context.abrupt("return", {
|
|
7063
7078
|
subscriptionPreview: subscriptionPreview,
|
|
7064
7079
|
errorMessage: errorMessage
|
|
7065
7080
|
});
|
|
7066
7081
|
|
|
7067
|
-
case
|
|
7082
|
+
case 20:
|
|
7068
7083
|
case "end":
|
|
7069
7084
|
return _context.stop();
|
|
7070
7085
|
}
|
|
7071
7086
|
}
|
|
7072
|
-
}, _callee, null, [[
|
|
7087
|
+
}, _callee, null, [[7, 15]]);
|
|
7073
7088
|
}));
|
|
7074
7089
|
|
|
7075
7090
|
return function (_x) {
|
|
@@ -7094,7 +7109,7 @@ var usePreviewSubscription = function usePreviewSubscription() {
|
|
|
7094
7109
|
|
|
7095
7110
|
useEffect(function () {
|
|
7096
7111
|
var estimateSubscription = /*#__PURE__*/function () {
|
|
7097
|
-
var
|
|
7112
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
7098
7113
|
var _yield$previewSubscri, subscriptionPreview;
|
|
7099
7114
|
|
|
7100
7115
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
@@ -7108,7 +7123,11 @@ var usePreviewSubscription = function usePreviewSubscription() {
|
|
|
7108
7123
|
case 3:
|
|
7109
7124
|
_yield$previewSubscri = _context2.sent;
|
|
7110
7125
|
subscriptionPreview = _yield$previewSubscri.subscriptionPreview;
|
|
7111
|
-
|
|
7126
|
+
|
|
7127
|
+
if (subscriptionPreview) {
|
|
7128
|
+
setSubscriptionPreview(subscriptionPreview);
|
|
7129
|
+
}
|
|
7130
|
+
|
|
7112
7131
|
setIsFetchingSubscriptionPreview(false);
|
|
7113
7132
|
|
|
7114
7133
|
case 7:
|
|
@@ -7120,7 +7139,7 @@ var usePreviewSubscription = function usePreviewSubscription() {
|
|
|
7120
7139
|
}));
|
|
7121
7140
|
|
|
7122
7141
|
return function estimateSubscription() {
|
|
7123
|
-
return
|
|
7142
|
+
return _ref8.apply(this, arguments);
|
|
7124
7143
|
};
|
|
7125
7144
|
}();
|
|
7126
7145
|
|
|
@@ -12945,29 +12964,15 @@ function PlanCharge(_ref) {
|
|
|
12945
12964
|
var _charge$feature, _charge$feature2, _charge$feature3;
|
|
12946
12965
|
|
|
12947
12966
|
var charge = _ref.charge,
|
|
12967
|
+
isValid = _ref.isValid,
|
|
12948
12968
|
setBillableFeature = _ref.setBillableFeature,
|
|
12949
12969
|
billableFeature = _ref.billableFeature,
|
|
12950
12970
|
onValidationChange = _ref.onValidationChange;
|
|
12951
|
-
|
|
12952
|
-
var _React$useState = React__default.useState(true),
|
|
12953
|
-
isValid = _React$useState[0],
|
|
12954
|
-
setIsValid = _React$useState[1];
|
|
12955
|
-
|
|
12956
12971
|
var featureId = (_charge$feature = charge.feature) == null ? void 0 : _charge$feature.featureId;
|
|
12957
12972
|
var isBaseCharge = !featureId;
|
|
12958
12973
|
var isPayAsYouGo = charge.pricingModel === BillingModel.UsageBased;
|
|
12959
12974
|
var displayName = isBaseCharge ? 'Base charge' : (_charge$feature2 = charge.feature) == null ? void 0 : _charge$feature2.displayName;
|
|
12960
12975
|
var hasQuantityRestrictions = !!(charge != null && charge.minUnitQuantity || charge != null && charge.maxUnitQuantity);
|
|
12961
|
-
useEffect(function () {
|
|
12962
|
-
if (!featureId) {
|
|
12963
|
-
return;
|
|
12964
|
-
}
|
|
12965
|
-
|
|
12966
|
-
onValidationChange({
|
|
12967
|
-
featureId: featureId,
|
|
12968
|
-
isValid: isValid
|
|
12969
|
-
});
|
|
12970
|
-
}, [featureId, isValid, onValidationChange]);
|
|
12971
12976
|
|
|
12972
12977
|
var handleQuantityChange = function handleQuantityChange(event) {
|
|
12973
12978
|
var _event$target, _event$target2;
|
|
@@ -12976,14 +12981,20 @@ function PlanCharge(_ref) {
|
|
|
12976
12981
|
var value = event != null && (_event$target = event.target) != null && _event$target.value ? Number(event == null ? void 0 : (_event$target2 = event.target) == null ? void 0 : _event$target2.value) : charge.minUnitQuantity;
|
|
12977
12982
|
|
|
12978
12983
|
if (!value || value <= 0) {
|
|
12979
|
-
|
|
12984
|
+
onValidationChange({
|
|
12985
|
+
featureId: featureId,
|
|
12986
|
+
isValid: false
|
|
12987
|
+
}); // Reset the input value to null
|
|
12980
12988
|
// @ts-ignore
|
|
12981
12989
|
|
|
12982
12990
|
setBillableFeature(featureId, null);
|
|
12983
12991
|
return;
|
|
12984
12992
|
}
|
|
12985
12993
|
|
|
12986
|
-
|
|
12994
|
+
onValidationChange({
|
|
12995
|
+
featureId: featureId,
|
|
12996
|
+
isValid: true
|
|
12997
|
+
});
|
|
12987
12998
|
var quantity = getValidPriceQuantity(charge, value);
|
|
12988
12999
|
setBillableFeature(featureId, quantity);
|
|
12989
13000
|
};
|
|
@@ -13032,7 +13043,7 @@ function PlanCharge(_ref) {
|
|
|
13032
13043
|
margin: '4px'
|
|
13033
13044
|
}
|
|
13034
13045
|
},
|
|
13035
|
-
value: (billableFeature == null ? void 0 : billableFeature.quantity) || charge.minUnitQuantity,
|
|
13046
|
+
value: (billableFeature == null ? void 0 : billableFeature.quantity) || charge.minUnitQuantity || '',
|
|
13036
13047
|
onChange: handleQuantityChange
|
|
13037
13048
|
});
|
|
13038
13049
|
}
|
|
@@ -13070,7 +13081,12 @@ function CheckoutChargeList(_ref2) {
|
|
|
13070
13081
|
return p.billingPeriod === billingPeriod;
|
|
13071
13082
|
})) || []);
|
|
13072
13083
|
|
|
13073
|
-
var _useState = useState({
|
|
13084
|
+
var _useState = useState(planCharges == null ? void 0 : planCharges.reduce(function (acc, curr) {
|
|
13085
|
+
var _curr$feature;
|
|
13086
|
+
|
|
13087
|
+
acc[((_curr$feature = curr.feature) == null ? void 0 : _curr$feature.featureId) || 'base-charge'] = true;
|
|
13088
|
+
return acc;
|
|
13089
|
+
}, {})),
|
|
13074
13090
|
chargesValidation = _useState[0],
|
|
13075
13091
|
setChargesValidation = _useState[1];
|
|
13076
13092
|
|
|
@@ -13081,7 +13097,7 @@ function CheckoutChargeList(_ref2) {
|
|
|
13081
13097
|
setIsDisabled(isDisabled);
|
|
13082
13098
|
}, [chargesValidation, setIsDisabled]);
|
|
13083
13099
|
return React__default.createElement("div", null, planCharges == null ? void 0 : planCharges.map(function (charge) {
|
|
13084
|
-
var _charge$feature5;
|
|
13100
|
+
var _charge$feature5, _charge$feature6;
|
|
13085
13101
|
|
|
13086
13102
|
var billableFeature = billableFeatures.find(function (x) {
|
|
13087
13103
|
var _charge$feature4;
|
|
@@ -13093,6 +13109,7 @@ function CheckoutChargeList(_ref2) {
|
|
|
13093
13109
|
charge: charge,
|
|
13094
13110
|
setBillableFeature: setBillableFeature,
|
|
13095
13111
|
billableFeature: billableFeature,
|
|
13112
|
+
isValid: chargesValidation[((_charge$feature6 = charge.feature) == null ? void 0 : _charge$feature6.featureId) || 'base-charge'],
|
|
13096
13113
|
onValidationChange: function onValidationChange(_ref3) {
|
|
13097
13114
|
var featureId = _ref3.featureId,
|
|
13098
13115
|
isValid = _ref3.isValid;
|