@bunnyapp/components 1.0.42 → 1.0.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/README.md
CHANGED
|
@@ -30,6 +30,11 @@ Ensure all peer dependencies in the package.json are installed.
|
|
|
30
30
|
|
|
31
31
|
To run the development server, run `npm run dev`.
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
### Storybook stories
|
|
34
34
|
|
|
35
|
-
To view the storybook stories, run `
|
|
35
|
+
To view the storybook stories, run `npx storybook dev`.
|
|
36
|
+
|
|
37
|
+
#### Visual tests
|
|
38
|
+
|
|
39
|
+
Once storybook is running, visual tests can be run by clicking on the visual tests tab, and then clicking on the "Run Tests" button.
|
|
40
|
+
Refer to [these docs](https://storybook.js.org/docs/writing-tests/visual-testing#enable-visual-tests) for more information.
|
package/dist/cjs/index.js
CHANGED
|
@@ -19931,8 +19931,8 @@ function InitialSignupForm(_a) {
|
|
|
19931
19931
|
{ required: true, message: "Please input your email!" },
|
|
19932
19932
|
{ type: "email", message: "Please enter a valid email!" },
|
|
19933
19933
|
] }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "Email" }) })), jsxRuntime.jsx(antd.Form.Item, __assign({ name: "accountName", rules: [
|
|
19934
|
-
{ required: true, message: "Please input your
|
|
19935
|
-
] }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "
|
|
19934
|
+
{ required: true, message: "Please input your company name!" },
|
|
19935
|
+
] }, { children: jsxRuntime.jsx(antd.Input, { placeholder: "Company name" }) }))] })), jsxRuntime.jsx(antd.Form.Item, { children: jsxRuntime.jsx(antd.Button, __assign({ type: "primary", onClick: handleSubmit, loading: submitting, className: "w-full mt-4" }, { children: "Proceed to payment" })) })] })));
|
|
19936
19936
|
}
|
|
19937
19937
|
|
|
19938
19938
|
var Title = antd.Typography.Title, Text$4 = antd.Typography.Text;
|
|
@@ -20108,10 +20108,10 @@ var SUBSCRIPTIONS_QUERY = "\nquery subscriptions {\n subscriptions {\n n
|
|
|
20108
20108
|
var getSubscriptions = function (_a) {
|
|
20109
20109
|
var apiHost = _a.apiHost, entityId = _a.entityId, isInPreviewMode = _a.isInPreviewMode, token = _a.token;
|
|
20110
20110
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
20111
|
-
var response;
|
|
20112
|
-
var _b;
|
|
20113
|
-
return __generator(this, function (
|
|
20114
|
-
switch (
|
|
20111
|
+
var response, combinedSubscriptions;
|
|
20112
|
+
var _b, _c;
|
|
20113
|
+
return __generator(this, function (_d) {
|
|
20114
|
+
switch (_d.label) {
|
|
20115
20115
|
case 0: return [4 /*yield*/, common.gqlRequest({
|
|
20116
20116
|
isInPreviewMode: isInPreviewMode,
|
|
20117
20117
|
query: SUBSCRIPTIONS_QUERY,
|
|
@@ -20120,78 +20120,14 @@ var getSubscriptions = function (_a) {
|
|
|
20120
20120
|
apiHost: apiHost,
|
|
20121
20121
|
})];
|
|
20122
20122
|
case 1:
|
|
20123
|
-
response =
|
|
20124
|
-
|
|
20123
|
+
response = _d.sent();
|
|
20124
|
+
combinedSubscriptions = (_c = (_b = response === null || response === void 0 ? void 0 : response.subscriptions) === null || _b === void 0 ? void 0 : _b.nodes) === null || _c === void 0 ? void 0 : _c.map(function (subscription) { return (__assign(__assign({}, subscription), { charges: common.sortSubscriptionCharges(subscription.charges) })); });
|
|
20125
|
+
return [2 /*return*/, combinedSubscriptions];
|
|
20125
20126
|
}
|
|
20126
20127
|
});
|
|
20127
20128
|
});
|
|
20128
20129
|
};
|
|
20129
20130
|
|
|
20130
|
-
var useSubscriptions = function (_a) {
|
|
20131
|
-
var data = _a.data;
|
|
20132
|
-
return react.useMemo(function () {
|
|
20133
|
-
var clonedData = lodashExports.cloneDeep(data);
|
|
20134
|
-
var combinedSubscriptions = clonedData === null || clonedData === void 0 ? void 0 : clonedData.map(function (subscription) {
|
|
20135
|
-
var _a;
|
|
20136
|
-
var orderedSubscriptionCharges = subscription.charges.sort(function (a, b) {
|
|
20137
|
-
if (a.priceListChargeId !== b.priceListChargeId) {
|
|
20138
|
-
return a.priceListChargeId.localeCompare(b.priceListChargeId);
|
|
20139
|
-
}
|
|
20140
|
-
if (a.kind === common.SubscriptionChargeKind.DISCOUNT &&
|
|
20141
|
-
b.kind !== common.SubscriptionChargeKind.DISCOUNT) {
|
|
20142
|
-
return 1;
|
|
20143
|
-
}
|
|
20144
|
-
if (a.kind !== common.SubscriptionChargeKind.DISCOUNT &&
|
|
20145
|
-
b.kind === common.SubscriptionChargeKind.DISCOUNT) {
|
|
20146
|
-
return -1;
|
|
20147
|
-
}
|
|
20148
|
-
return (a.endDate.localeCompare(b.endDate) ||
|
|
20149
|
-
a.startDate.localeCompare(b.startDate));
|
|
20150
|
-
});
|
|
20151
|
-
var isTrial = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === common.SubscriptionState.TRIAL;
|
|
20152
|
-
var combinedSubscriptionCharges = [];
|
|
20153
|
-
var aggregationCharge;
|
|
20154
|
-
for (var index = 0; index < orderedSubscriptionCharges.length; index++) {
|
|
20155
|
-
var charge = orderedSubscriptionCharges[index];
|
|
20156
|
-
var nextCharge = orderedSubscriptionCharges[index + 1];
|
|
20157
|
-
if (!aggregationCharge)
|
|
20158
|
-
aggregationCharge = charge;
|
|
20159
|
-
// If the next charge is the same priceListChargeId and endDate, aggregate the quantities
|
|
20160
|
-
if (nextCharge &&
|
|
20161
|
-
charge.priceListChargeId === nextCharge.priceListChargeId &&
|
|
20162
|
-
charge.endDate === nextCharge.endDate &&
|
|
20163
|
-
charge.startDate === nextCharge.startDate &&
|
|
20164
|
-
charge.kind === nextCharge.kind) {
|
|
20165
|
-
aggregationCharge.quantity += nextCharge.quantity;
|
|
20166
|
-
// If the next charge is different, push the aggregationCharge to the combinedSubscriptionCharges
|
|
20167
|
-
}
|
|
20168
|
-
else if (nextCharge &&
|
|
20169
|
-
charge.priceListChargeId === nextCharge.priceListChargeId &&
|
|
20170
|
-
(charge.endDate !== nextCharge.endDate ||
|
|
20171
|
-
charge.startDate !== nextCharge.startDate) &&
|
|
20172
|
-
charge.kind === nextCharge.kind &&
|
|
20173
|
-
(!isTrial || charge.trial) &&
|
|
20174
|
-
(isTrial || !charge.trial)) {
|
|
20175
|
-
nextCharge.name = "";
|
|
20176
|
-
combinedSubscriptionCharges.push(aggregationCharge);
|
|
20177
|
-
aggregationCharge = undefined;
|
|
20178
|
-
}
|
|
20179
|
-
else {
|
|
20180
|
-
combinedSubscriptionCharges.push(aggregationCharge);
|
|
20181
|
-
aggregationCharge = undefined;
|
|
20182
|
-
}
|
|
20183
|
-
}
|
|
20184
|
-
subscription.charges = combinedSubscriptionCharges;
|
|
20185
|
-
return subscription;
|
|
20186
|
-
});
|
|
20187
|
-
var subscriptionOrder = Object.values(common.SubscriptionState);
|
|
20188
|
-
combinedSubscriptions === null || combinedSubscriptions === void 0 ? void 0 : combinedSubscriptions.sort(function (a, b) {
|
|
20189
|
-
return subscriptionOrder.indexOf(a.state) - subscriptionOrder.indexOf(b.state);
|
|
20190
|
-
});
|
|
20191
|
-
return combinedSubscriptions;
|
|
20192
|
-
}, [data]);
|
|
20193
|
-
};
|
|
20194
|
-
|
|
20195
20131
|
var ErrorView = function (_a) {
|
|
20196
20132
|
var children = _a.children, message = _a.message;
|
|
20197
20133
|
return (jsxRuntime.jsxs("div", __assign({ className: "flex flex-col w-full", style: { marginTop: "80px" } }, { children: [jsxRuntime.jsx("div", __assign({ style: { fontSize: "32px" } }, { children: message })), children] })));
|
|
@@ -20503,8 +20439,7 @@ var SubscriptionCardDesktopRow = function (_a) {
|
|
|
20503
20439
|
// Derived state
|
|
20504
20440
|
var isRamp = charge.isRamp;
|
|
20505
20441
|
var prevCharge = subscription.charges[chargeIndex - 1];
|
|
20506
|
-
var isFirstRampRow = chargeIndex === 0 ||
|
|
20507
|
-
(prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.priceListChargeId) !== charge.priceListChargeId;
|
|
20442
|
+
var isFirstRampRow = chargeIndex === 0 || (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.priceListChargeId) !== charge.priceListChargeId;
|
|
20508
20443
|
var chargePeriod = "".concat(common.formatDate(charge.startDate), " - ").concat(common.formatDate(charge.endDate));
|
|
20509
20444
|
// Queries
|
|
20510
20445
|
var data = reactQuery.useQuery({
|
|
@@ -20518,18 +20453,15 @@ var SubscriptionCardDesktopRow = function (_a) {
|
|
|
20518
20453
|
apiHost: apiHost,
|
|
20519
20454
|
});
|
|
20520
20455
|
},
|
|
20521
|
-
enabled: (!isRamp || (isRamp && isFirstRampRow)) &&
|
|
20522
|
-
charge.chargeType === common.ChargeType.USAGE,
|
|
20456
|
+
enabled: (!isRamp || (isRamp && isFirstRampRow)) && charge.chargeType === common.ChargeType.USAGE,
|
|
20523
20457
|
}).data;
|
|
20524
20458
|
var isRampFirstRow = isRamp && chargeIndex === 0;
|
|
20525
20459
|
var isTrial = charge.trial;
|
|
20526
|
-
var dontShowChargeName = (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.
|
|
20460
|
+
var dontShowChargeName = (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.priceListChargeId) === charge.priceListChargeId &&
|
|
20527
20461
|
(!isTrial || prevCharge.trial) &&
|
|
20528
20462
|
(isTrial || !prevCharge.trial);
|
|
20529
20463
|
var isDiscount = charge.kind === common.SubscriptionChargeKind.DISCOUNT;
|
|
20530
|
-
return (jsxRuntime.jsxs("div", __assign({ className: "contents" }, { children: [(isRampFirstRow || !isRamp) && (jsxRuntime.jsx(SubscriptionsListCell, __assign({ gridColumn: isRamp ? "1/-1" : "1" }, { children: jsxRuntime.jsx("div", __assign({ className: "flex items-center gap-2 ".concat(isDiscount ? "pl-4" : "") }, { children: jsxRuntime.jsx("div", { children: isRampFirstRow || (!isRamp && !dontShowChargeName)
|
|
20531
|
-
? charge.name
|
|
20532
|
-
: "" }) })) }))), jsxRuntime.jsx(SubscriptionsListCell, __assign({ gridColumn: 2 }, { children: jsxRuntime.jsx("div", { children: chargePeriod }) })), jsxRuntime.jsx(SubscriptionsListCell, __assign({ right: true }, { children: charge.kind === common.SubscriptionChargeKind.DISCOUNT
|
|
20464
|
+
return (jsxRuntime.jsxs("div", __assign({ className: "contents" }, { children: [(isRampFirstRow || !isRamp) && (jsxRuntime.jsx(SubscriptionsListCell, __assign({ gridColumn: isRamp ? "1/-1" : "1" }, { children: jsxRuntime.jsx("div", __assign({ className: "flex items-center gap-2 ".concat(isDiscount ? "pl-4" : "") }, { children: jsxRuntime.jsx("div", { children: isRampFirstRow || (!isRamp && !dontShowChargeName) ? charge.name : "" }) })) }))), jsxRuntime.jsx(SubscriptionsListCell, __assign({ gridColumn: 2 }, { children: jsxRuntime.jsx("div", { children: chargePeriod }) })), jsxRuntime.jsx(SubscriptionsListCell, __assign({ right: true }, { children: charge.kind === common.SubscriptionChargeKind.DISCOUNT
|
|
20533
20465
|
? ""
|
|
20534
20466
|
: charge.chargeType === common.ChargeType.USAGE
|
|
20535
20467
|
? data && jsxRuntime.jsx(FeatureUsageGraph, { charge: charge, featureUsage: data })
|
|
@@ -20624,14 +20556,12 @@ var Subscriptions = function (_a) {
|
|
|
20624
20556
|
}),
|
|
20625
20557
|
queryFn: function () { return getSubscriptions({ entityId: entityId, token: token, apiHost: apiHost }); },
|
|
20626
20558
|
enabled: Boolean(entityId),
|
|
20627
|
-
}),
|
|
20559
|
+
}), subscriptions = _d.data, subscriptionsAreLoading = _d.isLoading;
|
|
20628
20560
|
var _e = reactQuery.useQuery({
|
|
20629
20561
|
queryKey: common.QueryKeyFactory.default.planChangeOptionsKey({ token: token }),
|
|
20630
20562
|
queryFn: function () { return getPlanChangeOptions({ token: token, apiHost: apiHost }); },
|
|
20631
20563
|
enabled: Boolean(onChangePlanClick),
|
|
20632
20564
|
}), planChangeOptions = _e.data, arePlanChangeOptionsLoading = _e.isLoading;
|
|
20633
|
-
// Derived state
|
|
20634
|
-
var subscriptions = useSubscriptions({ data: rawSubscriptions });
|
|
20635
20565
|
react.useEffect(function () {
|
|
20636
20566
|
if (subscriptions)
|
|
20637
20567
|
onSubscriptionsLoaded === null || onSubscriptionsLoaded === void 0 ? void 0 : onSubscriptionsLoaded(subscriptions);
|
package/dist/esm/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Markup } from 'interweave';
|
|
|
4
4
|
import { ConfigProvider, Button, Typography, Tag, Divider, Popconfirm, Input, Checkbox, Collapse, Skeleton, Modal, Form, Drawer, Card as Card$1, Select, Image, Dropdown } from 'antd';
|
|
5
5
|
import { DownloadOutlined, CreditCardOutlined, BankOutlined, SearchOutlined, CloseOutlined, CheckCircleFilled } from '@ant-design/icons';
|
|
6
6
|
import styled from 'styled-components';
|
|
7
|
-
import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest, QueryKeyFactory, useIsMobile, isColorTooDark, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, getPlugins, useAllErrorFormats, formatCurrency, invokePlugin, GRAY_500, GRAY_200, useErrorNotification, useSuccessNotification, getFormattedInvoice, PAYABLE_INVOICE_STATES, BreakpointNumbers, useGraphQLmutation, formatDate, FrontendTransaction, SLATE_600, WHITE, TransactionKind, Lists, getAccount,
|
|
7
|
+
import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest, QueryKeyFactory, useIsMobile, isColorTooDark, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, getPlugins, useAllErrorFormats, formatCurrency, invokePlugin, GRAY_500, GRAY_200, useErrorNotification, useSuccessNotification, getFormattedInvoice, PAYABLE_INVOICE_STATES, BreakpointNumbers, useGraphQLmutation, formatDate, FrontendTransaction, SLATE_600, WHITE, TransactionKind, Lists, getAccount, sortSubscriptionCharges, MODAL_MAX_HEIGHT, SLATE_500, DataInterval, SubscriptionState as SubscriptionState$2, TAG_COLORS, ChargeType, SubscriptionChargeKind, PricingModel } from '@bunnyapp/common';
|
|
8
8
|
import { QueryClient, QueryClientProvider, useQuery, useQueryClient, keepPreviousData, useMutation } from '@tanstack/react-query';
|
|
9
9
|
import theme from 'antd/lib/theme/index.js';
|
|
10
10
|
import { RecoilRoot } from 'recoil';
|
|
@@ -19903,8 +19903,8 @@ function InitialSignupForm(_a) {
|
|
|
19903
19903
|
{ required: true, message: "Please input your email!" },
|
|
19904
19904
|
{ type: "email", message: "Please enter a valid email!" },
|
|
19905
19905
|
] }, { children: jsx(Input, { placeholder: "Email" }) })), jsx(Form.Item, __assign({ name: "accountName", rules: [
|
|
19906
|
-
{ required: true, message: "Please input your
|
|
19907
|
-
] }, { children: jsx(Input, { placeholder: "
|
|
19906
|
+
{ required: true, message: "Please input your company name!" },
|
|
19907
|
+
] }, { children: jsx(Input, { placeholder: "Company name" }) }))] })), jsx(Form.Item, { children: jsx(Button, __assign({ type: "primary", onClick: handleSubmit, loading: submitting, className: "w-full mt-4" }, { children: "Proceed to payment" })) })] })));
|
|
19908
19908
|
}
|
|
19909
19909
|
|
|
19910
19910
|
var Title = Typography.Title, Text$4 = Typography.Text;
|
|
@@ -20080,10 +20080,10 @@ var SUBSCRIPTIONS_QUERY = "\nquery subscriptions {\n subscriptions {\n n
|
|
|
20080
20080
|
var getSubscriptions = function (_a) {
|
|
20081
20081
|
var apiHost = _a.apiHost, entityId = _a.entityId, isInPreviewMode = _a.isInPreviewMode, token = _a.token;
|
|
20082
20082
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
20083
|
-
var response;
|
|
20084
|
-
var _b;
|
|
20085
|
-
return __generator(this, function (
|
|
20086
|
-
switch (
|
|
20083
|
+
var response, combinedSubscriptions;
|
|
20084
|
+
var _b, _c;
|
|
20085
|
+
return __generator(this, function (_d) {
|
|
20086
|
+
switch (_d.label) {
|
|
20087
20087
|
case 0: return [4 /*yield*/, gqlRequest({
|
|
20088
20088
|
isInPreviewMode: isInPreviewMode,
|
|
20089
20089
|
query: SUBSCRIPTIONS_QUERY,
|
|
@@ -20092,78 +20092,14 @@ var getSubscriptions = function (_a) {
|
|
|
20092
20092
|
apiHost: apiHost,
|
|
20093
20093
|
})];
|
|
20094
20094
|
case 1:
|
|
20095
|
-
response =
|
|
20096
|
-
|
|
20095
|
+
response = _d.sent();
|
|
20096
|
+
combinedSubscriptions = (_c = (_b = response === null || response === void 0 ? void 0 : response.subscriptions) === null || _b === void 0 ? void 0 : _b.nodes) === null || _c === void 0 ? void 0 : _c.map(function (subscription) { return (__assign(__assign({}, subscription), { charges: sortSubscriptionCharges(subscription.charges) })); });
|
|
20097
|
+
return [2 /*return*/, combinedSubscriptions];
|
|
20097
20098
|
}
|
|
20098
20099
|
});
|
|
20099
20100
|
});
|
|
20100
20101
|
};
|
|
20101
20102
|
|
|
20102
|
-
var useSubscriptions = function (_a) {
|
|
20103
|
-
var data = _a.data;
|
|
20104
|
-
return useMemo(function () {
|
|
20105
|
-
var clonedData = lodashExports.cloneDeep(data);
|
|
20106
|
-
var combinedSubscriptions = clonedData === null || clonedData === void 0 ? void 0 : clonedData.map(function (subscription) {
|
|
20107
|
-
var _a;
|
|
20108
|
-
var orderedSubscriptionCharges = subscription.charges.sort(function (a, b) {
|
|
20109
|
-
if (a.priceListChargeId !== b.priceListChargeId) {
|
|
20110
|
-
return a.priceListChargeId.localeCompare(b.priceListChargeId);
|
|
20111
|
-
}
|
|
20112
|
-
if (a.kind === SubscriptionChargeKind.DISCOUNT &&
|
|
20113
|
-
b.kind !== SubscriptionChargeKind.DISCOUNT) {
|
|
20114
|
-
return 1;
|
|
20115
|
-
}
|
|
20116
|
-
if (a.kind !== SubscriptionChargeKind.DISCOUNT &&
|
|
20117
|
-
b.kind === SubscriptionChargeKind.DISCOUNT) {
|
|
20118
|
-
return -1;
|
|
20119
|
-
}
|
|
20120
|
-
return (a.endDate.localeCompare(b.endDate) ||
|
|
20121
|
-
a.startDate.localeCompare(b.startDate));
|
|
20122
|
-
});
|
|
20123
|
-
var isTrial = ((_a = subscription.state) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === SubscriptionState$2.TRIAL;
|
|
20124
|
-
var combinedSubscriptionCharges = [];
|
|
20125
|
-
var aggregationCharge;
|
|
20126
|
-
for (var index = 0; index < orderedSubscriptionCharges.length; index++) {
|
|
20127
|
-
var charge = orderedSubscriptionCharges[index];
|
|
20128
|
-
var nextCharge = orderedSubscriptionCharges[index + 1];
|
|
20129
|
-
if (!aggregationCharge)
|
|
20130
|
-
aggregationCharge = charge;
|
|
20131
|
-
// If the next charge is the same priceListChargeId and endDate, aggregate the quantities
|
|
20132
|
-
if (nextCharge &&
|
|
20133
|
-
charge.priceListChargeId === nextCharge.priceListChargeId &&
|
|
20134
|
-
charge.endDate === nextCharge.endDate &&
|
|
20135
|
-
charge.startDate === nextCharge.startDate &&
|
|
20136
|
-
charge.kind === nextCharge.kind) {
|
|
20137
|
-
aggregationCharge.quantity += nextCharge.quantity;
|
|
20138
|
-
// If the next charge is different, push the aggregationCharge to the combinedSubscriptionCharges
|
|
20139
|
-
}
|
|
20140
|
-
else if (nextCharge &&
|
|
20141
|
-
charge.priceListChargeId === nextCharge.priceListChargeId &&
|
|
20142
|
-
(charge.endDate !== nextCharge.endDate ||
|
|
20143
|
-
charge.startDate !== nextCharge.startDate) &&
|
|
20144
|
-
charge.kind === nextCharge.kind &&
|
|
20145
|
-
(!isTrial || charge.trial) &&
|
|
20146
|
-
(isTrial || !charge.trial)) {
|
|
20147
|
-
nextCharge.name = "";
|
|
20148
|
-
combinedSubscriptionCharges.push(aggregationCharge);
|
|
20149
|
-
aggregationCharge = undefined;
|
|
20150
|
-
}
|
|
20151
|
-
else {
|
|
20152
|
-
combinedSubscriptionCharges.push(aggregationCharge);
|
|
20153
|
-
aggregationCharge = undefined;
|
|
20154
|
-
}
|
|
20155
|
-
}
|
|
20156
|
-
subscription.charges = combinedSubscriptionCharges;
|
|
20157
|
-
return subscription;
|
|
20158
|
-
});
|
|
20159
|
-
var subscriptionOrder = Object.values(SubscriptionState$2);
|
|
20160
|
-
combinedSubscriptions === null || combinedSubscriptions === void 0 ? void 0 : combinedSubscriptions.sort(function (a, b) {
|
|
20161
|
-
return subscriptionOrder.indexOf(a.state) - subscriptionOrder.indexOf(b.state);
|
|
20162
|
-
});
|
|
20163
|
-
return combinedSubscriptions;
|
|
20164
|
-
}, [data]);
|
|
20165
|
-
};
|
|
20166
|
-
|
|
20167
20103
|
var ErrorView = function (_a) {
|
|
20168
20104
|
var children = _a.children, message = _a.message;
|
|
20169
20105
|
return (jsxs("div", __assign({ className: "flex flex-col w-full", style: { marginTop: "80px" } }, { children: [jsx("div", __assign({ style: { fontSize: "32px" } }, { children: message })), children] })));
|
|
@@ -20475,8 +20411,7 @@ var SubscriptionCardDesktopRow = function (_a) {
|
|
|
20475
20411
|
// Derived state
|
|
20476
20412
|
var isRamp = charge.isRamp;
|
|
20477
20413
|
var prevCharge = subscription.charges[chargeIndex - 1];
|
|
20478
|
-
var isFirstRampRow = chargeIndex === 0 ||
|
|
20479
|
-
(prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.priceListChargeId) !== charge.priceListChargeId;
|
|
20414
|
+
var isFirstRampRow = chargeIndex === 0 || (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.priceListChargeId) !== charge.priceListChargeId;
|
|
20480
20415
|
var chargePeriod = "".concat(formatDate(charge.startDate), " - ").concat(formatDate(charge.endDate));
|
|
20481
20416
|
// Queries
|
|
20482
20417
|
var data = useQuery({
|
|
@@ -20490,18 +20425,15 @@ var SubscriptionCardDesktopRow = function (_a) {
|
|
|
20490
20425
|
apiHost: apiHost,
|
|
20491
20426
|
});
|
|
20492
20427
|
},
|
|
20493
|
-
enabled: (!isRamp || (isRamp && isFirstRampRow)) &&
|
|
20494
|
-
charge.chargeType === ChargeType.USAGE,
|
|
20428
|
+
enabled: (!isRamp || (isRamp && isFirstRampRow)) && charge.chargeType === ChargeType.USAGE,
|
|
20495
20429
|
}).data;
|
|
20496
20430
|
var isRampFirstRow = isRamp && chargeIndex === 0;
|
|
20497
20431
|
var isTrial = charge.trial;
|
|
20498
|
-
var dontShowChargeName = (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.
|
|
20432
|
+
var dontShowChargeName = (prevCharge === null || prevCharge === void 0 ? void 0 : prevCharge.priceListChargeId) === charge.priceListChargeId &&
|
|
20499
20433
|
(!isTrial || prevCharge.trial) &&
|
|
20500
20434
|
(isTrial || !prevCharge.trial);
|
|
20501
20435
|
var isDiscount = charge.kind === SubscriptionChargeKind.DISCOUNT;
|
|
20502
|
-
return (jsxs("div", __assign({ className: "contents" }, { children: [(isRampFirstRow || !isRamp) && (jsx(SubscriptionsListCell, __assign({ gridColumn: isRamp ? "1/-1" : "1" }, { children: jsx("div", __assign({ className: "flex items-center gap-2 ".concat(isDiscount ? "pl-4" : "") }, { children: jsx("div", { children: isRampFirstRow || (!isRamp && !dontShowChargeName)
|
|
20503
|
-
? charge.name
|
|
20504
|
-
: "" }) })) }))), jsx(SubscriptionsListCell, __assign({ gridColumn: 2 }, { children: jsx("div", { children: chargePeriod }) })), jsx(SubscriptionsListCell, __assign({ right: true }, { children: charge.kind === SubscriptionChargeKind.DISCOUNT
|
|
20436
|
+
return (jsxs("div", __assign({ className: "contents" }, { children: [(isRampFirstRow || !isRamp) && (jsx(SubscriptionsListCell, __assign({ gridColumn: isRamp ? "1/-1" : "1" }, { children: jsx("div", __assign({ className: "flex items-center gap-2 ".concat(isDiscount ? "pl-4" : "") }, { children: jsx("div", { children: isRampFirstRow || (!isRamp && !dontShowChargeName) ? charge.name : "" }) })) }))), jsx(SubscriptionsListCell, __assign({ gridColumn: 2 }, { children: jsx("div", { children: chargePeriod }) })), jsx(SubscriptionsListCell, __assign({ right: true }, { children: charge.kind === SubscriptionChargeKind.DISCOUNT
|
|
20505
20437
|
? ""
|
|
20506
20438
|
: charge.chargeType === ChargeType.USAGE
|
|
20507
20439
|
? data && jsx(FeatureUsageGraph, { charge: charge, featureUsage: data })
|
|
@@ -20596,14 +20528,12 @@ var Subscriptions = function (_a) {
|
|
|
20596
20528
|
}),
|
|
20597
20529
|
queryFn: function () { return getSubscriptions({ entityId: entityId, token: token, apiHost: apiHost }); },
|
|
20598
20530
|
enabled: Boolean(entityId),
|
|
20599
|
-
}),
|
|
20531
|
+
}), subscriptions = _d.data, subscriptionsAreLoading = _d.isLoading;
|
|
20600
20532
|
var _e = useQuery({
|
|
20601
20533
|
queryKey: QueryKeyFactory.default.planChangeOptionsKey({ token: token }),
|
|
20602
20534
|
queryFn: function () { return getPlanChangeOptions({ token: token, apiHost: apiHost }); },
|
|
20603
20535
|
enabled: Boolean(onChangePlanClick),
|
|
20604
20536
|
}), planChangeOptions = _e.data, arePlanChangeOptionsLoading = _e.isLoading;
|
|
20605
|
-
// Derived state
|
|
20606
|
-
var subscriptions = useSubscriptions({ data: rawSubscriptions });
|
|
20607
20537
|
useEffect(function () {
|
|
20608
20538
|
if (subscriptions)
|
|
20609
20539
|
onSubscriptionsLoaded === null || onSubscriptionsLoaded === void 0 ? void 0 : onSubscriptionsLoaded(subscriptions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bunnyapp/components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.44",
|
|
4
4
|
"description": "Components from the Bunny portal to embed Bunny UI functionality into your application.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -63,7 +63,8 @@
|
|
|
63
63
|
"vite": "^6.2.1"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@
|
|
66
|
+
"@ant-design/icons": "^5.6.1",
|
|
67
|
+
"@bunnyapp/common": "^1.0.53",
|
|
67
68
|
"@fortawesome/fontawesome-svg-core": "^6.7.2",
|
|
68
69
|
"@fortawesome/free-brands-svg-icons": "^6.7.2",
|
|
69
70
|
"@fortawesome/free-regular-svg-icons": "^6.7.2",
|
|
@@ -78,17 +79,19 @@
|
|
|
78
79
|
"interweave": "^13.1.0",
|
|
79
80
|
"less": "^4.2.0",
|
|
80
81
|
"lodash-es": "^4.17.21",
|
|
82
|
+
"pluralize": "^8.0.0",
|
|
81
83
|
"react": "^18.3.1",
|
|
82
84
|
"react-dom": "^18.3.1",
|
|
83
85
|
"recharts": "^2.15.0",
|
|
84
86
|
"recoil": "^0.7.7",
|
|
85
|
-
"
|
|
86
|
-
"styled-components": "^6.1.13",
|
|
87
|
-
"pluralize": "^8.0.0"
|
|
87
|
+
"styled-components": "^6.1.13"
|
|
88
88
|
},
|
|
89
89
|
"msw": {
|
|
90
90
|
"workerDirectory": [
|
|
91
91
|
"public"
|
|
92
92
|
]
|
|
93
|
+
},
|
|
94
|
+
"dependencies": {
|
|
95
|
+
"msw-storybook-addon": "^2.0.4"
|
|
93
96
|
}
|
|
94
97
|
}
|