@bunnyapp/components 1.0.70 → 1.0.72
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/cjs/index.js
CHANGED
|
@@ -154,7 +154,7 @@ var BrandContext = react.createContext({
|
|
|
154
154
|
});
|
|
155
155
|
|
|
156
156
|
// This will be replaced at build time by rollup-plugin-replace
|
|
157
|
-
var PACKAGE_VERSION = '1.0.
|
|
157
|
+
var PACKAGE_VERSION = '1.0.71';
|
|
158
158
|
var createRequestHeaders = function (token) {
|
|
159
159
|
var headers = common.createClientDevHeaders(token);
|
|
160
160
|
// Add the components version header
|
|
@@ -22697,6 +22697,11 @@ var quoteChargeCreate = function (_a) {
|
|
|
22697
22697
|
});
|
|
22698
22698
|
};
|
|
22699
22699
|
|
|
22700
|
+
var formatDateForApi = function (date) {
|
|
22701
|
+
if (typeof date === 'string')
|
|
22702
|
+
date = dayjs(date);
|
|
22703
|
+
return date.format('YYYY-MM-DD');
|
|
22704
|
+
};
|
|
22700
22705
|
var QuantityInput = function (_a) {
|
|
22701
22706
|
var charge = _a.charge, chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote, setEditingQuoteData = _a.setEditingQuoteData, subscription = _a.subscription, subscriptionIndex = _a.subscriptionIndex, subscriptions = _a.subscriptions;
|
|
22702
22707
|
// Context
|
|
@@ -22717,17 +22722,14 @@ var QuantityInput = function (_a) {
|
|
|
22717
22722
|
(updatingChargeQuantityId && updatingChargeQuantityId !== charge.id) ||
|
|
22718
22723
|
// If the subscription is not self-service, we disable the quantity input
|
|
22719
22724
|
!charge.selfServiceQuantity;
|
|
22720
|
-
var value = (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) === undefined
|
|
22721
|
-
? ""
|
|
22722
|
-
: editedSubscription.quantity;
|
|
22725
|
+
var value = (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) === undefined ? '' : editedSubscription.quantity;
|
|
22723
22726
|
// Mutations
|
|
22724
22727
|
var createCharge = reactQuery.useMutation({
|
|
22725
22728
|
mutationFn: quoteChargeCreate,
|
|
22726
22729
|
onSuccess: function (response) {
|
|
22727
22730
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
22728
22731
|
if (!(editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id)) {
|
|
22729
|
-
var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) ===
|
|
22730
|
-
common.SubscriptionState.TRIAL;
|
|
22732
|
+
var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.TRIAL;
|
|
22731
22733
|
setEditingQuoteData({
|
|
22732
22734
|
id: (_e = (_d = (_c = response.quoteChargeCreate) === null || _c === void 0 ? void 0 : _c.quoteCharge) === null || _d === void 0 ? void 0 : _d.quoteChange) === null || _e === void 0 ? void 0 : _e.quoteId,
|
|
22733
22735
|
isTrial: isTrial,
|
|
@@ -22736,7 +22738,7 @@ var QuantityInput = function (_a) {
|
|
|
22736
22738
|
queryClient.invalidateQueries({
|
|
22737
22739
|
queryKey: common.QueryKeyFactory.default.createObjectKey({
|
|
22738
22740
|
id: (_h = (_g = (_f = response.quoteChargeCreate) === null || _f === void 0 ? void 0 : _f.quoteCharge) === null || _g === void 0 ? void 0 : _g.quoteChange) === null || _h === void 0 ? void 0 : _h.quoteId,
|
|
22739
|
-
objectName:
|
|
22741
|
+
objectName: 'editingQuote',
|
|
22740
22742
|
token: token,
|
|
22741
22743
|
}),
|
|
22742
22744
|
});
|
|
@@ -22749,17 +22751,14 @@ var QuantityInput = function (_a) {
|
|
|
22749
22751
|
onSuccess: function (subscriptionUpdateData) {
|
|
22750
22752
|
var _a, _b;
|
|
22751
22753
|
var quote = (_a = subscriptionUpdateData === null || subscriptionUpdateData === void 0 ? void 0 : subscriptionUpdateData.quoteSubscriptionUpdate) === null || _a === void 0 ? void 0 : _a.quote;
|
|
22752
|
-
var quoteChange = quote.quoteChanges.find(function (quoteChange) {
|
|
22753
|
-
return quoteChange.priceList.id ===
|
|
22754
|
-
(editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id);
|
|
22755
|
-
});
|
|
22754
|
+
var quoteChange = quote.quoteChanges.find(function (quoteChange) { return quoteChange.priceList.id === (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id); });
|
|
22756
22755
|
var subscriptionCharge = (_b = quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.subscription) === null || _b === void 0 ? void 0 : _b.charges.find(function (charge) { var _a; return ((_a = charge === null || charge === void 0 ? void 0 : charge.priceListCharge) === null || _a === void 0 ? void 0 : _a.id) === (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.chargeId); });
|
|
22757
22756
|
if (subscriptionCharge && quoteChange && editedSubscription) {
|
|
22758
22757
|
createCharge({
|
|
22759
22758
|
apiHost: apiHost,
|
|
22760
22759
|
quantity: editedSubscription.quantity,
|
|
22761
22760
|
quoteChangeId: quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.id,
|
|
22762
|
-
startDate:
|
|
22761
|
+
startDate: formatDateForApi(dayjs()),
|
|
22763
22762
|
subscriptionChargeId: subscriptionCharge.id,
|
|
22764
22763
|
token: token,
|
|
22765
22764
|
});
|
|
@@ -22774,8 +22773,7 @@ var QuantityInput = function (_a) {
|
|
|
22774
22773
|
onSuccess: function (response) {
|
|
22775
22774
|
var _a, _b, _c, _d, _e, _f;
|
|
22776
22775
|
if (!(editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id)) {
|
|
22777
|
-
var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) ===
|
|
22778
|
-
common.SubscriptionState.TRIAL;
|
|
22776
|
+
var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === common.SubscriptionState.TRIAL;
|
|
22779
22777
|
setEditingQuoteData({
|
|
22780
22778
|
id: (_d = (_c = response.quoteChangeUpdate) === null || _c === void 0 ? void 0 : _c.quoteChange) === null || _d === void 0 ? void 0 : _d.quoteId,
|
|
22781
22779
|
isTrial: isTrial,
|
|
@@ -22784,7 +22782,7 @@ var QuantityInput = function (_a) {
|
|
|
22784
22782
|
queryClient.invalidateQueries({
|
|
22785
22783
|
queryKey: common.QueryKeyFactory.default.createObjectKey({
|
|
22786
22784
|
id: (_f = (_e = response.quoteChangeUpdate) === null || _e === void 0 ? void 0 : _e.quoteChange) === null || _f === void 0 ? void 0 : _f.quoteId,
|
|
22787
|
-
objectName:
|
|
22785
|
+
objectName: 'editingQuote',
|
|
22788
22786
|
token: token,
|
|
22789
22787
|
}),
|
|
22790
22788
|
});
|
|
@@ -22792,8 +22790,7 @@ var QuantityInput = function (_a) {
|
|
|
22792
22790
|
});
|
|
22793
22791
|
// Handlers
|
|
22794
22792
|
var isQuantityLowerThanOriginal = function (quantity) {
|
|
22795
|
-
return (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) !== undefined &&
|
|
22796
|
-
editedSubscription.quantity <= quantity;
|
|
22793
|
+
return (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) !== undefined && editedSubscription.quantity <= quantity;
|
|
22797
22794
|
};
|
|
22798
22795
|
var onChangeQuantity = function (chargeIndex, value, priceListChargeId, subscription, subscriptionIndex) {
|
|
22799
22796
|
var quantity = isNaN(parseInt(value)) ? 0 : parseInt(value);
|
|
@@ -22872,12 +22869,12 @@ var QuantityInput = function (_a) {
|
|
|
22872
22869
|
// eslint-disable-next-line
|
|
22873
22870
|
}, [editedSubscription]);
|
|
22874
22871
|
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(antd.Input, { className: "bunny-text-right", disabled: quantityDisabled, onBlur: function () {
|
|
22875
|
-
if (typeof value ===
|
|
22876
|
-
showErrorNotification(
|
|
22872
|
+
if (typeof value === 'number' && value < charge.quantity) {
|
|
22873
|
+
showErrorNotification('New value is less than the original quantity. This is not allowed');
|
|
22877
22874
|
}
|
|
22878
22875
|
}, onChange: function (e) {
|
|
22879
22876
|
onChangeQuantity(chargeIndex, e.target.value, charge.priceListChargeId, subscription, subscriptionIndex);
|
|
22880
|
-
}, status: isQuantityLowerThanOriginal(charge.quantity) ?
|
|
22877
|
+
}, status: isQuantityLowerThanOriginal(charge.quantity) ? 'error' : '', style: { width: '96px' }, value: value }) }));
|
|
22881
22878
|
};
|
|
22882
22879
|
|
|
22883
22880
|
var Text$2 = antd.Typography.Text;
|
package/dist/esm/index.js
CHANGED
|
@@ -143,7 +143,7 @@ var BrandContext = createContext({
|
|
|
143
143
|
});
|
|
144
144
|
|
|
145
145
|
// This will be replaced at build time by rollup-plugin-replace
|
|
146
|
-
var PACKAGE_VERSION = '1.0.
|
|
146
|
+
var PACKAGE_VERSION = '1.0.71';
|
|
147
147
|
var createRequestHeaders = function (token) {
|
|
148
148
|
var headers = createClientDevHeaders(token);
|
|
149
149
|
// Add the components version header
|
|
@@ -22686,6 +22686,11 @@ var quoteChargeCreate = function (_a) {
|
|
|
22686
22686
|
});
|
|
22687
22687
|
};
|
|
22688
22688
|
|
|
22689
|
+
var formatDateForApi = function (date) {
|
|
22690
|
+
if (typeof date === 'string')
|
|
22691
|
+
date = dayjs(date);
|
|
22692
|
+
return date.format('YYYY-MM-DD');
|
|
22693
|
+
};
|
|
22689
22694
|
var QuantityInput = function (_a) {
|
|
22690
22695
|
var charge = _a.charge, chargeIndex = _a.chargeIndex, editingQuote = _a.editingQuote, setEditingQuoteData = _a.setEditingQuoteData, subscription = _a.subscription, subscriptionIndex = _a.subscriptionIndex, subscriptions = _a.subscriptions;
|
|
22691
22696
|
// Context
|
|
@@ -22706,17 +22711,14 @@ var QuantityInput = function (_a) {
|
|
|
22706
22711
|
(updatingChargeQuantityId && updatingChargeQuantityId !== charge.id) ||
|
|
22707
22712
|
// If the subscription is not self-service, we disable the quantity input
|
|
22708
22713
|
!charge.selfServiceQuantity;
|
|
22709
|
-
var value = (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) === undefined
|
|
22710
|
-
? ""
|
|
22711
|
-
: editedSubscription.quantity;
|
|
22714
|
+
var value = (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) === undefined ? '' : editedSubscription.quantity;
|
|
22712
22715
|
// Mutations
|
|
22713
22716
|
var createCharge = useMutation({
|
|
22714
22717
|
mutationFn: quoteChargeCreate,
|
|
22715
22718
|
onSuccess: function (response) {
|
|
22716
22719
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
22717
22720
|
if (!(editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id)) {
|
|
22718
|
-
var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) ===
|
|
22719
|
-
SubscriptionState$2.TRIAL;
|
|
22721
|
+
var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.TRIAL;
|
|
22720
22722
|
setEditingQuoteData({
|
|
22721
22723
|
id: (_e = (_d = (_c = response.quoteChargeCreate) === null || _c === void 0 ? void 0 : _c.quoteCharge) === null || _d === void 0 ? void 0 : _d.quoteChange) === null || _e === void 0 ? void 0 : _e.quoteId,
|
|
22722
22724
|
isTrial: isTrial,
|
|
@@ -22725,7 +22727,7 @@ var QuantityInput = function (_a) {
|
|
|
22725
22727
|
queryClient.invalidateQueries({
|
|
22726
22728
|
queryKey: QueryKeyFactory.default.createObjectKey({
|
|
22727
22729
|
id: (_h = (_g = (_f = response.quoteChargeCreate) === null || _f === void 0 ? void 0 : _f.quoteCharge) === null || _g === void 0 ? void 0 : _g.quoteChange) === null || _h === void 0 ? void 0 : _h.quoteId,
|
|
22728
|
-
objectName:
|
|
22730
|
+
objectName: 'editingQuote',
|
|
22729
22731
|
token: token,
|
|
22730
22732
|
}),
|
|
22731
22733
|
});
|
|
@@ -22738,17 +22740,14 @@ var QuantityInput = function (_a) {
|
|
|
22738
22740
|
onSuccess: function (subscriptionUpdateData) {
|
|
22739
22741
|
var _a, _b;
|
|
22740
22742
|
var quote = (_a = subscriptionUpdateData === null || subscriptionUpdateData === void 0 ? void 0 : subscriptionUpdateData.quoteSubscriptionUpdate) === null || _a === void 0 ? void 0 : _a.quote;
|
|
22741
|
-
var quoteChange = quote.quoteChanges.find(function (quoteChange) {
|
|
22742
|
-
return quoteChange.priceList.id ===
|
|
22743
|
-
(editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id);
|
|
22744
|
-
});
|
|
22743
|
+
var quoteChange = quote.quoteChanges.find(function (quoteChange) { return quoteChange.priceList.id === (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription.priceList.id); });
|
|
22745
22744
|
var subscriptionCharge = (_b = quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.subscription) === null || _b === void 0 ? void 0 : _b.charges.find(function (charge) { var _a; return ((_a = charge === null || charge === void 0 ? void 0 : charge.priceListCharge) === null || _a === void 0 ? void 0 : _a.id) === (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.chargeId); });
|
|
22746
22745
|
if (subscriptionCharge && quoteChange && editedSubscription) {
|
|
22747
22746
|
createCharge({
|
|
22748
22747
|
apiHost: apiHost,
|
|
22749
22748
|
quantity: editedSubscription.quantity,
|
|
22750
22749
|
quoteChangeId: quoteChange === null || quoteChange === void 0 ? void 0 : quoteChange.id,
|
|
22751
|
-
startDate:
|
|
22750
|
+
startDate: formatDateForApi(dayjs()),
|
|
22752
22751
|
subscriptionChargeId: subscriptionCharge.id,
|
|
22753
22752
|
token: token,
|
|
22754
22753
|
});
|
|
@@ -22763,8 +22762,7 @@ var QuantityInput = function (_a) {
|
|
|
22763
22762
|
onSuccess: function (response) {
|
|
22764
22763
|
var _a, _b, _c, _d, _e, _f;
|
|
22765
22764
|
if (!(editingQuote === null || editingQuote === void 0 ? void 0 : editingQuote.id)) {
|
|
22766
|
-
var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) ===
|
|
22767
|
-
SubscriptionState$2.TRIAL;
|
|
22765
|
+
var isTrial = ((_b = (_a = editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.subscription) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === SubscriptionState$2.TRIAL;
|
|
22768
22766
|
setEditingQuoteData({
|
|
22769
22767
|
id: (_d = (_c = response.quoteChangeUpdate) === null || _c === void 0 ? void 0 : _c.quoteChange) === null || _d === void 0 ? void 0 : _d.quoteId,
|
|
22770
22768
|
isTrial: isTrial,
|
|
@@ -22773,7 +22771,7 @@ var QuantityInput = function (_a) {
|
|
|
22773
22771
|
queryClient.invalidateQueries({
|
|
22774
22772
|
queryKey: QueryKeyFactory.default.createObjectKey({
|
|
22775
22773
|
id: (_f = (_e = response.quoteChangeUpdate) === null || _e === void 0 ? void 0 : _e.quoteChange) === null || _f === void 0 ? void 0 : _f.quoteId,
|
|
22776
|
-
objectName:
|
|
22774
|
+
objectName: 'editingQuote',
|
|
22777
22775
|
token: token,
|
|
22778
22776
|
}),
|
|
22779
22777
|
});
|
|
@@ -22781,8 +22779,7 @@ var QuantityInput = function (_a) {
|
|
|
22781
22779
|
});
|
|
22782
22780
|
// Handlers
|
|
22783
22781
|
var isQuantityLowerThanOriginal = function (quantity) {
|
|
22784
|
-
return (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) !== undefined &&
|
|
22785
|
-
editedSubscription.quantity <= quantity;
|
|
22782
|
+
return (editedSubscription === null || editedSubscription === void 0 ? void 0 : editedSubscription.quantity) !== undefined && editedSubscription.quantity <= quantity;
|
|
22786
22783
|
};
|
|
22787
22784
|
var onChangeQuantity = function (chargeIndex, value, priceListChargeId, subscription, subscriptionIndex) {
|
|
22788
22785
|
var quantity = isNaN(parseInt(value)) ? 0 : parseInt(value);
|
|
@@ -22861,12 +22858,12 @@ var QuantityInput = function (_a) {
|
|
|
22861
22858
|
// eslint-disable-next-line
|
|
22862
22859
|
}, [editedSubscription]);
|
|
22863
22860
|
return (jsx(Fragment, { children: jsx(Input, { className: "bunny-text-right", disabled: quantityDisabled, onBlur: function () {
|
|
22864
|
-
if (typeof value ===
|
|
22865
|
-
showErrorNotification(
|
|
22861
|
+
if (typeof value === 'number' && value < charge.quantity) {
|
|
22862
|
+
showErrorNotification('New value is less than the original quantity. This is not allowed');
|
|
22866
22863
|
}
|
|
22867
22864
|
}, onChange: function (e) {
|
|
22868
22865
|
onChangeQuantity(chargeIndex, e.target.value, charge.priceListChargeId, subscription, subscriptionIndex);
|
|
22869
|
-
}, status: isQuantityLowerThanOriginal(charge.quantity) ?
|
|
22866
|
+
}, status: isQuantityLowerThanOriginal(charge.quantity) ? 'error' : '', style: { width: '96px' }, value: value }) }));
|
|
22870
22867
|
};
|
|
22871
22868
|
|
|
22872
22869
|
var Text$2 = Typography.Text;
|
package/package.json
CHANGED