@burdenoff/microfe-billing 2026.1113.2 → 2026.1113.3
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/billing/BillingRoot.js +83 -77
- package/dist/billing/BillingRoot.js.map +1 -1
- package/dist/billing/modules/addons/pages/AddonBrowseDetailPage.js +78 -78
- package/dist/billing/modules/addons/pages/AddonCreatePage.js +70 -70
- package/dist/billing/modules/addons/pages/AddonDetailPage.js +72 -72
- package/dist/billing/modules/addons/pages/AddonEditPage.js +79 -79
- package/dist/billing/modules/addons/pages/AddonsBrowsePage.js +224 -224
- package/dist/billing/modules/addons/pages/AddonsListPage.js +186 -186
- package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js +168 -168
- package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js.map +1 -1
- package/dist/billing/modules/analytics/pages/AnalyticsPage.js +88 -88
- package/dist/billing/modules/billing/hooks/index.js +5 -5
- package/dist/billing/modules/billing/hooks/useInvoices.js +39 -20
- package/dist/billing/modules/billing/hooks/useInvoices.js.map +1 -1
- package/dist/billing/modules/billing/index.js +14 -14
- package/dist/billing/modules/billing/pages/BillingWebhookLogsPage.js +92 -92
- package/dist/billing/modules/billing/pages/InvoiceDetailPage.js +160 -160
- package/dist/billing/modules/billing/pages/InvoiceDetailPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/InvoicesListPage.js +100 -100
- package/dist/billing/modules/billing/pages/OrderCallbackLogsPage.js +105 -105
- package/dist/billing/modules/billing/pages/PaymentMethodsPage.js +37 -37
- package/dist/billing/modules/billing/pages/RefundIssueLogsPage.js +41 -41
- package/dist/billing/modules/billing/pages/RefundsPage.js +334 -334
- package/dist/billing/modules/billing/pages/RefundsPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/TransactionsPage.js +174 -174
- package/dist/billing/modules/billing/pages/TransactionsPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/UserRefundsPage.js +24 -24
- package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -1
- package/dist/billing/modules/checkout/components/OrderSummary.js +71 -71
- package/dist/billing/modules/checkout/pages/CheckoutPage.js +646 -625
- package/dist/billing/modules/checkout/pages/CheckoutPage.js.map +1 -1
- package/dist/billing/modules/checkout/utils/checkoutOptions.d.ts +23 -0
- package/dist/billing/modules/checkout/utils/checkoutOptions.js +8 -0
- package/dist/billing/modules/checkout/utils/checkoutOptions.js.map +1 -0
- package/dist/billing/modules/coupons/pages/CouponDetailPage.js +112 -112
- package/dist/billing/modules/coupons/pages/CouponsListPage.js +118 -118
- package/dist/billing/modules/coupons/pages/CouponsListPage.js.map +1 -1
- package/dist/billing/modules/coupons/pages/CreateCouponPage.js +119 -119
- package/dist/billing/modules/coupons/pages/EditCouponPage.js +82 -82
- package/dist/billing/modules/credits/pages/AdminCreditsPage.js +30 -30
- package/dist/billing/modules/credits/pages/CreditTransactionsPage.js +77 -77
- package/dist/billing/modules/credits/pages/CreditWithdrawalPage.js +144 -144
- package/dist/billing/modules/credits/pages/CreditsPage.js +67 -67
- package/dist/billing/modules/dashboard/pages/OverviewPage.js +594 -442
- package/dist/billing/modules/dashboard/pages/OverviewPage.js.map +1 -1
- package/dist/billing/modules/dashboard/utils/overviewSummary.d.ts +46 -0
- package/dist/billing/modules/dashboard/utils/overviewSummary.js +37 -0
- package/dist/billing/modules/dashboard/utils/overviewSummary.js.map +1 -0
- package/dist/billing/modules/discounts/pages/DiscountsListPage.js +199 -199
- package/dist/billing/modules/discounts/pages/DiscountsListPage.js.map +1 -1
- package/dist/billing/modules/earnings/pages/DeveloperRevenueAdminPage.js +64 -64
- package/dist/billing/modules/earnings/pages/DeveloperRevenueOrgDetailPage.js +122 -122
- package/dist/billing/modules/earnings/pages/DeveloperRevenueOrgDetailPage.js.map +1 -1
- package/dist/billing/modules/earnings/pages/EarningsPage.js +102 -102
- package/dist/billing/modules/earnings/pages/EarningsPage.js.map +1 -1
- package/dist/billing/modules/earnings/pages/PayoutAdminPage.js +178 -178
- package/dist/billing/modules/earnings/pages/PayoutAdminPage.js.map +1 -1
- package/dist/billing/modules/earnings/pages/PayoutsPage.js +107 -107
- package/dist/billing/modules/earnings/pages/PayoutsPage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlanAssignFreePage.js +54 -54
- package/dist/billing/modules/plans/pages/PlanBrowseDetailPage.js +94 -94
- package/dist/billing/modules/plans/pages/PlanCreatePage.js +73 -73
- package/dist/billing/modules/plans/pages/PlanDetailPage.js +96 -96
- package/dist/billing/modules/plans/pages/PlanEditPage.js +16 -16
- package/dist/billing/modules/plans/pages/PlanEditPage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlansBrowsePage.js +100 -100
- package/dist/billing/modules/plans/pages/PlansListPage.js +88 -88
- package/dist/billing/modules/promotions/pages/CreatePromotionPage.js +60 -60
- package/dist/billing/modules/promotions/pages/PromotionsListPage.js +37 -37
- package/dist/billing/modules/quota/pages/QuotaAssignFreePage.js +62 -62
- package/dist/billing/modules/quota/pages/QuotaPage.js +1 -1
- package/dist/billing/modules/quota/pages/QuotaTemplateCreatePage.js +69 -69
- package/dist/billing/modules/quota/pages/QuotaTemplateDetailPage.js +76 -76
- package/dist/billing/modules/quota/pages/QuotaTemplateEditPage.js +80 -80
- package/dist/billing/modules/quota/pages/QuotaTemplatesListPage.js +95 -95
- package/dist/billing/modules/settings/pages/SettingsPage.js +134 -134
- package/dist/billing/modules/settings/pages/SettingsPage.js.map +1 -1
- package/dist/billing/modules/settings/pages/TeamPermissionsPage.js +62 -62
- package/dist/billing/modules/settings/pages/TeamPermissionsPage.js.map +1 -1
- package/dist/billing/modules/subscriptions/components/ManageSeatsModal.js +36 -36
- package/dist/billing/modules/subscriptions/pages/SubscriptionDetailPage.js +534 -410
- package/dist/billing/modules/subscriptions/pages/SubscriptionDetailPage.js.map +1 -1
- package/dist/billing/modules/subscriptions/pages/SubscriptionsListPage.js +111 -111
- package/dist/billing/modules/subscriptions/pages/UpgradeSubscriptionPage.js +166 -160
- package/dist/billing/modules/subscriptions/pages/UpgradeSubscriptionPage.js.map +1 -1
- package/dist/billing/modules/subscriptions/utils/subscriptionDetailView.d.ts +30 -0
- package/dist/billing/modules/subscriptions/utils/subscriptionDetailView.js +20 -0
- package/dist/billing/modules/subscriptions/utils/subscriptionDetailView.js.map +1 -0
- package/dist/billing/modules/subscriptions/utils/upgradeAccess.d.ts +10 -0
- package/dist/billing/modules/subscriptions/utils/upgradeAccess.js +7 -0
- package/dist/billing/modules/subscriptions/utils/upgradeAccess.js.map +1 -0
- package/dist/billing/modules/usage/pages/UsagePage.js +722 -591
- package/dist/billing/modules/usage/pages/UsagePage.js.map +1 -1
- package/dist/billing/modules/usage/utils/usageHealth.d.ts +63 -0
- package/dist/billing/modules/usage/utils/usageHealth.js +43 -0
- package/dist/billing/modules/usage/utils/usageHealth.js.map +1 -0
- package/dist/billing/shared/components/EmptyState.js +3 -3
- package/dist/billing/shared/components/MoneyActionDialog.js +12 -12
- package/dist/billing/shared/ui/MetricCard.js +13 -13
- package/dist/billing/shared/utils/format.js +16 -4
- package/dist/billing/shared/utils/format.js.map +1 -1
- package/dist/billing/shared/utils/index.js +8 -8
- package/dist/generated/global-operations.js +294 -286
- package/dist/generated/global-operations.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for the FluidGrids "Plan health" summary (BOFF-11860).
|
|
3
|
+
* No React, no I/O: percent, threshold, scoping and label logic live here so
|
|
4
|
+
* they can be unit tested.
|
|
5
|
+
*/
|
|
6
|
+
/** A quota at or above this percentage is "warning". */
|
|
7
|
+
export declare const WARNING_THRESHOLD_PERCENT = 80;
|
|
8
|
+
/** A quota at or above this percentage is "at limit" (critical). */
|
|
9
|
+
export declare const CRITICAL_THRESHOLD_PERCENT = 100;
|
|
10
|
+
export type HealthLevel = 'ok' | 'warning' | 'critical';
|
|
11
|
+
export interface HealthQuotaInput {
|
|
12
|
+
/** Machine key, e.g. `ai.credits.monthly`. Never shown at level 1. */
|
|
13
|
+
key: string;
|
|
14
|
+
/** Optional display name supplied by the backend. */
|
|
15
|
+
displayName?: string | null;
|
|
16
|
+
used: number;
|
|
17
|
+
limit: number | null | undefined;
|
|
18
|
+
noLimit: boolean;
|
|
19
|
+
/** Product ids of every assignment behind this quota (may be empty). */
|
|
20
|
+
productIds?: readonly string[];
|
|
21
|
+
/** Quota modes of every assignment behind this quota (may be empty). */
|
|
22
|
+
quotaModes?: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
export interface HealthQuota {
|
|
25
|
+
key: string;
|
|
26
|
+
label: string;
|
|
27
|
+
used: number;
|
|
28
|
+
limit: number;
|
|
29
|
+
/** Raw (unclamped) percentage, may exceed 100. */
|
|
30
|
+
percent: number;
|
|
31
|
+
level: HealthLevel;
|
|
32
|
+
}
|
|
33
|
+
export interface HealthSummary {
|
|
34
|
+
/** Mean of the per-quota percentages (each capped at 100); null if nothing is limited. */
|
|
35
|
+
overallPercent: number | null;
|
|
36
|
+
level: HealthLevel;
|
|
37
|
+
/** Limited quotas considered for the summary. */
|
|
38
|
+
limitedCount: number;
|
|
39
|
+
/** Quotas with no limit; they are never part of the percentage. */
|
|
40
|
+
unlimitedCount: number;
|
|
41
|
+
/** Warning and critical quotas, worst first. */
|
|
42
|
+
attention: HealthQuota[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Percentage of the limit used. Returns null when there is nothing to measure:
|
|
46
|
+
* unlimited quotas and zero/negative/missing limits.
|
|
47
|
+
*/
|
|
48
|
+
export declare function quotaPercent(used: number, limit: number | null | undefined, noLimit: boolean): number | null;
|
|
49
|
+
export declare function healthLevelForPercent(percent: number): HealthLevel;
|
|
50
|
+
/**
|
|
51
|
+
* Whether a quota belongs in the FluidGrids summary. The page has no explicit
|
|
52
|
+
* "owning app" field, so the rule uses what it does have:
|
|
53
|
+
* - key starts with `fluidgrids.` / `fluidgrid.` -> FluidGrids
|
|
54
|
+
* - any assignment product id contains `fluidgrids` -> FluidGrids
|
|
55
|
+
* - any assignment is `pooled` (shared across all products) -> included
|
|
56
|
+
* - no product id at all (cannot tell) -> included
|
|
57
|
+
* - otherwise (dedicated quota of another product) -> hidden
|
|
58
|
+
*/
|
|
59
|
+
export declare function isFluidgridsQuota(input: Pick<HealthQuotaInput, 'key' | 'productIds' | 'quotaModes'>): boolean;
|
|
60
|
+
/** Plain label for a machine key: `ai.credits.monthly` -> `Credits Monthly`. */
|
|
61
|
+
export declare function plainQuotaLabel(key: string, displayName?: string | null): string;
|
|
62
|
+
/** Builds the summary from FluidGrids quotas only. */
|
|
63
|
+
export declare function summarizeHealth(inputs: readonly HealthQuotaInput[]): HealthSummary;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function e(e, t, n) {
|
|
2
|
+
return n || t == null || !Number.isFinite(t) || t <= 0 ? null : !Number.isFinite(e) || e < 0 ? 0 : e / t * 100;
|
|
3
|
+
}
|
|
4
|
+
function t(e) {
|
|
5
|
+
return e >= 100 ? "critical" : e >= 80 ? "warning" : "ok";
|
|
6
|
+
}
|
|
7
|
+
function n(e) {
|
|
8
|
+
let t = e.key.trim().toLowerCase();
|
|
9
|
+
if (t.startsWith("fluidgrids.") || t.startsWith("fluidgrid.")) return !0;
|
|
10
|
+
let n = (e.productIds ?? []).map((e) => e.trim().toLowerCase()).filter(Boolean);
|
|
11
|
+
return n.some((e) => e.includes("fluidgrids")) || (e.quotaModes ?? []).some((e) => e.toLowerCase() === "pooled") ? !0 : n.length === 0;
|
|
12
|
+
}
|
|
13
|
+
function r(e, t) {
|
|
14
|
+
let n = t?.trim();
|
|
15
|
+
if (n) return n;
|
|
16
|
+
let r = e.split(".").filter(Boolean);
|
|
17
|
+
return (r.length > 1 ? r.slice(1) : r).map((e) => e.replace(/[_-]+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase())).filter(Boolean).join(" ") || e;
|
|
18
|
+
}
|
|
19
|
+
function i(i) {
|
|
20
|
+
let a = i.filter(n), o = [], s = 0;
|
|
21
|
+
for (let n of a) {
|
|
22
|
+
let i = e(n.used, n.limit, n.noLimit);
|
|
23
|
+
i === null ? s += 1 : o.push({
|
|
24
|
+
key: n.key,
|
|
25
|
+
label: r(n.key, n.displayName),
|
|
26
|
+
used: n.used,
|
|
27
|
+
limit: n.limit ?? 0,
|
|
28
|
+
percent: i,
|
|
29
|
+
level: t(i)
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
let c = o.length === 0 ? null : o.reduce((e, t) => e + Math.min(100, t.percent), 0) / o.length, l = o.filter((e) => e.level !== "ok").sort((e, t) => t.percent - e.percent || e.label.localeCompare(t.label));
|
|
33
|
+
return {
|
|
34
|
+
overallPercent: c,
|
|
35
|
+
level: l.some((e) => e.level === "critical") ? "critical" : l.length > 0 ? "warning" : "ok",
|
|
36
|
+
limitedCount: o.length,
|
|
37
|
+
unlimitedCount: s,
|
|
38
|
+
attention: l
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export { t as healthLevelForPercent, n as isFluidgridsQuota, r as plainQuotaLabel, e as quotaPercent, i as summarizeHealth };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=usageHealth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usageHealth.js","names":["quotaPercent","noLimit","limit","used","healthLevelForPercent","percent","isFluidgridsQuota","key","input","productIds","p","m","plainQuotaLabel","given","displayName","parts","c","summarizeHealth","scoped","inputs","limited","unlimitedCount","q","overallPercent","sum","attention","b","a"],"sources":["../../../../../src/billing/modules/usage/utils/usageHealth.ts"],"sourcesContent":["/**\n * Pure helpers for the FluidGrids \"Plan health\" summary (BOFF-11860).\n * No React, no I/O: percent, threshold, scoping and label logic live here so\n * they can be unit tested.\n */\n\n/** A quota at or above this percentage is \"warning\". */\nexport const WARNING_THRESHOLD_PERCENT = 80;\n/** A quota at or above this percentage is \"at limit\" (critical). */\nexport const CRITICAL_THRESHOLD_PERCENT = 100;\n\nexport type HealthLevel = 'ok' | 'warning' | 'critical';\n\nexport interface HealthQuotaInput {\n /** Machine key, e.g. `ai.credits.monthly`. Never shown at level 1. */\n key: string;\n /** Optional display name supplied by the backend. */\n displayName?: string | null;\n used: number;\n limit: number | null | undefined;\n noLimit: boolean;\n /** Product ids of every assignment behind this quota (may be empty). */\n productIds?: readonly string[];\n /** Quota modes of every assignment behind this quota (may be empty). */\n quotaModes?: readonly string[];\n}\n\nexport interface HealthQuota {\n key: string;\n label: string;\n used: number;\n limit: number;\n /** Raw (unclamped) percentage, may exceed 100. */\n percent: number;\n level: HealthLevel;\n}\n\nexport interface HealthSummary {\n /** Mean of the per-quota percentages (each capped at 100); null if nothing is limited. */\n overallPercent: number | null;\n level: HealthLevel;\n /** Limited quotas considered for the summary. */\n limitedCount: number;\n /** Quotas with no limit; they are never part of the percentage. */\n unlimitedCount: number;\n /** Warning and critical quotas, worst first. */\n attention: HealthQuota[];\n}\n\n/**\n * Percentage of the limit used. Returns null when there is nothing to measure:\n * unlimited quotas and zero/negative/missing limits.\n */\nexport function quotaPercent(\n used: number,\n limit: number | null | undefined,\n noLimit: boolean\n): number | null {\n if (noLimit) return null;\n if (limit == null || !Number.isFinite(limit) || limit <= 0) return null;\n if (!Number.isFinite(used) || used < 0) return 0;\n return (used / limit) * 100;\n}\n\nexport function healthLevelForPercent(percent: number): HealthLevel {\n if (percent >= CRITICAL_THRESHOLD_PERCENT) return 'critical';\n if (percent >= WARNING_THRESHOLD_PERCENT) return 'warning';\n return 'ok';\n}\n\n/**\n * Whether a quota belongs in the FluidGrids summary. The page has no explicit\n * \"owning app\" field, so the rule uses what it does have:\n * - key starts with `fluidgrids.` / `fluidgrid.` -> FluidGrids\n * - any assignment product id contains `fluidgrids` -> FluidGrids\n * - any assignment is `pooled` (shared across all products) -> included\n * - no product id at all (cannot tell) -> included\n * - otherwise (dedicated quota of another product) -> hidden\n */\nexport function isFluidgridsQuota(\n input: Pick<HealthQuotaInput, 'key' | 'productIds' | 'quotaModes'>\n): boolean {\n const key = input.key.trim().toLowerCase();\n if (key.startsWith('fluidgrids.') || key.startsWith('fluidgrid.')) return true;\n const productIds = (input.productIds ?? []).map((p) => p.trim().toLowerCase()).filter(Boolean);\n if (productIds.some((p) => p.includes('fluidgrids'))) return true;\n if ((input.quotaModes ?? []).some((m) => m.toLowerCase() === 'pooled')) return true;\n return productIds.length === 0;\n}\n\n/** Plain label for a machine key: `ai.credits.monthly` -> `Credits Monthly`. */\nexport function plainQuotaLabel(key: string, displayName?: string | null): string {\n const given = displayName?.trim();\n if (given) return given;\n const parts = key.split('.').filter(Boolean);\n const meaningful = parts.length > 1 ? parts.slice(1) : parts;\n const label = meaningful\n .map((p) =>\n p\n .replace(/[_-]+/g, ' ')\n .trim()\n .replace(/\\b\\w/g, (c) => c.toUpperCase())\n )\n .filter(Boolean)\n .join(' ');\n return label || key;\n}\n\n/** Builds the summary from FluidGrids quotas only. */\nexport function summarizeHealth(inputs: readonly HealthQuotaInput[]): HealthSummary {\n const scoped = inputs.filter(isFluidgridsQuota);\n const limited: HealthQuota[] = [];\n let unlimitedCount = 0;\n for (const q of scoped) {\n const percent = quotaPercent(q.used, q.limit, q.noLimit);\n if (percent === null) {\n unlimitedCount += 1;\n continue;\n }\n limited.push({\n key: q.key,\n label: plainQuotaLabel(q.key, q.displayName),\n used: q.used,\n limit: q.limit ?? 0,\n percent,\n level: healthLevelForPercent(percent),\n });\n }\n const overallPercent =\n limited.length === 0\n ? null\n : limited.reduce((sum, q) => sum + Math.min(100, q.percent), 0) / limited.length;\n const attention = limited\n .filter((q) => q.level !== 'ok')\n .sort((a, b) => b.percent - a.percent || a.label.localeCompare(b.label));\n const level: HealthLevel = attention.some((q) => q.level === 'critical')\n ? 'critical'\n : attention.length > 0\n ? 'warning'\n : 'ok';\n return { overallPercent, level, limitedCount: limited.length, unlimitedCount, attention };\n}\n"],"mappings":"AAqDA,SAAgBA,EACd,GACA,GACA,GACe;CAIf,OAHIC,KACAC,KAAS,QAAQ,CAAC,OAAO,SAASA,CAAK,KAAKA,KAAS,IAAU,OAC/D,CAAC,OAAO,SAASC,CAAI,KAAKA,IAAO,IAAU,IACvCA,IAAOD,IAAS;AAC1B;AAEA,SAAgBE,EAAsB,GAA8B;CAGlE,OAFIC,KAAA,MAA8C,aAC9CA,KAAA,KAA6C,YAC1C;AACT;AAWA,SAAgBC,EACd,GACS;CACT,IAAMC,IAAMC,EAAM,IAAI,KAAK,CAAC,CAAC,YAAY;CACzC,IAAID,EAAI,WAAW,aAAa,KAAKA,EAAI,WAAW,YAAY,GAAG,OAAO;CAC1E,IAAME,KAAcD,EAAM,cAAc,CAAC,EAAA,CAAG,KAAK,MAAME,EAAE,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,OAAO;CAG7F,OAFID,EAAW,MAAM,MAAMC,EAAE,SAAS,YAAY,CAAC,MAC9CF,EAAM,cAAc,CAAC,EAAA,CAAG,MAAM,MAAMG,EAAE,YAAY,MAAM,QAAQ,IAAU,KACxEF,EAAW,WAAW;AAC/B;AAGA,SAAgBG,EAAgB,GAAa,GAAqC;CAChF,IAAMC,IAAQC,GAAa,KAAK;CAChC,IAAID,GAAO,OAAOA;CAClB,IAAME,IAAQR,EAAI,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO;CAW3C,QAVmBQ,EAAM,SAAS,IAAIA,EAAM,MAAM,CAAC,IAAIA,EAAA,CAEpD,KAAK,MACJL,EACG,QAAQ,UAAU,GAAG,CAAC,CACtB,KAAK,CAAC,CACN,QAAQ,UAAU,MAAMM,EAAE,YAAY,CAAC,CAC5C,CAAC,CACA,OAAO,OAAO,CAAC,CACf,KAAK,GACD,KAAST;AAClB;AAGA,SAAgBU,EAAgB,GAAoD;CAClF,IAAMC,IAASC,EAAO,OAAOb,CAAiB,GACxCc,IAAyB,CAAC,GAC5BC,IAAiB;CACrB,KAAK,IAAMC,KAAKJ,GAAQ;EACtB,IAAMb,IAAUL,EAAasB,EAAE,MAAMA,EAAE,OAAOA,EAAE,OAAO;EACvD,AAAIjB,MAAY,OACd,KAAkB,IAGpBe,EAAQ,KAAK;GACX,KAAKE,EAAE;GACP,OAAOV,EAAgBU,EAAE,KAAKA,EAAE,WAAW;GAC3C,MAAMA,EAAE;GACR,OAAOA,EAAE,SAAS;GAClB;GACA,OAAOlB,EAAsBC,CAAO;EACtC,CAAC;CACH;CACA,IAAMkB,IACJH,EAAQ,WAAW,IACf,OACAA,EAAQ,QAAQ,GAAK,MAAMI,IAAM,KAAK,IAAI,KAAKF,EAAE,OAAO,GAAG,CAAC,IAAIF,EAAQ,QACxEK,IAAYL,EACf,QAAQ,MAAME,EAAE,UAAU,IAAI,CAAC,CAC/B,MAAM,GAAG,MAAMI,EAAE,UAAUC,EAAE,WAAWA,EAAE,MAAM,cAAcD,EAAE,KAAK,CAAC;CAMzE,OAAO;EAAE;EAAgB,OALED,EAAU,MAAM,MAAMH,EAAE,UAAU,UAAU,IACnE,aACAG,EAAU,SAAS,IACjB,YACA;EAC0B,cAAcL,EAAQ;EAAQ;EAAgB;CAAU;AAC1F"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { EmptyState as e } from "@burdenoff/fe-libs/ui";
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
3
|
// src/billing/shared/components/EmptyState.tsx
|
|
4
|
-
var n = ({ icon: n, title: r, description: i, action: a }) => /* @__PURE__ */ e
|
|
4
|
+
var n = ({ icon: n, title: r, description: i, action: a }) => /* @__PURE__ */ t(e, {
|
|
5
5
|
icon: n,
|
|
6
6
|
title: r,
|
|
7
7
|
description: i,
|
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
import { useTr as e } from "../hooks/useTr.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ResponsiveDialog as t, ResponsiveDialogContent as n, ResponsiveDialogDescription as r, ResponsiveDialogFooter as i, ResponsiveDialogHeader as a, ResponsiveDialogTitle as o } from "@burdenoff/fe-libs/ui";
|
|
3
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
4
4
|
// src/billing/shared/components/MoneyActionDialog.tsx
|
|
5
5
|
var l = ({ open: l, title: u, description: d, details: f, confirmLabel: p, busyLabel: m, isBusy: h, error: g, tone: _ = "primary", onConfirm: v, onCancel: y }) => {
|
|
6
6
|
let b = e(), x = _ === "danger" ? "bg-action-danger-bg text-action-primary-text hover:bg-action-danger-bgHover" : "bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bgHover";
|
|
7
|
-
return /* @__PURE__ */ t
|
|
7
|
+
return /* @__PURE__ */ s(t, {
|
|
8
8
|
open: l,
|
|
9
9
|
onOpenChange: (e) => {
|
|
10
10
|
!e && !h && y();
|
|
11
11
|
},
|
|
12
|
-
children: /* @__PURE__ */ n
|
|
12
|
+
children: /* @__PURE__ */ c(n, {
|
|
13
13
|
className: "sm:max-w-md",
|
|
14
14
|
children: [
|
|
15
|
-
/* @__PURE__ */
|
|
16
|
-
/* @__PURE__ */
|
|
15
|
+
/* @__PURE__ */ c(a, { children: [/* @__PURE__ */ s(o, { children: u }), d ? /* @__PURE__ */ s(r, { children: d }) : null] }),
|
|
16
|
+
/* @__PURE__ */ s("dl", {
|
|
17
17
|
className: "divide-y divide-border-subtle rounded-card border border-border-subtle",
|
|
18
|
-
children: f.map((e) => /* @__PURE__ */
|
|
18
|
+
children: f.map((e) => /* @__PURE__ */ c("div", {
|
|
19
19
|
className: "flex items-baseline justify-between gap-4 p-3",
|
|
20
|
-
children: [/* @__PURE__ */
|
|
20
|
+
children: [/* @__PURE__ */ s("dt", {
|
|
21
21
|
className: "text-sm text-text-secondary",
|
|
22
22
|
children: e.label
|
|
23
|
-
}), /* @__PURE__ */
|
|
23
|
+
}), /* @__PURE__ */ s("dd", {
|
|
24
24
|
className: "text-right text-sm font-medium text-text-primary",
|
|
25
25
|
children: e.value
|
|
26
26
|
})]
|
|
27
27
|
}, e.label))
|
|
28
28
|
}),
|
|
29
|
-
g ? /* @__PURE__ */
|
|
29
|
+
g ? /* @__PURE__ */ s("p", {
|
|
30
30
|
role: "alert",
|
|
31
31
|
className: "text-sm text-status-error-text",
|
|
32
32
|
children: g
|
|
33
33
|
}) : null,
|
|
34
|
-
/* @__PURE__ */
|
|
34
|
+
/* @__PURE__ */ c(i, { children: [/* @__PURE__ */ s("button", {
|
|
35
35
|
type: "button",
|
|
36
36
|
onClick: y,
|
|
37
37
|
disabled: h,
|
|
38
38
|
className: "rounded-button border border-border-subtle px-4 py-2 text-sm font-medium text-text-primary hover:bg-bg-sunken disabled:opacity-50",
|
|
39
39
|
children: b("billing.common.cancel", "Cancel")
|
|
40
|
-
}), /* @__PURE__ */
|
|
40
|
+
}), /* @__PURE__ */ s("button", {
|
|
41
41
|
type: "button",
|
|
42
42
|
onClick: v,
|
|
43
43
|
disabled: h,
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { GlassCard as e } from "@burdenoff/fe-libs/ui";
|
|
2
|
+
import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
3
|
+
import { cn as i } from "@burdenoff/fe-libs/shared/utils";
|
|
4
4
|
// src/billing/shared/ui/MetricCard.tsx
|
|
5
5
|
function a({ label: a, value: o, icon: s, trend: c, onClick: l, isActive: u = !1, className: d, ...f }) {
|
|
6
|
-
let p =
|
|
7
|
-
/* @__PURE__ */
|
|
6
|
+
let p = i("p-5 text-left", l && "w-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)]", u && "ring-1 ring-[var(--color-focus-ring)] border-border-strong", d), m = /* @__PURE__ */ r(t, { children: [
|
|
7
|
+
/* @__PURE__ */ r("div", {
|
|
8
8
|
className: "flex items-start justify-between gap-3",
|
|
9
|
-
children: [/* @__PURE__ */
|
|
9
|
+
children: [/* @__PURE__ */ n("p", {
|
|
10
10
|
className: "text-sm text-text-secondary",
|
|
11
11
|
children: a
|
|
12
|
-
}), s && /* @__PURE__ */
|
|
12
|
+
}), s && /* @__PURE__ */ n("span", {
|
|
13
13
|
className: "flex size-9 shrink-0 items-center justify-center rounded-lg bg-[var(--color-accent-soft)] text-text-primary",
|
|
14
14
|
children: s
|
|
15
15
|
})]
|
|
16
16
|
}),
|
|
17
|
-
/* @__PURE__ */
|
|
17
|
+
/* @__PURE__ */ n("p", {
|
|
18
18
|
className: "mt-2 text-2xl font-semibold tabular-nums text-text-primary",
|
|
19
19
|
children: o
|
|
20
20
|
}),
|
|
21
|
-
c && /* @__PURE__ */
|
|
22
|
-
className:
|
|
21
|
+
c && /* @__PURE__ */ r("p", {
|
|
22
|
+
className: i("mt-1 text-xs font-medium tabular-nums", c.isPositive ? "text-status-success-text" : "text-status-error-text"),
|
|
23
23
|
children: [
|
|
24
24
|
c.isPositive ? "+" : "",
|
|
25
25
|
c.value,
|
|
@@ -27,7 +27,7 @@ function a({ label: a, value: o, icon: s, trend: c, onClick: l, isActive: u = !1
|
|
|
27
27
|
]
|
|
28
28
|
})
|
|
29
29
|
] });
|
|
30
|
-
return l ? /* @__PURE__ */
|
|
30
|
+
return l ? /* @__PURE__ */ n(e, {
|
|
31
31
|
treatment: "metric",
|
|
32
32
|
role: "button",
|
|
33
33
|
tabIndex: 0,
|
|
@@ -35,10 +35,10 @@ function a({ label: a, value: o, icon: s, trend: c, onClick: l, isActive: u = !1
|
|
|
35
35
|
onKeyDown: (e) => {
|
|
36
36
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), l());
|
|
37
37
|
},
|
|
38
|
-
className:
|
|
38
|
+
className: i(p, "cursor-pointer"),
|
|
39
39
|
...f,
|
|
40
40
|
children: m
|
|
41
|
-
}) : /* @__PURE__ */
|
|
41
|
+
}) : /* @__PURE__ */ n(e, {
|
|
42
42
|
treatment: "metric",
|
|
43
43
|
className: p,
|
|
44
44
|
...f,
|
|
@@ -39,7 +39,19 @@ function _(e) {
|
|
|
39
39
|
[n.YEARLY]: "Yearly"
|
|
40
40
|
}[e] || e;
|
|
41
41
|
}
|
|
42
|
-
function v(t) {
|
|
42
|
+
function v(e, t, n) {
|
|
43
|
+
return `${f(e, t)}/${g(n)}`;
|
|
44
|
+
}
|
|
45
|
+
function y(e) {
|
|
46
|
+
return e ? e.charAt(0).toUpperCase() + e.slice(1).toLowerCase() : "Card";
|
|
47
|
+
}
|
|
48
|
+
function b(e) {
|
|
49
|
+
return e ? `•••• ${e}` : "****";
|
|
50
|
+
}
|
|
51
|
+
function x(e, t) {
|
|
52
|
+
return !e || !t ? "" : `${e.toString().padStart(2, "0")}/${t.toString().slice(-2)}`;
|
|
53
|
+
}
|
|
54
|
+
function S(t) {
|
|
43
55
|
return {
|
|
44
56
|
[e.PURCHASE]: "Purchase",
|
|
45
57
|
[e.USAGE]: "Usage",
|
|
@@ -47,12 +59,12 @@ function v(t) {
|
|
|
47
59
|
[e.GRANTED]: "Granted"
|
|
48
60
|
}[t] || t;
|
|
49
61
|
}
|
|
50
|
-
function
|
|
62
|
+
function C(e) {
|
|
51
63
|
return `#${e}`;
|
|
52
64
|
}
|
|
53
|
-
function
|
|
65
|
+
function w(e, t) {
|
|
54
66
|
return t === "bytes" ? i(e) : e.toLocaleString();
|
|
55
67
|
}
|
|
56
|
-
export { a as formatBytes,
|
|
68
|
+
export { a as formatBytes, y as formatCardBrand, x as formatCardExpiry, b as formatCardNumber, S as formatCreditTransactionType, p as formatCredits, f as formatCurrency, s as formatDate, c as formatDateTime, C as formatInvoiceNumber, h as formatInvoiceStatus, l as formatNumber, u as formatPercentage, g as formatPlanDuration, _ as formatPlanDurationLabel, v as formatPlanPrice, w as formatQuotaValue, d as formatRelativeTime, m as formatSubscriptionStatus };
|
|
57
69
|
|
|
58
70
|
//# sourceMappingURL=format.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","names":["formatCurrency","formatCurrencyBase","formatBytes$1","formatCurrency$1","currency","formatCredits","amount","formatCurrency","locale","formatSubscriptionStatus","SubscriptionStatus","status","formatInvoiceStatus","InvoiceStatus","formatPlanDuration","PlanDuration","duration","formatPlanDurationLabel","formatCreditTransactionType","CreditTransactionType","type","formatInvoiceNumber","number","formatQuotaValue","unit","formatBytes","value","formatDate","formatDateTime","formatNumber","formatPercentage","formatRelativeTime"],"sources":["../../../../src/billing/shared/utils/format.ts"],"sourcesContent":["/**\n * Formatting utilities for the billing module\n *\n * Re-exports common formatting utilities from fe-libs and adds billing-specific ones.\n */\n\nimport {\n SubscriptionStatus,\n InvoiceStatus,\n PaymentStatus,\n ChargeStatus,\n QuotaStatus,\n PlanDuration,\n PaymentMethodType,\n TransactionType,\n CreditTransactionType,\n} from '../types';\n\n// Re-export common formatting utilities from fe-libs\nexport {\n formatCurrency as formatCurrencyBase,\n formatCurrencyCompact as formatCurrencyCompactBase,\n formatDate,\n formatDateTime,\n formatRelativeTime,\n formatDuration,\n formatNumber,\n formatPercentage,\n formatBytes,\n formatCompactNumber,\n} from '@burdenoff/fe-libs/shared/utils';\n\n// Import for internal use\nimport {\n formatCurrency as formatCurrencyBase,\n formatCurrencyCompact as formatCurrencyCompactBase,\n formatBytes,\n} from '@burdenoff/fe-libs/shared/utils';\n\n// ============================================================================\n// Billing-specific Currency Formatting (handles CREDITS)\n// ============================================================================\n\nexport function formatCurrency(amount: number, currency = 'USD', locale = 'en-US'): string {\n // Handle CREDITS specially - credits are not a real currency\n if (currency.toUpperCase() === 'CREDITS') {\n return formatCredits(amount);\n }\n return formatCurrencyBase(amount, currency, locale);\n}\n\n/**\n * Format credits as \"X Credits\" or \"X.XX Credits\"\n * Credits are always displayed as a unit count, not as currency\n */\nexport function formatCredits(amount: number): string {\n // For whole numbers, show without decimals\n if (Number.isInteger(amount)) {\n return `${amount.toLocaleString()} Credits`;\n }\n // For fractional credits, show up to 2 decimals\n return `${amount.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 })} Credits`;\n}\n\nexport function formatCurrencyCompact(amount: number, currency = 'USD'): string {\n if (currency.toUpperCase() === 'CREDITS') {\n return formatCredits(amount);\n }\n return formatCurrencyCompactBase(amount, currency);\n}\n\n// ============================================================================\n// Status Formatting\n// ============================================================================\n\nexport function formatSubscriptionStatus(status: SubscriptionStatus): string {\n const labels: Record<SubscriptionStatus, string> = {\n [SubscriptionStatus.ACTIVE]: 'Active',\n [SubscriptionStatus.CANCELED]: 'Canceled',\n [SubscriptionStatus.EXPIRED]: 'Expired',\n [SubscriptionStatus.UPGRADED]: 'Upgraded',\n };\n return labels[status] || status;\n}\n\nexport function formatInvoiceStatus(status: InvoiceStatus): string {\n const labels: Record<InvoiceStatus, string> = {\n [InvoiceStatus.DRAFT]: 'Draft',\n [InvoiceStatus.OPEN]: 'Open',\n [InvoiceStatus.PAID]: 'Paid',\n [InvoiceStatus.VOID]: 'Void',\n [InvoiceStatus.UNCOLLECTIBLE]: 'Uncollectible',\n };\n return labels[status] || status;\n}\n\nexport function formatPaymentStatus(status: PaymentStatus): string {\n const labels: Record<PaymentStatus, string> = {\n [PaymentStatus.PENDING]: 'Pending',\n [PaymentStatus.SUCCEEDED]: 'Succeeded',\n [PaymentStatus.FAILED]: 'Failed',\n [PaymentStatus.CANCELED]: 'Canceled',\n [PaymentStatus.REFUNDED]: 'Refunded',\n };\n return labels[status] || status;\n}\n\nexport function formatChargeStatus(status: ChargeStatus): string {\n const labels: Record<ChargeStatus, string> = {\n [ChargeStatus.PENDING]: 'Pending',\n [ChargeStatus.SUCCEEDED]: 'Succeeded',\n [ChargeStatus.FAILED]: 'Failed',\n [ChargeStatus.REFUNDED]: 'Refunded',\n };\n return labels[status] || status;\n}\n\nexport function formatQuotaStatus(status: QuotaStatus): string {\n const labels: Record<QuotaStatus, string> = {\n [QuotaStatus.HEALTHY]: 'Healthy',\n [QuotaStatus.WARNING]: 'Warning',\n [QuotaStatus.CRITICAL]: 'Critical',\n [QuotaStatus.EXHAUSTED]: 'Exhausted',\n [QuotaStatus.INACTIVE]: 'Inactive',\n };\n return labels[status] || status;\n}\n\n// ============================================================================\n// Plan & Duration Formatting\n// ============================================================================\n\nexport function formatPlanDuration(duration: PlanDuration): string {\n const labels: Record<PlanDuration, string> = {\n [PlanDuration.MONTHLY]: 'month',\n [PlanDuration.YEARLY]: 'year',\n };\n return labels[duration] || duration;\n}\n\nexport function formatPlanDurationLabel(duration: PlanDuration): string {\n const labels: Record<PlanDuration, string> = {\n [PlanDuration.MONTHLY]: 'Monthly',\n [PlanDuration.YEARLY]: 'Yearly',\n };\n return labels[duration] || duration;\n}\n\nexport function formatPlanPrice(price: number, currency: string, duration: PlanDuration): string {\n return `${formatCurrency(price, currency)}/${formatPlanDuration(duration)}`;\n}\n\n// ============================================================================\n// Payment Method Formatting\n// ============================================================================\n\nexport function formatPaymentMethodType(type: PaymentMethodType): string {\n const labels: Record<PaymentMethodType, string> = {\n [PaymentMethodType.CREDIT_CARD]: 'Credit Card',\n [PaymentMethodType.DEBIT_CARD]: 'Debit Card',\n [PaymentMethodType.BANK_TRANSFER]: 'Bank Transfer',\n [PaymentMethodType.PAYPAL]: 'PayPal',\n [PaymentMethodType.CRYPTO]: 'Cryptocurrency',\n [PaymentMethodType.WALLET]: 'Wallet',\n [PaymentMethodType.NETBANKING]: 'Netbanking',\n };\n return labels[type] || type;\n}\n\nexport function formatCardBrand(brand?: string): string {\n if (!brand) return 'Card';\n return brand.charAt(0).toUpperCase() + brand.slice(1).toLowerCase();\n}\n\nexport function formatCardNumber(last4?: string): string {\n if (!last4) return '****';\n return `•••• ${last4}`;\n}\n\nexport function formatCardExpiry(month?: number, year?: number): string {\n if (!month || !year) return '';\n return `${month.toString().padStart(2, '0')}/${year.toString().slice(-2)}`;\n}\n\n// ============================================================================\n// Transaction Formatting\n// ============================================================================\n\nexport function formatTransactionType(type: TransactionType): string {\n const labels: Record<TransactionType, string> = {\n [TransactionType.PAYMENT]: 'Payment',\n [TransactionType.REFUND]: 'Refund',\n [TransactionType.ADJUSTMENT]: 'Adjustment',\n };\n return labels[type] || type;\n}\n\nexport function formatCreditTransactionType(type: CreditTransactionType): string {\n const labels: Record<CreditTransactionType, string> = {\n [CreditTransactionType.PURCHASE]: 'Purchase',\n [CreditTransactionType.USAGE]: 'Usage',\n [CreditTransactionType.ADJUSTMENT]: 'Earned',\n [CreditTransactionType.GRANTED]: 'Granted',\n };\n return labels[type] || type;\n}\n\n// ============================================================================\n// Text Formatting\n// ============================================================================\n\nexport function truncateText(text: string, maxLength: number): string {\n if (text.length <= maxLength) return text;\n return `${text.slice(0, maxLength - 3)}...`;\n}\n\nexport function capitalizeFirst(text: string): string {\n if (!text) return '';\n return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();\n}\n\nexport function formatInvoiceNumber(number: string): string {\n return `#${number}`;\n}\n\n// ============================================================================\n// Quota Value Formatting\n// ============================================================================\n\n/**\n * Format a quota's total value for display, unit-aware. Byte-denominated\n * quotas (storage, upload caps) render as MB/GB via formatBytes instead of a\n * raw byte count — everything else falls back to a plain localized number.\n */\nexport function formatQuotaValue(value: number, unit?: string): string {\n if (unit === 'bytes') return formatBytes(value);\n return value.toLocaleString();\n}\n"],"mappings":";;;AA2CA,SAAgBA,EAAe,GAAgB,IAAW,OAAO,IAAS,SAAiB;CAKzF,OAHII,EAAS,YAAY,MAAM,YACtBC,EAAcC,CAAM,IAEtBL,EAAmBK,GAAQF,GAAUI,CAAM;AACpD;AAMA,SAAgBH,EAAc,GAAwB;CAMpD,OAJI,OAAO,UAAUC,CAAM,IAClB,GAAGA,EAAO,eAAe,EAAE,YAG7B,GAAGA,EAAO,eAAe,KAAA,GAAW;EAAE,uBAAuB;EAAG,uBAAuB;CAAE,CAAC,EAAE;AACrG;AAaA,SAAgBG,EAAyB,GAAoC;CAO3E,OAAO;GALJC,EAAmB,SAAS;GAC5BA,EAAmB,WAAW;GAC9BA,EAAmB,UAAU;GAC7BA,EAAmB,WAAW;CAE1B,EAAOC,MAAWA;AAC3B;AAEA,SAAgBC,EAAoB,GAA+B;CAQjE,OAAO;GANJC,EAAc,QAAQ;GACtBA,EAAc,OAAO;GACrBA,EAAc,OAAO;GACrBA,EAAc,OAAO;GACrBA,EAAc,gBAAgB;CAE1B,EAAOF,MAAWA;AAC3B;AAsCA,SAAgBG,EAAmB,GAAgC;CAKjE,OAAO;GAHJC,EAAa,UAAU;GACvBA,EAAa,SAAS;CAElB,EAAOC,MAAaA;AAC7B;AAEA,SAAgBC,EAAwB,GAAgC;CAKtE,OAAO;GAHJF,EAAa,UAAU;GACvBA,EAAa,SAAS;CAElB,EAAOC,MAAaA;AAC7B;AAmDA,SAAgBE,EAA4B,GAAqC;CAO/E,OAAO;GALJC,EAAsB,WAAW;GACjCA,EAAsB,QAAQ;GAC9BA,EAAsB,aAAa;GACnCA,EAAsB,UAAU;CAE5B,EAAOC,MAASA;AACzB;AAgBA,SAAgBC,EAAoB,GAAwB;CAC1D,OAAO,IAAIC;AACb;AAWA,SAAgBC,EAAiB,GAAe,GAAuB;CAErE,OADIC,MAAS,UAAgBC,EAAYC,CAAK,IACvCA,EAAM,eAAe;AAC9B"}
|
|
1
|
+
{"version":3,"file":"format.js","names":["formatCurrency","formatCurrencyBase","formatBytes$1","formatCurrency$1","currency","formatCredits","amount","formatCurrency","locale","formatSubscriptionStatus","SubscriptionStatus","status","formatInvoiceStatus","InvoiceStatus","formatPlanDuration","PlanDuration","duration","formatPlanDurationLabel","formatPlanPrice","price","formatCardBrand","brand","formatCardNumber","last4","formatCardExpiry","month","year","formatCreditTransactionType","CreditTransactionType","type","formatInvoiceNumber","number","formatQuotaValue","unit","formatBytes","value","formatDate","formatDateTime","formatNumber","formatPercentage","formatRelativeTime"],"sources":["../../../../src/billing/shared/utils/format.ts"],"sourcesContent":["/**\n * Formatting utilities for the billing module\n *\n * Re-exports common formatting utilities from fe-libs and adds billing-specific ones.\n */\n\nimport {\n SubscriptionStatus,\n InvoiceStatus,\n PaymentStatus,\n ChargeStatus,\n QuotaStatus,\n PlanDuration,\n PaymentMethodType,\n TransactionType,\n CreditTransactionType,\n} from '../types';\n\n// Re-export common formatting utilities from fe-libs\nexport {\n formatCurrency as formatCurrencyBase,\n formatCurrencyCompact as formatCurrencyCompactBase,\n formatDate,\n formatDateTime,\n formatRelativeTime,\n formatDuration,\n formatNumber,\n formatPercentage,\n formatBytes,\n formatCompactNumber,\n} from '@burdenoff/fe-libs/shared/utils';\n\n// Import for internal use\nimport {\n formatCurrency as formatCurrencyBase,\n formatCurrencyCompact as formatCurrencyCompactBase,\n formatBytes,\n} from '@burdenoff/fe-libs/shared/utils';\n\n// ============================================================================\n// Billing-specific Currency Formatting (handles CREDITS)\n// ============================================================================\n\nexport function formatCurrency(amount: number, currency = 'USD', locale = 'en-US'): string {\n // Handle CREDITS specially - credits are not a real currency\n if (currency.toUpperCase() === 'CREDITS') {\n return formatCredits(amount);\n }\n return formatCurrencyBase(amount, currency, locale);\n}\n\n/**\n * Format credits as \"X Credits\" or \"X.XX Credits\"\n * Credits are always displayed as a unit count, not as currency\n */\nexport function formatCredits(amount: number): string {\n // For whole numbers, show without decimals\n if (Number.isInteger(amount)) {\n return `${amount.toLocaleString()} Credits`;\n }\n // For fractional credits, show up to 2 decimals\n return `${amount.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 })} Credits`;\n}\n\nexport function formatCurrencyCompact(amount: number, currency = 'USD'): string {\n if (currency.toUpperCase() === 'CREDITS') {\n return formatCredits(amount);\n }\n return formatCurrencyCompactBase(amount, currency);\n}\n\n// ============================================================================\n// Status Formatting\n// ============================================================================\n\nexport function formatSubscriptionStatus(status: SubscriptionStatus): string {\n const labels: Record<SubscriptionStatus, string> = {\n [SubscriptionStatus.ACTIVE]: 'Active',\n [SubscriptionStatus.CANCELED]: 'Canceled',\n [SubscriptionStatus.EXPIRED]: 'Expired',\n [SubscriptionStatus.UPGRADED]: 'Upgraded',\n };\n return labels[status] || status;\n}\n\nexport function formatInvoiceStatus(status: InvoiceStatus): string {\n const labels: Record<InvoiceStatus, string> = {\n [InvoiceStatus.DRAFT]: 'Draft',\n [InvoiceStatus.OPEN]: 'Open',\n [InvoiceStatus.PAID]: 'Paid',\n [InvoiceStatus.VOID]: 'Void',\n [InvoiceStatus.UNCOLLECTIBLE]: 'Uncollectible',\n };\n return labels[status] || status;\n}\n\nexport function formatPaymentStatus(status: PaymentStatus): string {\n const labels: Record<PaymentStatus, string> = {\n [PaymentStatus.PENDING]: 'Pending',\n [PaymentStatus.SUCCEEDED]: 'Succeeded',\n [PaymentStatus.FAILED]: 'Failed',\n [PaymentStatus.CANCELED]: 'Canceled',\n [PaymentStatus.REFUNDED]: 'Refunded',\n };\n return labels[status] || status;\n}\n\nexport function formatChargeStatus(status: ChargeStatus): string {\n const labels: Record<ChargeStatus, string> = {\n [ChargeStatus.PENDING]: 'Pending',\n [ChargeStatus.SUCCEEDED]: 'Succeeded',\n [ChargeStatus.FAILED]: 'Failed',\n [ChargeStatus.REFUNDED]: 'Refunded',\n };\n return labels[status] || status;\n}\n\nexport function formatQuotaStatus(status: QuotaStatus): string {\n const labels: Record<QuotaStatus, string> = {\n [QuotaStatus.HEALTHY]: 'Healthy',\n [QuotaStatus.WARNING]: 'Warning',\n [QuotaStatus.CRITICAL]: 'Critical',\n [QuotaStatus.EXHAUSTED]: 'Exhausted',\n [QuotaStatus.INACTIVE]: 'Inactive',\n };\n return labels[status] || status;\n}\n\n// ============================================================================\n// Plan & Duration Formatting\n// ============================================================================\n\nexport function formatPlanDuration(duration: PlanDuration): string {\n const labels: Record<PlanDuration, string> = {\n [PlanDuration.MONTHLY]: 'month',\n [PlanDuration.YEARLY]: 'year',\n };\n return labels[duration] || duration;\n}\n\nexport function formatPlanDurationLabel(duration: PlanDuration): string {\n const labels: Record<PlanDuration, string> = {\n [PlanDuration.MONTHLY]: 'Monthly',\n [PlanDuration.YEARLY]: 'Yearly',\n };\n return labels[duration] || duration;\n}\n\nexport function formatPlanPrice(price: number, currency: string, duration: PlanDuration): string {\n return `${formatCurrency(price, currency)}/${formatPlanDuration(duration)}`;\n}\n\n// ============================================================================\n// Payment Method Formatting\n// ============================================================================\n\nexport function formatPaymentMethodType(type: PaymentMethodType): string {\n const labels: Record<PaymentMethodType, string> = {\n [PaymentMethodType.CREDIT_CARD]: 'Credit Card',\n [PaymentMethodType.DEBIT_CARD]: 'Debit Card',\n [PaymentMethodType.BANK_TRANSFER]: 'Bank Transfer',\n [PaymentMethodType.PAYPAL]: 'PayPal',\n [PaymentMethodType.CRYPTO]: 'Cryptocurrency',\n [PaymentMethodType.WALLET]: 'Wallet',\n [PaymentMethodType.NETBANKING]: 'Netbanking',\n };\n return labels[type] || type;\n}\n\nexport function formatCardBrand(brand?: string): string {\n if (!brand) return 'Card';\n return brand.charAt(0).toUpperCase() + brand.slice(1).toLowerCase();\n}\n\nexport function formatCardNumber(last4?: string): string {\n if (!last4) return '****';\n return `•••• ${last4}`;\n}\n\nexport function formatCardExpiry(month?: number, year?: number): string {\n if (!month || !year) return '';\n return `${month.toString().padStart(2, '0')}/${year.toString().slice(-2)}`;\n}\n\n// ============================================================================\n// Transaction Formatting\n// ============================================================================\n\nexport function formatTransactionType(type: TransactionType): string {\n const labels: Record<TransactionType, string> = {\n [TransactionType.PAYMENT]: 'Payment',\n [TransactionType.REFUND]: 'Refund',\n [TransactionType.ADJUSTMENT]: 'Adjustment',\n };\n return labels[type] || type;\n}\n\nexport function formatCreditTransactionType(type: CreditTransactionType): string {\n const labels: Record<CreditTransactionType, string> = {\n [CreditTransactionType.PURCHASE]: 'Purchase',\n [CreditTransactionType.USAGE]: 'Usage',\n [CreditTransactionType.ADJUSTMENT]: 'Earned',\n [CreditTransactionType.GRANTED]: 'Granted',\n };\n return labels[type] || type;\n}\n\n// ============================================================================\n// Text Formatting\n// ============================================================================\n\nexport function truncateText(text: string, maxLength: number): string {\n if (text.length <= maxLength) return text;\n return `${text.slice(0, maxLength - 3)}...`;\n}\n\nexport function capitalizeFirst(text: string): string {\n if (!text) return '';\n return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase();\n}\n\nexport function formatInvoiceNumber(number: string): string {\n return `#${number}`;\n}\n\n// ============================================================================\n// Quota Value Formatting\n// ============================================================================\n\n/**\n * Format a quota's total value for display, unit-aware. Byte-denominated\n * quotas (storage, upload caps) render as MB/GB via formatBytes instead of a\n * raw byte count — everything else falls back to a plain localized number.\n */\nexport function formatQuotaValue(value: number, unit?: string): string {\n if (unit === 'bytes') return formatBytes(value);\n return value.toLocaleString();\n}\n"],"mappings":";;;AA2CA,SAAgBA,EAAe,GAAgB,IAAW,OAAO,IAAS,SAAiB;CAKzF,OAHII,EAAS,YAAY,MAAM,YACtBC,EAAcC,CAAM,IAEtBL,EAAmBK,GAAQF,GAAUI,CAAM;AACpD;AAMA,SAAgBH,EAAc,GAAwB;CAMpD,OAJI,OAAO,UAAUC,CAAM,IAClB,GAAGA,EAAO,eAAe,EAAE,YAG7B,GAAGA,EAAO,eAAe,KAAA,GAAW;EAAE,uBAAuB;EAAG,uBAAuB;CAAE,CAAC,EAAE;AACrG;AAaA,SAAgBG,EAAyB,GAAoC;CAO3E,OAAO;GALJC,EAAmB,SAAS;GAC5BA,EAAmB,WAAW;GAC9BA,EAAmB,UAAU;GAC7BA,EAAmB,WAAW;CAE1B,EAAOC,MAAWA;AAC3B;AAEA,SAAgBC,EAAoB,GAA+B;CAQjE,OAAO;GANJC,EAAc,QAAQ;GACtBA,EAAc,OAAO;GACrBA,EAAc,OAAO;GACrBA,EAAc,OAAO;GACrBA,EAAc,gBAAgB;CAE1B,EAAOF,MAAWA;AAC3B;AAsCA,SAAgBG,EAAmB,GAAgC;CAKjE,OAAO;GAHJC,EAAa,UAAU;GACvBA,EAAa,SAAS;CAElB,EAAOC,MAAaA;AAC7B;AAEA,SAAgBC,EAAwB,GAAgC;CAKtE,OAAO;GAHJF,EAAa,UAAU;GACvBA,EAAa,SAAS;CAElB,EAAOC,MAAaA;AAC7B;AAEA,SAAgBE,EAAgB,GAAe,GAAkB,GAAgC;CAC/F,OAAO,GAAGlB,EAAemB,GAAOf,CAAQ,EAAE,GAAGU,EAAmBE,CAAQ;AAC1E;AAmBA,SAAgBI,EAAgB,GAAwB;CAEtD,OADKC,IACEA,EAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAIA,EAAM,MAAM,CAAC,CAAC,CAAC,YAAY,IAD/C;AAErB;AAEA,SAAgBC,EAAiB,GAAwB;CAEvD,OADKC,IACE,QAAQA,MADI;AAErB;AAEA,SAAgBC,EAAiB,GAAgB,GAAuB;CAEtE,OADI,CAACC,KAAS,CAACC,IAAa,KACrB,GAAGD,EAAM,SAAS,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAGC,EAAK,SAAS,CAAC,CAAC,MAAM,EAAE;AACzE;AAeA,SAAgBC,EAA4B,GAAqC;CAO/E,OAAO;GALJC,EAAsB,WAAW;GACjCA,EAAsB,QAAQ;GAC9BA,EAAsB,aAAa;GACnCA,EAAsB,UAAU;CAE5B,EAAOC,MAASA;AACzB;AAgBA,SAAgBC,EAAoB,GAAwB;CAC1D,OAAO,IAAIC;AACb;AAWA,SAAgBC,EAAiB,GAAe,GAAuB;CAErE,OADIC,MAAS,UAAgBC,EAAYC,CAAK,IACvCA,EAAM,eAAe;AAC9B"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { alertTokens as e, categoryTokens as t, getProgressTokens as n, getStatusBadgeTokens as r, getStatusTokens as i, progressTokens as a, statusTokens as o } from "./tokens.js";
|
|
2
|
-
import { formatBytes as s,
|
|
3
|
-
import { getCreditTransactionStatusColor as
|
|
4
|
-
import { isServerError as
|
|
5
|
-
import { getPaymentProviderThemeColor as
|
|
6
|
-
import { directBillingGraphqlRequest as
|
|
2
|
+
import { formatBytes as s, formatCardBrand as c, formatCardExpiry as l, formatCardNumber as u, formatCreditTransactionType as d, formatCredits as f, formatCurrency as p, formatDate as m, formatDateTime as h, formatInvoiceNumber as g, formatInvoiceStatus as _, formatNumber as v, formatPercentage as y, formatPlanDuration as b, formatPlanDurationLabel as x, formatPlanPrice as S, formatQuotaValue as C, formatRelativeTime as w, formatSubscriptionStatus as T } from "./format.js";
|
|
3
|
+
import { getCreditTransactionStatusColor as E, getInvoiceStatusColor as D, getQuotaProgressColor as O, getStatusBadgeClasses as k, getSubscriptionStatusColor as A, getTransactionStatusColor as j } from "./status.js";
|
|
4
|
+
import { isServerError as M } from "./error.js";
|
|
5
|
+
import { getPaymentProviderThemeColor as N, getPaymentThemePalette as P, getStripeCardElementStyle as F } from "./paymentTheme.js";
|
|
6
|
+
import { directBillingGraphqlRequest as I, resolveDirectBillingGraphqlUrl as L } from "./directBillingGraphql.js";
|
|
7
7
|
import "./directActivityGraphql.js";
|
|
8
|
-
import { gatewayGraphqlRequest as
|
|
9
|
-
import { getPlanFeatureQuantity as
|
|
10
|
-
export { e as alertTokens, t as categoryTokens,
|
|
8
|
+
import { gatewayGraphqlRequest as R, normalizeGlobalGatewayBaseUrl as z, toGraphqlQuery as B } from "./gatewayGraphql.js";
|
|
9
|
+
import { getPlanFeatureQuantity as V, getPlanFeatureUnit as H, getQuotaDisplayName as U, humanizeQuotaName as W } from "./planFeatureQuantity.js";
|
|
10
|
+
export { e as alertTokens, t as categoryTokens, I as directBillingGraphqlRequest, s as formatBytes, c as formatCardBrand, l as formatCardExpiry, u as formatCardNumber, d as formatCreditTransactionType, f as formatCredits, p as formatCurrency, m as formatDate, h as formatDateTime, g as formatInvoiceNumber, _ as formatInvoiceStatus, v as formatNumber, y as formatPercentage, b as formatPlanDuration, x as formatPlanDurationLabel, S as formatPlanPrice, C as formatQuotaValue, w as formatRelativeTime, T as formatSubscriptionStatus, R as gatewayGraphqlRequest, E as getCreditTransactionStatusColor, D as getInvoiceStatusColor, N as getPaymentProviderThemeColor, P as getPaymentThemePalette, V as getPlanFeatureQuantity, H as getPlanFeatureUnit, n as getProgressTokens, U as getQuotaDisplayName, O as getQuotaProgressColor, k as getStatusBadgeClasses, r as getStatusBadgeTokens, i as getStatusTokens, F as getStripeCardElementStyle, A as getSubscriptionStatusColor, j as getTransactionStatusColor, W as humanizeQuotaName, M as isServerError, z as normalizeGlobalGatewayBaseUrl, a as progressTokens, L as resolveDirectBillingGraphqlUrl, o as statusTokens, B as toGraphqlQuery };
|