@streamoid/settings 0.21.0 → 0.22.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/README.md +8 -0
- package/dist/index.d.mts +151 -12
- package/dist/index.d.ts +151 -12
- package/dist/index.js +353 -42
- package/dist/index.mjs +353 -42
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -40,6 +40,8 @@ __export(index_exports, {
|
|
|
40
40
|
EMPTY_USAGE_LOGS_PAGE: () => EMPTY_USAGE_LOGS_PAGE,
|
|
41
41
|
ExportDateModal: () => ExportDateModal,
|
|
42
42
|
INITIAL_USAGE_LOGS_STATE: () => INITIAL_USAGE_LOGS_STATE,
|
|
43
|
+
INVOICE_DOWNLOAD_FAILED_MESSAGE: () => INVOICE_DOWNLOAD_FAILED_MESSAGE,
|
|
44
|
+
INVOICE_NOT_AVAILABLE_MESSAGE: () => INVOICE_NOT_AVAILABLE_MESSAGE,
|
|
43
45
|
InviteUpdateModal: () => InviteUpdateModal,
|
|
44
46
|
MOCK_REFERRED_USERS: () => MOCK_REFERRED_USERS,
|
|
45
47
|
MemberCreditLimitModal: () => MemberCreditLimitModal,
|
|
@@ -61,6 +63,7 @@ __export(index_exports, {
|
|
|
61
63
|
ReferralHistoryView: () => ReferralHistoryView,
|
|
62
64
|
ReferralTab: () => ReferralTab,
|
|
63
65
|
RemovePoolMemberModal: () => RemovePoolMemberModal,
|
|
66
|
+
RemoveSelfShareModal: () => RemoveSelfShareModal,
|
|
64
67
|
SCOPE_LABELS: () => SCOPE_LABELS,
|
|
65
68
|
ScopeHeader: () => ScopeHeader,
|
|
66
69
|
SettingsAdaptersProvider: () => SettingsAdaptersProvider,
|
|
@@ -94,6 +97,7 @@ __export(index_exports, {
|
|
|
94
97
|
belowUsageReason: () => belowUsageReason,
|
|
95
98
|
canManageOnlyWorkspaceCreditLimit: () => canManageOnlyWorkspaceCreditLimit,
|
|
96
99
|
canShowSharedCredits: () => canShowSharedCredits,
|
|
100
|
+
checkPoolPercentTotal: () => checkPoolPercentTotal,
|
|
97
101
|
cleanCreditLimitInput: () => cleanCreditLimitInput,
|
|
98
102
|
cleanPoolValueInput: () => cleanPoolValueInput,
|
|
99
103
|
countLabel: () => countLabel,
|
|
@@ -118,6 +122,7 @@ __export(index_exports, {
|
|
|
118
122
|
groupWorkspaceList: () => groupWorkspaceList,
|
|
119
123
|
hasPaidFeatures: () => hasPaidFeatures,
|
|
120
124
|
inviteUpdate: () => inviteUpdate,
|
|
125
|
+
invoiceDownloadKind: () => invoiceDownloadKind,
|
|
121
126
|
isLimitAboveTotal: () => isLimitAboveTotal,
|
|
122
127
|
isLimitBelowUsage: () => isLimitBelowUsage,
|
|
123
128
|
isPaidPlan: () => isPaidPlan,
|
|
@@ -139,9 +144,12 @@ __export(index_exports, {
|
|
|
139
144
|
parseBillingEntitlement: () => parseBillingEntitlement,
|
|
140
145
|
parseInviteEmails: () => parseInviteEmails,
|
|
141
146
|
pausedOwnCreditsText: () => pausedOwnCreditsText,
|
|
147
|
+
poolAllocatedPercent: () => poolAllocatedPercent,
|
|
148
|
+
poolAllocationText: () => poolAllocationText,
|
|
142
149
|
poolEndsAtFrom: () => poolEndsAtFrom,
|
|
143
150
|
poolErrorMessage: () => poolErrorMessage,
|
|
144
151
|
poolRenewsAtCycleEnd: () => poolRenewsAtCycleEnd,
|
|
152
|
+
poolUnallocatedPercent: () => poolUnallocatedPercent,
|
|
145
153
|
poolWorkspaceName: () => poolWorkspaceName,
|
|
146
154
|
productsForCountry: () => productsForCountry,
|
|
147
155
|
readSettingsCaller: () => readSettingsCaller,
|
|
@@ -157,6 +165,9 @@ __export(index_exports, {
|
|
|
157
165
|
sharedPoolEndsText: () => sharedPoolEndsText,
|
|
158
166
|
sliceUsageLogsPage: () => sliceUsageLogsPage,
|
|
159
167
|
sortReferredUsers: () => sortReferredUsers,
|
|
168
|
+
sponsorShareBannerText: () => sponsorShareBannerText,
|
|
169
|
+
sponsorShareDetailText: () => sponsorShareDetailText,
|
|
170
|
+
sponsorShareSpentText: () => sponsorShareSpentText,
|
|
160
171
|
sponsoredCreditsText: () => sponsoredCreditsText,
|
|
161
172
|
ssoLabel: () => ssoLabel,
|
|
162
173
|
toCsv: () => toCsv,
|
|
@@ -8084,6 +8095,17 @@ function findBillingError(failure, codes) {
|
|
|
8084
8095
|
return visit(failure, 0);
|
|
8085
8096
|
}
|
|
8086
8097
|
|
|
8098
|
+
// src/invoice-download.ts
|
|
8099
|
+
function invoiceDownloadKind(item) {
|
|
8100
|
+
const id = item.transactionId;
|
|
8101
|
+
if (!id) return null;
|
|
8102
|
+
if (id.startsWith("in_")) return "invoice";
|
|
8103
|
+
if (id.startsWith("pi_")) return "receipt";
|
|
8104
|
+
return null;
|
|
8105
|
+
}
|
|
8106
|
+
var INVOICE_NOT_AVAILABLE_MESSAGE = "There's no invoice for this order. Rolled-over, bonus and manually added credits don't have one.";
|
|
8107
|
+
var INVOICE_DOWNLOAD_FAILED_MESSAGE = "Couldn't download this invoice.";
|
|
8108
|
+
|
|
8087
8109
|
// src/billing-content.tsx
|
|
8088
8110
|
var import_react24 = require("react");
|
|
8089
8111
|
var import_ui18 = require("@streamoid/ui");
|
|
@@ -10169,6 +10191,32 @@ function validatePoolText(raw, max) {
|
|
|
10169
10191
|
if (value.length > max) return { ok: false, reason: `At most ${max} characters` };
|
|
10170
10192
|
return { ok: true, value };
|
|
10171
10193
|
}
|
|
10194
|
+
var round2 = (value) => Math.round(value * 100) / 100;
|
|
10195
|
+
function poolAllocatedPercent(pool, exclude) {
|
|
10196
|
+
if (!pool) return 0;
|
|
10197
|
+
if (exclude === void 0 && typeof pool.allocatedPercent === "number") return round2(pool.allocatedPercent);
|
|
10198
|
+
let total = 0;
|
|
10199
|
+
if (exclude !== "self" && pool.self?.mode === "percent") total += pool.self.value;
|
|
10200
|
+
for (const member of pool.members ?? []) {
|
|
10201
|
+
if (member._id !== exclude && member.mode === "percent") total += member.value;
|
|
10202
|
+
}
|
|
10203
|
+
return round2(total);
|
|
10204
|
+
}
|
|
10205
|
+
function poolUnallocatedPercent(pool, exclude) {
|
|
10206
|
+
return Math.max(0, round2(100 - poolAllocatedPercent(pool, exclude)));
|
|
10207
|
+
}
|
|
10208
|
+
function checkPoolPercentTotal(split, unallocatedPercent) {
|
|
10209
|
+
if (split.mode !== "percent" || round2(split.value) <= round2(unallocatedPercent)) return { ok: true };
|
|
10210
|
+
const left = formatCredits(Math.max(0, unallocatedPercent));
|
|
10211
|
+
return {
|
|
10212
|
+
ok: false,
|
|
10213
|
+
reason: unallocatedPercent > 0 ? `Only ${left}% is unallocated. Percentage shares, this workspace's included, can total at most 100%.` : "All 100% is allocated. Lower another percentage share first, or share fixed credits."
|
|
10214
|
+
};
|
|
10215
|
+
}
|
|
10216
|
+
function poolAllocationText(pool) {
|
|
10217
|
+
const allocated = poolAllocatedPercent(pool);
|
|
10218
|
+
return `Allocated ${formatCredits(allocated)}% \xB7 Unallocated ${formatCredits(Math.max(0, round2(100 - allocated)))}%`;
|
|
10219
|
+
}
|
|
10172
10220
|
var credits = (value) => `${formatCredits(value)} ${value === 1 ? "credit" : "credits"}`;
|
|
10173
10221
|
function formatPoolSplit(split) {
|
|
10174
10222
|
if (split.mode === "percent") return `${formatCredits(split.value)}%`;
|
|
@@ -10255,6 +10303,16 @@ function sharedPoolBannerText(pool) {
|
|
|
10255
10303
|
const sponsor = pool.sponsorName?.trim() || "another workspace";
|
|
10256
10304
|
return `Credits shared by ${sponsor}: ${formatCredits(pool.remaining)} of ${formatCredits(pool.allowance)} left this cycle`;
|
|
10257
10305
|
}
|
|
10306
|
+
function sponsorShareSpentText() {
|
|
10307
|
+
return "This workspace has used its share of the credits for this cycle.";
|
|
10308
|
+
}
|
|
10309
|
+
function sponsorShareBannerText(share) {
|
|
10310
|
+
if (share.remaining <= 0) return sponsorShareSpentText();
|
|
10311
|
+
return `This workspace's share: ${formatCredits(share.remaining)} of ${credits(share.allowance)} left this cycle`;
|
|
10312
|
+
}
|
|
10313
|
+
function sponsorShareDetailText() {
|
|
10314
|
+
return "The rest of this workspace's credits are kept for the workspaces it shares them with. Organization admins change this in Shared credits.";
|
|
10315
|
+
}
|
|
10258
10316
|
function pausedOwnCreditsText(_pool) {
|
|
10259
10317
|
return ownCreditsFirstText();
|
|
10260
10318
|
}
|
|
@@ -10264,8 +10322,16 @@ function ownCreditsFirstText() {
|
|
|
10264
10322
|
function creditsMeter({
|
|
10265
10323
|
availableCredits,
|
|
10266
10324
|
totalCredits,
|
|
10267
|
-
sharedPool
|
|
10325
|
+
sharedPool,
|
|
10326
|
+
sponsorShare = null
|
|
10268
10327
|
}) {
|
|
10328
|
+
if (sponsorShare && !sharedPool) {
|
|
10329
|
+
const used2 = Math.max(0, sponsorShare.used);
|
|
10330
|
+
const left = Math.max(0, sponsorShare.remaining);
|
|
10331
|
+
const remaining = availableCredits != null ? Math.min(left, Math.max(0, availableCredits)) : left;
|
|
10332
|
+
const progressPct2 = sponsorShare.allowance > 0 ? Math.min(100, Math.round(used2 / sponsorShare.allowance * 100)) : 100;
|
|
10333
|
+
return { used: used2, remaining, progressPct: progressPct2, remainingPct: 100 - progressPct2 };
|
|
10334
|
+
}
|
|
10269
10335
|
if (sharedPool && availableCredits != null && totalCredits != null) {
|
|
10270
10336
|
const total = Math.max(0, totalCredits) + Math.max(0, sharedPool.allowance);
|
|
10271
10337
|
const used2 = Math.max(0, total - availableCredits);
|
|
@@ -10476,18 +10542,31 @@ var EXPIRY_OPTIONS = [
|
|
|
10476
10542
|
];
|
|
10477
10543
|
var isExpiryKind = (id) => EXPIRY_OPTIONS.some((o) => o.id === id);
|
|
10478
10544
|
var endsText = (member) => member.endsAt ? `, until ${formatPoolEndsAt(member.endsAt)}` : "";
|
|
10479
|
-
function endsAtHelp(kind, endsAt) {
|
|
10480
|
-
if (kind === "never")
|
|
10545
|
+
function endsAtHelp(kind, endsAt, self) {
|
|
10546
|
+
if (kind === "never") {
|
|
10547
|
+
return self ? "Applies every billing cycle until it is removed." : "Shares every billing cycle until it is removed.";
|
|
10548
|
+
}
|
|
10549
|
+
if (self) {
|
|
10550
|
+
const stop2 = "After that, this workspace may spend all its credits again.";
|
|
10551
|
+
return endsAt ? `The share ends on ${formatPoolEndsAt(endsAt)}. ${stop2}` : stop2;
|
|
10552
|
+
}
|
|
10481
10553
|
const stop = "After that, the other workspace spends only its own credits.";
|
|
10482
10554
|
return endsAt ? `Sharing stops on ${formatPoolEndsAt(endsAt)}. ${stop}` : stop;
|
|
10483
10555
|
}
|
|
10556
|
+
function valueHelp(kind, mode) {
|
|
10557
|
+
if (kind === "self") {
|
|
10558
|
+
return mode === "percent" ? "The most this workspace may spend of its own plan credits each billing cycle. It counts toward the same 100% as the shares other workspaces get." : "The most credits this workspace may spend itself each billing cycle. Fixed credits don't count toward the 100%.";
|
|
10559
|
+
}
|
|
10560
|
+
return mode === "percent" ? "A share of this workspace's plan credits for each billing cycle. Credits stay with this workspace; the other workspace spends them up to this share, after its own credits." : "Credits the other workspace may spend each billing cycle, after its own credits. Credits stay with this workspace until spent.";
|
|
10561
|
+
}
|
|
10484
10562
|
function CreditPoolMemberModal(props) {
|
|
10485
10563
|
const { toast } = useSettingsAdapters();
|
|
10486
|
-
const editing = props.kind === "edit" ? props.member : null;
|
|
10564
|
+
const editing = props.kind === "edit" ? props.member : props.kind === "self" ? props.self : null;
|
|
10565
|
+
const initialNote = props.kind === "self" ? props.self?.note ?? "" : "";
|
|
10487
10566
|
const [memberId, setMemberId] = (0, import_react21.useState)("");
|
|
10488
10567
|
const [mode, setMode] = (0, import_react21.useState)(editing?.mode ?? "percent");
|
|
10489
10568
|
const [raw, setRaw] = (0, import_react21.useState)(editing ? String(editing.value) : "");
|
|
10490
|
-
const [note, setNote] = (0, import_react21.useState)(
|
|
10569
|
+
const [note, setNote] = (0, import_react21.useState)(initialNote);
|
|
10491
10570
|
const [touched, setTouched] = (0, import_react21.useState)(false);
|
|
10492
10571
|
const [saving, setSaving] = (0, import_react21.useState)(false);
|
|
10493
10572
|
const [serverError, setServerError] = (0, import_react21.useState)(null);
|
|
@@ -10504,10 +10583,13 @@ function CreditPoolMemberModal(props) {
|
|
|
10504
10583
|
const endsAtUnchanged = Boolean(editing) && expiry.kind === initialExpiry.kind && (expiry.kind !== "date" || initialExpiry.kind === "date" && expiry.date === initialExpiry.date);
|
|
10505
10584
|
const endsAt = endsAtUnchanged ? null : poolEndsAtFrom(expiry);
|
|
10506
10585
|
const splitChanged = !editing || mode !== editing.mode || !value.ok || value.value !== editing.value;
|
|
10507
|
-
const
|
|
10508
|
-
const
|
|
10586
|
+
const noteChanged = props.kind === "self" && note.trim() !== initialNote.trim();
|
|
10587
|
+
const changed = splitChanged || !endsAtUnchanged || noteChanged;
|
|
10588
|
+
const percentTotal = value.ok && props.unallocatedPercent !== void 0 ? checkPoolPercentTotal({ mode, value: value.value }, props.unallocatedPercent) : null;
|
|
10589
|
+
const valid = value.ok && (percentTotal === null || percentTotal.ok) && (endsAt === null || endsAt.ok) && (props.kind === "edit" || (props.kind === "self" || Boolean(memberId)) && noteCheck.ok);
|
|
10509
10590
|
const canSave = !saving && changed && valid;
|
|
10510
|
-
const valueHint = touched && !value.ok ? value.reason : null;
|
|
10591
|
+
const valueHint = touched && !value.ok ? value.reason : percentTotal && !percentTotal.ok ? percentTotal.reason : null;
|
|
10592
|
+
const unallocatedHint = mode === "percent" && props.unallocatedPercent !== void 0 ? ` ${formatCredits(Math.max(0, props.unallocatedPercent))}% is unallocated.` : "";
|
|
10511
10593
|
const expiryHint = endsAt && !endsAt.ok && !(expiry.kind === "date" && !expiry.date) ? endsAt.reason : null;
|
|
10512
10594
|
const handleSave = async () => {
|
|
10513
10595
|
if (!canSave || !value.ok) return;
|
|
@@ -10524,6 +10606,17 @@ function CreditPoolMemberModal(props) {
|
|
|
10524
10606
|
...sendEndsAt?.value ? { endsAt: sendEndsAt.value } : {}
|
|
10525
10607
|
});
|
|
10526
10608
|
toast.success(`Credits shared. ${describeAllowance(added)}${endsText(added)}.`);
|
|
10609
|
+
} else if (props.kind === "self") {
|
|
10610
|
+
const nextEndsAt = sendEndsAt ? sendEndsAt.value : props.self?.endsAt ?? null;
|
|
10611
|
+
await props.onSave({
|
|
10612
|
+
mode,
|
|
10613
|
+
value: value.value,
|
|
10614
|
+
note: noteCheck.ok ? noteCheck.value : "",
|
|
10615
|
+
endsAt: nextEndsAt
|
|
10616
|
+
});
|
|
10617
|
+
toast.success(
|
|
10618
|
+
`This workspace's share is ${formatPoolSplit({ mode, value: value.value })} each billing cycle${endsText({ endsAt: nextEndsAt })}.`
|
|
10619
|
+
);
|
|
10527
10620
|
} else {
|
|
10528
10621
|
const updated = await props.onSave({
|
|
10529
10622
|
mode,
|
|
@@ -10537,7 +10630,10 @@ function CreditPoolMemberModal(props) {
|
|
|
10537
10630
|
} catch (err) {
|
|
10538
10631
|
const message = poolErrorMessage(err);
|
|
10539
10632
|
if (message) setServerError(message);
|
|
10540
|
-
else
|
|
10633
|
+
else {
|
|
10634
|
+
const method = props.kind === "add" ? "POST" : props.kind === "self" ? "PUT" : "PATCH";
|
|
10635
|
+
toast.error(errorMessage(err, { method }));
|
|
10636
|
+
}
|
|
10541
10637
|
setSaving(false);
|
|
10542
10638
|
}
|
|
10543
10639
|
};
|
|
@@ -10545,7 +10641,7 @@ function CreditPoolMemberModal(props) {
|
|
|
10545
10641
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
10546
10642
|
PoolModalShell,
|
|
10547
10643
|
{
|
|
10548
|
-
title: props.kind === "add" ? "Share credits" : "Edit shared credits",
|
|
10644
|
+
title: props.kind === "add" ? "Share credits" : props.kind === "edit" ? "Edit shared credits" : props.self ? "Edit this workspace's share" : "Set this workspace's share",
|
|
10549
10645
|
busy: saving,
|
|
10550
10646
|
onClose: props.onClose,
|
|
10551
10647
|
footer: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
@@ -10572,7 +10668,7 @@ function CreditPoolMemberModal(props) {
|
|
|
10572
10668
|
] }),
|
|
10573
10669
|
children: [
|
|
10574
10670
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex flex-col w-full", style: { gap: T17.spXs }, children: [
|
|
10575
|
-
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { style: fieldLabel, children: "Share with" }),
|
|
10671
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { style: fieldLabel, children: props.kind === "self" ? "Workspace" : "Share with" }),
|
|
10576
10672
|
props.kind === "add" ? candidateOptions.length ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
10577
10673
|
import_ui15.ScSelect,
|
|
10578
10674
|
{
|
|
@@ -10582,7 +10678,7 @@ function CreditPoolMemberModal(props) {
|
|
|
10582
10678
|
placeholder: "Choose a workspace",
|
|
10583
10679
|
disabled: saving
|
|
10584
10680
|
}
|
|
10585
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { style: { ...modalBodyText, color: T17.muted }, children: "There are no other workspaces in this organization to share credits with." }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { style: { ...modalBodyText, color: T17.primary }, children: props.memberName })
|
|
10681
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { style: { ...modalBodyText, color: T17.muted }, children: "There are no other workspaces in this organization to share credits with." }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { style: { ...modalBodyText, color: T17.primary }, children: props.kind === "self" ? props.workspaceName : props.memberName })
|
|
10586
10682
|
] }),
|
|
10587
10683
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex flex-col w-full", style: { gap: T17.spMd }, children: [
|
|
10588
10684
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { style: fieldLabel, children: "How much, each billing cycle" }),
|
|
@@ -10641,7 +10737,8 @@ function CreditPoolMemberModal(props) {
|
|
|
10641
10737
|
}
|
|
10642
10738
|
),
|
|
10643
10739
|
valueHint ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { role: "alert", style: { ...modalBodyText, color: T17.error }, children: valueHint }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { style: { ...modalBodyText, color: T17.tertiary }, children: [
|
|
10644
|
-
|
|
10740
|
+
valueHelp(props.kind, mode),
|
|
10741
|
+
unallocatedHint,
|
|
10645
10742
|
editing ? " Applies immediately." : ""
|
|
10646
10743
|
] })
|
|
10647
10744
|
] }),
|
|
@@ -10709,16 +10806,20 @@ function CreditPoolMemberModal(props) {
|
|
|
10709
10806
|
)
|
|
10710
10807
|
}
|
|
10711
10808
|
),
|
|
10712
|
-
expiryHint ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { role: "alert", style: { ...modalBodyText, color: T17.error }, children: expiryHint }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { style: { ...modalBodyText, color: T17.tertiary }, children: endsAtHelp(
|
|
10809
|
+
expiryHint ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { role: "alert", style: { ...modalBodyText, color: T17.error }, children: expiryHint }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { style: { ...modalBodyText, color: T17.tertiary }, children: endsAtHelp(
|
|
10810
|
+
expiryKind,
|
|
10811
|
+
endsAtUnchanged ? editing?.endsAt ?? null : endsAt?.ok ? endsAt.value : null,
|
|
10812
|
+
props.kind === "self"
|
|
10813
|
+
) })
|
|
10713
10814
|
] }),
|
|
10714
|
-
props.kind
|
|
10815
|
+
props.kind !== "edit" && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex flex-col w-full", style: { gap: T17.spXs }, children: [
|
|
10715
10816
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { style: fieldLabel, children: "Note" }),
|
|
10716
10817
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
10717
10818
|
import_ui15.ScTextArea,
|
|
10718
10819
|
{
|
|
10719
10820
|
value: note,
|
|
10720
10821
|
maxLength: POOL_NOTE_MAX_LENGTH,
|
|
10721
|
-
placeholder: "Why are these credits being shared?",
|
|
10822
|
+
placeholder: props.kind === "self" ? "Why does this workspace keep only this share?" : "Why are these credits being shared?",
|
|
10722
10823
|
disabled: saving,
|
|
10723
10824
|
onChange: (e) => setNote(e.target.value),
|
|
10724
10825
|
rows: 3,
|
|
@@ -10831,6 +10932,73 @@ function RemovePoolMemberModal({
|
|
|
10831
10932
|
}
|
|
10832
10933
|
);
|
|
10833
10934
|
}
|
|
10935
|
+
function RemoveSelfShareModal({
|
|
10936
|
+
self,
|
|
10937
|
+
workspaceName,
|
|
10938
|
+
onRemove,
|
|
10939
|
+
onClose,
|
|
10940
|
+
onRemoved
|
|
10941
|
+
}) {
|
|
10942
|
+
const { toast } = useSettingsAdapters();
|
|
10943
|
+
const [saving, setSaving] = (0, import_react22.useState)(false);
|
|
10944
|
+
const handleConfirm = async () => {
|
|
10945
|
+
if (saving) return;
|
|
10946
|
+
setSaving(true);
|
|
10947
|
+
try {
|
|
10948
|
+
await onRemove();
|
|
10949
|
+
toast.success(`${workspaceName} can spend all its credits again`);
|
|
10950
|
+
onRemoved();
|
|
10951
|
+
onClose();
|
|
10952
|
+
} catch (err) {
|
|
10953
|
+
toast.error(errorMessage(err, { method: "DELETE" }));
|
|
10954
|
+
setSaving(false);
|
|
10955
|
+
}
|
|
10956
|
+
};
|
|
10957
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
10958
|
+
PoolModalShell,
|
|
10959
|
+
{
|
|
10960
|
+
title: "Remove this workspace's share",
|
|
10961
|
+
busy: saving,
|
|
10962
|
+
onClose,
|
|
10963
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
|
|
10964
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
10965
|
+
import_ui16.ScButton,
|
|
10966
|
+
{
|
|
10967
|
+
text: "Keep share",
|
|
10968
|
+
variant: "secondary",
|
|
10969
|
+
size: "md",
|
|
10970
|
+
state: saving ? "disabled" : "default",
|
|
10971
|
+
onClick: saving ? void 0 : onClose
|
|
10972
|
+
}
|
|
10973
|
+
),
|
|
10974
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
10975
|
+
import_ui16.ScButton,
|
|
10976
|
+
{
|
|
10977
|
+
text: "Remove share",
|
|
10978
|
+
variant: "error",
|
|
10979
|
+
size: "md",
|
|
10980
|
+
state: saving ? "disabled" : "default",
|
|
10981
|
+
onClick: saving ? void 0 : () => void handleConfirm()
|
|
10982
|
+
}
|
|
10983
|
+
)
|
|
10984
|
+
] }),
|
|
10985
|
+
children: [
|
|
10986
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { style: { ...modalBodyText, color: MODAL_T.primary }, children: [
|
|
10987
|
+
workspaceName,
|
|
10988
|
+
" may spend its whole balance again, starting now."
|
|
10989
|
+
] }),
|
|
10990
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { style: { ...modalBodyText, color: MODAL_T.tertiary }, children: [
|
|
10991
|
+
"It kept ",
|
|
10992
|
+
describeAllowance(self),
|
|
10993
|
+
" and has used ",
|
|
10994
|
+
formatCredits(self.used),
|
|
10995
|
+
".",
|
|
10996
|
+
self.mode === "percent" ? ` Its ${formatPoolSplit(self)} goes back to unallocated, so other workspaces can be given more.` : ""
|
|
10997
|
+
] })
|
|
10998
|
+
]
|
|
10999
|
+
}
|
|
11000
|
+
);
|
|
11001
|
+
}
|
|
10834
11002
|
|
|
10835
11003
|
// src/shared-credits-view.tsx
|
|
10836
11004
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
@@ -10913,10 +11081,49 @@ function MemberRow2({
|
|
|
10913
11081
|
}
|
|
10914
11082
|
);
|
|
10915
11083
|
}
|
|
11084
|
+
function SelfShareRow({
|
|
11085
|
+
self,
|
|
11086
|
+
onSet,
|
|
11087
|
+
onRemove
|
|
11088
|
+
}) {
|
|
11089
|
+
const spent = Boolean(self) && self.remaining <= 0;
|
|
11090
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
11091
|
+
"div",
|
|
11092
|
+
{
|
|
11093
|
+
style: {
|
|
11094
|
+
borderBottom: `1px solid ${T18.borderSubtle}`,
|
|
11095
|
+
display: "grid",
|
|
11096
|
+
gridTemplateColumns: MEMBER_COLUMNS2,
|
|
11097
|
+
alignItems: "center",
|
|
11098
|
+
padding: `10px ${T18.sp3xl}`,
|
|
11099
|
+
gap: MEMBER_GAP,
|
|
11100
|
+
backgroundColor: T18.fillPlus
|
|
11101
|
+
},
|
|
11102
|
+
children: [
|
|
11103
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col min-w-0", style: { gap: 2 }, children: [
|
|
11104
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "truncate", style: { ...cellText3, fontWeight: 500 }, children: "This workspace" }),
|
|
11105
|
+
self?.note && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "truncate", title: self.note, style: { ...cellText3, color: T18.tertiary }, children: self.note })
|
|
11106
|
+
] }),
|
|
11107
|
+
self ? /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col min-w-0", style: { gap: 2 }, children: [
|
|
11108
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { style: cellText3, children: formatPoolSplit({ mode: "fixed", value: self.allowance }) }),
|
|
11109
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { style: { ...cellText3, color: T18.tertiary }, children: self.mode === "percent" ? `${formatPoolSplit(self)} \xB7 this cycle` : "this cycle" })
|
|
11110
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { style: { ...cellText3, color: T18.muted }, children: "All its credits" }),
|
|
11111
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { style: { ...cellText3, color: self ? T18.primary : T18.muted }, children: self ? formatCredits(self.used) : "\u2014" }),
|
|
11112
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { style: { ...cellText3, color: !self ? T18.muted : spent ? T18.warning : T18.primary }, children: self ? formatCredits(self.remaining) : "\u2014" }),
|
|
11113
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { style: { ...cellText3, color: self?.endsAt ? T18.primary : T18.muted }, children: self ? formatPoolEndsAt(self.endsAt) : "\u2014" }),
|
|
11114
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-center whitespace-nowrap", style: { gap: 8 }, children: [
|
|
11115
|
+
onSet && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_ui17.ScButton, { text: self ? "Edit" : "Set share", variant: "secondary", size: "sm", onClick: onSet }),
|
|
11116
|
+
self && onRemove && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_ui17.ScButton, { text: "Remove", variant: "secondary", size: "sm", onClick: onRemove })
|
|
11117
|
+
] })
|
|
11118
|
+
]
|
|
11119
|
+
}
|
|
11120
|
+
);
|
|
11121
|
+
}
|
|
10916
11122
|
function SharedCreditsView() {
|
|
10917
11123
|
const { api, workspace, toast } = useSettingsAdapters();
|
|
10918
11124
|
const workspaceId = workspace.current?.id ?? null;
|
|
10919
11125
|
const workspaceName = workspace.current?.name?.trim() || "this workspace";
|
|
11126
|
+
const selfName = workspace.current?.name?.trim() || "This workspace";
|
|
10920
11127
|
const [data, setData] = (0, import_react23.useState)(null);
|
|
10921
11128
|
const [loading, setLoading] = (0, import_react23.useState)(true);
|
|
10922
11129
|
const [failed, setFailed] = (0, import_react23.useState)(false);
|
|
@@ -10924,6 +11131,8 @@ function SharedCreditsView() {
|
|
|
10924
11131
|
const [adding, setAdding] = (0, import_react23.useState)(false);
|
|
10925
11132
|
const [editing, setEditing] = (0, import_react23.useState)(null);
|
|
10926
11133
|
const [removing, setRemoving] = (0, import_react23.useState)(null);
|
|
11134
|
+
const [settingSelf, setSettingSelf] = (0, import_react23.useState)(false);
|
|
11135
|
+
const [removingSelf, setRemovingSelf] = (0, import_react23.useState)(false);
|
|
10927
11136
|
const latestLoad = (0, import_react23.useRef)(0);
|
|
10928
11137
|
const load = (0, import_react23.useCallback)(
|
|
10929
11138
|
async ({ refresh = false } = {}) => {
|
|
@@ -10952,6 +11161,8 @@ function SharedCreditsView() {
|
|
|
10952
11161
|
setAdding(false);
|
|
10953
11162
|
setEditing(null);
|
|
10954
11163
|
setRemoving(null);
|
|
11164
|
+
setSettingSelf(false);
|
|
11165
|
+
setRemovingSelf(false);
|
|
10955
11166
|
void load();
|
|
10956
11167
|
}, [workspaceId]);
|
|
10957
11168
|
(0, import_react23.useEffect)(
|
|
@@ -10999,6 +11210,8 @@ function SharedCreditsView() {
|
|
|
10999
11210
|
);
|
|
11000
11211
|
}
|
|
11001
11212
|
const members = data?.members ?? [];
|
|
11213
|
+
const self = data?.self ?? null;
|
|
11214
|
+
const showSelf = !failed && Boolean(data) && (Boolean(api.setCreditPoolSelfShare) || Boolean(self));
|
|
11002
11215
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col flex-1 min-h-0 w-full overflow-y-auto", style: { gap: 16 }, children: [
|
|
11003
11216
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-start justify-between shrink-0 w-full", style: { gap: 12 }, children: [
|
|
11004
11217
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col min-w-0", style: { gap: 4 }, children: [
|
|
@@ -11043,25 +11256,46 @@ function SharedCreditsView() {
|
|
|
11043
11256
|
}
|
|
11044
11257
|
),
|
|
11045
11258
|
!sponsor && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col shrink-0 w-full", style: { gap: 8 }, children: [
|
|
11046
|
-
/* @__PURE__ */ (0, import_jsx_runtime29.
|
|
11047
|
-
|
|
11259
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex items-baseline justify-between w-full", style: { gap: 12 }, children: [
|
|
11260
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { style: { ...cellText3, fontWeight: 500 }, children: "Shared with" }),
|
|
11261
|
+
!failed && data && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
11262
|
+
"span",
|
|
11263
|
+
{
|
|
11264
|
+
style: { ...cellText3, color: T18.muted },
|
|
11265
|
+
title: "Percentage shares, this workspace's included, total at most 100%. Fixed-credit shares aren't counted.",
|
|
11266
|
+
children: poolAllocationText(data)
|
|
11267
|
+
}
|
|
11268
|
+
)
|
|
11269
|
+
] }),
|
|
11270
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
11048
11271
|
MemberListFrame,
|
|
11049
11272
|
{
|
|
11050
11273
|
grow: "cap",
|
|
11051
11274
|
maxHeight: 420,
|
|
11052
11275
|
contentMinWidth: MEMBER_MIN_WIDTH,
|
|
11053
11276
|
header: tableHeader(MEMBER_COLUMNS2, ["Workspace", "Allowance", "Used", "Remaining", "Ends", "Actions"]),
|
|
11054
|
-
isEmpty: failed || members.length === 0,
|
|
11277
|
+
isEmpty: failed || members.length === 0 && !showSelf,
|
|
11055
11278
|
emptyText: failed ? "Couldn't load shared credits. Try again later." : "This workspace doesn't share its credits with any other workspace.",
|
|
11056
|
-
children:
|
|
11057
|
-
|
|
11058
|
-
|
|
11059
|
-
|
|
11060
|
-
|
|
11061
|
-
|
|
11062
|
-
|
|
11063
|
-
|
|
11064
|
-
|
|
11279
|
+
children: [
|
|
11280
|
+
showSelf && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
11281
|
+
SelfShareRow,
|
|
11282
|
+
{
|
|
11283
|
+
self,
|
|
11284
|
+
onSet: canManage && api.setCreditPoolSelfShare ? () => setSettingSelf(true) : void 0,
|
|
11285
|
+
onRemove: canManage && api.removeCreditPoolSelfShare ? () => setRemovingSelf(true) : void 0
|
|
11286
|
+
}
|
|
11287
|
+
),
|
|
11288
|
+
showSelf && members.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { style: { ...cellText3, color: T18.muted, padding: `12px ${T18.sp3xl}` }, children: "This workspace doesn't share its credits with any other workspace." }),
|
|
11289
|
+
members.map((member) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
11290
|
+
MemberRow2,
|
|
11291
|
+
{
|
|
11292
|
+
member,
|
|
11293
|
+
onEdit: canManage && api.updateCreditPoolMember ? () => setEditing(member) : void 0,
|
|
11294
|
+
onRemove: canManage && api.removeCreditPoolMember ? () => setRemoving(member) : void 0
|
|
11295
|
+
},
|
|
11296
|
+
member._id
|
|
11297
|
+
))
|
|
11298
|
+
]
|
|
11065
11299
|
}
|
|
11066
11300
|
)
|
|
11067
11301
|
] }),
|
|
@@ -11070,6 +11304,7 @@ function SharedCreditsView() {
|
|
|
11070
11304
|
{
|
|
11071
11305
|
kind: "add",
|
|
11072
11306
|
candidates,
|
|
11307
|
+
unallocatedPercent: poolUnallocatedPercent(data),
|
|
11073
11308
|
onSave: (input) => api.addCreditPoolMember(input),
|
|
11074
11309
|
onClose: () => setAdding(false),
|
|
11075
11310
|
onSaved: () => void load({ refresh: true })
|
|
@@ -11081,11 +11316,34 @@ function SharedCreditsView() {
|
|
|
11081
11316
|
kind: "edit",
|
|
11082
11317
|
member: editing,
|
|
11083
11318
|
memberName: poolWorkspaceName(editing.memberWorkspaceName),
|
|
11319
|
+
unallocatedPercent: poolUnallocatedPercent(data, editing._id),
|
|
11084
11320
|
onSave: (patch) => api.updateCreditPoolMember(editing._id, patch),
|
|
11085
11321
|
onClose: () => setEditing(null),
|
|
11086
11322
|
onSaved: () => void load({ refresh: true })
|
|
11087
11323
|
}
|
|
11088
11324
|
),
|
|
11325
|
+
settingSelf && api.setCreditPoolSelfShare && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
11326
|
+
CreditPoolMemberModal,
|
|
11327
|
+
{
|
|
11328
|
+
kind: "self",
|
|
11329
|
+
self,
|
|
11330
|
+
workspaceName: selfName,
|
|
11331
|
+
unallocatedPercent: poolUnallocatedPercent(data, "self"),
|
|
11332
|
+
onSave: (input) => api.setCreditPoolSelfShare(input),
|
|
11333
|
+
onClose: () => setSettingSelf(false),
|
|
11334
|
+
onSaved: () => void load({ refresh: true })
|
|
11335
|
+
}
|
|
11336
|
+
),
|
|
11337
|
+
removingSelf && self && api.removeCreditPoolSelfShare && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
11338
|
+
RemoveSelfShareModal,
|
|
11339
|
+
{
|
|
11340
|
+
self,
|
|
11341
|
+
workspaceName: selfName,
|
|
11342
|
+
onRemove: () => api.removeCreditPoolSelfShare(),
|
|
11343
|
+
onClose: () => setRemovingSelf(false),
|
|
11344
|
+
onRemoved: () => void load({ refresh: true })
|
|
11345
|
+
}
|
|
11346
|
+
),
|
|
11089
11347
|
removing && api.removeCreditPoolMember && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
11090
11348
|
RemovePoolMemberModal,
|
|
11091
11349
|
{
|
|
@@ -12156,19 +12414,20 @@ function InvoiceHistoryTable({
|
|
|
12156
12414
|
const currencySymbol = getCurrencySymbolByCountry(workspaceCountry);
|
|
12157
12415
|
const handleDownload = async (item) => {
|
|
12158
12416
|
const orderId = item.transactionId;
|
|
12159
|
-
|
|
12160
|
-
|
|
12417
|
+
const kind = invoiceDownloadKind(item);
|
|
12418
|
+
if (!orderId || !kind) {
|
|
12419
|
+
toast.info?.(INVOICE_NOT_AVAILABLE_MESSAGE);
|
|
12161
12420
|
return;
|
|
12162
12421
|
}
|
|
12163
12422
|
try {
|
|
12164
12423
|
const res = await api.downloadInvoice(orderId);
|
|
12165
|
-
const
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
window.open(
|
|
12169
|
-
} else if (
|
|
12170
|
-
const
|
|
12171
|
-
|
|
12424
|
+
const invoicePdfUrl = res?.data?.invoiceData?.invoice_pdf;
|
|
12425
|
+
const receiptPdfUrl = res?.data?.receiptPdfUrl;
|
|
12426
|
+
if (kind === "invoice" && invoicePdfUrl) {
|
|
12427
|
+
window.open(invoicePdfUrl, "_blank");
|
|
12428
|
+
} else if (kind === "receipt" && receiptPdfUrl) {
|
|
12429
|
+
const response = await fetch(receiptPdfUrl);
|
|
12430
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
12172
12431
|
const blob = await response.blob();
|
|
12173
12432
|
const url = window.URL.createObjectURL(blob);
|
|
12174
12433
|
const a = document.createElement("a");
|
|
@@ -12179,10 +12438,14 @@ function InvoiceHistoryTable({
|
|
|
12179
12438
|
a.remove();
|
|
12180
12439
|
window.URL.revokeObjectURL(url);
|
|
12181
12440
|
} else {
|
|
12182
|
-
toast.info?.(
|
|
12441
|
+
toast.info?.(
|
|
12442
|
+
kind === "receipt" ? "The receipt for this payment isn't ready yet. Try again in a few minutes." : "The PDF for this invoice isn't available yet. Try again in a few minutes."
|
|
12443
|
+
);
|
|
12183
12444
|
}
|
|
12184
|
-
} catch {
|
|
12185
|
-
toast.error(
|
|
12445
|
+
} catch (err) {
|
|
12446
|
+
toast.error(
|
|
12447
|
+
`${INVOICE_DOWNLOAD_FAILED_MESSAGE} ${errorMessage(err, { method: "GET" })}`
|
|
12448
|
+
);
|
|
12186
12449
|
}
|
|
12187
12450
|
};
|
|
12188
12451
|
const handleRowClick = (e, invoiceNumber) => {
|
|
@@ -12260,6 +12523,9 @@ function InvoiceHistoryTable({
|
|
|
12260
12523
|
amount: inv.amountPaid != null ? `${currencySymbol}${inv.amountPaid.toFixed(2)}` : `${currencySymbol}${(inv.amount / 100).toFixed(2)}`,
|
|
12261
12524
|
date: formatDate3(inv.createdAt),
|
|
12262
12525
|
downloadLabel: "Download invoice",
|
|
12526
|
+
downloadable: invoiceDownloadKind(inv) !== null,
|
|
12527
|
+
unavailableLabel: "No invoice",
|
|
12528
|
+
title: invoiceDownloadKind(inv) === null ? INVOICE_NOT_AVAILABLE_MESSAGE : void 0,
|
|
12263
12529
|
onClick: (e) => handleRowClick(e, inv)
|
|
12264
12530
|
},
|
|
12265
12531
|
inv._id
|
|
@@ -12663,6 +12929,7 @@ function BillingContent({
|
|
|
12663
12929
|
);
|
|
12664
12930
|
const [availableCredits, setAvailableCredits] = (0, import_react24.useState)(null);
|
|
12665
12931
|
const [sharedPool, setSharedPool] = (0, import_react24.useState)(null);
|
|
12932
|
+
const [sponsorShare, setSponsorShare] = (0, import_react24.useState)(null);
|
|
12666
12933
|
const [usedByNames, setUsedByNames] = (0, import_react24.useState)({});
|
|
12667
12934
|
const [allProducts, setProducts] = (0, import_react24.useState)([]);
|
|
12668
12935
|
const workspaceCountry = workspace.current?.country;
|
|
@@ -12753,6 +13020,7 @@ function BillingContent({
|
|
|
12753
13020
|
if (creditsRes?.availableCredits != null)
|
|
12754
13021
|
setAvailableCredits(creditsRes.availableCredits);
|
|
12755
13022
|
setSharedPool(creditsRes?.sharedPool ?? null);
|
|
13023
|
+
setSponsorShare(creditsRes?.sponsorShare ?? null);
|
|
12756
13024
|
if (productsRes?.data) setProducts(productsRes.data);
|
|
12757
13025
|
if (customRes?.data?.credits != null) {
|
|
12758
13026
|
setCustomPlanCredits(customRes.data.credits);
|
|
@@ -13041,7 +13309,7 @@ function BillingContent({
|
|
|
13041
13309
|
remaining: remainingCredits,
|
|
13042
13310
|
progressPct,
|
|
13043
13311
|
remainingPct
|
|
13044
|
-
} = creditsMeter({ availableCredits, totalCredits, sharedPool });
|
|
13312
|
+
} = creditsMeter({ availableCredits, totalCredits, sharedPool, sponsorShare });
|
|
13045
13313
|
const usageText = usedCredits != null ? formatCredits2(usedCredits) : remainingCredits != null ? `${formatCredits2(remainingCredits)} available` : customPlanCredits != null ? `${formatCredits2(customPlanCredits)} credits` : "\u2014";
|
|
13046
13314
|
const handleExport = async (startDate, endDate) => {
|
|
13047
13315
|
const end = new Date(endDate);
|
|
@@ -13049,7 +13317,7 @@ function BillingContent({
|
|
|
13049
13317
|
if (activeTab === "invoice") {
|
|
13050
13318
|
const filtered = invoices.filter((inv) => {
|
|
13051
13319
|
const d = new Date(inv.createdAt);
|
|
13052
|
-
return d >= startDate && d <= end;
|
|
13320
|
+
return d >= startDate && d <= end && invoiceDownloadKind(inv) === "invoice";
|
|
13053
13321
|
});
|
|
13054
13322
|
if (filtered.length === 0) {
|
|
13055
13323
|
toast.info?.("No invoices found in the selected date range.");
|
|
@@ -13454,6 +13722,49 @@ function BillingContent({
|
|
|
13454
13722
|
]
|
|
13455
13723
|
}
|
|
13456
13724
|
)
|
|
13725
|
+
) : sponsorShare ? (
|
|
13726
|
+
// A sponsor keeping only a share of its credits: what is left of it.
|
|
13727
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
13728
|
+
"div",
|
|
13729
|
+
{
|
|
13730
|
+
role: "status",
|
|
13731
|
+
className: "flex flex-col shrink-0 w-full",
|
|
13732
|
+
style: {
|
|
13733
|
+
gap: 4,
|
|
13734
|
+
padding: 16,
|
|
13735
|
+
backgroundColor: "var(--alias-surface-base)",
|
|
13736
|
+
border: "1px solid var(--alias-border-subtle)",
|
|
13737
|
+
borderRadius: "var(--radius-3xl)"
|
|
13738
|
+
},
|
|
13739
|
+
children: [
|
|
13740
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
13741
|
+
"span",
|
|
13742
|
+
{
|
|
13743
|
+
style: {
|
|
13744
|
+
fontFamily: "var(--font-family-font-family-body)",
|
|
13745
|
+
fontSize: "var(--font-size-font-size-sm)",
|
|
13746
|
+
fontWeight: 500,
|
|
13747
|
+
lineHeight: "var(--line-height-line-height-sm)",
|
|
13748
|
+
color: sponsorShare.remaining <= 0 ? "var(--alias-text---icons-warning)" : "var(--alias-text---icons-primary)"
|
|
13749
|
+
},
|
|
13750
|
+
children: sponsorShareBannerText(sponsorShare)
|
|
13751
|
+
}
|
|
13752
|
+
),
|
|
13753
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
13754
|
+
"span",
|
|
13755
|
+
{
|
|
13756
|
+
style: {
|
|
13757
|
+
fontFamily: "var(--font-family-font-family-body)",
|
|
13758
|
+
fontSize: "var(--font-size-font-size-sm)",
|
|
13759
|
+
lineHeight: "var(--line-height-line-height-sm)",
|
|
13760
|
+
color: "var(--alias-text---icons-muted)"
|
|
13761
|
+
},
|
|
13762
|
+
children: sponsorShareDetailText()
|
|
13763
|
+
}
|
|
13764
|
+
)
|
|
13765
|
+
]
|
|
13766
|
+
}
|
|
13767
|
+
)
|
|
13457
13768
|
) : null,
|
|
13458
13769
|
usage ? /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
13459
13770
|
"div",
|