@bunnyapp/components 1.7.0-beta.42 → 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 +67 -33
- package/dist/cjs/types/src/components/Signup/PriceListDisplay.d.ts +1 -0
- package/dist/cjs/types/src/utils/priceListUtils/getPrice.d.ts +9 -0
- package/dist/cjs/types/src/utils/pricePickerUtils.d.ts +1 -1
- package/dist/esm/index.js +67 -33
- package/dist/esm/types/src/components/Signup/PriceListDisplay.d.ts +1 -0
- package/dist/esm/types/src/utils/priceListUtils/getPrice.d.ts +9 -0
- package/dist/esm/types/src/utils/pricePickerUtils.d.ts +1 -1
- 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.43';
|
|
1287
1287
|
const createRequestHeaders = (token) => {
|
|
1288
1288
|
const headers = createClientDevHeaders({ token });
|
|
1289
1289
|
// Add the components version header
|
|
@@ -23314,6 +23314,35 @@ const TAG_COLORS = {
|
|
|
23314
23314
|
PENDING: 'yellow',
|
|
23315
23315
|
};
|
|
23316
23316
|
|
|
23317
|
+
const graphql = initGraphQLTada();
|
|
23318
|
+
|
|
23319
|
+
const periodMonthsConverter = (period) => {
|
|
23320
|
+
if (period === 0)
|
|
23321
|
+
return graphql.scalar('BillingPeriod', 'ONCE');
|
|
23322
|
+
else if (period === 1)
|
|
23323
|
+
return graphql.scalar('BillingPeriod', 'MONTHLY');
|
|
23324
|
+
else if (period === 3)
|
|
23325
|
+
return graphql.scalar('BillingPeriod', 'QUARTERLY');
|
|
23326
|
+
else if (period === 6)
|
|
23327
|
+
return graphql.scalar('BillingPeriod', 'SEMI_ANNUAL');
|
|
23328
|
+
else if (period === 12)
|
|
23329
|
+
return graphql.scalar('BillingPeriod', 'ANNUAL');
|
|
23330
|
+
else
|
|
23331
|
+
return null;
|
|
23332
|
+
};
|
|
23333
|
+
const billingPeriodConverter = (period) => {
|
|
23334
|
+
if (period === graphql.scalar('BillingPeriod', 'ONCE'))
|
|
23335
|
+
return 0;
|
|
23336
|
+
else if (period === graphql.scalar('BillingPeriod', 'MONTHLY'))
|
|
23337
|
+
return 1;
|
|
23338
|
+
else if (period === graphql.scalar('BillingPeriod', 'QUARTERLY'))
|
|
23339
|
+
return 3;
|
|
23340
|
+
else if (period === graphql.scalar('BillingPeriod', 'SEMI_ANNUAL'))
|
|
23341
|
+
return 6;
|
|
23342
|
+
else
|
|
23343
|
+
return 12;
|
|
23344
|
+
};
|
|
23345
|
+
|
|
23317
23346
|
const { Text: Text$p } = antd.Typography;
|
|
23318
23347
|
const PriceListDisplay_PriceListFragment = t(`
|
|
23319
23348
|
fragment PriceListDisplay_PriceListFragment on PriceList {
|
|
@@ -23325,14 +23354,17 @@ const PriceListDisplay_PriceListFragment = t(`
|
|
|
23325
23354
|
currencyId
|
|
23326
23355
|
trialAllowed
|
|
23327
23356
|
trialLengthDays
|
|
23357
|
+
periodMonths
|
|
23328
23358
|
}
|
|
23329
23359
|
`);
|
|
23330
23360
|
function PriceListDisplay({ priceList: maskedPriceList }) {
|
|
23331
23361
|
var _a, _b;
|
|
23332
23362
|
const priceList = readFragment(PriceListDisplay_PriceListFragment, maskedPriceList);
|
|
23363
|
+
const convertedPeriodMonths = periodMonthsConverter(priceList === null || priceList === void 0 ? void 0 : priceList.periodMonths);
|
|
23364
|
+
const periodLabel = convertedPeriodMonths ? PERIOD_LABELS[convertedPeriodMonths] : 'undefined';
|
|
23333
23365
|
if (!priceList)
|
|
23334
23366
|
return null;
|
|
23335
|
-
return (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-4", children: [jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-0", children: [jsxRuntime.jsxs(Text$p, { className: "bunny-text-slate-500 bunny-font-bold bunny-text-lg", children: [(_a = priceList.product) === null || _a === void 0 ? void 0 : _a.name, " ", priceList.name] }), jsxRuntime.jsxs(Text$p, { className: "bunny-font-bold bunny-text-xl", children: [formatCurrency(priceList.basePrice, priceList.currencyId), " /
|
|
23367
|
+
return (jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-4", children: [jsxRuntime.jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-0", children: [jsxRuntime.jsxs(Text$p, { className: "bunny-text-slate-500 bunny-font-bold bunny-text-lg", children: [(_a = priceList.product) === null || _a === void 0 ? void 0 : _a.name, " ", priceList.name] }), jsxRuntime.jsxs(Text$p, { className: "bunny-font-bold bunny-text-xl", children: [formatCurrency(priceList.basePrice, priceList.currencyId), " / ", periodLabel] })] }), priceList.trialAllowed ? (jsxRuntime.jsx("div", { className: "bunny-flex", children: jsxRuntime.jsx(CustomizedTag, { color: TAG_COLORS["TRIAL"], children: `${(_b = priceList.trialLengthDays) !== null && _b !== void 0 ? _b : 'N/A'} day trial` }) })) : null] }));
|
|
23336
23368
|
}
|
|
23337
23369
|
|
|
23338
23370
|
const Signup_PriceListFragment = t(`
|
|
@@ -23351,8 +23383,6 @@ const Signup_PriceListFragment = t(`
|
|
|
23351
23383
|
SelfServiceBuyWarning_PriceListFragment,
|
|
23352
23384
|
]);
|
|
23353
23385
|
|
|
23354
|
-
const graphql = initGraphQLTada();
|
|
23355
|
-
|
|
23356
23386
|
const mutation$g = graphql(`
|
|
23357
23387
|
mutation AccountSignup (
|
|
23358
23388
|
$pluginId: String!,
|
|
@@ -24168,33 +24198,6 @@ const CheckoutButton = ({ disabled, onClickCheckout, loading, tooltipText, }) =>
|
|
|
24168
24198
|
return (jsxRuntime.jsx(TooltipWrapper, { children: jsxRuntime.jsx(antd.Button, { className: isMobile ? 'w-full' : '', disabled: disabled, onClick: onClickCheckout, size: isMobile ? 'large' : 'middle', type: "primary", loading: loading, children: "Proceed to checkout" }) }));
|
|
24169
24199
|
};
|
|
24170
24200
|
|
|
24171
|
-
const periodMonthsConverter = (period) => {
|
|
24172
|
-
if (period === 0)
|
|
24173
|
-
return graphql.scalar('BillingPeriod', 'ONCE');
|
|
24174
|
-
else if (period === 1)
|
|
24175
|
-
return graphql.scalar('BillingPeriod', 'MONTHLY');
|
|
24176
|
-
else if (period === 3)
|
|
24177
|
-
return graphql.scalar('BillingPeriod', 'QUARTERLY');
|
|
24178
|
-
else if (period === 6)
|
|
24179
|
-
return graphql.scalar('BillingPeriod', 'SEMI_ANNUAL');
|
|
24180
|
-
else if (period === 12)
|
|
24181
|
-
return graphql.scalar('BillingPeriod', 'ANNUAL');
|
|
24182
|
-
else
|
|
24183
|
-
return null;
|
|
24184
|
-
};
|
|
24185
|
-
const billingPeriodConverter = (period) => {
|
|
24186
|
-
if (period === graphql.scalar('BillingPeriod', 'ONCE'))
|
|
24187
|
-
return 0;
|
|
24188
|
-
else if (period === graphql.scalar('BillingPeriod', 'MONTHLY'))
|
|
24189
|
-
return 1;
|
|
24190
|
-
else if (period === graphql.scalar('BillingPeriod', 'QUARTERLY'))
|
|
24191
|
-
return 3;
|
|
24192
|
-
else if (period === graphql.scalar('BillingPeriod', 'SEMI_ANNUAL'))
|
|
24193
|
-
return 6;
|
|
24194
|
-
else
|
|
24195
|
-
return 12;
|
|
24196
|
-
};
|
|
24197
|
-
|
|
24198
24201
|
const CheckoutPrice_QuoteFragment = t(`
|
|
24199
24202
|
fragment CheckoutPrice_QuoteFragment on Quote {
|
|
24200
24203
|
periodAmount
|
|
@@ -26807,11 +26810,41 @@ const GetPrice_PriceListFragment = t(`
|
|
|
26807
26810
|
showPriceAsMonthly
|
|
26808
26811
|
monthlyBasePrice
|
|
26809
26812
|
basePrice
|
|
26813
|
+
charges {
|
|
26814
|
+
basePrice
|
|
26815
|
+
chargeType
|
|
26816
|
+
featureAddon
|
|
26817
|
+
deprecated
|
|
26818
|
+
...filterDeprecatedCharges_PriceListChargeFragment
|
|
26819
|
+
}
|
|
26810
26820
|
}
|
|
26811
|
-
|
|
26821
|
+
`, [filterDeprecatedCharges_PriceListChargeFragment]);
|
|
26812
26822
|
function getPrice(maskedPriceList) {
|
|
26823
|
+
var _a, _b;
|
|
26813
26824
|
// Read fragments
|
|
26814
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
|
|
26815
26848
|
if (priceList.showPriceAsMonthly) {
|
|
26816
26849
|
return priceList.monthlyBasePrice;
|
|
26817
26850
|
}
|
|
@@ -26847,10 +26880,11 @@ function priceListPriceText({ priceList: maskedPriceList, }) {
|
|
|
26847
26880
|
}
|
|
26848
26881
|
return 0;
|
|
26849
26882
|
};
|
|
26883
|
+
const basePrice = getPrice(priceList);
|
|
26850
26884
|
const priceDecimals = calculatePriceDecimals();
|
|
26851
26885
|
const price = !((_a = priceList.plan) === null || _a === void 0 ? void 0 : _a.pricingStyle) ||
|
|
26852
26886
|
((_b = priceList.plan) === null || _b === void 0 ? void 0 : _b.pricingStyle) === t.scalar('PlanPricingStyles', 'PRICED')
|
|
26853
|
-
? formatCurrency(
|
|
26887
|
+
? formatCurrency(basePrice, priceList.currencyId, priceDecimals)
|
|
26854
26888
|
: ((_c = priceList.plan) === null || _c === void 0 ? void 0 : _c.pricingStyle) === t.scalar('PlanPricingStyles', 'CONTACT_US')
|
|
26855
26889
|
? 'Custom'
|
|
26856
26890
|
: 'Free';
|
|
@@ -8,6 +8,7 @@ export declare const PriceListDisplay_PriceListFragment: import("gql.tada").Tada
|
|
|
8
8
|
currencyId: string;
|
|
9
9
|
trialAllowed: boolean;
|
|
10
10
|
trialLengthDays: number | null;
|
|
11
|
+
periodMonths: number | null;
|
|
11
12
|
}, {}, {
|
|
12
13
|
fragment: "PriceListDisplay_PriceListFragment";
|
|
13
14
|
on: "PriceList";
|
|
@@ -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";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BillingPeriod } from '@/graphql-codegen/exportedScalarTypes';
|
|
2
2
|
import { Plan } from '@/types/Plan';
|
|
3
3
|
import Product from '@/types/Product';
|
|
4
|
-
export declare const periodMonthsConverter: (period: number | null) => "MONTHLY" | "QUARTERLY" | "SEMI_ANNUAL" | "ANNUAL" | "ONCE" | null;
|
|
4
|
+
export declare const periodMonthsConverter: (period: number | undefined | null) => "MONTHLY" | "QUARTERLY" | "SEMI_ANNUAL" | "ANNUAL" | "ONCE" | null;
|
|
5
5
|
export declare const billingPeriodConverter: (period?: BillingPeriod) => 3 | 0 | 1 | 6 | 12;
|
|
6
6
|
export declare const createAvailableBillingPeriods: (plans?: Plan[], selectedProduct?: Product) => (0 | 1 | 3 | 6 | 12)[] | undefined;
|
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
|
|
@@ -23312,6 +23312,35 @@ const TAG_COLORS = {
|
|
|
23312
23312
|
PENDING: 'yellow',
|
|
23313
23313
|
};
|
|
23314
23314
|
|
|
23315
|
+
const graphql = initGraphQLTada();
|
|
23316
|
+
|
|
23317
|
+
const periodMonthsConverter = (period) => {
|
|
23318
|
+
if (period === 0)
|
|
23319
|
+
return graphql.scalar('BillingPeriod', 'ONCE');
|
|
23320
|
+
else if (period === 1)
|
|
23321
|
+
return graphql.scalar('BillingPeriod', 'MONTHLY');
|
|
23322
|
+
else if (period === 3)
|
|
23323
|
+
return graphql.scalar('BillingPeriod', 'QUARTERLY');
|
|
23324
|
+
else if (period === 6)
|
|
23325
|
+
return graphql.scalar('BillingPeriod', 'SEMI_ANNUAL');
|
|
23326
|
+
else if (period === 12)
|
|
23327
|
+
return graphql.scalar('BillingPeriod', 'ANNUAL');
|
|
23328
|
+
else
|
|
23329
|
+
return null;
|
|
23330
|
+
};
|
|
23331
|
+
const billingPeriodConverter = (period) => {
|
|
23332
|
+
if (period === graphql.scalar('BillingPeriod', 'ONCE'))
|
|
23333
|
+
return 0;
|
|
23334
|
+
else if (period === graphql.scalar('BillingPeriod', 'MONTHLY'))
|
|
23335
|
+
return 1;
|
|
23336
|
+
else if (period === graphql.scalar('BillingPeriod', 'QUARTERLY'))
|
|
23337
|
+
return 3;
|
|
23338
|
+
else if (period === graphql.scalar('BillingPeriod', 'SEMI_ANNUAL'))
|
|
23339
|
+
return 6;
|
|
23340
|
+
else
|
|
23341
|
+
return 12;
|
|
23342
|
+
};
|
|
23343
|
+
|
|
23315
23344
|
const { Text: Text$p } = Typography;
|
|
23316
23345
|
const PriceListDisplay_PriceListFragment = t(`
|
|
23317
23346
|
fragment PriceListDisplay_PriceListFragment on PriceList {
|
|
@@ -23323,14 +23352,17 @@ const PriceListDisplay_PriceListFragment = t(`
|
|
|
23323
23352
|
currencyId
|
|
23324
23353
|
trialAllowed
|
|
23325
23354
|
trialLengthDays
|
|
23355
|
+
periodMonths
|
|
23326
23356
|
}
|
|
23327
23357
|
`);
|
|
23328
23358
|
function PriceListDisplay({ priceList: maskedPriceList }) {
|
|
23329
23359
|
var _a, _b;
|
|
23330
23360
|
const priceList = readFragment(PriceListDisplay_PriceListFragment, maskedPriceList);
|
|
23361
|
+
const convertedPeriodMonths = periodMonthsConverter(priceList === null || priceList === void 0 ? void 0 : priceList.periodMonths);
|
|
23362
|
+
const periodLabel = convertedPeriodMonths ? PERIOD_LABELS[convertedPeriodMonths] : 'undefined';
|
|
23331
23363
|
if (!priceList)
|
|
23332
23364
|
return null;
|
|
23333
|
-
return (jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-4", children: [jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-0", children: [jsxs(Text$p, { className: "bunny-text-slate-500 bunny-font-bold bunny-text-lg", children: [(_a = priceList.product) === null || _a === void 0 ? void 0 : _a.name, " ", priceList.name] }), jsxs(Text$p, { className: "bunny-font-bold bunny-text-xl", children: [formatCurrency(priceList.basePrice, priceList.currencyId), " /
|
|
23365
|
+
return (jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-4", children: [jsxs("div", { className: "bunny-flex bunny-flex-col bunny-gap-0", children: [jsxs(Text$p, { className: "bunny-text-slate-500 bunny-font-bold bunny-text-lg", children: [(_a = priceList.product) === null || _a === void 0 ? void 0 : _a.name, " ", priceList.name] }), jsxs(Text$p, { className: "bunny-font-bold bunny-text-xl", children: [formatCurrency(priceList.basePrice, priceList.currencyId), " / ", periodLabel] })] }), priceList.trialAllowed ? (jsx("div", { className: "bunny-flex", children: jsx(CustomizedTag, { color: TAG_COLORS["TRIAL"], children: `${(_b = priceList.trialLengthDays) !== null && _b !== void 0 ? _b : 'N/A'} day trial` }) })) : null] }));
|
|
23334
23366
|
}
|
|
23335
23367
|
|
|
23336
23368
|
const Signup_PriceListFragment = t(`
|
|
@@ -23349,8 +23381,6 @@ const Signup_PriceListFragment = t(`
|
|
|
23349
23381
|
SelfServiceBuyWarning_PriceListFragment,
|
|
23350
23382
|
]);
|
|
23351
23383
|
|
|
23352
|
-
const graphql = initGraphQLTada();
|
|
23353
|
-
|
|
23354
23384
|
const mutation$g = graphql(`
|
|
23355
23385
|
mutation AccountSignup (
|
|
23356
23386
|
$pluginId: String!,
|
|
@@ -24166,33 +24196,6 @@ const CheckoutButton = ({ disabled, onClickCheckout, loading, tooltipText, }) =>
|
|
|
24166
24196
|
return (jsx(TooltipWrapper, { children: jsx(Button, { className: isMobile ? 'w-full' : '', disabled: disabled, onClick: onClickCheckout, size: isMobile ? 'large' : 'middle', type: "primary", loading: loading, children: "Proceed to checkout" }) }));
|
|
24167
24197
|
};
|
|
24168
24198
|
|
|
24169
|
-
const periodMonthsConverter = (period) => {
|
|
24170
|
-
if (period === 0)
|
|
24171
|
-
return graphql.scalar('BillingPeriod', 'ONCE');
|
|
24172
|
-
else if (period === 1)
|
|
24173
|
-
return graphql.scalar('BillingPeriod', 'MONTHLY');
|
|
24174
|
-
else if (period === 3)
|
|
24175
|
-
return graphql.scalar('BillingPeriod', 'QUARTERLY');
|
|
24176
|
-
else if (period === 6)
|
|
24177
|
-
return graphql.scalar('BillingPeriod', 'SEMI_ANNUAL');
|
|
24178
|
-
else if (period === 12)
|
|
24179
|
-
return graphql.scalar('BillingPeriod', 'ANNUAL');
|
|
24180
|
-
else
|
|
24181
|
-
return null;
|
|
24182
|
-
};
|
|
24183
|
-
const billingPeriodConverter = (period) => {
|
|
24184
|
-
if (period === graphql.scalar('BillingPeriod', 'ONCE'))
|
|
24185
|
-
return 0;
|
|
24186
|
-
else if (period === graphql.scalar('BillingPeriod', 'MONTHLY'))
|
|
24187
|
-
return 1;
|
|
24188
|
-
else if (period === graphql.scalar('BillingPeriod', 'QUARTERLY'))
|
|
24189
|
-
return 3;
|
|
24190
|
-
else if (period === graphql.scalar('BillingPeriod', 'SEMI_ANNUAL'))
|
|
24191
|
-
return 6;
|
|
24192
|
-
else
|
|
24193
|
-
return 12;
|
|
24194
|
-
};
|
|
24195
|
-
|
|
24196
24199
|
const CheckoutPrice_QuoteFragment = t(`
|
|
24197
24200
|
fragment CheckoutPrice_QuoteFragment on Quote {
|
|
24198
24201
|
periodAmount
|
|
@@ -26805,11 +26808,41 @@ const GetPrice_PriceListFragment = t(`
|
|
|
26805
26808
|
showPriceAsMonthly
|
|
26806
26809
|
monthlyBasePrice
|
|
26807
26810
|
basePrice
|
|
26811
|
+
charges {
|
|
26812
|
+
basePrice
|
|
26813
|
+
chargeType
|
|
26814
|
+
featureAddon
|
|
26815
|
+
deprecated
|
|
26816
|
+
...filterDeprecatedCharges_PriceListChargeFragment
|
|
26817
|
+
}
|
|
26808
26818
|
}
|
|
26809
|
-
|
|
26819
|
+
`, [filterDeprecatedCharges_PriceListChargeFragment]);
|
|
26810
26820
|
function getPrice(maskedPriceList) {
|
|
26821
|
+
var _a, _b;
|
|
26811
26822
|
// Read fragments
|
|
26812
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
|
|
26813
26846
|
if (priceList.showPriceAsMonthly) {
|
|
26814
26847
|
return priceList.monthlyBasePrice;
|
|
26815
26848
|
}
|
|
@@ -26845,10 +26878,11 @@ function priceListPriceText({ priceList: maskedPriceList, }) {
|
|
|
26845
26878
|
}
|
|
26846
26879
|
return 0;
|
|
26847
26880
|
};
|
|
26881
|
+
const basePrice = getPrice(priceList);
|
|
26848
26882
|
const priceDecimals = calculatePriceDecimals();
|
|
26849
26883
|
const price = !((_a = priceList.plan) === null || _a === void 0 ? void 0 : _a.pricingStyle) ||
|
|
26850
26884
|
((_b = priceList.plan) === null || _b === void 0 ? void 0 : _b.pricingStyle) === t.scalar('PlanPricingStyles', 'PRICED')
|
|
26851
|
-
? formatCurrency(
|
|
26885
|
+
? formatCurrency(basePrice, priceList.currencyId, priceDecimals)
|
|
26852
26886
|
: ((_c = priceList.plan) === null || _c === void 0 ? void 0 : _c.pricingStyle) === t.scalar('PlanPricingStyles', 'CONTACT_US')
|
|
26853
26887
|
? 'Custom'
|
|
26854
26888
|
: 'Free';
|
|
@@ -8,6 +8,7 @@ export declare const PriceListDisplay_PriceListFragment: import("gql.tada").Tada
|
|
|
8
8
|
currencyId: string;
|
|
9
9
|
trialAllowed: boolean;
|
|
10
10
|
trialLengthDays: number | null;
|
|
11
|
+
periodMonths: number | null;
|
|
11
12
|
}, {}, {
|
|
12
13
|
fragment: "PriceListDisplay_PriceListFragment";
|
|
13
14
|
on: "PriceList";
|
|
@@ -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";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BillingPeriod } from '@/graphql-codegen/exportedScalarTypes';
|
|
2
2
|
import { Plan } from '@/types/Plan';
|
|
3
3
|
import Product from '@/types/Product';
|
|
4
|
-
export declare const periodMonthsConverter: (period: number | null) => "MONTHLY" | "QUARTERLY" | "SEMI_ANNUAL" | "ANNUAL" | "ONCE" | null;
|
|
4
|
+
export declare const periodMonthsConverter: (period: number | undefined | null) => "MONTHLY" | "QUARTERLY" | "SEMI_ANNUAL" | "ANNUAL" | "ONCE" | null;
|
|
5
5
|
export declare const billingPeriodConverter: (period?: BillingPeriod) => 3 | 0 | 1 | 6 | 12;
|
|
6
6
|
export declare const createAvailableBillingPeriods: (plans?: Plan[], selectedProduct?: Product) => (0 | 1 | 3 | 6 | 12)[] | undefined;
|
package/package.json
CHANGED