@bunnyapp/components 1.7.0-beta.43 → 1.7.0-beta.44
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
|
@@ -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.43';
|
|
1287
1287
|
const createRequestHeaders = (token) => {
|
|
1288
1288
|
const headers = createClientDevHeaders({ token });
|
|
1289
1289
|
// Add the components version header
|
|
@@ -26810,11 +26810,41 @@ const GetPrice_PriceListFragment = t(`
|
|
|
26810
26810
|
showPriceAsMonthly
|
|
26811
26811
|
monthlyBasePrice
|
|
26812
26812
|
basePrice
|
|
26813
|
+
charges {
|
|
26814
|
+
basePrice
|
|
26815
|
+
chargeType
|
|
26816
|
+
featureAddon
|
|
26817
|
+
deprecated
|
|
26818
|
+
...filterDeprecatedCharges_PriceListChargeFragment
|
|
26819
|
+
}
|
|
26813
26820
|
}
|
|
26814
|
-
|
|
26821
|
+
`, [filterDeprecatedCharges_PriceListChargeFragment]);
|
|
26815
26822
|
function getPrice(maskedPriceList) {
|
|
26823
|
+
var _a, _b;
|
|
26816
26824
|
// Read fragments
|
|
26817
26825
|
const priceList = readFragment(GetPrice_PriceListFragment, maskedPriceList);
|
|
26826
|
+
// ============= HACK FOR THOMAS' CUSTOMER MEETING =============
|
|
26827
|
+
// note: delete shortly after and implement a better pricing solution
|
|
26828
|
+
// to take other charges into account.
|
|
26829
|
+
// Filter charges: exclude deprecated and featureAddon charges, keep only USAGE charges
|
|
26830
|
+
const usageCharges = (_b = (_a = priceList.charges) === null || _a === void 0 ? void 0 : _a.filter(charge => {
|
|
26831
|
+
// Exclude deprecated charges
|
|
26832
|
+
if (!filterDeprecatedCharges(undefined, charge)) {
|
|
26833
|
+
return false;
|
|
26834
|
+
}
|
|
26835
|
+
// Exclude featureAddon charges
|
|
26836
|
+
if (charge.featureAddon === true) {
|
|
26837
|
+
return false;
|
|
26838
|
+
}
|
|
26839
|
+
// Keep only USAGE charges
|
|
26840
|
+
return charge.chargeType === t.scalar('ChargeType', 'USAGE');
|
|
26841
|
+
})) !== null && _b !== void 0 ? _b : [];
|
|
26842
|
+
// If there are any usage charges, sum their basePrice
|
|
26843
|
+
if (usageCharges.length > 0) {
|
|
26844
|
+
return usageCharges.reduce((sum, charge) => sum + charge.basePrice, 0);
|
|
26845
|
+
}
|
|
26846
|
+
// =================================================================
|
|
26847
|
+
// Otherwise, return the priceList basePrice or monthlyBasePrice
|
|
26818
26848
|
if (priceList.showPriceAsMonthly) {
|
|
26819
26849
|
return priceList.monthlyBasePrice;
|
|
26820
26850
|
}
|
|
@@ -26850,10 +26880,11 @@ function priceListPriceText({ priceList: maskedPriceList, }) {
|
|
|
26850
26880
|
}
|
|
26851
26881
|
return 0;
|
|
26852
26882
|
};
|
|
26883
|
+
const basePrice = getPrice(priceList);
|
|
26853
26884
|
const priceDecimals = calculatePriceDecimals();
|
|
26854
26885
|
const price = !((_a = priceList.plan) === null || _a === void 0 ? void 0 : _a.pricingStyle) ||
|
|
26855
26886
|
((_b = priceList.plan) === null || _b === void 0 ? void 0 : _b.pricingStyle) === t.scalar('PlanPricingStyles', 'PRICED')
|
|
26856
|
-
? formatCurrency(
|
|
26887
|
+
? formatCurrency(basePrice, priceList.currencyId, priceDecimals)
|
|
26857
26888
|
: ((_c = priceList.plan) === null || _c === void 0 ? void 0 : _c.pricingStyle) === t.scalar('PlanPricingStyles', 'CONTACT_US')
|
|
26858
26889
|
? 'Custom'
|
|
26859
26890
|
: 'Free';
|
|
@@ -3,6 +3,15 @@ export declare const GetPrice_PriceListFragment: import("gql.tada").TadaDocument
|
|
|
3
3
|
showPriceAsMonthly: boolean | null;
|
|
4
4
|
monthlyBasePrice: number | null;
|
|
5
5
|
basePrice: number | null;
|
|
6
|
+
charges: {
|
|
7
|
+
basePrice: number;
|
|
8
|
+
chargeType: "ONE_TIME" | "RECURRING" | "USAGE" | null;
|
|
9
|
+
featureAddon: boolean | null;
|
|
10
|
+
deprecated: boolean | null;
|
|
11
|
+
[$tada.fragmentRefs]: {
|
|
12
|
+
filterDeprecatedCharges_PriceListChargeFragment: "PriceListCharge";
|
|
13
|
+
};
|
|
14
|
+
}[] | null;
|
|
6
15
|
}, {}, {
|
|
7
16
|
fragment: "GetPrice_PriceListFragment";
|
|
8
17
|
on: "PriceList";
|
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.43';
|
|
1285
1285
|
const createRequestHeaders = (token) => {
|
|
1286
1286
|
const headers = createClientDevHeaders({ token });
|
|
1287
1287
|
// Add the components version header
|
|
@@ -26808,11 +26808,41 @@ const GetPrice_PriceListFragment = t(`
|
|
|
26808
26808
|
showPriceAsMonthly
|
|
26809
26809
|
monthlyBasePrice
|
|
26810
26810
|
basePrice
|
|
26811
|
+
charges {
|
|
26812
|
+
basePrice
|
|
26813
|
+
chargeType
|
|
26814
|
+
featureAddon
|
|
26815
|
+
deprecated
|
|
26816
|
+
...filterDeprecatedCharges_PriceListChargeFragment
|
|
26817
|
+
}
|
|
26811
26818
|
}
|
|
26812
|
-
|
|
26819
|
+
`, [filterDeprecatedCharges_PriceListChargeFragment]);
|
|
26813
26820
|
function getPrice(maskedPriceList) {
|
|
26821
|
+
var _a, _b;
|
|
26814
26822
|
// Read fragments
|
|
26815
26823
|
const priceList = readFragment(GetPrice_PriceListFragment, maskedPriceList);
|
|
26824
|
+
// ============= HACK FOR THOMAS' CUSTOMER MEETING =============
|
|
26825
|
+
// note: delete shortly after and implement a better pricing solution
|
|
26826
|
+
// to take other charges into account.
|
|
26827
|
+
// Filter charges: exclude deprecated and featureAddon charges, keep only USAGE charges
|
|
26828
|
+
const usageCharges = (_b = (_a = priceList.charges) === null || _a === void 0 ? void 0 : _a.filter(charge => {
|
|
26829
|
+
// Exclude deprecated charges
|
|
26830
|
+
if (!filterDeprecatedCharges(undefined, charge)) {
|
|
26831
|
+
return false;
|
|
26832
|
+
}
|
|
26833
|
+
// Exclude featureAddon charges
|
|
26834
|
+
if (charge.featureAddon === true) {
|
|
26835
|
+
return false;
|
|
26836
|
+
}
|
|
26837
|
+
// Keep only USAGE charges
|
|
26838
|
+
return charge.chargeType === t.scalar('ChargeType', 'USAGE');
|
|
26839
|
+
})) !== null && _b !== void 0 ? _b : [];
|
|
26840
|
+
// If there are any usage charges, sum their basePrice
|
|
26841
|
+
if (usageCharges.length > 0) {
|
|
26842
|
+
return usageCharges.reduce((sum, charge) => sum + charge.basePrice, 0);
|
|
26843
|
+
}
|
|
26844
|
+
// =================================================================
|
|
26845
|
+
// Otherwise, return the priceList basePrice or monthlyBasePrice
|
|
26816
26846
|
if (priceList.showPriceAsMonthly) {
|
|
26817
26847
|
return priceList.monthlyBasePrice;
|
|
26818
26848
|
}
|
|
@@ -26848,10 +26878,11 @@ function priceListPriceText({ priceList: maskedPriceList, }) {
|
|
|
26848
26878
|
}
|
|
26849
26879
|
return 0;
|
|
26850
26880
|
};
|
|
26881
|
+
const basePrice = getPrice(priceList);
|
|
26851
26882
|
const priceDecimals = calculatePriceDecimals();
|
|
26852
26883
|
const price = !((_a = priceList.plan) === null || _a === void 0 ? void 0 : _a.pricingStyle) ||
|
|
26853
26884
|
((_b = priceList.plan) === null || _b === void 0 ? void 0 : _b.pricingStyle) === t.scalar('PlanPricingStyles', 'PRICED')
|
|
26854
|
-
? formatCurrency(
|
|
26885
|
+
? formatCurrency(basePrice, priceList.currencyId, priceDecimals)
|
|
26855
26886
|
: ((_c = priceList.plan) === null || _c === void 0 ? void 0 : _c.pricingStyle) === t.scalar('PlanPricingStyles', 'CONTACT_US')
|
|
26856
26887
|
? 'Custom'
|
|
26857
26888
|
: 'Free';
|
|
@@ -3,6 +3,15 @@ export declare const GetPrice_PriceListFragment: import("gql.tada").TadaDocument
|
|
|
3
3
|
showPriceAsMonthly: boolean | null;
|
|
4
4
|
monthlyBasePrice: number | null;
|
|
5
5
|
basePrice: number | null;
|
|
6
|
+
charges: {
|
|
7
|
+
basePrice: number;
|
|
8
|
+
chargeType: "ONE_TIME" | "RECURRING" | "USAGE" | null;
|
|
9
|
+
featureAddon: boolean | null;
|
|
10
|
+
deprecated: boolean | null;
|
|
11
|
+
[$tada.fragmentRefs]: {
|
|
12
|
+
filterDeprecatedCharges_PriceListChargeFragment: "PriceListCharge";
|
|
13
|
+
};
|
|
14
|
+
}[] | null;
|
|
6
15
|
}, {}, {
|
|
7
16
|
fragment: "GetPrice_PriceListFragment";
|
|
8
17
|
on: "PriceList";
|
package/package.json
CHANGED