@schematichq/schematic-components 0.6.4 → 0.7.1
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/schematic-components.cjs.js +450 -392
- package/dist/schematic-components.d.ts +38 -840
- package/dist/schematic-components.esm.js +450 -392
- package/package.json +8 -8
|
@@ -2275,6 +2275,7 @@ __export(index_exports, {
|
|
|
2275
2275
|
MeteredFeatures: () => MeteredFeatures,
|
|
2276
2276
|
Modal: () => Modal,
|
|
2277
2277
|
ModalHeader: () => ModalHeader,
|
|
2278
|
+
Notice: () => Notice,
|
|
2278
2279
|
PaymentMethod: () => PaymentMethod,
|
|
2279
2280
|
PaymentMethodDetails: () => PaymentMethodDetails,
|
|
2280
2281
|
PlanManager: () => PlanManager,
|
|
@@ -10721,7 +10722,8 @@ function BillingPriceResponseDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
10721
10722
|
externalPriceId: json["external_price_id"],
|
|
10722
10723
|
id: json["id"],
|
|
10723
10724
|
interval: json["interval"],
|
|
10724
|
-
price: json["price"]
|
|
10725
|
+
price: json["price"],
|
|
10726
|
+
priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"]
|
|
10725
10727
|
};
|
|
10726
10728
|
}
|
|
10727
10729
|
|
|
@@ -10741,6 +10743,7 @@ function BillingPriceViewFromJSONTyped(json, ignoreDiscriminator) {
|
|
|
10741
10743
|
isActive: json["is_active"],
|
|
10742
10744
|
meterId: json["meter_id"] == null ? void 0 : json["meter_id"],
|
|
10743
10745
|
price: json["price"],
|
|
10746
|
+
priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
|
|
10744
10747
|
priceExternalId: json["price_external_id"],
|
|
10745
10748
|
priceId: json["price_id"],
|
|
10746
10749
|
productExternalId: json["product_external_id"],
|
|
@@ -10767,6 +10770,7 @@ function BillingProductDetailResponseDataFromJSONTyped(json, ignoreDiscriminator
|
|
|
10767
10770
|
externalId: json["external_id"],
|
|
10768
10771
|
name: json["name"],
|
|
10769
10772
|
price: json["price"],
|
|
10773
|
+
priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
|
|
10770
10774
|
prices: json["prices"].map(
|
|
10771
10775
|
BillingPriceResponseDataFromJSON
|
|
10772
10776
|
),
|
|
@@ -10795,6 +10799,7 @@ function BillingProductForSubscriptionResponseDataFromJSONTyped(json, ignoreDisc
|
|
|
10795
10799
|
meterId: json["meter_id"] == null ? void 0 : json["meter_id"],
|
|
10796
10800
|
name: json["name"],
|
|
10797
10801
|
price: json["price"],
|
|
10802
|
+
priceDecimal: json["price_decimal"] == null ? void 0 : json["price_decimal"],
|
|
10798
10803
|
priceExternalId: json["price_external_id"],
|
|
10799
10804
|
priceId: json["price_id"],
|
|
10800
10805
|
quantity: json["quantity"],
|
|
@@ -13107,7 +13112,7 @@ var EmbedProvider = ({
|
|
|
13107
13112
|
(0, import_react11.useEffect)(() => {
|
|
13108
13113
|
if (accessToken) {
|
|
13109
13114
|
const { headers = {} } = apiConfig ?? {};
|
|
13110
|
-
headers["X-Schematic-Components-Version"] = "0.
|
|
13115
|
+
headers["X-Schematic-Components-Version"] = "0.7.1";
|
|
13111
13116
|
headers["X-Schematic-Session-ID"] = sessionIdRef.current;
|
|
13112
13117
|
const config = new Configuration({
|
|
13113
13118
|
...apiConfig,
|
|
@@ -13183,6 +13188,13 @@ var getFeatureName = (feature, count = 0) => {
|
|
|
13183
13188
|
}
|
|
13184
13189
|
return (0, import_pluralize.default)(name, count);
|
|
13185
13190
|
};
|
|
13191
|
+
function getBillingPrice(billingPrice) {
|
|
13192
|
+
if (!billingPrice) {
|
|
13193
|
+
return;
|
|
13194
|
+
}
|
|
13195
|
+
const price = typeof billingPrice.priceDecimal === "string" ? parseFloat(billingPrice.priceDecimal) : billingPrice.price;
|
|
13196
|
+
return { ...billingPrice, price };
|
|
13197
|
+
}
|
|
13186
13198
|
|
|
13187
13199
|
// src/utils/color.ts
|
|
13188
13200
|
function hexToHSL(color) {
|
|
@@ -13322,7 +13334,7 @@ function formatCurrency(amount, currency) {
|
|
|
13322
13334
|
return `$${formatted}${symbol}`;
|
|
13323
13335
|
};
|
|
13324
13336
|
if (dollars >= 1e6) {
|
|
13325
|
-
formatValue(dollars / 1e6, "M");
|
|
13337
|
+
return formatValue(dollars / 1e6, "M");
|
|
13326
13338
|
}
|
|
13327
13339
|
if (dollars >= 1e3) {
|
|
13328
13340
|
return formatValue(dollars / 1e3, "k");
|
|
@@ -13445,10 +13457,7 @@ var import_react20 = require("react");
|
|
|
13445
13457
|
// src/components/ui/box/styles.ts
|
|
13446
13458
|
var Box = dt.div((props) => {
|
|
13447
13459
|
function reducer(acc, [key, value]) {
|
|
13448
|
-
if (key.startsWith("$") && ![
|
|
13449
|
-
"$viewport",
|
|
13450
|
-
...Object.values(TextPropNames).filter((prop) => prop !== "$color")
|
|
13451
|
-
].includes(key)) {
|
|
13460
|
+
if (key.startsWith("$") && !["$viewport"].includes(key)) {
|
|
13452
13461
|
acc.push(
|
|
13453
13462
|
// keys will always be CSS properties
|
|
13454
13463
|
attr(camelToHyphen(key.slice(1)), value)
|
|
@@ -13571,6 +13580,7 @@ var Button2 = (0, import_react16.forwardRef)(
|
|
|
13571
13580
|
children,
|
|
13572
13581
|
...props
|
|
13573
13582
|
}, ref) => {
|
|
13583
|
+
const theme = nt();
|
|
13574
13584
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
13575
13585
|
Button,
|
|
13576
13586
|
{
|
|
@@ -13581,7 +13591,7 @@ var Button2 = (0, import_react16.forwardRef)(
|
|
|
13581
13591
|
disabled,
|
|
13582
13592
|
...props,
|
|
13583
13593
|
children: [
|
|
13584
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Loader, { $size: "sm", $isLoading: isLoading }),
|
|
13594
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Loader, { $color: theme.primary, $size: "sm", $isLoading: isLoading }),
|
|
13585
13595
|
children
|
|
13586
13596
|
]
|
|
13587
13597
|
}
|
|
@@ -14089,7 +14099,7 @@ var Loader = dt.div`
|
|
|
14089
14099
|
}
|
|
14090
14100
|
return lt`
|
|
14091
14101
|
border-color: ${color};
|
|
14092
|
-
border-top-color: ${colorFn(color,
|
|
14102
|
+
border-top-color: ${colorFn(color, 0.425)};
|
|
14093
14103
|
`;
|
|
14094
14104
|
}}
|
|
14095
14105
|
|
|
@@ -14269,8 +14279,11 @@ var ModalHeader = ({
|
|
|
14269
14279
|
};
|
|
14270
14280
|
|
|
14271
14281
|
// src/components/ui/progress-bar/styles.ts
|
|
14272
|
-
var Container3 = dt
|
|
14282
|
+
var Container3 = dt.div`
|
|
14273
14283
|
position: relative;
|
|
14284
|
+
display: flex;
|
|
14285
|
+
align-items: center;
|
|
14286
|
+
gap: 1rem;
|
|
14274
14287
|
`;
|
|
14275
14288
|
|
|
14276
14289
|
// src/components/ui/progress-bar/ProgressBar.tsx
|
|
@@ -14300,59 +14313,51 @@ var ProgressBar = ({
|
|
|
14300
14313
|
orange: "#DB6769",
|
|
14301
14314
|
red: "#EF4444"
|
|
14302
14315
|
};
|
|
14303
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
14304
|
-
|
|
14305
|
-
|
|
14306
|
-
|
|
14307
|
-
|
|
14308
|
-
|
|
14309
|
-
|
|
14310
|
-
|
|
14316
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Container3, { ...props, children: [
|
|
14317
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
14318
|
+
Flex,
|
|
14319
|
+
{
|
|
14320
|
+
$position: "relative",
|
|
14321
|
+
$alignItems: "center",
|
|
14322
|
+
$width: `${barWidth}`,
|
|
14323
|
+
$maxWidth: "100%",
|
|
14324
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
14311
14325
|
Flex,
|
|
14312
14326
|
{
|
|
14313
14327
|
$position: "relative",
|
|
14314
|
-
$
|
|
14315
|
-
$width:
|
|
14316
|
-
$
|
|
14328
|
+
$overflow: "hidden",
|
|
14329
|
+
$width: "100%",
|
|
14330
|
+
$height: `${8 / TEXT_BASE_SIZE}rem`,
|
|
14331
|
+
$backgroundColor: bgColor,
|
|
14332
|
+
$borderRadius: "9999px",
|
|
14317
14333
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
14318
|
-
|
|
14334
|
+
Box,
|
|
14319
14335
|
{
|
|
14320
|
-
$
|
|
14321
|
-
$
|
|
14322
|
-
$
|
|
14323
|
-
$
|
|
14324
|
-
$backgroundColor: bgColor,
|
|
14325
|
-
$borderRadius: "9999px",
|
|
14326
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
14327
|
-
Box,
|
|
14328
|
-
{
|
|
14329
|
-
$width: `${Math.min(progress, 100)}%`,
|
|
14330
|
-
$height: "100%",
|
|
14331
|
-
$backgroundColor: barColorMap[color],
|
|
14332
|
-
$borderRadius: "9999px"
|
|
14333
|
-
}
|
|
14334
|
-
)
|
|
14336
|
+
$width: `${Math.min(progress, 100)}%`,
|
|
14337
|
+
$height: "100%",
|
|
14338
|
+
$backgroundColor: barColorMap[color],
|
|
14339
|
+
$borderRadius: "9999px"
|
|
14335
14340
|
}
|
|
14336
14341
|
)
|
|
14337
14342
|
}
|
|
14338
|
-
),
|
|
14339
|
-
total !== 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
14340
|
-
Text,
|
|
14341
|
-
{
|
|
14342
|
-
$font: theme.typography.text.fontFamily,
|
|
14343
|
-
$size: 14,
|
|
14344
|
-
$weight: 500,
|
|
14345
|
-
$color: theme.typography.text.color,
|
|
14346
|
-
children: [
|
|
14347
|
-
value,
|
|
14348
|
-
"/",
|
|
14349
|
-
total
|
|
14350
|
-
]
|
|
14351
|
-
}
|
|
14352
14343
|
)
|
|
14353
|
-
|
|
14354
|
-
|
|
14355
|
-
|
|
14344
|
+
}
|
|
14345
|
+
),
|
|
14346
|
+
total !== 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
14347
|
+
Text,
|
|
14348
|
+
{
|
|
14349
|
+
$font: theme.typography.text.fontFamily,
|
|
14350
|
+
$size: 14,
|
|
14351
|
+
$weight: 500,
|
|
14352
|
+
$color: theme.typography.text.color,
|
|
14353
|
+
children: [
|
|
14354
|
+
value,
|
|
14355
|
+
"/",
|
|
14356
|
+
total
|
|
14357
|
+
]
|
|
14358
|
+
}
|
|
14359
|
+
)
|
|
14360
|
+
] });
|
|
14356
14361
|
};
|
|
14357
14362
|
|
|
14358
14363
|
// src/components/ui/text/styles.ts
|
|
@@ -14365,8 +14370,7 @@ var TextPropNames = /* @__PURE__ */ ((TextPropNames2) => {
|
|
|
14365
14370
|
TextPropNames2["Leading"] = "$leading";
|
|
14366
14371
|
return TextPropNames2;
|
|
14367
14372
|
})(TextPropNames || {});
|
|
14368
|
-
var Text = dt
|
|
14369
|
-
as,
|
|
14373
|
+
var Text = dt.span.attrs(({ onClick }) => ({
|
|
14370
14374
|
...onClick && { tabIndex: 0 }
|
|
14371
14375
|
}))`
|
|
14372
14376
|
${({ $font }) => $font && lt`
|
|
@@ -14402,7 +14406,7 @@ var import_react19 = require("react");
|
|
|
14402
14406
|
var import_react_dom = require("react-dom");
|
|
14403
14407
|
|
|
14404
14408
|
// src/components/ui/tooltip/styles.ts
|
|
14405
|
-
var Trigger = dt
|
|
14409
|
+
var Trigger = dt.div``;
|
|
14406
14410
|
var coords = (position2) => {
|
|
14407
14411
|
let x2 = 0;
|
|
14408
14412
|
let y2 = 0;
|
|
@@ -14469,7 +14473,7 @@ var grow = (translate) => {
|
|
|
14469
14473
|
}
|
|
14470
14474
|
`;
|
|
14471
14475
|
};
|
|
14472
|
-
var Content = dt
|
|
14476
|
+
var Content = dt.div.withConfig({
|
|
14473
14477
|
shouldForwardProp: (prop) => !["x", "y", "position", "zIndex"].includes(prop)
|
|
14474
14478
|
})(({ x: x2, y: y2, position: position2, zIndex }) => {
|
|
14475
14479
|
const translate = coords(position2);
|
|
@@ -14586,6 +14590,7 @@ var Tooltip = ({
|
|
|
14586
14590
|
// src/components/layout/card/styles.ts
|
|
14587
14591
|
var Element = dt(Box)``;
|
|
14588
14592
|
var FussyChild = dt(Element)``;
|
|
14593
|
+
var Notice = dt(Box)``;
|
|
14589
14594
|
var cardBoxShadow = "0px 1px 20px 0px #1018280F, 0px 1px 3px 0px #1018281A";
|
|
14590
14595
|
var StyledCard = dt.div(({ theme }) => {
|
|
14591
14596
|
const { l: l2 } = hexToHSL(theme.card.background);
|
|
@@ -14613,6 +14618,11 @@ var StyledCard = dt.div(({ theme }) => {
|
|
|
14613
14618
|
`}
|
|
14614
14619
|
}
|
|
14615
14620
|
}
|
|
14621
|
+
|
|
14622
|
+
${Notice}:first-child {
|
|
14623
|
+
border-top-left-radius: ${borderRadius};
|
|
14624
|
+
border-top-right-radius: ${borderRadius};
|
|
14625
|
+
}
|
|
14616
14626
|
`;
|
|
14617
14627
|
});
|
|
14618
14628
|
|
|
@@ -14667,11 +14677,12 @@ Column.displayName = "Column";
|
|
|
14667
14677
|
var import_react22 = require("react");
|
|
14668
14678
|
|
|
14669
14679
|
// src/components/layout/root/styles.ts
|
|
14670
|
-
var Container2 = dt
|
|
14680
|
+
var Container2 = dt.div`
|
|
14671
14681
|
all: initial;
|
|
14672
14682
|
box-sizing: border-box;
|
|
14673
14683
|
display: block;
|
|
14674
14684
|
font-size: ${TEXT_BASE_SIZE}px;
|
|
14685
|
+
line-height: 1.35;
|
|
14675
14686
|
width: 100%;
|
|
14676
14687
|
height: 100%;
|
|
14677
14688
|
|
|
@@ -14942,49 +14953,65 @@ var Sidebar = ({
|
|
|
14942
14953
|
const isLightBackground = useIsLightBackground();
|
|
14943
14954
|
const currentPlan = data.company?.plan;
|
|
14944
14955
|
const currentAddOns = data.company?.addOns || [];
|
|
14945
|
-
const currentUsageBasedEntitlements =
|
|
14946
|
-
(
|
|
14947
|
-
|
|
14948
|
-
(
|
|
14949
|
-
|
|
14950
|
-
|
|
14951
|
-
|
|
14952
|
-
|
|
14953
|
-
|
|
14954
|
-
|
|
14955
|
-
|
|
14956
|
-
|
|
14957
|
-
|
|
14958
|
-
|
|
14959
|
-
|
|
14960
|
-
|
|
14961
|
-
|
|
14962
|
-
|
|
14963
|
-
|
|
14964
|
-
|
|
14965
|
-
|
|
14966
|
-
|
|
14967
|
-
|
|
14956
|
+
const currentUsageBasedEntitlements = (0, import_react23.useMemo)(() => {
|
|
14957
|
+
return (data.featureUsage?.features || []).reduce(
|
|
14958
|
+
(acc, entitlement) => {
|
|
14959
|
+
if (entitlement.priceBehavior && (planPeriod === "month" && entitlement.monthlyUsageBasedPrice || planPeriod === "year" && entitlement.yearlyUsageBasedPrice)) {
|
|
14960
|
+
const allocation = entitlement.allocation || 0;
|
|
14961
|
+
const usage = entitlement.usage || 0;
|
|
14962
|
+
acc.push({
|
|
14963
|
+
...entitlement,
|
|
14964
|
+
allocation,
|
|
14965
|
+
usage,
|
|
14966
|
+
quantity: allocation ?? usage
|
|
14967
|
+
});
|
|
14968
|
+
}
|
|
14969
|
+
return acc;
|
|
14970
|
+
},
|
|
14971
|
+
[]
|
|
14972
|
+
);
|
|
14973
|
+
}, [data.featureUsage?.features, planPeriod]);
|
|
14974
|
+
const { payAsYouGoEntitlements, payInAdvanceEntitlements } = (0, import_react23.useMemo)(() => {
|
|
14975
|
+
const payAsYouGoEntitlements2 = [];
|
|
14976
|
+
const payInAdvanceEntitlements2 = usageBasedEntitlements.filter(
|
|
14977
|
+
(entitlement) => {
|
|
14978
|
+
if (entitlement.priceBehavior === "pay_as_you_go") {
|
|
14979
|
+
payAsYouGoEntitlements2.push(entitlement);
|
|
14980
|
+
}
|
|
14981
|
+
return entitlement.priceBehavior === "pay_in_advance";
|
|
14982
|
+
}
|
|
14983
|
+
);
|
|
14984
|
+
return { payAsYouGoEntitlements: payAsYouGoEntitlements2, payInAdvanceEntitlements: payInAdvanceEntitlements2 };
|
|
14985
|
+
}, [usageBasedEntitlements]);
|
|
14968
14986
|
const subscriptionPrice = (0, import_react23.useMemo)(() => {
|
|
14969
|
-
let total = 0;
|
|
14970
14987
|
let planPrice;
|
|
14971
14988
|
let currency;
|
|
14972
14989
|
if (selectedPlan) {
|
|
14973
|
-
|
|
14974
|
-
|
|
14975
|
-
|
|
14976
|
-
|
|
14977
|
-
|
|
14990
|
+
const planBillingPrice = getBillingPrice(
|
|
14991
|
+
planPeriod === "year" ? selectedPlan.yearlyPrice : selectedPlan.monthlyPrice
|
|
14992
|
+
);
|
|
14993
|
+
planPrice = planBillingPrice?.price;
|
|
14994
|
+
currency = planBillingPrice?.currency;
|
|
14978
14995
|
} else if (typeof currentPlan?.planPrice === "number") {
|
|
14979
14996
|
planPrice = currentPlan.planPrice;
|
|
14980
14997
|
}
|
|
14981
|
-
|
|
14982
|
-
|
|
14983
|
-
|
|
14984
|
-
|
|
14998
|
+
let total = 0;
|
|
14999
|
+
if (planPrice) {
|
|
15000
|
+
total += planPrice;
|
|
15001
|
+
}
|
|
15002
|
+
const addOnCost = addOns.reduce((sum, addOn) => {
|
|
15003
|
+
if (addOn.isSelected) {
|
|
15004
|
+
sum += getBillingPrice(
|
|
15005
|
+
planPeriod === "year" ? addOn.yearlyPrice : addOn.monthlyPrice
|
|
15006
|
+
)?.price ?? 0;
|
|
15007
|
+
}
|
|
15008
|
+
return sum;
|
|
15009
|
+
}, 0);
|
|
14985
15010
|
total += addOnCost;
|
|
14986
15011
|
const payInAdvanceCost = payInAdvanceEntitlements.reduce(
|
|
14987
|
-
(sum,
|
|
15012
|
+
(sum, entitlement) => sum + entitlement.quantity * (getBillingPrice(
|
|
15013
|
+
planPeriod === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
|
|
15014
|
+
)?.price ?? 0),
|
|
14988
15015
|
0
|
|
14989
15016
|
);
|
|
14990
15017
|
total += payInAdvanceCost;
|
|
@@ -15008,7 +15035,7 @@ var Sidebar = ({
|
|
|
15008
15035
|
window.dispatchEvent(event);
|
|
15009
15036
|
};
|
|
15010
15037
|
const checkout = (0, import_react23.useCallback)(async () => {
|
|
15011
|
-
const priceId = (planPeriod === "
|
|
15038
|
+
const priceId = (planPeriod === "year" ? selectedPlan?.yearlyPrice : selectedPlan?.monthlyPrice)?.id;
|
|
15012
15039
|
if (!api || !selectedPlan || !priceId) {
|
|
15013
15040
|
return;
|
|
15014
15041
|
}
|
|
@@ -15021,7 +15048,7 @@ var Sidebar = ({
|
|
|
15021
15048
|
newPriceId: priceId,
|
|
15022
15049
|
addOnIds: addOns.reduce((acc, addOn) => {
|
|
15023
15050
|
if (addOn.isSelected && !selectedPlan.companyCanTrial) {
|
|
15024
|
-
const addOnPriceId = (planPeriod === "
|
|
15051
|
+
const addOnPriceId = (planPeriod === "year" ? addOn?.yearlyPrice : addOn?.monthlyPrice)?.id;
|
|
15025
15052
|
if (addOnPriceId) {
|
|
15026
15053
|
acc.push({
|
|
15027
15054
|
addOnId: addOn.id,
|
|
@@ -15032,8 +15059,8 @@ var Sidebar = ({
|
|
|
15032
15059
|
return acc;
|
|
15033
15060
|
}, []),
|
|
15034
15061
|
payInAdvance: payInAdvanceEntitlements.reduce(
|
|
15035
|
-
(acc, {
|
|
15036
|
-
const priceId2 = (planPeriod === "
|
|
15062
|
+
(acc, { meteredMonthlyPrice, meteredYearlyPrice, quantity }) => {
|
|
15063
|
+
const priceId2 = (planPeriod === "year" ? meteredYearlyPrice : meteredMonthlyPrice)?.priceId;
|
|
15037
15064
|
if (priceId2) {
|
|
15038
15065
|
acc.push({
|
|
15039
15066
|
priceId: priceId2,
|
|
@@ -15101,48 +15128,62 @@ var Sidebar = ({
|
|
|
15101
15128
|
({ quantity, usage }) => quantity >= usage
|
|
15102
15129
|
)) && !isLoading;
|
|
15103
15130
|
const canCheckout = canUpdateSubscription && (!!data.subscription?.paymentMethod || typeof paymentMethodId === "string");
|
|
15104
|
-
const
|
|
15105
|
-
|
|
15106
|
-
|
|
15107
|
-
|
|
15108
|
-
|
|
15109
|
-
|
|
15110
|
-
|
|
15111
|
-
|
|
15112
|
-
|
|
15113
|
-
|
|
15114
|
-
|
|
15115
|
-
|
|
15116
|
-
|
|
15117
|
-
|
|
15118
|
-
|
|
15119
|
-
|
|
15120
|
-
|
|
15121
|
-
|
|
15122
|
-
|
|
15123
|
-
|
|
15124
|
-
|
|
15125
|
-
|
|
15126
|
-
|
|
15127
|
-
|
|
15128
|
-
|
|
15129
|
-
|
|
15130
|
-
|
|
15131
|
-
|
|
15132
|
-
|
|
15133
|
-
|
|
15134
|
-
|
|
15135
|
-
|
|
15136
|
-
|
|
15137
|
-
|
|
15138
|
-
|
|
15139
|
-
|
|
15140
|
-
|
|
15141
|
-
|
|
15142
|
-
|
|
15143
|
-
|
|
15144
|
-
|
|
15145
|
-
|
|
15131
|
+
const {
|
|
15132
|
+
changedUsageBasedEntitlements,
|
|
15133
|
+
addedUsageBasedEntitlements,
|
|
15134
|
+
removedUsageBasedEntitlements,
|
|
15135
|
+
willUsageBasedEntitlementsChange
|
|
15136
|
+
} = (0, import_react23.useMemo)(() => {
|
|
15137
|
+
const changedUsageBasedEntitlements2 = [];
|
|
15138
|
+
const addedUsageBasedEntitlements2 = selectedPlan ? usageBasedEntitlements.reduce(
|
|
15139
|
+
(acc, selected) => {
|
|
15140
|
+
const changed = currentUsageBasedEntitlements.find(
|
|
15141
|
+
(current) => current.entitlementId === selected.id && current.quantity !== selected.quantity
|
|
15142
|
+
);
|
|
15143
|
+
if (changed) {
|
|
15144
|
+
changedUsageBasedEntitlements2.push({
|
|
15145
|
+
previous: changed,
|
|
15146
|
+
next: selected
|
|
15147
|
+
});
|
|
15148
|
+
} else {
|
|
15149
|
+
acc.push(selected);
|
|
15150
|
+
}
|
|
15151
|
+
return acc;
|
|
15152
|
+
},
|
|
15153
|
+
[]
|
|
15154
|
+
) : [];
|
|
15155
|
+
const removedUsageBasedEntitlements2 = selectedPlan ? currentUsageBasedEntitlements.reduce(
|
|
15156
|
+
(acc, current) => {
|
|
15157
|
+
const match2 = usageBasedEntitlements.every(
|
|
15158
|
+
(entitlement) => entitlement.id !== current.entitlementId
|
|
15159
|
+
) && data.featureUsage?.features.find(
|
|
15160
|
+
(usage) => usage.entitlementId === current.entitlementId
|
|
15161
|
+
);
|
|
15162
|
+
if (match2) {
|
|
15163
|
+
acc.push({
|
|
15164
|
+
...match2,
|
|
15165
|
+
allocation: current.allocation,
|
|
15166
|
+
usage: current.usage,
|
|
15167
|
+
quantity: current.quantity
|
|
15168
|
+
});
|
|
15169
|
+
}
|
|
15170
|
+
return acc;
|
|
15171
|
+
},
|
|
15172
|
+
[]
|
|
15173
|
+
) : [];
|
|
15174
|
+
const willUsageBasedEntitlementsChange2 = changedUsageBasedEntitlements2.length > 0 || addedUsageBasedEntitlements2.length > 0 || removedUsageBasedEntitlements2.length > 0;
|
|
15175
|
+
return {
|
|
15176
|
+
changedUsageBasedEntitlements: changedUsageBasedEntitlements2,
|
|
15177
|
+
addedUsageBasedEntitlements: addedUsageBasedEntitlements2,
|
|
15178
|
+
removedUsageBasedEntitlements: removedUsageBasedEntitlements2,
|
|
15179
|
+
willUsageBasedEntitlementsChange: willUsageBasedEntitlementsChange2
|
|
15180
|
+
};
|
|
15181
|
+
}, [
|
|
15182
|
+
selectedPlan,
|
|
15183
|
+
data.featureUsage?.features,
|
|
15184
|
+
currentUsageBasedEntitlements,
|
|
15185
|
+
usageBasedEntitlements
|
|
15186
|
+
]);
|
|
15146
15187
|
const removedAddOns = currentAddOns.filter(
|
|
15147
15188
|
(current) => !selectedAddOns.some((selected) => current.id === selected.id)
|
|
15148
15189
|
);
|
|
@@ -15156,6 +15197,9 @@ var Sidebar = ({
|
|
|
15156
15197
|
if (isTrialable && selectedPlan.trialDays) {
|
|
15157
15198
|
trialEndsOn.setDate(trialEndsOn.getDate() + selectedPlan.trialDays);
|
|
15158
15199
|
}
|
|
15200
|
+
const selectedPlanBillingPrice = getBillingPrice(
|
|
15201
|
+
planPeriod === "year" ? selectedPlan?.yearlyPrice : selectedPlan?.monthlyPrice
|
|
15202
|
+
);
|
|
15159
15203
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
15160
15204
|
Flex,
|
|
15161
15205
|
{
|
|
@@ -15316,8 +15360,8 @@ var Sidebar = ({
|
|
|
15316
15360
|
$color: theme.typography.text.color,
|
|
15317
15361
|
children: [
|
|
15318
15362
|
formatCurrency(
|
|
15319
|
-
|
|
15320
|
-
|
|
15363
|
+
selectedPlanBillingPrice?.price ?? 0,
|
|
15364
|
+
selectedPlanBillingPrice?.currency
|
|
15321
15365
|
),
|
|
15322
15366
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
|
|
15323
15367
|
"/",
|
|
@@ -15343,9 +15387,14 @@ var Sidebar = ({
|
|
|
15343
15387
|
}
|
|
15344
15388
|
) }),
|
|
15345
15389
|
removedUsageBasedEntitlements.reduce(
|
|
15346
|
-
(acc,
|
|
15347
|
-
if (typeof allocation === "number" &&
|
|
15348
|
-
const
|
|
15390
|
+
(acc, entitlement, index) => {
|
|
15391
|
+
if (typeof entitlement.allocation === "number" && entitlement.feature?.name) {
|
|
15392
|
+
const {
|
|
15393
|
+
price: entitlementPrice,
|
|
15394
|
+
currency: entitlementCurrency
|
|
15395
|
+
} = getBillingPrice(
|
|
15396
|
+
planPeriod === "year" ? entitlement.yearlyUsageBasedPrice : entitlement.monthlyUsageBasedPrice
|
|
15397
|
+
) || {};
|
|
15349
15398
|
acc.push(
|
|
15350
15399
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
15351
15400
|
Flex,
|
|
@@ -15364,11 +15413,14 @@ var Sidebar = ({
|
|
|
15364
15413
|
$size: theme.typography.heading4.fontSize,
|
|
15365
15414
|
$weight: theme.typography.heading4.fontWeight,
|
|
15366
15415
|
$color: theme.typography.heading4.color,
|
|
15367
|
-
children:
|
|
15368
|
-
quantity,
|
|
15416
|
+
children: entitlement.priceBehavior === "pay_in_advance" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
15417
|
+
entitlement.quantity,
|
|
15369
15418
|
" ",
|
|
15370
|
-
getFeatureName(
|
|
15371
|
-
|
|
15419
|
+
getFeatureName(
|
|
15420
|
+
entitlement.feature,
|
|
15421
|
+
entitlement.quantity
|
|
15422
|
+
)
|
|
15423
|
+
] }) : entitlement.feature.name
|
|
15372
15424
|
}
|
|
15373
15425
|
) }),
|
|
15374
15426
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
@@ -15379,24 +15431,24 @@ var Sidebar = ({
|
|
|
15379
15431
|
$weight: theme.typography.text.fontWeight,
|
|
15380
15432
|
$color: theme.typography.text.color,
|
|
15381
15433
|
children: [
|
|
15382
|
-
|
|
15434
|
+
entitlement.priceBehavior === "pay_in_advance" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
15383
15435
|
formatCurrency(
|
|
15384
|
-
|
|
15385
|
-
|
|
15436
|
+
(entitlementPrice ?? 0) * entitlement.quantity,
|
|
15437
|
+
entitlementCurrency
|
|
15386
15438
|
),
|
|
15387
15439
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
|
|
15388
15440
|
"/",
|
|
15389
15441
|
shortenPeriod(planPeriod)
|
|
15390
15442
|
] })
|
|
15391
15443
|
] }),
|
|
15392
|
-
|
|
15444
|
+
entitlement.priceBehavior === "pay_as_you_go" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
15393
15445
|
formatCurrency(
|
|
15394
|
-
|
|
15395
|
-
|
|
15446
|
+
entitlementPrice ?? 0,
|
|
15447
|
+
entitlementCurrency
|
|
15396
15448
|
),
|
|
15397
15449
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
|
|
15398
15450
|
"/",
|
|
15399
|
-
getFeatureName(
|
|
15451
|
+
getFeatureName(entitlement.feature, 1)
|
|
15400
15452
|
] })
|
|
15401
15453
|
] })
|
|
15402
15454
|
]
|
|
@@ -15413,8 +15465,14 @@ var Sidebar = ({
|
|
|
15413
15465
|
[]
|
|
15414
15466
|
),
|
|
15415
15467
|
changedUsageBasedEntitlements.reduce(
|
|
15416
|
-
(acc, {
|
|
15417
|
-
if (
|
|
15468
|
+
(acc, { previous, next: next2 }, index) => {
|
|
15469
|
+
if (next2.feature?.name) {
|
|
15470
|
+
const {
|
|
15471
|
+
price: entitlementPrice,
|
|
15472
|
+
currency: entitlementCurrency
|
|
15473
|
+
} = getBillingPrice(
|
|
15474
|
+
planPeriod === "year" ? next2.meteredYearlyPrice : next2.meteredMonthlyPrice
|
|
15475
|
+
) || {};
|
|
15418
15476
|
acc.push(
|
|
15419
15477
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Box, { children: [
|
|
15420
15478
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
@@ -15437,7 +15495,7 @@ var Sidebar = ({
|
|
|
15437
15495
|
children: [
|
|
15438
15496
|
previous.quantity,
|
|
15439
15497
|
" ",
|
|
15440
|
-
getFeatureName(
|
|
15498
|
+
getFeatureName(next2.feature)
|
|
15441
15499
|
]
|
|
15442
15500
|
}
|
|
15443
15501
|
) }),
|
|
@@ -15450,8 +15508,8 @@ var Sidebar = ({
|
|
|
15450
15508
|
$color: theme.typography.text.color,
|
|
15451
15509
|
children: [
|
|
15452
15510
|
formatCurrency(
|
|
15453
|
-
(
|
|
15454
|
-
|
|
15511
|
+
(entitlementPrice ?? 0) * previous.quantity,
|
|
15512
|
+
entitlementCurrency
|
|
15455
15513
|
),
|
|
15456
15514
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
|
|
15457
15515
|
"/",
|
|
@@ -15480,7 +15538,7 @@ var Sidebar = ({
|
|
|
15480
15538
|
children: [
|
|
15481
15539
|
next2.quantity,
|
|
15482
15540
|
" ",
|
|
15483
|
-
getFeatureName(
|
|
15541
|
+
getFeatureName(next2.feature)
|
|
15484
15542
|
]
|
|
15485
15543
|
}
|
|
15486
15544
|
) }),
|
|
@@ -15493,8 +15551,8 @@ var Sidebar = ({
|
|
|
15493
15551
|
$color: theme.typography.text.color,
|
|
15494
15552
|
children: [
|
|
15495
15553
|
formatCurrency(
|
|
15496
|
-
(
|
|
15497
|
-
|
|
15554
|
+
(entitlementPrice ?? 0) * next2.quantity,
|
|
15555
|
+
entitlementCurrency
|
|
15498
15556
|
),
|
|
15499
15557
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
|
|
15500
15558
|
"/",
|
|
@@ -15514,9 +15572,14 @@ var Sidebar = ({
|
|
|
15514
15572
|
[]
|
|
15515
15573
|
),
|
|
15516
15574
|
addedUsageBasedEntitlements.reduce(
|
|
15517
|
-
(acc,
|
|
15575
|
+
(acc, entitlement, index) => {
|
|
15518
15576
|
if (entitlement.feature?.name) {
|
|
15519
|
-
const
|
|
15577
|
+
const {
|
|
15578
|
+
price: entitlementPrice,
|
|
15579
|
+
currency: entitlementCurrency
|
|
15580
|
+
} = getBillingPrice(
|
|
15581
|
+
planPeriod === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
|
|
15582
|
+
) || {};
|
|
15520
15583
|
acc.push(
|
|
15521
15584
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
15522
15585
|
Flex,
|
|
@@ -15533,9 +15596,12 @@ var Sidebar = ({
|
|
|
15533
15596
|
$weight: theme.typography.heading4.fontWeight,
|
|
15534
15597
|
$color: theme.typography.heading4.color,
|
|
15535
15598
|
children: entitlement.priceBehavior === "pay_in_advance" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
15536
|
-
quantity,
|
|
15599
|
+
entitlement.quantity,
|
|
15537
15600
|
" ",
|
|
15538
|
-
getFeatureName(
|
|
15601
|
+
getFeatureName(
|
|
15602
|
+
entitlement.feature,
|
|
15603
|
+
entitlement.quantity
|
|
15604
|
+
)
|
|
15539
15605
|
] }) : entitlement.feature.name
|
|
15540
15606
|
}
|
|
15541
15607
|
) }),
|
|
@@ -15547,20 +15613,20 @@ var Sidebar = ({
|
|
|
15547
15613
|
$weight: theme.typography.text.fontWeight,
|
|
15548
15614
|
$color: theme.typography.text.color,
|
|
15549
15615
|
children: [
|
|
15550
|
-
entitlement.priceBehavior === "pay_in_advance" &&
|
|
15616
|
+
entitlement.priceBehavior === "pay_in_advance" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
15551
15617
|
formatCurrency(
|
|
15552
|
-
|
|
15553
|
-
|
|
15618
|
+
(entitlementPrice ?? 0) * entitlement.quantity,
|
|
15619
|
+
entitlementCurrency
|
|
15554
15620
|
),
|
|
15555
15621
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
|
|
15556
15622
|
"/",
|
|
15557
15623
|
shortenPeriod(planPeriod)
|
|
15558
15624
|
] })
|
|
15559
15625
|
] }),
|
|
15560
|
-
entitlement.priceBehavior === "pay_as_you_go" &&
|
|
15626
|
+
entitlement.priceBehavior === "pay_as_you_go" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
15561
15627
|
formatCurrency(
|
|
15562
|
-
|
|
15563
|
-
|
|
15628
|
+
entitlementPrice ?? 0,
|
|
15629
|
+
entitlementCurrency
|
|
15564
15630
|
),
|
|
15565
15631
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
|
|
15566
15632
|
"/",
|
|
@@ -15619,8 +15685,8 @@ var Sidebar = ({
|
|
|
15619
15685
|
children: [
|
|
15620
15686
|
"-",
|
|
15621
15687
|
formatCurrency(
|
|
15622
|
-
|
|
15623
|
-
|
|
15688
|
+
selectedPlanBillingPrice?.price ?? 0,
|
|
15689
|
+
selectedPlanBillingPrice?.currency
|
|
15624
15690
|
),
|
|
15625
15691
|
"/",
|
|
15626
15692
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("sub", { children: shortenPeriod(planPeriod) })
|
|
@@ -15642,89 +15708,93 @@ var Sidebar = ({
|
|
|
15642
15708
|
children: t2("Add-ons")
|
|
15643
15709
|
}
|
|
15644
15710
|
) }),
|
|
15645
|
-
removedAddOns.map((addOn, index) =>
|
|
15646
|
-
|
|
15647
|
-
|
|
15648
|
-
|
|
15649
|
-
|
|
15650
|
-
|
|
15651
|
-
|
|
15652
|
-
|
|
15653
|
-
|
|
15654
|
-
|
|
15655
|
-
|
|
15656
|
-
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
|
|
15660
|
-
|
|
15661
|
-
|
|
15662
|
-
|
|
15663
|
-
|
|
15664
|
-
|
|
15665
|
-
|
|
15666
|
-
|
|
15667
|
-
|
|
15668
|
-
|
|
15669
|
-
|
|
15670
|
-
|
|
15671
|
-
|
|
15672
|
-
|
|
15673
|
-
|
|
15674
|
-
|
|
15675
|
-
|
|
15676
|
-
|
|
15677
|
-
|
|
15678
|
-
"
|
|
15679
|
-
|
|
15680
|
-
|
|
15681
|
-
|
|
15682
|
-
|
|
15683
|
-
|
|
15684
|
-
|
|
15685
|
-
|
|
15686
|
-
|
|
15687
|
-
|
|
15688
|
-
|
|
15689
|
-
|
|
15690
|
-
|
|
15691
|
-
|
|
15692
|
-
|
|
15693
|
-
|
|
15694
|
-
|
|
15695
|
-
|
|
15696
|
-
|
|
15697
|
-
|
|
15698
|
-
|
|
15699
|
-
|
|
15700
|
-
|
|
15701
|
-
|
|
15702
|
-
|
|
15703
|
-
|
|
15704
|
-
|
|
15705
|
-
|
|
15706
|
-
|
|
15707
|
-
|
|
15708
|
-
|
|
15709
|
-
|
|
15710
|
-
|
|
15711
|
-
|
|
15712
|
-
|
|
15713
|
-
|
|
15714
|
-
|
|
15715
|
-
|
|
15716
|
-
|
|
15717
|
-
|
|
15718
|
-
|
|
15719
|
-
|
|
15720
|
-
|
|
15721
|
-
|
|
15722
|
-
|
|
15723
|
-
|
|
15724
|
-
|
|
15725
|
-
|
|
15726
|
-
|
|
15727
|
-
|
|
15711
|
+
removedAddOns.map((addOn, index) => {
|
|
15712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
15713
|
+
Flex,
|
|
15714
|
+
{
|
|
15715
|
+
$justifyContent: "space-between",
|
|
15716
|
+
$alignItems: "center",
|
|
15717
|
+
$gap: "1rem",
|
|
15718
|
+
$opacity: "0.625",
|
|
15719
|
+
$textDecoration: "line-through",
|
|
15720
|
+
$color: theme.typography.heading4.color,
|
|
15721
|
+
children: [
|
|
15722
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
15723
|
+
Text,
|
|
15724
|
+
{
|
|
15725
|
+
$font: theme.typography.heading4.fontFamily,
|
|
15726
|
+
$size: theme.typography.heading4.fontSize,
|
|
15727
|
+
$weight: theme.typography.heading4.fontWeight,
|
|
15728
|
+
$color: theme.typography.heading4.color,
|
|
15729
|
+
children: addOn.name
|
|
15730
|
+
}
|
|
15731
|
+
) }),
|
|
15732
|
+
typeof addOn.planPrice === "number" && addOn.planPeriod && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
15733
|
+
Text,
|
|
15734
|
+
{
|
|
15735
|
+
$font: theme.typography.text.fontFamily,
|
|
15736
|
+
$size: theme.typography.text.fontSize,
|
|
15737
|
+
$weight: theme.typography.text.fontWeight,
|
|
15738
|
+
$color: theme.typography.text.color,
|
|
15739
|
+
children: [
|
|
15740
|
+
formatCurrency(
|
|
15741
|
+
addOn.planPrice,
|
|
15742
|
+
selectedPlanBillingPrice?.currency
|
|
15743
|
+
),
|
|
15744
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
|
|
15745
|
+
"/",
|
|
15746
|
+
shortenPeriod(addOn.planPeriod)
|
|
15747
|
+
] })
|
|
15748
|
+
]
|
|
15749
|
+
}
|
|
15750
|
+
) })
|
|
15751
|
+
]
|
|
15752
|
+
},
|
|
15753
|
+
index
|
|
15754
|
+
);
|
|
15755
|
+
}),
|
|
15756
|
+
selectedAddOns.map((addOn, index) => {
|
|
15757
|
+
const { price: addOnPrice, currency: addOnCurrency } = getBillingPrice(
|
|
15758
|
+
planPeriod === "year" ? addOn.yearlyPrice : addOn.monthlyPrice
|
|
15759
|
+
) || {};
|
|
15760
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
15761
|
+
Flex,
|
|
15762
|
+
{
|
|
15763
|
+
$justifyContent: "space-between",
|
|
15764
|
+
$alignItems: "center",
|
|
15765
|
+
$gap: "1rem",
|
|
15766
|
+
children: [
|
|
15767
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Box, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
15768
|
+
Text,
|
|
15769
|
+
{
|
|
15770
|
+
$font: theme.typography.heading4.fontFamily,
|
|
15771
|
+
$size: theme.typography.heading4.fontSize,
|
|
15772
|
+
$weight: theme.typography.heading4.fontWeight,
|
|
15773
|
+
$color: theme.typography.heading4.color,
|
|
15774
|
+
children: addOn.name
|
|
15775
|
+
}
|
|
15776
|
+
) }),
|
|
15777
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Box, { $whiteSpace: "nowrap", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
15778
|
+
Text,
|
|
15779
|
+
{
|
|
15780
|
+
$font: theme.typography.text.fontFamily,
|
|
15781
|
+
$size: theme.typography.text.fontSize,
|
|
15782
|
+
$weight: theme.typography.text.fontWeight,
|
|
15783
|
+
$color: theme.typography.text.color,
|
|
15784
|
+
children: [
|
|
15785
|
+
formatCurrency(addOnPrice ?? 0, addOnCurrency),
|
|
15786
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("sub", { children: [
|
|
15787
|
+
"/",
|
|
15788
|
+
shortenPeriod(planPeriod)
|
|
15789
|
+
] })
|
|
15790
|
+
]
|
|
15791
|
+
}
|
|
15792
|
+
) })
|
|
15793
|
+
]
|
|
15794
|
+
},
|
|
15795
|
+
index
|
|
15796
|
+
);
|
|
15797
|
+
})
|
|
15728
15798
|
] }),
|
|
15729
15799
|
proration !== 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
15730
15800
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Box, { $opacity: "0.625", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
@@ -15763,7 +15833,7 @@ var Sidebar = ({
|
|
|
15763
15833
|
$color: theme.typography.text.color,
|
|
15764
15834
|
children: formatCurrency(
|
|
15765
15835
|
proration,
|
|
15766
|
-
|
|
15836
|
+
selectedPlanBillingPrice?.currency
|
|
15767
15837
|
)
|
|
15768
15838
|
}
|
|
15769
15839
|
) })
|
|
@@ -15870,7 +15940,7 @@ var Sidebar = ({
|
|
|
15870
15940
|
$color: theme.typography.text.color,
|
|
15871
15941
|
children: formatCurrency(
|
|
15872
15942
|
newCharges / 100 * percentOff,
|
|
15873
|
-
|
|
15943
|
+
selectedPlanBillingPrice?.currency
|
|
15874
15944
|
)
|
|
15875
15945
|
}
|
|
15876
15946
|
) })
|
|
@@ -15894,7 +15964,7 @@ var Sidebar = ({
|
|
|
15894
15964
|
children: t2("X off", {
|
|
15895
15965
|
amount: formatCurrency(
|
|
15896
15966
|
Math.abs(amountOff),
|
|
15897
|
-
|
|
15967
|
+
selectedPlanBillingPrice?.currency
|
|
15898
15968
|
)
|
|
15899
15969
|
})
|
|
15900
15970
|
}
|
|
@@ -15910,7 +15980,7 @@ var Sidebar = ({
|
|
|
15910
15980
|
"-",
|
|
15911
15981
|
formatCurrency(
|
|
15912
15982
|
Math.abs(amountOff),
|
|
15913
|
-
|
|
15983
|
+
selectedPlanBillingPrice?.currency
|
|
15914
15984
|
)
|
|
15915
15985
|
]
|
|
15916
15986
|
}
|
|
@@ -15933,7 +16003,7 @@ var Sidebar = ({
|
|
|
15933
16003
|
$weight: theme.typography.text.fontWeight,
|
|
15934
16004
|
$color: theme.typography.text.color,
|
|
15935
16005
|
children: [
|
|
15936
|
-
planPeriod === "
|
|
16006
|
+
planPeriod === "year" ? "Yearly" : "Monthly",
|
|
15937
16007
|
" total:"
|
|
15938
16008
|
]
|
|
15939
16009
|
}
|
|
@@ -15986,7 +16056,7 @@ var Sidebar = ({
|
|
|
15986
16056
|
$color: theme.typography.text.color,
|
|
15987
16057
|
children: formatCurrency(
|
|
15988
16058
|
Math.max(0, dueNow),
|
|
15989
|
-
|
|
16059
|
+
selectedPlanBillingPrice?.currency
|
|
15990
16060
|
)
|
|
15991
16061
|
}
|
|
15992
16062
|
) })
|
|
@@ -16016,7 +16086,7 @@ var Sidebar = ({
|
|
|
16016
16086
|
$color: theme.typography.text.color,
|
|
16017
16087
|
children: formatCurrency(
|
|
16018
16088
|
Math.abs(dueNow),
|
|
16019
|
-
|
|
16089
|
+
selectedPlanBillingPrice?.currency
|
|
16020
16090
|
)
|
|
16021
16091
|
}
|
|
16022
16092
|
) })
|
|
@@ -16083,6 +16153,9 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
|
|
|
16083
16153
|
$gridTemplateColumns: "repeat(auto-fill, minmax(300px, 1fr))",
|
|
16084
16154
|
$gap: "1rem",
|
|
16085
16155
|
children: addOns.map((addOn, index) => {
|
|
16156
|
+
const { price, currency } = getBillingPrice(
|
|
16157
|
+
period === "year" ? addOn.yearlyPrice : addOn.monthlyPrice
|
|
16158
|
+
) || {};
|
|
16086
16159
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
16087
16160
|
Flex,
|
|
16088
16161
|
{
|
|
@@ -16126,10 +16199,7 @@ var AddOns = ({ addOns, toggle, isLoading, period }) => {
|
|
|
16126
16199
|
$size: theme.typography.heading2.fontSize,
|
|
16127
16200
|
$weight: theme.typography.heading2.fontWeight,
|
|
16128
16201
|
$color: theme.typography.heading2.color,
|
|
16129
|
-
children: formatCurrency(
|
|
16130
|
-
(period === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.price ?? 0,
|
|
16131
|
-
(period === "month" ? addOn.monthlyPrice : addOn.yearlyPrice)?.currency
|
|
16132
|
-
)
|
|
16202
|
+
children: formatCurrency(price ?? 0, currency)
|
|
16133
16203
|
}
|
|
16134
16204
|
),
|
|
16135
16205
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
@@ -16400,7 +16470,7 @@ var Checkout = ({
|
|
|
16400
16470
|
$alignItems: "center",
|
|
16401
16471
|
$flexGrow: 1,
|
|
16402
16472
|
$marginTop: "-3.5rem",
|
|
16403
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Loader, { $size: "3xl" })
|
|
16473
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Loader, { $color: theme.primary, $size: "3xl" })
|
|
16404
16474
|
}
|
|
16405
16475
|
);
|
|
16406
16476
|
}
|
|
@@ -16628,7 +16698,9 @@ var Plan = ({
|
|
|
16628
16698
|
children: plans.map((plan, planIndex) => {
|
|
16629
16699
|
const count = entitlementCounts[plan.id];
|
|
16630
16700
|
const isExpanded = count.limit > VISIBLE_ENTITLEMENT_COUNT;
|
|
16631
|
-
const { price: planPrice, currency: planCurrency } = (
|
|
16701
|
+
const { price: planPrice, currency: planCurrency } = getBillingPrice(
|
|
16702
|
+
period === "year" ? plan.yearlyPrice : plan.monthlyPrice
|
|
16703
|
+
) || {};
|
|
16632
16704
|
const hasUsageBasedEntitlements = plan.entitlements.some(
|
|
16633
16705
|
(entitlement) => !!entitlement.priceBehavior
|
|
16634
16706
|
);
|
|
@@ -16758,7 +16830,9 @@ var Plan = ({
|
|
|
16758
16830
|
const {
|
|
16759
16831
|
price: entitlementPrice,
|
|
16760
16832
|
currency: entitlementCurrency
|
|
16761
|
-
} = (
|
|
16833
|
+
} = getBillingPrice(
|
|
16834
|
+
period === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
|
|
16835
|
+
) || {};
|
|
16762
16836
|
if (entitlement.priceBehavior && typeof entitlementPrice !== "number") {
|
|
16763
16837
|
return acc;
|
|
16764
16838
|
}
|
|
@@ -17002,8 +17076,11 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
|
|
|
17002
17076
|
const unitPriceFontSize = 0.875 * theme.typography.text.fontSize;
|
|
17003
17077
|
const unitPriceColor = hexToHSL(theme.typography.text.color).l > 50 ? darken(theme.typography.text.color, 0.46) : lighten(theme.typography.text.color, 0.46);
|
|
17004
17078
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Flex, { $flexDirection: "column", $gap: "1rem", children: entitlements.reduce(
|
|
17005
|
-
(acc,
|
|
17079
|
+
(acc, entitlement, index) => {
|
|
17006
17080
|
if (entitlement.priceBehavior === "pay_in_advance" && entitlement.feature) {
|
|
17081
|
+
const { price, currency } = getBillingPrice(
|
|
17082
|
+
period === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
|
|
17083
|
+
) || {};
|
|
17007
17084
|
acc.push(
|
|
17008
17085
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
17009
17086
|
Flex,
|
|
@@ -17058,8 +17135,8 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
|
|
|
17058
17135
|
{
|
|
17059
17136
|
$size: "lg",
|
|
17060
17137
|
type: "number",
|
|
17061
|
-
value: quantity,
|
|
17062
|
-
min: usage,
|
|
17138
|
+
value: entitlement.quantity,
|
|
17139
|
+
min: entitlement.usage,
|
|
17063
17140
|
autoFocus: true,
|
|
17064
17141
|
onFocus: (event) => event.target.select(),
|
|
17065
17142
|
onChange: (event) => {
|
|
@@ -17079,12 +17156,12 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
|
|
|
17079
17156
|
$weight: theme.typography.text.fontWeight,
|
|
17080
17157
|
$color: unitPriceColor,
|
|
17081
17158
|
children: [
|
|
17082
|
-
quantity < usage && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { style: { color: "#DB6669" }, children: [
|
|
17159
|
+
entitlement.quantity < entitlement.usage && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { style: { color: "#DB6669" }, children: [
|
|
17083
17160
|
t2("Cannot downgrade entitlement"),
|
|
17084
17161
|
" "
|
|
17085
17162
|
] }),
|
|
17086
17163
|
t2("Currently using", {
|
|
17087
|
-
quantity: usage,
|
|
17164
|
+
quantity: entitlement.usage,
|
|
17088
17165
|
unit: getFeatureName(entitlement.feature)
|
|
17089
17166
|
})
|
|
17090
17167
|
]
|
|
@@ -17108,8 +17185,8 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
|
|
|
17108
17185
|
$color: theme.typography.text.color,
|
|
17109
17186
|
children: [
|
|
17110
17187
|
formatCurrency(
|
|
17111
|
-
(
|
|
17112
|
-
|
|
17188
|
+
(price ?? 0) * entitlement.quantity,
|
|
17189
|
+
currency
|
|
17113
17190
|
),
|
|
17114
17191
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("sub", { children: [
|
|
17115
17192
|
"/",
|
|
@@ -17126,10 +17203,7 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
|
|
|
17126
17203
|
$weight: theme.typography.text.fontWeight,
|
|
17127
17204
|
$color: unitPriceColor,
|
|
17128
17205
|
children: [
|
|
17129
|
-
formatCurrency(
|
|
17130
|
-
(period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.price || 0,
|
|
17131
|
-
(period === "month" ? entitlement.meteredMonthlyPrice : entitlement.meteredYearlyPrice)?.currency
|
|
17132
|
-
),
|
|
17206
|
+
formatCurrency(price ?? 0, currency),
|
|
17133
17207
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("sub", { children: [
|
|
17134
17208
|
"/",
|
|
17135
17209
|
getFeatureName(entitlement.feature, 1),
|
|
@@ -17156,6 +17230,22 @@ var Usage = ({ entitlements, updateQuantity, period }) => {
|
|
|
17156
17230
|
|
|
17157
17231
|
// src/components/shared/checkout-dialog/CheckoutDialog.tsx
|
|
17158
17232
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
17233
|
+
var createActiveUsageBasedEntitlementsReducer = (entitlements, period) => (acc, entitlement) => {
|
|
17234
|
+
if (entitlement.priceBehavior && (period === "month" && entitlement.meteredMonthlyPrice || period === "year" && entitlement.meteredYearlyPrice)) {
|
|
17235
|
+
const featureUsage = entitlements.find(
|
|
17236
|
+
(usage2) => usage2.feature?.id === entitlement.feature?.id
|
|
17237
|
+
);
|
|
17238
|
+
const allocation = featureUsage?.allocation || 0;
|
|
17239
|
+
const usage = featureUsage?.usage || 0;
|
|
17240
|
+
acc.push({
|
|
17241
|
+
...entitlement,
|
|
17242
|
+
allocation,
|
|
17243
|
+
usage,
|
|
17244
|
+
quantity: allocation
|
|
17245
|
+
});
|
|
17246
|
+
}
|
|
17247
|
+
return acc;
|
|
17248
|
+
};
|
|
17159
17249
|
var CheckoutDialog = ({ top = 0 }) => {
|
|
17160
17250
|
const { t: t2 } = useTranslation();
|
|
17161
17251
|
const theme = nt();
|
|
@@ -17189,34 +17279,21 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
17189
17279
|
)
|
|
17190
17280
|
}))
|
|
17191
17281
|
);
|
|
17192
|
-
const
|
|
17193
|
-
|
|
17194
|
-
|
|
17195
|
-
const featureUsage = data.featureUsage?.features.find(
|
|
17196
|
-
(usage2) => usage2.feature?.id === entitlement.feature?.id
|
|
17197
|
-
);
|
|
17198
|
-
const allocation = featureUsage?.allocation ?? 0;
|
|
17199
|
-
const usage = featureUsage?.usage ?? 0;
|
|
17200
|
-
acc.push({
|
|
17201
|
-
entitlement,
|
|
17202
|
-
allocation,
|
|
17203
|
-
quantity: allocation,
|
|
17204
|
-
usage
|
|
17205
|
-
});
|
|
17206
|
-
}
|
|
17207
|
-
return acc;
|
|
17208
|
-
},
|
|
17209
|
-
[planPeriod, data.featureUsage?.features]
|
|
17210
|
-
);
|
|
17282
|
+
const currentEntitlements = (0, import_react26.useMemo)(() => {
|
|
17283
|
+
return data.featureUsage?.features || [];
|
|
17284
|
+
}, [data.featureUsage?.features]);
|
|
17211
17285
|
const [usageBasedEntitlements, setUsageBasedEntitlements] = (0, import_react26.useState)(
|
|
17212
17286
|
() => (selectedPlan?.entitlements || []).reduce(
|
|
17213
|
-
createActiveUsageBasedEntitlementsReducer(
|
|
17287
|
+
createActiveUsageBasedEntitlementsReducer(
|
|
17288
|
+
currentEntitlements,
|
|
17289
|
+
planPeriod
|
|
17290
|
+
),
|
|
17214
17291
|
[]
|
|
17215
17292
|
)
|
|
17216
17293
|
);
|
|
17217
17294
|
const payInAdvanceEntitlements = (0, import_react26.useMemo)(
|
|
17218
17295
|
() => usageBasedEntitlements.filter(
|
|
17219
|
-
(
|
|
17296
|
+
(entitlement) => entitlement.priceBehavior === "pay_in_advance"
|
|
17220
17297
|
),
|
|
17221
17298
|
[usageBasedEntitlements]
|
|
17222
17299
|
);
|
|
@@ -17280,7 +17357,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
17280
17357
|
async (updates) => {
|
|
17281
17358
|
const period = updates.period || planPeriod;
|
|
17282
17359
|
const plan = updates.plan || selectedPlan;
|
|
17283
|
-
const planPriceId = period === "
|
|
17360
|
+
const planPriceId = period === "year" ? plan?.yearlyPrice?.id : plan?.monthlyPrice?.id;
|
|
17284
17361
|
if (!api || !plan || !planPriceId) {
|
|
17285
17362
|
return;
|
|
17286
17363
|
}
|
|
@@ -17295,7 +17372,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
17295
17372
|
addOnIds: (updates.addOns || addOns).reduce(
|
|
17296
17373
|
(acc, addOn) => {
|
|
17297
17374
|
if (addOn.isSelected) {
|
|
17298
|
-
const addOnPriceId = (period === "
|
|
17375
|
+
const addOnPriceId = (period === "year" ? addOn?.yearlyPrice : addOn?.monthlyPrice)?.id;
|
|
17299
17376
|
if (addOnPriceId) {
|
|
17300
17377
|
acc.push({
|
|
17301
17378
|
addOnId: addOn.id,
|
|
@@ -17308,8 +17385,8 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
17308
17385
|
[]
|
|
17309
17386
|
),
|
|
17310
17387
|
payInAdvance: (updates.payInAdvanceEntitlements || payInAdvanceEntitlements).reduce(
|
|
17311
|
-
(acc, {
|
|
17312
|
-
const priceId = (period === "
|
|
17388
|
+
(acc, { meteredMonthlyPrice, meteredYearlyPrice, quantity }) => {
|
|
17389
|
+
const priceId = (period === "year" ? meteredYearlyPrice : meteredMonthlyPrice)?.priceId;
|
|
17313
17390
|
if (priceId) {
|
|
17314
17391
|
acc.push({
|
|
17315
17392
|
priceId,
|
|
@@ -17358,7 +17435,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
17358
17435
|
}
|
|
17359
17436
|
const period = updates.period || planPeriod;
|
|
17360
17437
|
const entitlements = plan.entitlements.reduce(
|
|
17361
|
-
createActiveUsageBasedEntitlementsReducer(period),
|
|
17438
|
+
createActiveUsageBasedEntitlementsReducer(currentEntitlements, period),
|
|
17362
17439
|
[]
|
|
17363
17440
|
);
|
|
17364
17441
|
if (updates.plan) {
|
|
@@ -17369,16 +17446,11 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
17369
17446
|
period,
|
|
17370
17447
|
plan: updates.plan,
|
|
17371
17448
|
payInAdvanceEntitlements: entitlements.filter(
|
|
17372
|
-
({
|
|
17449
|
+
({ priceBehavior }) => priceBehavior === "pay_in_advance"
|
|
17373
17450
|
)
|
|
17374
17451
|
});
|
|
17375
17452
|
},
|
|
17376
|
-
[
|
|
17377
|
-
planPeriod,
|
|
17378
|
-
selectedPlan,
|
|
17379
|
-
createActiveUsageBasedEntitlementsReducer,
|
|
17380
|
-
previewCheckout
|
|
17381
|
-
]
|
|
17453
|
+
[planPeriod, selectedPlan, currentEntitlements, previewCheckout]
|
|
17382
17454
|
);
|
|
17383
17455
|
const changePlanPeriod = (0, import_react26.useCallback)(
|
|
17384
17456
|
(period) => {
|
|
@@ -17401,16 +17473,14 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
17401
17473
|
(id, updatedQuantity) => {
|
|
17402
17474
|
setUsageBasedEntitlements((prev2) => {
|
|
17403
17475
|
const updated = prev2.map(
|
|
17404
|
-
(
|
|
17405
|
-
entitlement,
|
|
17406
|
-
|
|
17407
|
-
|
|
17408
|
-
usage
|
|
17409
|
-
} : { entitlement, allocation, quantity, usage }
|
|
17476
|
+
(entitlement) => entitlement.id === id ? {
|
|
17477
|
+
...entitlement,
|
|
17478
|
+
quantity: updatedQuantity
|
|
17479
|
+
} : entitlement
|
|
17410
17480
|
);
|
|
17411
17481
|
previewCheckout({
|
|
17412
17482
|
payInAdvanceEntitlements: updated.filter(
|
|
17413
|
-
({
|
|
17483
|
+
({ priceBehavior }) => priceBehavior === "pay_in_advance"
|
|
17414
17484
|
)
|
|
17415
17485
|
});
|
|
17416
17486
|
return updated;
|
|
@@ -17539,7 +17609,7 @@ var CheckoutDialog = ({ top = 0 }) => {
|
|
|
17539
17609
|
$size: theme.typography.heading3.fontSize,
|
|
17540
17610
|
$weight: theme.typography.heading3.fontWeight,
|
|
17541
17611
|
$color: theme.typography.heading3.color,
|
|
17542
|
-
|
|
17612
|
+
style: { marginBottom: "0.5rem" },
|
|
17543
17613
|
children: activeCheckoutStage.label
|
|
17544
17614
|
}
|
|
17545
17615
|
),
|
|
@@ -17760,8 +17830,10 @@ var PeriodToggle = ({
|
|
|
17760
17830
|
const [tooltipZIndex, setTooltipZIndex] = (0, import_react28.useState)(1);
|
|
17761
17831
|
const savingsPercentage = (0, import_react28.useMemo)(() => {
|
|
17762
17832
|
if (selectedPlan) {
|
|
17763
|
-
const
|
|
17764
|
-
const
|
|
17833
|
+
const monthlyBillingPrice = getBillingPrice(selectedPlan?.monthlyPrice);
|
|
17834
|
+
const yearlyBillingPrice = getBillingPrice(selectedPlan?.yearlyPrice);
|
|
17835
|
+
const monthly = (monthlyBillingPrice?.price ?? 0) * 12;
|
|
17836
|
+
const yearly = yearlyBillingPrice?.price ?? 0;
|
|
17765
17837
|
return Math.round((monthly - yearly) / monthly * 1e4) / 100;
|
|
17766
17838
|
}
|
|
17767
17839
|
return 0;
|
|
@@ -17812,11 +17884,11 @@ var PeriodToggle = ({
|
|
|
17812
17884
|
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
17813
17885
|
Text,
|
|
17814
17886
|
{
|
|
17815
|
-
$flexShrink: 0,
|
|
17816
17887
|
$font: theme.typography.text.fontFamily,
|
|
17817
17888
|
$size: 15,
|
|
17818
17889
|
$weight: option === selectedOption ? 600 : 400,
|
|
17819
17890
|
$color: theme.typography.text.color,
|
|
17891
|
+
style: { flexShrink: 0 },
|
|
17820
17892
|
children: t2("Billed", { period: adjectify(option) })
|
|
17821
17893
|
}
|
|
17822
17894
|
)
|
|
@@ -17876,23 +17948,9 @@ var UnsubscribeDialog = ({ top = 0 }) => {
|
|
|
17876
17948
|
),
|
|
17877
17949
|
[data.company?.plan, planPeriod, availablePlans]
|
|
17878
17950
|
);
|
|
17951
|
+
const currentEntitlements = data.featureUsage?.features || [];
|
|
17879
17952
|
const usageBasedEntitlements = (selectedPlan?.entitlements || []).reduce(
|
|
17880
|
-
(
|
|
17881
|
-
if (entitlement.priceBehavior && (planPeriod === "month" && entitlement.meteredMonthlyPrice || planPeriod === "year" && entitlement.meteredYearlyPrice)) {
|
|
17882
|
-
const featureUsage = data.featureUsage?.features.find(
|
|
17883
|
-
(usage2) => usage2.feature?.id === entitlement.feature?.id
|
|
17884
|
-
);
|
|
17885
|
-
const allocation = featureUsage?.allocation ?? 0;
|
|
17886
|
-
const usage = featureUsage?.usage ?? 0;
|
|
17887
|
-
acc.push({
|
|
17888
|
-
entitlement,
|
|
17889
|
-
allocation,
|
|
17890
|
-
quantity: allocation,
|
|
17891
|
-
usage
|
|
17892
|
-
});
|
|
17893
|
-
}
|
|
17894
|
-
return acc;
|
|
17895
|
-
},
|
|
17953
|
+
createActiveUsageBasedEntitlementsReducer(currentEntitlements, planPeriod),
|
|
17896
17954
|
[]
|
|
17897
17955
|
);
|
|
17898
17956
|
const addOns = (0, import_react29.useMemo)(
|
|
@@ -18215,21 +18273,18 @@ var RenderLayout = ({ children }) => {
|
|
|
18215
18273
|
};
|
|
18216
18274
|
|
|
18217
18275
|
// src/components/layout/viewport/styles.ts
|
|
18218
|
-
var StyledViewport = dt
|
|
18219
|
-
$gridTemplateColumns: "repeat(1, minmax(300px, 1fr))",
|
|
18220
|
-
$viewport: {
|
|
18221
|
-
md: {
|
|
18222
|
-
$gridTemplateColumns: `repeat(${theme.numberOfColumns}, minmax(300px, 1fr))`
|
|
18223
|
-
}
|
|
18224
|
-
}
|
|
18225
|
-
})).withConfig({
|
|
18276
|
+
var StyledViewport = dt.div.withConfig({
|
|
18226
18277
|
shouldForwardProp: (prop) => !["$numberOfColumns", "numberOfColumns"].includes(prop)
|
|
18227
18278
|
})`
|
|
18228
18279
|
display: grid;
|
|
18229
|
-
|
|
18280
|
+
grid-template-columns: repeat(1, minmax(300px, 1fr));
|
|
18230
18281
|
margin-left: auto;
|
|
18231
18282
|
margin-right: auto;
|
|
18232
18283
|
gap: 1rem;
|
|
18284
|
+
|
|
18285
|
+
@media (min-width: 768px) {
|
|
18286
|
+
grid-template-columns: ${({ theme }) => lt`repeat(${theme.numberOfColumns}, minmax(300px, 1fr))`};
|
|
18287
|
+
}
|
|
18233
18288
|
`;
|
|
18234
18289
|
|
|
18235
18290
|
// src/components/layout/viewport/Viewport.tsx
|
|
@@ -18290,25 +18345,11 @@ var Details = ({
|
|
|
18290
18345
|
const { t: t2 } = useTranslation();
|
|
18291
18346
|
const theme = nt();
|
|
18292
18347
|
const { data } = useEmbed();
|
|
18293
|
-
const currency = (0, import_react31.useMemo)(() => {
|
|
18294
|
-
|
|
18295
|
-
|
|
18296
|
-
}
|
|
18297
|
-
|
|
18298
|
-
return yearlyUsageBasedPrice?.currency;
|
|
18299
|
-
}
|
|
18300
|
-
}, [
|
|
18301
|
-
data.company?.plan?.planPeriod,
|
|
18302
|
-
monthlyUsageBasedPrice,
|
|
18303
|
-
yearlyUsageBasedPrice
|
|
18304
|
-
]);
|
|
18305
|
-
const price = (0, import_react31.useMemo)(() => {
|
|
18306
|
-
if (data.company?.plan?.planPeriod === "month") {
|
|
18307
|
-
return monthlyUsageBasedPrice?.price;
|
|
18308
|
-
}
|
|
18309
|
-
if (data.company?.plan?.planPeriod === "year") {
|
|
18310
|
-
return yearlyUsageBasedPrice?.price;
|
|
18311
|
-
}
|
|
18348
|
+
const { price, currency } = (0, import_react31.useMemo)(() => {
|
|
18349
|
+
const { price: entitlementPrice, currency: entitlementCurrency } = getBillingPrice(
|
|
18350
|
+
data.company?.plan?.planPeriod === "year" ? yearlyUsageBasedPrice : monthlyUsageBasedPrice
|
|
18351
|
+
) || {};
|
|
18352
|
+
return { price: entitlementPrice, currency: entitlementCurrency };
|
|
18312
18353
|
}, [
|
|
18313
18354
|
data.company?.plan?.planPeriod,
|
|
18314
18355
|
monthlyUsageBasedPrice,
|
|
@@ -18742,7 +18783,8 @@ Invoices.displayName = "Invoices";
|
|
|
18742
18783
|
var import_react34 = require("react");
|
|
18743
18784
|
|
|
18744
18785
|
// src/components/elements/metered-features/styles.ts
|
|
18745
|
-
var Container4 = dt
|
|
18786
|
+
var Container4 = dt.div`
|
|
18787
|
+
display: flex;
|
|
18746
18788
|
flex-direction: column;
|
|
18747
18789
|
gap: 1rem;
|
|
18748
18790
|
|
|
@@ -18850,7 +18892,9 @@ var MeteredFeatures = (0, import_react34.forwardRef)(({ className, ...rest }, re
|
|
|
18850
18892
|
}, index) => {
|
|
18851
18893
|
const limit = softLimit ?? allocation ?? 0;
|
|
18852
18894
|
const isOverage = priceBehavior === "overage" && typeof softLimit === "number" && typeof usage === "number" && usage > softLimit;
|
|
18853
|
-
const { price, currency } = (
|
|
18895
|
+
const { price, currency } = getBillingPrice(
|
|
18896
|
+
planPeriod === "year" ? yearlyUsageBasedPrice : monthlyUsageBasedPrice
|
|
18897
|
+
) || {};
|
|
18854
18898
|
const progressBar = props.isVisible && typeof usage === "number" && limit > 0 && priceBehavior !== "pay_as_you_go" && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
18855
18899
|
ProgressBar,
|
|
18856
18900
|
{
|
|
@@ -19549,7 +19593,7 @@ var PaymentMethodDetails = ({
|
|
|
19549
19593
|
$zIndex: 1,
|
|
19550
19594
|
$backgroundColor: "black",
|
|
19551
19595
|
$opacity: 0.5,
|
|
19552
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Loader, { $size: "2xl" })
|
|
19596
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Loader, { $color: theme.primary, $size: "2xl" })
|
|
19553
19597
|
}
|
|
19554
19598
|
),
|
|
19555
19599
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
@@ -19713,8 +19757,10 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
|
|
|
19713
19757
|
};
|
|
19714
19758
|
const usageBasedEntitlements = (featureUsage?.features || []).reduce(
|
|
19715
19759
|
(acc, usage) => {
|
|
19716
|
-
const { price, currency } = (
|
|
19717
|
-
|
|
19760
|
+
const { price, currency } = getBillingPrice(
|
|
19761
|
+
currentPlan?.planPeriod === "year" ? usage.yearlyUsageBasedPrice : usage.monthlyUsageBasedPrice
|
|
19762
|
+
) || {};
|
|
19763
|
+
if (usage.priceBehavior) {
|
|
19718
19764
|
acc.push({ ...usage, price, currency });
|
|
19719
19765
|
}
|
|
19720
19766
|
return acc;
|
|
@@ -19737,11 +19783,14 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
|
|
|
19737
19783
|
const headerPriceFontStyle = isUsageBasedPlan ? theme.typography.heading3 : theme.typography[props.header.price.fontStyle];
|
|
19738
19784
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
|
|
19739
19785
|
isTrialSubscription && !willSubscriptionCancel ? /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
19740
|
-
|
|
19786
|
+
Notice,
|
|
19741
19787
|
{
|
|
19742
|
-
|
|
19788
|
+
as: Flex,
|
|
19789
|
+
$flexDirection: "column",
|
|
19790
|
+
$gap: "0.5rem",
|
|
19791
|
+
$padding: "1.5rem",
|
|
19743
19792
|
$textAlign: "center",
|
|
19744
|
-
$
|
|
19793
|
+
$backgroundColor: isLightBackground ? darken(theme.card.background, 0.04) : lighten(theme.card.background, 0.04),
|
|
19745
19794
|
children: [
|
|
19746
19795
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
19747
19796
|
Text,
|
|
@@ -19772,11 +19821,14 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
|
|
|
19772
19821
|
]
|
|
19773
19822
|
}
|
|
19774
19823
|
) : willSubscriptionCancel && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
19775
|
-
|
|
19824
|
+
Notice,
|
|
19776
19825
|
{
|
|
19777
|
-
|
|
19826
|
+
as: Flex,
|
|
19827
|
+
$flexDirection: "column",
|
|
19828
|
+
$gap: "0.5rem",
|
|
19829
|
+
$padding: "1.5rem",
|
|
19778
19830
|
$textAlign: "center",
|
|
19779
|
-
$
|
|
19831
|
+
$backgroundColor: isLightBackground ? darken(theme.card.background, 0.04) : lighten(theme.card.background, 0.04),
|
|
19780
19832
|
children: [
|
|
19781
19833
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
19782
19834
|
Text,
|
|
@@ -19789,7 +19841,7 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
|
|
|
19789
19841
|
children: t2("Subscription canceled")
|
|
19790
19842
|
}
|
|
19791
19843
|
),
|
|
19792
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
19844
|
+
billingSubscription?.cancelAt && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
19793
19845
|
Text,
|
|
19794
19846
|
{
|
|
19795
19847
|
as: "p",
|
|
@@ -19797,14 +19849,14 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
|
|
|
19797
19849
|
$size: 0.8125 * theme.typography.text.fontSize,
|
|
19798
19850
|
$weight: theme.typography.text.fontWeight,
|
|
19799
19851
|
$color: theme.typography.text.color,
|
|
19800
|
-
children:
|
|
19852
|
+
children: t2("Access to plan will end on", {
|
|
19801
19853
|
date: toPrettyDate(
|
|
19802
19854
|
new Date(billingSubscription.cancelAt * 1e3),
|
|
19803
19855
|
{
|
|
19804
19856
|
month: "numeric"
|
|
19805
19857
|
}
|
|
19806
19858
|
)
|
|
19807
|
-
})
|
|
19859
|
+
})
|
|
19808
19860
|
}
|
|
19809
19861
|
)
|
|
19810
19862
|
]
|
|
@@ -19996,7 +20048,7 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
|
|
|
19996
20048
|
":",
|
|
19997
20049
|
" ",
|
|
19998
20050
|
formatCurrency(
|
|
19999
|
-
entitlement.price,
|
|
20051
|
+
entitlement.price ?? 0,
|
|
20000
20052
|
entitlement.currency
|
|
20001
20053
|
),
|
|
20002
20054
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("sub", { children: [
|
|
@@ -20018,7 +20070,7 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
|
|
|
20018
20070
|
$color: hexToHSL(theme.typography.text.color).l > 50 ? darken(theme.typography.text.color, 0.46) : lighten(theme.typography.text.color, 0.46),
|
|
20019
20071
|
children: [
|
|
20020
20072
|
formatCurrency(
|
|
20021
|
-
entitlement.price,
|
|
20073
|
+
entitlement.price ?? 0,
|
|
20022
20074
|
entitlement.currency
|
|
20023
20075
|
),
|
|
20024
20076
|
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("sub", { children: [
|
|
@@ -20039,7 +20091,7 @@ var PlanManager = (0, import_react38.forwardRef)(({ children, className, portal,
|
|
|
20039
20091
|
$color: theme.typography.text.color,
|
|
20040
20092
|
children: [
|
|
20041
20093
|
formatCurrency(
|
|
20042
|
-
entitlement.price * amount,
|
|
20094
|
+
(entitlement.price ?? 0) * amount,
|
|
20043
20095
|
entitlement.currency
|
|
20044
20096
|
),
|
|
20045
20097
|
(entitlement.priceBehavior === "pay_in_advance" || entitlement.priceBehavior !== "overage") && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("sub", { children: [
|
|
@@ -20219,7 +20271,9 @@ var PricingTable = (0, import_react39.forwardRef)(({ children, className, ...res
|
|
|
20219
20271
|
$gap: "1rem",
|
|
20220
20272
|
children: plans.map((plan, planIndex, self2) => {
|
|
20221
20273
|
const isActivePlan = plan.current && data.company?.plan?.planPeriod === selectedPeriod;
|
|
20222
|
-
const { price: planPrice, currency: planCurrency } = (
|
|
20274
|
+
const { price: planPrice, currency: planCurrency } = getBillingPrice(
|
|
20275
|
+
selectedPeriod === "year" ? plan.yearlyPrice : plan.monthlyPrice
|
|
20276
|
+
) || {};
|
|
20223
20277
|
const count = entitlementCounts[plan.id];
|
|
20224
20278
|
const isExpanded = count.limit > VISIBLE_ENTITLEMENT_COUNT;
|
|
20225
20279
|
const hasUsageBasedEntitlements = plan.entitlements.some(
|
|
@@ -20348,7 +20402,9 @@ var PricingTable = (0, import_react39.forwardRef)(({ children, className, ...res
|
|
|
20348
20402
|
const {
|
|
20349
20403
|
price: entitlementPrice,
|
|
20350
20404
|
currency: entitlementCurrency
|
|
20351
|
-
} = (
|
|
20405
|
+
} = getBillingPrice(
|
|
20406
|
+
selectedPeriod === "year" ? entitlement.meteredYearlyPrice : entitlement.meteredMonthlyPrice
|
|
20407
|
+
) || {};
|
|
20352
20408
|
if (entitlement.priceBehavior && typeof entitlementPrice !== "number") {
|
|
20353
20409
|
return acc;
|
|
20354
20410
|
}
|
|
@@ -20622,7 +20678,9 @@ var PricingTable = (0, import_react39.forwardRef)(({ children, className, ...res
|
|
|
20622
20678
|
$gap: "1rem",
|
|
20623
20679
|
children: addOns.map((addOn, addOnIndex) => {
|
|
20624
20680
|
const isActiveAddOn = addOn.current && selectedPeriod === data.company?.addOns.find((a2) => a2.id === addOn.id)?.planPeriod;
|
|
20625
|
-
const { price: addOnPrice, currency: addOnCurrency } = (
|
|
20681
|
+
const { price: addOnPrice, currency: addOnCurrency } = getBillingPrice(
|
|
20682
|
+
selectedPeriod === "year" ? addOn.yearlyPrice : addOn.monthlyPrice
|
|
20683
|
+
) || {};
|
|
20626
20684
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
20627
20685
|
Flex,
|
|
20628
20686
|
{
|
|
@@ -21098,7 +21156,7 @@ var Loading = () => {
|
|
|
21098
21156
|
$alignItems: "center",
|
|
21099
21157
|
$justifyContent: "center",
|
|
21100
21158
|
$padding: `${theme.card.padding / TEXT_BASE_SIZE}rem`,
|
|
21101
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Loader, { $
|
|
21159
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Loader, { $color: "#194BFB", $size: "2xl" })
|
|
21102
21160
|
}
|
|
21103
21161
|
);
|
|
21104
21162
|
};
|