@bunnyapp/components 1.7.0-beta.21 → 1.7.0-beta.23
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 +14 -8
- package/dist/esm/index.js +14 -8
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1283,7 +1283,7 @@ const DEFAULT_CONFIG = {
|
|
|
1283
1283
|
};
|
|
1284
1284
|
|
|
1285
1285
|
// This will be replaced at build time by rollup-plugin-replace
|
|
1286
|
-
const PACKAGE_VERSION = '1.7.0-beta.
|
|
1286
|
+
const PACKAGE_VERSION = '1.7.0-beta.22';
|
|
1287
1287
|
const createRequestHeaders = (token) => {
|
|
1288
1288
|
const headers = createClientDevHeaders({ token });
|
|
1289
1289
|
// Add the components version header
|
|
@@ -20196,8 +20196,9 @@ const getQuoteAmountDue_QuoteFragment = t(`
|
|
|
20196
20196
|
}
|
|
20197
20197
|
`, []);
|
|
20198
20198
|
const getQuoteAmountDue = (maskedQuote) => {
|
|
20199
|
+
var _a;
|
|
20199
20200
|
const quote = readFragment(getQuoteAmountDue_QuoteFragment, maskedQuote);
|
|
20200
|
-
return quote.amountDue
|
|
20201
|
+
return (_a = quote.amountDue) !== null && _a !== void 0 ? _a : quote.amount;
|
|
20201
20202
|
};
|
|
20202
20203
|
|
|
20203
20204
|
const { useToken: useAntdToken$1 } = antd.theme;
|
|
@@ -20487,10 +20488,14 @@ const useHandlePayment = ({ quote: maskedQuote, invoice, onPaymentSuccess, onPay
|
|
|
20487
20488
|
const token = useToken();
|
|
20488
20489
|
// State
|
|
20489
20490
|
const [isPaid, setIsPaid] = react.useState(false);
|
|
20491
|
+
const getAmountDue = () => {
|
|
20492
|
+
return quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
|
|
20493
|
+
};
|
|
20490
20494
|
const formattedAmountDue = () => {
|
|
20491
|
-
|
|
20492
|
-
const
|
|
20493
|
-
|
|
20495
|
+
var _a;
|
|
20496
|
+
const amountDue = getAmountDue();
|
|
20497
|
+
const currencyId = (_a = quote === null || quote === void 0 ? void 0 : quote.currencyId) !== null && _a !== void 0 ? _a : invoice === null || invoice === void 0 ? void 0 : invoice.currencyId;
|
|
20498
|
+
return amountDue !== undefined && currencyId !== undefined ? formatCurrency(amountDue, currencyId).toString() : undefined;
|
|
20494
20499
|
};
|
|
20495
20500
|
// Validation checks
|
|
20496
20501
|
if (quote !== undefined && invoice !== undefined) {
|
|
@@ -20606,7 +20611,7 @@ const useHandlePayment = ({ quote: maskedQuote, invoice, onPaymentSuccess, onPay
|
|
|
20606
20611
|
isApprovingHoldDemoPay ||
|
|
20607
20612
|
isApprovingHoldStripe,
|
|
20608
20613
|
isPaid,
|
|
20609
|
-
paymentType: paymentHoldOptions.payToAccept ? PaymentType.APPROVE_HOLD : PaymentType.PAY,
|
|
20614
|
+
paymentType: paymentHoldOptions.payToAccept ? PaymentType.APPROVE_HOLD : getAmountDue() === 0 ? PaymentType.CHECKOUT_NO_PAYMENT : PaymentType.PAY,
|
|
20610
20615
|
formattedAmountDue: formattedAmountDue(),
|
|
20611
20616
|
};
|
|
20612
20617
|
};
|
|
@@ -27079,7 +27084,7 @@ const createAvailableBillingPeriods_SubscriptionFragment = t(`
|
|
|
27079
27084
|
}
|
|
27080
27085
|
`);
|
|
27081
27086
|
const createAvailableBillingPeriods = (priceLists, selectedProduct, maskedUpgradingSubscription) => {
|
|
27082
|
-
var _a, _b, _c, _d;
|
|
27087
|
+
var _a, _b, _c, _d, _e;
|
|
27083
27088
|
// Read fragment
|
|
27084
27089
|
const upgradingSubscription = readFragment(createAvailableBillingPeriods_SubscriptionFragment, maskedUpgradingSubscription);
|
|
27085
27090
|
if (((_b = (_a = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList) === null || _a === void 0 ? void 0 : _a.plan) === null || _b === void 0 ? void 0 : _b.addon) === true) {
|
|
@@ -27087,7 +27092,8 @@ const createAvailableBillingPeriods = (priceLists, selectedProduct, maskedUpgrad
|
|
|
27087
27092
|
? [(_d = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList) === null || _d === void 0 ? void 0 : _d.periodMonths]
|
|
27088
27093
|
: undefined;
|
|
27089
27094
|
}
|
|
27090
|
-
const availablePriceLists = priceLists === null || priceLists === void 0 ? void 0 : priceLists.filter(priceList => priceList.product.id === (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.id))
|
|
27095
|
+
const availablePriceLists = (_e = priceLists === null || priceLists === void 0 ? void 0 : priceLists.filter(priceList => priceList.product.id === (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.id)) // only show price lists for the selected product
|
|
27096
|
+
) === null || _e === void 0 ? void 0 : _e.filter(priceList => priceList.periodMonths !== 0).map(priceList => priceList.periodMonths).sort((a, b) => a - b).filter((currentValue, index, array) => index === array.indexOf(currentValue));
|
|
27091
27097
|
return availablePriceLists;
|
|
27092
27098
|
};
|
|
27093
27099
|
|
package/dist/esm/index.js
CHANGED
|
@@ -1281,7 +1281,7 @@ const DEFAULT_CONFIG = {
|
|
|
1281
1281
|
};
|
|
1282
1282
|
|
|
1283
1283
|
// This will be replaced at build time by rollup-plugin-replace
|
|
1284
|
-
const PACKAGE_VERSION = '1.7.0-beta.
|
|
1284
|
+
const PACKAGE_VERSION = '1.7.0-beta.22';
|
|
1285
1285
|
const createRequestHeaders = (token) => {
|
|
1286
1286
|
const headers = createClientDevHeaders({ token });
|
|
1287
1287
|
// Add the components version header
|
|
@@ -20194,8 +20194,9 @@ const getQuoteAmountDue_QuoteFragment = t(`
|
|
|
20194
20194
|
}
|
|
20195
20195
|
`, []);
|
|
20196
20196
|
const getQuoteAmountDue = (maskedQuote) => {
|
|
20197
|
+
var _a;
|
|
20197
20198
|
const quote = readFragment(getQuoteAmountDue_QuoteFragment, maskedQuote);
|
|
20198
|
-
return quote.amountDue
|
|
20199
|
+
return (_a = quote.amountDue) !== null && _a !== void 0 ? _a : quote.amount;
|
|
20199
20200
|
};
|
|
20200
20201
|
|
|
20201
20202
|
const { useToken: useAntdToken$1 } = theme;
|
|
@@ -20485,10 +20486,14 @@ const useHandlePayment = ({ quote: maskedQuote, invoice, onPaymentSuccess, onPay
|
|
|
20485
20486
|
const token = useToken();
|
|
20486
20487
|
// State
|
|
20487
20488
|
const [isPaid, setIsPaid] = useState(false);
|
|
20489
|
+
const getAmountDue = () => {
|
|
20490
|
+
return quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
|
|
20491
|
+
};
|
|
20488
20492
|
const formattedAmountDue = () => {
|
|
20489
|
-
|
|
20490
|
-
const
|
|
20491
|
-
|
|
20493
|
+
var _a;
|
|
20494
|
+
const amountDue = getAmountDue();
|
|
20495
|
+
const currencyId = (_a = quote === null || quote === void 0 ? void 0 : quote.currencyId) !== null && _a !== void 0 ? _a : invoice === null || invoice === void 0 ? void 0 : invoice.currencyId;
|
|
20496
|
+
return amountDue !== undefined && currencyId !== undefined ? formatCurrency(amountDue, currencyId).toString() : undefined;
|
|
20492
20497
|
};
|
|
20493
20498
|
// Validation checks
|
|
20494
20499
|
if (quote !== undefined && invoice !== undefined) {
|
|
@@ -20604,7 +20609,7 @@ const useHandlePayment = ({ quote: maskedQuote, invoice, onPaymentSuccess, onPay
|
|
|
20604
20609
|
isApprovingHoldDemoPay ||
|
|
20605
20610
|
isApprovingHoldStripe,
|
|
20606
20611
|
isPaid,
|
|
20607
|
-
paymentType: paymentHoldOptions.payToAccept ? PaymentType.APPROVE_HOLD : PaymentType.PAY,
|
|
20612
|
+
paymentType: paymentHoldOptions.payToAccept ? PaymentType.APPROVE_HOLD : getAmountDue() === 0 ? PaymentType.CHECKOUT_NO_PAYMENT : PaymentType.PAY,
|
|
20608
20613
|
formattedAmountDue: formattedAmountDue(),
|
|
20609
20614
|
};
|
|
20610
20615
|
};
|
|
@@ -27077,7 +27082,7 @@ const createAvailableBillingPeriods_SubscriptionFragment = t(`
|
|
|
27077
27082
|
}
|
|
27078
27083
|
`);
|
|
27079
27084
|
const createAvailableBillingPeriods = (priceLists, selectedProduct, maskedUpgradingSubscription) => {
|
|
27080
|
-
var _a, _b, _c, _d;
|
|
27085
|
+
var _a, _b, _c, _d, _e;
|
|
27081
27086
|
// Read fragment
|
|
27082
27087
|
const upgradingSubscription = readFragment(createAvailableBillingPeriods_SubscriptionFragment, maskedUpgradingSubscription);
|
|
27083
27088
|
if (((_b = (_a = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList) === null || _a === void 0 ? void 0 : _a.plan) === null || _b === void 0 ? void 0 : _b.addon) === true) {
|
|
@@ -27085,7 +27090,8 @@ const createAvailableBillingPeriods = (priceLists, selectedProduct, maskedUpgrad
|
|
|
27085
27090
|
? [(_d = upgradingSubscription === null || upgradingSubscription === void 0 ? void 0 : upgradingSubscription.priceList) === null || _d === void 0 ? void 0 : _d.periodMonths]
|
|
27086
27091
|
: undefined;
|
|
27087
27092
|
}
|
|
27088
|
-
const availablePriceLists = priceLists === null || priceLists === void 0 ? void 0 : priceLists.filter(priceList => priceList.product.id === (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.id))
|
|
27093
|
+
const availablePriceLists = (_e = priceLists === null || priceLists === void 0 ? void 0 : priceLists.filter(priceList => priceList.product.id === (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.id)) // only show price lists for the selected product
|
|
27094
|
+
) === null || _e === void 0 ? void 0 : _e.filter(priceList => priceList.periodMonths !== 0).map(priceList => priceList.periodMonths).sort((a, b) => a - b).filter((currentValue, index, array) => index === array.indexOf(currentValue));
|
|
27089
27095
|
return availablePriceLists;
|
|
27090
27096
|
};
|
|
27091
27097
|
|
package/package.json
CHANGED