@burdenoff/microfe-billing 2026.1116.1 → 2026.1119.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/billing/modules/addons/pages/AddonCreatePage.js +143 -143
- package/dist/billing/modules/addons/pages/AddonCreatePage.js.map +1 -1
- package/dist/billing/modules/addons/pages/AddonEditPage.js +170 -170
- package/dist/billing/modules/addons/pages/AddonEditPage.js.map +1 -1
- package/dist/billing/modules/analytics/pages/AnalyticsPage.js +148 -148
- package/dist/billing/modules/analytics/pages/AnalyticsPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/BillingWebhookLogsPage.js +115 -115
- package/dist/billing/modules/billing/pages/BillingWebhookLogsPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/InvoicesListPage.js +136 -136
- package/dist/billing/modules/billing/pages/InvoicesListPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/OrderCallbackLogsPage.js +129 -129
- package/dist/billing/modules/billing/pages/OrderCallbackLogsPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/RefundsPage.js +325 -325
- package/dist/billing/modules/billing/pages/RefundsPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/UserRefundsPage.js +149 -149
- package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -1
- package/dist/billing/modules/checkout/components/CompleteBillingAccountModal.js +99 -98
- package/dist/billing/modules/checkout/components/CompleteBillingAccountModal.js.map +1 -1
- package/dist/billing/modules/checkout/components/StoreShippingSection.js +125 -124
- package/dist/billing/modules/checkout/components/StoreShippingSection.js.map +1 -1
- package/dist/billing/modules/checkout/components/WorkspaceQuotaAssignmentModal.js +61 -60
- package/dist/billing/modules/checkout/components/WorkspaceQuotaAssignmentModal.js.map +1 -1
- package/dist/billing/modules/coupons/pages/CouponsListPage.js +177 -177
- package/dist/billing/modules/coupons/pages/CouponsListPage.js.map +1 -1
- package/dist/billing/modules/coupons/pages/CreateCouponPage.js +231 -231
- package/dist/billing/modules/coupons/pages/CreateCouponPage.js.map +1 -1
- package/dist/billing/modules/coupons/pages/EditCouponPage.js +139 -139
- package/dist/billing/modules/coupons/pages/EditCouponPage.js.map +1 -1
- package/dist/billing/modules/credits/pages/AdminCreditsPage.js +54 -54
- package/dist/billing/modules/credits/pages/AdminCreditsPage.js.map +1 -1
- package/dist/billing/modules/credits/pages/CreditWithdrawalPage.js +65 -65
- package/dist/billing/modules/credits/pages/CreditWithdrawalPage.js.map +1 -1
- package/dist/billing/modules/credits/pages/CreditsPage.js +95 -95
- package/dist/billing/modules/credits/pages/CreditsPage.js.map +1 -1
- package/dist/billing/modules/dashboard/components/CreateBillingAccountModal.js +232 -231
- package/dist/billing/modules/dashboard/components/CreateBillingAccountModal.js.map +1 -1
- package/dist/billing/modules/discounts/pages/DiscountsListPage.js +328 -328
- package/dist/billing/modules/discounts/pages/DiscountsListPage.js.map +1 -1
- package/dist/billing/modules/earnings/pages/DeveloperRevenueOrgDetailPage.js +57 -57
- package/dist/billing/modules/earnings/pages/DeveloperRevenueOrgDetailPage.js.map +1 -1
- package/dist/billing/modules/earnings/pages/EarningsPage.js +53 -53
- package/dist/billing/modules/earnings/pages/EarningsPage.js.map +1 -1
- package/dist/billing/modules/earnings/pages/PayoutsPage.js +100 -100
- package/dist/billing/modules/earnings/pages/PayoutsPage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlanCreatePage.js +150 -150
- package/dist/billing/modules/plans/pages/PlanCreatePage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlanEditPage.js +125 -125
- package/dist/billing/modules/plans/pages/PlanEditPage.js.map +1 -1
- package/dist/billing/modules/quota/pages/QuotaTemplateCreatePage.js +113 -113
- package/dist/billing/modules/quota/pages/QuotaTemplateCreatePage.js.map +1 -1
- package/dist/billing/modules/quota/pages/QuotaTemplateEditPage.js +132 -132
- package/dist/billing/modules/quota/pages/QuotaTemplateEditPage.js.map +1 -1
- package/dist/billing/modules/settings/pages/SettingsPage.js +101 -101
- package/dist/billing/modules/settings/pages/SettingsPage.js.map +1 -1
- package/dist/billing/modules/settings/pages/TeamPermissionsPage.js +125 -125
- package/dist/billing/modules/settings/pages/TeamPermissionsPage.js.map +1 -1
- package/dist/billing/modules/usage/components/WorkspaceAiSpendPanel.js +51 -50
- package/dist/billing/modules/usage/components/WorkspaceAiSpendPanel.js.map +1 -1
- package/dist/billing/modules/usage/pages/UsagePage.js +107 -107
- package/dist/billing/modules/usage/pages/UsagePage.js.map +1 -1
- package/dist/billing/shared/components/GeoPricingOverridesEditor.js +1 -0
- package/package.json +2 -2
|
@@ -9,37 +9,37 @@ import { getCreditTransactionStatusColor as c, getStatusBadgeClasses as l } from
|
|
|
9
9
|
import { useBillingAccount as u, useDefaultBillingAccount as d } from "../../subscriptions/hooks/useSubscriptions.js";
|
|
10
10
|
import { statusTokens as f } from "../../../shared/utils/tokens.js";
|
|
11
11
|
import { useMemo as p, useState as m } from "react";
|
|
12
|
-
import { EmphasisPanel as h, IllustratedEmptyState as g, PagePurpose as _ } from "@burdenoff/fe-libs/ui";
|
|
13
|
-
import { useSearchParams as
|
|
14
|
-
import { jsx as
|
|
15
|
-
import { useI18n as
|
|
12
|
+
import { EmphasisPanel as h, IllustratedEmptyState as g, PagePurpose as _, ThemedSelect as v } from "@burdenoff/fe-libs/ui";
|
|
13
|
+
import { useSearchParams as y } from "react-router";
|
|
14
|
+
import { jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
15
|
+
import { useI18n as S } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
16
16
|
// src/billing/modules/credits/pages/CreditsPage.tsx
|
|
17
|
-
var
|
|
18
|
-
let { t: o } =
|
|
17
|
+
var C = () => {
|
|
18
|
+
let { t: o } = S(), s = (e, t) => {
|
|
19
19
|
let n = o(e);
|
|
20
20
|
return n === e ? t : n;
|
|
21
|
-
}, c = e(), l = r(), f = i(),
|
|
21
|
+
}, c = e(), l = r(), f = i(), C = !f, { billingAccount: T, isLoading: E } = d(), [D] = y(), [O, k] = m(D.get("billingAccountId")), { data: A } = n({
|
|
22
22
|
fetchPolicy: "cache-first",
|
|
23
23
|
skip: !f
|
|
24
|
-
}),
|
|
25
|
-
billingAccountId:
|
|
26
|
-
days:
|
|
27
|
-
page:
|
|
24
|
+
}), j = p(() => f ? A?.getBillingAccountsByOrg ?? [] : [], [f, A]), M = f && O !== null && O !== T?.id, { billingAccount: N, isLoading: P } = u(M ? O : void 0), F = M ? N : T, I = M ? P : E, L = M ? O : T?.id ?? "", [R, z] = m(30), [B, V] = m("all"), [H, U] = m(1), { transactions: W, pagination: G, isLoading: K, error: q, refetch: J } = t({
|
|
25
|
+
billingAccountId: F?.id || "",
|
|
26
|
+
days: R,
|
|
27
|
+
page: H,
|
|
28
28
|
pageSize: 20
|
|
29
29
|
});
|
|
30
|
-
if (!l.canViewCredits) return /* @__PURE__ */
|
|
30
|
+
if (!l.canViewCredits) return /* @__PURE__ */ b("div", {
|
|
31
31
|
className: "flex items-center justify-center h-full min-h-[400px]",
|
|
32
|
-
children: /* @__PURE__ */
|
|
32
|
+
children: /* @__PURE__ */ x("div", {
|
|
33
33
|
className: "text-center space-y-2",
|
|
34
34
|
children: [
|
|
35
|
-
/* @__PURE__ */
|
|
35
|
+
/* @__PURE__ */ b("div", {
|
|
36
36
|
className: "size-12 mx-auto rounded-full bg-bg-sunken flex items-center justify-center",
|
|
37
|
-
children: /* @__PURE__ */
|
|
37
|
+
children: /* @__PURE__ */ b("svg", {
|
|
38
38
|
className: "size-6 text-text-secondary",
|
|
39
39
|
fill: "none",
|
|
40
40
|
viewBox: "0 0 24 24",
|
|
41
41
|
stroke: "currentColor",
|
|
42
|
-
children: /* @__PURE__ */
|
|
42
|
+
children: /* @__PURE__ */ b("path", {
|
|
43
43
|
strokeLinecap: "round",
|
|
44
44
|
strokeLinejoin: "round",
|
|
45
45
|
strokeWidth: 2,
|
|
@@ -47,41 +47,41 @@ var S = () => {
|
|
|
47
47
|
})
|
|
48
48
|
})
|
|
49
49
|
}),
|
|
50
|
-
/* @__PURE__ */
|
|
50
|
+
/* @__PURE__ */ b("h2", {
|
|
51
51
|
className: "text-lg font-semibold text-text-primary",
|
|
52
52
|
children: "Access Denied"
|
|
53
53
|
}),
|
|
54
|
-
/* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ b("p", {
|
|
55
55
|
className: "text-sm text-text-secondary max-w-sm",
|
|
56
56
|
children: "You don't have permission to view credits."
|
|
57
57
|
})
|
|
58
58
|
]
|
|
59
59
|
})
|
|
60
60
|
});
|
|
61
|
-
let
|
|
62
|
-
if (
|
|
61
|
+
let Y = I || K, X = W.filter((e) => B === "all" || e.type === B);
|
|
62
|
+
if (Y && !F) return /* @__PURE__ */ x("div", {
|
|
63
63
|
className: "space-y-6 px-6 lg:px-8 py-6",
|
|
64
|
-
children: [/* @__PURE__ */
|
|
64
|
+
children: [/* @__PURE__ */ b("div", { className: "h-8 w-48 bg-bg-sunken animate-pulse rounded" }), /* @__PURE__ */ b("div", {
|
|
65
65
|
className: "grid grid-cols-1 sm:grid-cols-2 gap-4",
|
|
66
|
-
children: /* @__PURE__ */
|
|
66
|
+
children: /* @__PURE__ */ x("div", {
|
|
67
67
|
className: "border border-border-subtle rounded-lg p-6",
|
|
68
|
-
children: [/* @__PURE__ */
|
|
68
|
+
children: [/* @__PURE__ */ b("div", { className: "h-6 w-24 bg-bg-sunken animate-pulse rounded mb-2" }), /* @__PURE__ */ b("div", { className: "h-10 w-32 bg-bg-sunken animate-pulse rounded" })]
|
|
69
69
|
})
|
|
70
70
|
})]
|
|
71
71
|
});
|
|
72
|
-
if (
|
|
72
|
+
if (q) return /* @__PURE__ */ b("div", {
|
|
73
73
|
className: "flex items-center justify-center h-full min-h-[400px]",
|
|
74
|
-
children: /* @__PURE__ */
|
|
74
|
+
children: /* @__PURE__ */ x("div", {
|
|
75
75
|
className: "text-center space-y-4",
|
|
76
76
|
children: [
|
|
77
|
-
/* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ b("div", {
|
|
78
78
|
className: "size-12 mx-auto rounded-full bg-status-error-bg-subtle flex items-center justify-center",
|
|
79
|
-
children: /* @__PURE__ */
|
|
79
|
+
children: /* @__PURE__ */ b("svg", {
|
|
80
80
|
className: "size-6 text-status-error-text",
|
|
81
81
|
fill: "none",
|
|
82
82
|
viewBox: "0 0 24 24",
|
|
83
83
|
stroke: "currentColor",
|
|
84
|
-
children: /* @__PURE__ */
|
|
84
|
+
children: /* @__PURE__ */ b("path", {
|
|
85
85
|
strokeLinecap: "round",
|
|
86
86
|
strokeLinejoin: "round",
|
|
87
87
|
strokeWidth: 2,
|
|
@@ -89,73 +89,73 @@ var S = () => {
|
|
|
89
89
|
})
|
|
90
90
|
})
|
|
91
91
|
}),
|
|
92
|
-
/* @__PURE__ */
|
|
92
|
+
/* @__PURE__ */ b("h2", {
|
|
93
93
|
className: "text-lg font-semibold text-text-primary",
|
|
94
94
|
children: "Failed to load credits"
|
|
95
95
|
}),
|
|
96
|
-
/* @__PURE__ */
|
|
96
|
+
/* @__PURE__ */ b("p", {
|
|
97
97
|
className: "text-sm text-text-secondary",
|
|
98
|
-
children:
|
|
98
|
+
children: q.message
|
|
99
99
|
}),
|
|
100
|
-
/* @__PURE__ */
|
|
100
|
+
/* @__PURE__ */ b("button", {
|
|
101
101
|
type: "button",
|
|
102
|
-
onClick: () =>
|
|
102
|
+
onClick: () => J(),
|
|
103
103
|
className: "px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors",
|
|
104
104
|
children: "Try Again"
|
|
105
105
|
})
|
|
106
106
|
]
|
|
107
107
|
})
|
|
108
108
|
});
|
|
109
|
-
let
|
|
110
|
-
return /* @__PURE__ */
|
|
109
|
+
let Z = F?.creditAmount || 0;
|
|
110
|
+
return /* @__PURE__ */ x("div", {
|
|
111
111
|
className: "space-y-6 px-6 lg:px-8 py-6",
|
|
112
112
|
children: [
|
|
113
|
-
/* @__PURE__ */
|
|
113
|
+
/* @__PURE__ */ x("div", {
|
|
114
114
|
className: f ? "flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between" : "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
|
|
115
|
-
children: [/* @__PURE__ */
|
|
115
|
+
children: [/* @__PURE__ */ x("div", {
|
|
116
116
|
className: f ? "min-w-0 lg:max-w-3xl" : void 0,
|
|
117
117
|
children: [
|
|
118
|
-
/* @__PURE__ */
|
|
118
|
+
/* @__PURE__ */ b("h1", {
|
|
119
119
|
className: "text-2xl md:text-3xl font-semibold tracking-tight text-text-primary",
|
|
120
120
|
children: s("billing.credits.title", "Credits")
|
|
121
121
|
}),
|
|
122
|
-
/* @__PURE__ */
|
|
122
|
+
/* @__PURE__ */ b("p", {
|
|
123
123
|
className: "text-sm text-text-secondary mt-1",
|
|
124
124
|
children: "Manage your credit balance and view transaction history"
|
|
125
125
|
}),
|
|
126
|
-
/* @__PURE__ */
|
|
126
|
+
/* @__PURE__ */ b(_, {
|
|
127
127
|
className: "mt-3",
|
|
128
128
|
children: f ? s("billing.credits.purposeFluidgrids", "Credits are your prepaid balance for usage and purchases. They are separate from the monthly AI credits that come with your plan. See your balance, top it up, and review every purchase, grant and deduction.") : s("billing.credits.purpose", "Credits are prepaid balance you can spend on usage and purchases instead of paying per invoice. See your available balance, top it up, withdraw unused credits, and review every credit purchase, grant and deduction over time.")
|
|
129
129
|
})
|
|
130
130
|
]
|
|
131
|
-
}), /* @__PURE__ */
|
|
131
|
+
}), /* @__PURE__ */ x("div", {
|
|
132
132
|
className: f ? "flex flex-wrap items-center gap-2 lg:shrink-0 [&_button]:whitespace-nowrap" : "flex items-center gap-2",
|
|
133
|
-
children: [
|
|
133
|
+
children: [C && /* @__PURE__ */ x("button", {
|
|
134
134
|
type: "button",
|
|
135
135
|
onClick: () => c("/credits/withdraw"),
|
|
136
136
|
className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken transition-colors",
|
|
137
|
-
children: [/* @__PURE__ */
|
|
137
|
+
children: [/* @__PURE__ */ b("svg", {
|
|
138
138
|
className: "size-4",
|
|
139
139
|
fill: "none",
|
|
140
140
|
viewBox: "0 0 24 24",
|
|
141
141
|
stroke: "currentColor",
|
|
142
|
-
children: /* @__PURE__ */
|
|
142
|
+
children: /* @__PURE__ */ b("path", {
|
|
143
143
|
strokeLinecap: "round",
|
|
144
144
|
strokeLinejoin: "round",
|
|
145
145
|
strokeWidth: 2,
|
|
146
146
|
d: "M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"
|
|
147
147
|
})
|
|
148
148
|
}), "Withdraw"]
|
|
149
|
-
}), /* @__PURE__ */
|
|
149
|
+
}), /* @__PURE__ */ x("button", {
|
|
150
150
|
type: "button",
|
|
151
151
|
onClick: () => c("/checkout/credits"),
|
|
152
152
|
className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors",
|
|
153
|
-
children: [/* @__PURE__ */
|
|
153
|
+
children: [/* @__PURE__ */ b("svg", {
|
|
154
154
|
className: "size-4",
|
|
155
155
|
fill: "none",
|
|
156
156
|
viewBox: "0 0 24 24",
|
|
157
157
|
stroke: "currentColor",
|
|
158
|
-
children: /* @__PURE__ */
|
|
158
|
+
children: /* @__PURE__ */ b("path", {
|
|
159
159
|
strokeLinecap: "round",
|
|
160
160
|
strokeLinejoin: "round",
|
|
161
161
|
strokeWidth: 2,
|
|
@@ -165,72 +165,72 @@ var S = () => {
|
|
|
165
165
|
})]
|
|
166
166
|
})]
|
|
167
167
|
}),
|
|
168
|
-
/* @__PURE__ */
|
|
168
|
+
/* @__PURE__ */ x("div", {
|
|
169
169
|
className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",
|
|
170
|
-
children: [/* @__PURE__ */
|
|
170
|
+
children: [/* @__PURE__ */ x(h, {
|
|
171
171
|
className: "p-6",
|
|
172
172
|
children: [
|
|
173
|
-
/* @__PURE__ */
|
|
173
|
+
/* @__PURE__ */ b("p", {
|
|
174
174
|
className: "text-sm text-text-secondary",
|
|
175
175
|
children: "Available Balance"
|
|
176
176
|
}),
|
|
177
|
-
/* @__PURE__ */
|
|
177
|
+
/* @__PURE__ */ x("p", {
|
|
178
178
|
className: "text-3xl font-bold tabular-nums text-text-primary mt-2",
|
|
179
|
-
children: [
|
|
179
|
+
children: [Z.toLocaleString(), " Credits"]
|
|
180
180
|
}),
|
|
181
|
-
f &&
|
|
181
|
+
f && j.length > 1 ? /* @__PURE__ */ b(v, {
|
|
182
182
|
"aria-label": s("billing.credits.billingAccountLabel", "Billing Account"),
|
|
183
|
-
value:
|
|
183
|
+
value: L ?? "",
|
|
184
184
|
onChange: (e) => {
|
|
185
|
-
|
|
185
|
+
k(e.target.value || null), U(1);
|
|
186
186
|
},
|
|
187
187
|
className: "mt-3 w-full min-w-0 truncate text-sm border border-border-subtle rounded-button bg-bg-surface text-text-primary px-3 py-2 focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary",
|
|
188
|
-
children:
|
|
188
|
+
children: j.map((e) => /* @__PURE__ */ x("option", {
|
|
189
189
|
value: e.id ?? "",
|
|
190
190
|
children: [e.name ?? e.email ?? e.id, e.isDefault ? s("billing.invoices.defaultSuffix", " (Default)") : ""]
|
|
191
191
|
}, e.id ?? ""))
|
|
192
|
-
}) : /* @__PURE__ */
|
|
192
|
+
}) : /* @__PURE__ */ b("p", {
|
|
193
193
|
className: "text-sm text-text-secondary mt-2",
|
|
194
|
-
children:
|
|
194
|
+
children: F?.name
|
|
195
195
|
})
|
|
196
196
|
]
|
|
197
|
-
}), /* @__PURE__ */
|
|
197
|
+
}), /* @__PURE__ */ x("div", {
|
|
198
198
|
className: "border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 p-5",
|
|
199
199
|
children: [
|
|
200
|
-
/* @__PURE__ */
|
|
200
|
+
/* @__PURE__ */ x("p", {
|
|
201
201
|
className: "text-sm text-text-secondary",
|
|
202
202
|
children: [
|
|
203
203
|
"Transactions (",
|
|
204
|
-
|
|
204
|
+
R,
|
|
205
205
|
"d)"
|
|
206
206
|
]
|
|
207
207
|
}),
|
|
208
|
-
/* @__PURE__ */
|
|
208
|
+
/* @__PURE__ */ b("p", {
|
|
209
209
|
className: "text-2xl md:text-3xl font-semibold tracking-tight text-text-primary mt-2",
|
|
210
|
-
children:
|
|
210
|
+
children: G.totalCount
|
|
211
211
|
}),
|
|
212
|
-
/* @__PURE__ */
|
|
212
|
+
/* @__PURE__ */ b("p", {
|
|
213
213
|
className: "text-sm text-text-secondary mt-2",
|
|
214
214
|
children: "Total transactions"
|
|
215
215
|
})
|
|
216
216
|
]
|
|
217
217
|
})]
|
|
218
218
|
}),
|
|
219
|
-
/* @__PURE__ */
|
|
219
|
+
/* @__PURE__ */ x("div", {
|
|
220
220
|
className: "flex flex-wrap items-center gap-4 pb-4 border-b border-border-subtle",
|
|
221
|
-
children: [/* @__PURE__ */
|
|
221
|
+
children: [/* @__PURE__ */ b("div", {
|
|
222
222
|
className: "inline-flex rounded-lg border border-border-subtle p-1 bg-bg-sunken",
|
|
223
223
|
children: [
|
|
224
224
|
7,
|
|
225
225
|
30,
|
|
226
226
|
90
|
|
227
|
-
].map((e) => /* @__PURE__ */
|
|
227
|
+
].map((e) => /* @__PURE__ */ x("button", {
|
|
228
228
|
type: "button",
|
|
229
|
-
onClick: () =>
|
|
230
|
-
className: `px-3 py-1.5 text-sm font-medium rounded-button transition-colors ${
|
|
229
|
+
onClick: () => z(e),
|
|
230
|
+
className: `px-3 py-1.5 text-sm font-medium rounded-button transition-colors ${R === e ? "bg-bg-surface text-text-primary shadow-sm" : "text-text-secondary hover:text-text-primary"}`,
|
|
231
231
|
children: [e, "d"]
|
|
232
232
|
}, e))
|
|
233
|
-
}), /* @__PURE__ */
|
|
233
|
+
}), /* @__PURE__ */ b("div", {
|
|
234
234
|
className: "inline-flex rounded-lg border border-border-subtle p-1 bg-bg-sunken",
|
|
235
235
|
children: [
|
|
236
236
|
"all",
|
|
@@ -238,25 +238,25 @@ var S = () => {
|
|
|
238
238
|
"usage",
|
|
239
239
|
"adjustment",
|
|
240
240
|
"granted"
|
|
241
|
-
].map((e) => /* @__PURE__ */
|
|
241
|
+
].map((e) => /* @__PURE__ */ b("button", {
|
|
242
242
|
type: "button",
|
|
243
|
-
onClick: () =>
|
|
244
|
-
className: `px-3 py-1.5 text-sm font-medium rounded-button transition-colors capitalize ${
|
|
243
|
+
onClick: () => V(e),
|
|
244
|
+
className: `px-3 py-1.5 text-sm font-medium rounded-button transition-colors capitalize ${B === e ? "bg-bg-surface text-text-primary shadow-sm" : "text-text-secondary hover:text-text-primary"}`,
|
|
245
245
|
children: e === "all" ? "All" : a(e)
|
|
246
246
|
}, e))
|
|
247
247
|
})]
|
|
248
248
|
}),
|
|
249
|
-
|
|
250
|
-
illustration:
|
|
249
|
+
X.length === 0 ? /* @__PURE__ */ b(g, {
|
|
250
|
+
illustration: B === "all" ? "empty-data" : "empty-search",
|
|
251
251
|
title: "No transactions found",
|
|
252
|
-
description:
|
|
253
|
-
}) : /* @__PURE__ */
|
|
252
|
+
description: B === "all" ? "No credit transactions in this period." : "No transactions match your filter."
|
|
253
|
+
}) : /* @__PURE__ */ x("div", {
|
|
254
254
|
className: "space-y-3",
|
|
255
|
-
children: [
|
|
255
|
+
children: [X.map((e) => /* @__PURE__ */ b(w, { transaction: e }, e.id)), G.hasMore && /* @__PURE__ */ b("div", {
|
|
256
256
|
className: "flex justify-center pt-4",
|
|
257
|
-
children: /* @__PURE__ */
|
|
257
|
+
children: /* @__PURE__ */ b("button", {
|
|
258
258
|
type: "button",
|
|
259
|
-
onClick: () =>
|
|
259
|
+
onClick: () => U((e) => e + 1),
|
|
260
260
|
className: "px-4 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken transition-colors",
|
|
261
261
|
children: "Load More"
|
|
262
262
|
})
|
|
@@ -264,30 +264,30 @@ var S = () => {
|
|
|
264
264
|
})
|
|
265
265
|
]
|
|
266
266
|
});
|
|
267
|
-
},
|
|
267
|
+
}, w = ({ transaction: e }) => {
|
|
268
268
|
let t = c(e.status), n = e.type === "purchase" || e.type === "adjustment" || e.type === "granted";
|
|
269
|
-
return /* @__PURE__ */
|
|
269
|
+
return /* @__PURE__ */ x("div", {
|
|
270
270
|
className: "flex items-center gap-4 p-4 border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 hover:shadow-sm transition-shadow",
|
|
271
271
|
children: [
|
|
272
|
-
/* @__PURE__ */
|
|
272
|
+
/* @__PURE__ */ b("div", {
|
|
273
273
|
className: `size-10 rounded-full flex items-center justify-center ${n ? f.success.bg : f.warning.bg}`,
|
|
274
|
-
children: n ? /* @__PURE__ */
|
|
274
|
+
children: n ? /* @__PURE__ */ b("svg", {
|
|
275
275
|
className: `size-5 ${f.success.icon}`,
|
|
276
276
|
fill: "none",
|
|
277
277
|
viewBox: "0 0 24 24",
|
|
278
278
|
stroke: "currentColor",
|
|
279
|
-
children: /* @__PURE__ */
|
|
279
|
+
children: /* @__PURE__ */ b("path", {
|
|
280
280
|
strokeLinecap: "round",
|
|
281
281
|
strokeLinejoin: "round",
|
|
282
282
|
strokeWidth: 2,
|
|
283
283
|
d: "M12 4v16m8-8H4"
|
|
284
284
|
})
|
|
285
|
-
}) : /* @__PURE__ */
|
|
285
|
+
}) : /* @__PURE__ */ b("svg", {
|
|
286
286
|
className: `size-5 ${f.warning.icon}`,
|
|
287
287
|
fill: "none",
|
|
288
288
|
viewBox: "0 0 24 24",
|
|
289
289
|
stroke: "currentColor",
|
|
290
|
-
children: /* @__PURE__ */
|
|
290
|
+
children: /* @__PURE__ */ b("path", {
|
|
291
291
|
strokeLinecap: "round",
|
|
292
292
|
strokeLinejoin: "round",
|
|
293
293
|
strokeWidth: 2,
|
|
@@ -295,18 +295,18 @@ var S = () => {
|
|
|
295
295
|
})
|
|
296
296
|
})
|
|
297
297
|
}),
|
|
298
|
-
/* @__PURE__ */
|
|
298
|
+
/* @__PURE__ */ x("div", {
|
|
299
299
|
className: "flex-1 min-w-0",
|
|
300
|
-
children: [/* @__PURE__ */
|
|
300
|
+
children: [/* @__PURE__ */ x("div", {
|
|
301
301
|
className: "flex items-center gap-2",
|
|
302
|
-
children: [/* @__PURE__ */
|
|
302
|
+
children: [/* @__PURE__ */ b("p", {
|
|
303
303
|
className: "font-medium text-text-primary capitalize",
|
|
304
304
|
children: a(e.type)
|
|
305
|
-
}), /* @__PURE__ */
|
|
305
|
+
}), /* @__PURE__ */ b("span", {
|
|
306
306
|
className: `px-2 py-0.5 text-xs font-medium rounded ${l(t)}`,
|
|
307
307
|
children: e.status
|
|
308
308
|
})]
|
|
309
|
-
}), /* @__PURE__ */
|
|
309
|
+
}), /* @__PURE__ */ x("p", {
|
|
310
310
|
className: "text-sm text-text-secondary mt-0.5",
|
|
311
311
|
children: [
|
|
312
312
|
s(e.createdAt),
|
|
@@ -315,9 +315,9 @@ var S = () => {
|
|
|
315
315
|
]
|
|
316
316
|
})]
|
|
317
317
|
}),
|
|
318
|
-
/* @__PURE__ */
|
|
318
|
+
/* @__PURE__ */ b("div", {
|
|
319
319
|
className: "text-right",
|
|
320
|
-
children: /* @__PURE__ */
|
|
320
|
+
children: /* @__PURE__ */ x("p", {
|
|
321
321
|
className: `font-semibold ${n ? f.success.text : "text-text-primary"}`,
|
|
322
322
|
children: [
|
|
323
323
|
n ? "+" : "-",
|
|
@@ -329,6 +329,6 @@ var S = () => {
|
|
|
329
329
|
]
|
|
330
330
|
});
|
|
331
331
|
};
|
|
332
|
-
export {
|
|
332
|
+
export { C as CreditsPage };
|
|
333
333
|
|
|
334
334
|
//# sourceMappingURL=CreditsPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreditsPage.js","names":["CreditsPage","useI18n","tr","translated","t","key","fallback","navigateTo","useBillingNavigate","permissions","useBillingPermissions","isFluidgrids","useIsFluidgridsVariant","showWithdraw","defaultAccount","isLoadingDefault","useDefaultBillingAccount","searchParams","useSearchParams","chosenAccountId","setChosenAccountId","useState","accountsData","useGetBillingAccountsByOrgQuery","accountOptions","useMemo","viewingOther","otherAccount","isLoadingOther","useBillingAccount","billingAccount","isLoadingAccount","selectedAccountId","days","setDays","filterType","setFilterType","page","setPage","isLoadingTransactions","useCreditTransactions","isLoading","filteredTransactions","transactions","tx","error","refetch","creditBalance","PagePurpose","EmphasisPanel","account","pagination","d","type","formatCreditTransactionType","IllustratedEmptyState","TransactionRow","p","statusColor","getCreditTransactionStatusColor","transaction","isCredit","statusTokens","getStatusBadgeClasses","formatRelativeTime","formatDate"],"sources":["../../../../../src/billing/modules/credits/pages/CreditsPage.tsx"],"sourcesContent":["/**\n * Credits Module - Credits Page\n * Displays credit balance and transaction history\n */\n\nimport { useMemo, useState, type FC } from 'react';\nimport { useSearchParams } from 'react-router';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { useCreditTransactions } from '../hooks/useCredits';\nimport { useBillingAccount, useDefaultBillingAccount } from '../../subscriptions/hooks';\nimport {\n useGetBillingAccountsByOrgQuery,\n type GetBillingAccountsByOrgQuery,\n} from '../../../../generated/global-operations';\n\ntype BillingAccountItem = GetBillingAccountsByOrgQuery['getBillingAccountsByOrg'][number];\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useIsFluidgridsVariant } from '../../../hooks/useBillingVariant';\nimport {\n formatDate,\n formatRelativeTime,\n formatCreditTransactionType,\n} from '../../../shared/utils/format';\nimport {\n getCreditTransactionStatusColor,\n getStatusBadgeClasses,\n} from '../../../shared/utils/status';\nimport { statusTokens } from '../../../shared/utils/tokens';\nimport type { CreditTransaction, CreditTransactionType } from '../../../shared/types';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { EmphasisPanel, PagePurpose, IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\n\ntype FilterType = 'all' | CreditTransactionType;\n\nexport const CreditsPage: FC = () => {\n const { t } = useI18n();\n const tr = (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n const navigateTo = useBillingNavigate();\n const permissions = useBillingPermissions();\n // FluidGrids: Withdraw lives only in the Seller area (BOFF-11861).\n const isFluidgrids = useIsFluidgridsVariant();\n const showWithdraw = !isFluidgrids;\n const { billingAccount: defaultAccount, isLoading: isLoadingDefault } =\n useDefaultBillingAccount();\n\n // FluidGrids: pick which billing account's credits to see, like Invoices does.\n const [searchParams] = useSearchParams();\n const [chosenAccountId, setChosenAccountId] = useState<string | null>(\n searchParams.get('billingAccountId')\n );\n const { data: accountsData } = useGetBillingAccountsByOrgQuery({\n fetchPolicy: 'cache-first',\n skip: !isFluidgrids,\n });\n const accountOptions = useMemo(\n () => (isFluidgrids ? (accountsData?.getBillingAccountsByOrg ?? []) : []),\n [isFluidgrids, accountsData]\n );\n const viewingOther =\n isFluidgrids && chosenAccountId !== null && chosenAccountId !== defaultAccount?.id;\n const { billingAccount: otherAccount, isLoading: isLoadingOther } = useBillingAccount(\n viewingOther ? chosenAccountId : undefined\n );\n const billingAccount = viewingOther ? otherAccount : defaultAccount;\n const isLoadingAccount = viewingOther ? isLoadingOther : isLoadingDefault;\n const selectedAccountId = viewingOther ? chosenAccountId : (defaultAccount?.id ?? '');\n\n const [days, setDays] = useState(30);\n const [filterType, setFilterType] = useState<FilterType>('all');\n const [page, setPage] = useState(1);\n\n const {\n transactions,\n pagination,\n isLoading: isLoadingTransactions,\n error,\n refetch,\n } = useCreditTransactions({\n billingAccountId: billingAccount?.id || '',\n days,\n page,\n pageSize: 20,\n });\n\n // Permission check\n if (!permissions.canViewCredits) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-2\">\n <div className=\"size-12 mx-auto rounded-full bg-bg-sunken flex items-center justify-center\">\n <svg\n className=\"size-6 text-text-secondary\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-text-primary\">Access Denied</h2>\n <p className=\"text-sm text-text-secondary max-w-sm\">\n You don't have permission to view credits.\n </p>\n </div>\n </div>\n );\n }\n\n const isLoading = isLoadingAccount || isLoadingTransactions;\n\n // Filter transactions\n const filteredTransactions = transactions.filter((tx) => {\n if (filterType === 'all') return true;\n return tx.type === filterType;\n });\n\n // Loading state\n if (isLoading && !billingAccount) {\n return (\n <div className=\"space-y-6 px-6 lg:px-8 py-6\">\n <div className=\"h-8 w-48 bg-bg-sunken animate-pulse rounded\" />\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-4\">\n <div className=\"border border-border-subtle rounded-lg p-6\">\n <div className=\"h-6 w-24 bg-bg-sunken animate-pulse rounded mb-2\" />\n <div className=\"h-10 w-32 bg-bg-sunken animate-pulse rounded\" />\n </div>\n </div>\n </div>\n );\n }\n\n // Error state\n if (error) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-4\">\n <div className=\"size-12 mx-auto rounded-full bg-status-error-bg-subtle flex items-center justify-center\">\n <svg\n className=\"size-6 text-status-error-text\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-text-primary\">Failed to load credits</h2>\n <p className=\"text-sm text-text-secondary\">{error.message}</p>\n <button\n type=\"button\"\n onClick={() => refetch()}\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors\"\n >\n Try Again\n </button>\n </div>\n </div>\n );\n }\n\n const creditBalance = billingAccount?.creditAmount || 0;\n\n return (\n <div className=\"space-y-6 px-6 lg:px-8 py-6\">\n {/* Header */}\n <div\n className={\n isFluidgrids\n ? 'flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between'\n : 'flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between'\n }\n >\n <div className={isFluidgrids ? 'min-w-0 lg:max-w-3xl' : undefined}>\n <h1 className=\"text-2xl md:text-3xl font-semibold tracking-tight text-text-primary\">\n {tr('billing.credits.title', 'Credits')}\n </h1>\n <p className=\"text-sm text-text-secondary mt-1\">\n Manage your credit balance and view transaction history\n </p>\n <PagePurpose className=\"mt-3\">\n {isFluidgrids\n ? tr(\n 'billing.credits.purposeFluidgrids',\n 'Credits are your prepaid balance for usage and purchases. They are separate from the monthly AI credits that come with your plan. See your balance, top it up, and review every purchase, grant and deduction.'\n )\n : tr(\n 'billing.credits.purpose',\n 'Credits are prepaid balance you can spend on usage and purchases instead of paying per invoice. See your available balance, top it up, withdraw unused credits, and review every credit purchase, grant and deduction over time.'\n )}\n </PagePurpose>\n </div>\n\n <div\n className={\n isFluidgrids\n ? 'flex flex-wrap items-center gap-2 lg:shrink-0 [&_button]:whitespace-nowrap'\n : 'flex items-center gap-2'\n }\n >\n {showWithdraw && (\n <button\n type=\"button\"\n onClick={() => navigateTo('/credits/withdraw')}\n className=\"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken transition-colors\"\n >\n <svg className=\"size-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z\"\n />\n </svg>\n Withdraw\n </button>\n )}\n <button\n type=\"button\"\n onClick={() => navigateTo('/checkout/credits')}\n className=\"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors\"\n >\n <svg className=\"size-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 4v16m8-8H4\"\n />\n </svg>\n Purchase Credits\n </button>\n </div>\n </div>\n\n {/* Balance Card */}\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4\">\n <EmphasisPanel className=\"p-6\">\n <p className=\"text-sm text-text-secondary\">Available Balance</p>\n <p className=\"text-3xl font-bold tabular-nums text-text-primary mt-2\">\n {creditBalance.toLocaleString()} Credits\n </p>\n {isFluidgrids && accountOptions.length > 1 ? (\n <select\n aria-label={tr('billing.credits.billingAccountLabel', 'Billing Account')}\n value={selectedAccountId ?? ''}\n onChange={(e) => {\n setChosenAccountId(e.target.value || null);\n setPage(1);\n }}\n className=\"mt-3 w-full min-w-0 truncate text-sm border border-border-subtle rounded-button bg-bg-surface text-text-primary px-3 py-2 focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n {accountOptions.map((account: BillingAccountItem) => (\n <option key={account.id ?? ''} value={account.id ?? ''}>\n {account.name ?? account.email ?? account.id}\n {account.isDefault ? tr('billing.invoices.defaultSuffix', ' (Default)') : ''}\n </option>\n ))}\n </select>\n ) : (\n <p className=\"text-sm text-text-secondary mt-2\">{billingAccount?.name}</p>\n )}\n </EmphasisPanel>\n\n <div className=\"border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 p-5\">\n <p className=\"text-sm text-text-secondary\">Transactions ({days}d)</p>\n <p className=\"text-2xl md:text-3xl font-semibold tracking-tight text-text-primary mt-2\">\n {pagination.totalCount}\n </p>\n <p className=\"text-sm text-text-secondary mt-2\">Total transactions</p>\n </div>\n </div>\n\n {/* Filters */}\n <div className=\"flex flex-wrap items-center gap-4 pb-4 border-b border-border-subtle\">\n {/* Time Range */}\n <div className=\"inline-flex rounded-lg border border-border-subtle p-1 bg-bg-sunken\">\n {[7, 30, 90].map((d) => (\n <button\n type=\"button\"\n key={d}\n onClick={() => setDays(d)}\n className={`px-3 py-1.5 text-sm font-medium rounded-button transition-colors ${\n days === d\n ? 'bg-bg-surface text-text-primary shadow-sm'\n : 'text-text-secondary hover:text-text-primary'\n }`}\n >\n {d}d\n </button>\n ))}\n </div>\n\n {/* Transaction Type Filter */}\n <div className=\"inline-flex rounded-lg border border-border-subtle p-1 bg-bg-sunken\">\n {(['all', 'purchase', 'usage', 'adjustment', 'granted'] as FilterType[]).map((type) => (\n <button\n type=\"button\"\n key={type}\n onClick={() => setFilterType(type)}\n className={`px-3 py-1.5 text-sm font-medium rounded-button transition-colors capitalize ${\n filterType === type\n ? 'bg-bg-surface text-text-primary shadow-sm'\n : 'text-text-secondary hover:text-text-primary'\n }`}\n >\n {type === 'all' ? 'All' : formatCreditTransactionType(type as CreditTransactionType)}\n </button>\n ))}\n </div>\n </div>\n\n {/* Transactions List */}\n {filteredTransactions.length === 0 ? (\n <IllustratedEmptyState\n illustration={filterType !== 'all' ? 'empty-search' : 'empty-data'}\n title=\"No transactions found\"\n description={\n filterType !== 'all'\n ? 'No transactions match your filter.'\n : 'No credit transactions in this period.'\n }\n />\n ) : (\n <div className=\"space-y-3\">\n {filteredTransactions.map((tx) => (\n <TransactionRow key={tx.id} transaction={tx} />\n ))}\n\n {/* Pagination */}\n {pagination.hasMore && (\n <div className=\"flex justify-center pt-4\">\n <button\n type=\"button\"\n onClick={() => setPage((p) => p + 1)}\n className=\"px-4 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken transition-colors\"\n >\n Load More\n </button>\n </div>\n )}\n </div>\n )}\n </div>\n );\n};\n\n// ============================================================================\n// Transaction Row Component\n// ============================================================================\n\ninterface TransactionRowProps {\n transaction: CreditTransaction;\n}\n\nconst TransactionRow: FC<TransactionRowProps> = ({ transaction }) => {\n const statusColor = getCreditTransactionStatusColor(transaction.status);\n const isCredit =\n transaction.type === 'purchase' ||\n transaction.type === 'adjustment' ||\n transaction.type === 'granted';\n\n return (\n <div className=\"flex items-center gap-4 p-4 border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 hover:shadow-sm transition-shadow\">\n {/* Icon */}\n <div\n className={`size-10 rounded-full flex items-center justify-center ${\n isCredit ? statusTokens.success.bg : statusTokens.warning.bg\n }`}\n >\n {isCredit ? (\n <svg\n className={`size-5 ${statusTokens.success.icon}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M12 4v16m8-8H4\" />\n </svg>\n ) : (\n <svg\n className={`size-5 ${statusTokens.warning.icon}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M20 12H4\" />\n </svg>\n )}\n </div>\n\n {/* Info */}\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2\">\n <p className=\"font-medium text-text-primary capitalize\">\n {formatCreditTransactionType(transaction.type)}\n </p>\n <span\n className={`px-2 py-0.5 text-xs font-medium rounded ${getStatusBadgeClasses(statusColor)}`}\n >\n {transaction.status}\n </span>\n </div>\n <p className=\"text-sm text-text-secondary mt-0.5\">\n {formatRelativeTime(transaction.createdAt)} • {formatDate(transaction.createdAt, 'short')}\n </p>\n </div>\n\n {/* Amount */}\n <div className=\"text-right\">\n <p\n className={`font-semibold ${isCredit ? statusTokens.success.text : 'text-text-primary'}`}\n >\n {isCredit ? '+' : '-'}\n {transaction.amount.toLocaleString()} credits\n </p>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAkCA,IAAaA,UAAwB;CACnC,IAAM,EAAE,SAAMC,EAAQ,GAChBC,KAAM,GAAa,MAA6B;EACpD,IAAMC,IAAaC,EAAEC,CAAG;EACxB,OAAOF,MAAeE,IAAMC,IAAWH;CACzC,GACMI,IAAaC,EAAmB,GAChCC,IAAcC,EAAsB,GAEpCC,IAAeC,EAAuB,GACtCC,IAAe,CAACF,GAChB,EAAE,gBAAgBG,GAAgB,WAAWC,MACjDC,EAAyB,GAGrB,CAACC,KAAgBC,EAAgB,GACjC,CAACC,GAAiBC,KAAsBC,EAC5CJ,EAAa,IAAI,kBAAkB,CACrC,GACM,EAAE,MAAMK,MAAiBC,EAAgC;EAC7D,aAAa;EACb,MAAM,CAACZ;CACT,CAAC,GACKa,IAAiBC,QACdd,IAAgBW,GAAc,2BAA2B,CAAC,IAAK,CAAC,GACvE,CAACX,GAAcW,CAAY,CAC7B,GACMI,IACJf,KAAgBQ,MAAoB,QAAQA,MAAoBL,GAAgB,IAC5E,EAAE,gBAAgBa,GAAc,WAAWC,MAAmBC,EAClEH,IAAeP,IAAkB,KAAA,CACnC,GACMW,IAAiBJ,IAAeC,IAAeb,GAC/CiB,IAAmBL,IAAeE,IAAiBb,GACnDiB,IAAoBN,IAAeP,IAAmBL,GAAgB,MAAM,IAE5E,CAACmB,GAAMC,KAAWb,EAAS,EAAE,GAC7B,CAACc,GAAYC,KAAiBf,EAAqB,KAAK,GACxD,CAACgB,GAAMC,KAAWjB,EAAS,CAAC,GAE5B,EACJ,iBACA,eACA,WAAWkB,GACX,UACA,eACEC,EAAsB;EACxB,kBAAkBV,GAAgB,MAAM;EACxC;EACA;EACA,UAAU;CACZ,CAAC;CAGD,IAAI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C,OAAD;KACE,WAAW,UAAUA,EAAa,QAAQ;KAC1C,MAAK;KACL,SAAQ;KACR,QAAO;KAEP,UAAA,kBAAC,QAAD;MAAM,eAAc;MAAQ,gBAAe;MAAQ,aAAa;MAAG,GAAE;KAAY,CAAA;IAC9E,CAAA;GAEJ,CAAA;GAGL,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,kBAAC,KAAD;MAAG,WAAU;MACV,UAAAR,EAA4BM,EAAY,IAAI;KAC5C,CAAA,GACH,kBAAC,QAAD;MACE,WAAW,2CAA2CG,EAAsBL,CAAW;MAEtF,UAAAE,EAAY;KACT,CAAA,CACH;IACL,CAAA,GAAA,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA;MACGI,EAAmBJ,EAAY,SAAS;MAAE;MAAIK,EAAWL,EAAY,WAAW,OAAO;KACvF;IACA,CAAA,CAAA;;GAGL,kBAAC,OAAD;IAAK,WAAU;IACb,UAAA,kBAAC,KAAD;KACE,WAAW,iBAAiBC,IAAWC,EAAa,QAAQ,OAAO;KADrE,UAAA;MAGGD,IAAW,MAAM;MACjBD,EAAY,OAAO,eAAe;MAAE;KACpC;;GACA,CAAA;EACF;;AAET"}
|
|
1
|
+
{"version":3,"file":"CreditsPage.js","names":["CreditsPage","useI18n","tr","translated","t","key","fallback","navigateTo","useBillingNavigate","permissions","useBillingPermissions","isFluidgrids","useIsFluidgridsVariant","showWithdraw","defaultAccount","isLoadingDefault","useDefaultBillingAccount","searchParams","useSearchParams","chosenAccountId","setChosenAccountId","useState","accountsData","useGetBillingAccountsByOrgQuery","accountOptions","useMemo","viewingOther","otherAccount","isLoadingOther","useBillingAccount","billingAccount","isLoadingAccount","selectedAccountId","days","setDays","filterType","setFilterType","page","setPage","isLoadingTransactions","useCreditTransactions","isLoading","filteredTransactions","transactions","tx","error","refetch","creditBalance","PagePurpose","EmphasisPanel","ThemedSelect","account","pagination","d","type","formatCreditTransactionType","IllustratedEmptyState","TransactionRow","p","statusColor","getCreditTransactionStatusColor","transaction","isCredit","statusTokens","getStatusBadgeClasses","formatRelativeTime","formatDate"],"sources":["../../../../../src/billing/modules/credits/pages/CreditsPage.tsx"],"sourcesContent":["/**\n * Credits Module - Credits Page\n * Displays credit balance and transaction history\n */\n\nimport { useMemo, useState, type FC } from 'react';\nimport { useSearchParams } from 'react-router';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { useCreditTransactions } from '../hooks/useCredits';\nimport { useBillingAccount, useDefaultBillingAccount } from '../../subscriptions/hooks';\nimport {\n useGetBillingAccountsByOrgQuery,\n type GetBillingAccountsByOrgQuery,\n} from '../../../../generated/global-operations';\n\ntype BillingAccountItem = GetBillingAccountsByOrgQuery['getBillingAccountsByOrg'][number];\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useIsFluidgridsVariant } from '../../../hooks/useBillingVariant';\nimport {\n formatDate,\n formatRelativeTime,\n formatCreditTransactionType,\n} from '../../../shared/utils/format';\nimport {\n getCreditTransactionStatusColor,\n getStatusBadgeClasses,\n} from '../../../shared/utils/status';\nimport { statusTokens } from '../../../shared/utils/tokens';\nimport type { CreditTransaction, CreditTransactionType } from '../../../shared/types';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n EmphasisPanel,\n PagePurpose,\n IllustratedEmptyState,\n ThemedSelect,\n} from '@burdenoff/fe-libs/ui';\n\ntype FilterType = 'all' | CreditTransactionType;\n\nexport const CreditsPage: FC = () => {\n const { t } = useI18n();\n const tr = (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n const navigateTo = useBillingNavigate();\n const permissions = useBillingPermissions();\n // FluidGrids: Withdraw lives only in the Seller area (BOFF-11861).\n const isFluidgrids = useIsFluidgridsVariant();\n const showWithdraw = !isFluidgrids;\n const { billingAccount: defaultAccount, isLoading: isLoadingDefault } =\n useDefaultBillingAccount();\n\n // FluidGrids: pick which billing account's credits to see, like Invoices does.\n const [searchParams] = useSearchParams();\n const [chosenAccountId, setChosenAccountId] = useState<string | null>(\n searchParams.get('billingAccountId')\n );\n const { data: accountsData } = useGetBillingAccountsByOrgQuery({\n fetchPolicy: 'cache-first',\n skip: !isFluidgrids,\n });\n const accountOptions = useMemo(\n () => (isFluidgrids ? (accountsData?.getBillingAccountsByOrg ?? []) : []),\n [isFluidgrids, accountsData]\n );\n const viewingOther =\n isFluidgrids && chosenAccountId !== null && chosenAccountId !== defaultAccount?.id;\n const { billingAccount: otherAccount, isLoading: isLoadingOther } = useBillingAccount(\n viewingOther ? chosenAccountId : undefined\n );\n const billingAccount = viewingOther ? otherAccount : defaultAccount;\n const isLoadingAccount = viewingOther ? isLoadingOther : isLoadingDefault;\n const selectedAccountId = viewingOther ? chosenAccountId : (defaultAccount?.id ?? '');\n\n const [days, setDays] = useState(30);\n const [filterType, setFilterType] = useState<FilterType>('all');\n const [page, setPage] = useState(1);\n\n const {\n transactions,\n pagination,\n isLoading: isLoadingTransactions,\n error,\n refetch,\n } = useCreditTransactions({\n billingAccountId: billingAccount?.id || '',\n days,\n page,\n pageSize: 20,\n });\n\n // Permission check\n if (!permissions.canViewCredits) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-2\">\n <div className=\"size-12 mx-auto rounded-full bg-bg-sunken flex items-center justify-center\">\n <svg\n className=\"size-6 text-text-secondary\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-text-primary\">Access Denied</h2>\n <p className=\"text-sm text-text-secondary max-w-sm\">\n You don't have permission to view credits.\n </p>\n </div>\n </div>\n );\n }\n\n const isLoading = isLoadingAccount || isLoadingTransactions;\n\n // Filter transactions\n const filteredTransactions = transactions.filter((tx) => {\n if (filterType === 'all') return true;\n return tx.type === filterType;\n });\n\n // Loading state\n if (isLoading && !billingAccount) {\n return (\n <div className=\"space-y-6 px-6 lg:px-8 py-6\">\n <div className=\"h-8 w-48 bg-bg-sunken animate-pulse rounded\" />\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-4\">\n <div className=\"border border-border-subtle rounded-lg p-6\">\n <div className=\"h-6 w-24 bg-bg-sunken animate-pulse rounded mb-2\" />\n <div className=\"h-10 w-32 bg-bg-sunken animate-pulse rounded\" />\n </div>\n </div>\n </div>\n );\n }\n\n // Error state\n if (error) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-4\">\n <div className=\"size-12 mx-auto rounded-full bg-status-error-bg-subtle flex items-center justify-center\">\n <svg\n className=\"size-6 text-status-error-text\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-text-primary\">Failed to load credits</h2>\n <p className=\"text-sm text-text-secondary\">{error.message}</p>\n <button\n type=\"button\"\n onClick={() => refetch()}\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors\"\n >\n Try Again\n </button>\n </div>\n </div>\n );\n }\n\n const creditBalance = billingAccount?.creditAmount || 0;\n\n return (\n <div className=\"space-y-6 px-6 lg:px-8 py-6\">\n {/* Header */}\n <div\n className={\n isFluidgrids\n ? 'flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between'\n : 'flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between'\n }\n >\n <div className={isFluidgrids ? 'min-w-0 lg:max-w-3xl' : undefined}>\n <h1 className=\"text-2xl md:text-3xl font-semibold tracking-tight text-text-primary\">\n {tr('billing.credits.title', 'Credits')}\n </h1>\n <p className=\"text-sm text-text-secondary mt-1\">\n Manage your credit balance and view transaction history\n </p>\n <PagePurpose className=\"mt-3\">\n {isFluidgrids\n ? tr(\n 'billing.credits.purposeFluidgrids',\n 'Credits are your prepaid balance for usage and purchases. They are separate from the monthly AI credits that come with your plan. See your balance, top it up, and review every purchase, grant and deduction.'\n )\n : tr(\n 'billing.credits.purpose',\n 'Credits are prepaid balance you can spend on usage and purchases instead of paying per invoice. See your available balance, top it up, withdraw unused credits, and review every credit purchase, grant and deduction over time.'\n )}\n </PagePurpose>\n </div>\n\n <div\n className={\n isFluidgrids\n ? 'flex flex-wrap items-center gap-2 lg:shrink-0 [&_button]:whitespace-nowrap'\n : 'flex items-center gap-2'\n }\n >\n {showWithdraw && (\n <button\n type=\"button\"\n onClick={() => navigateTo('/credits/withdraw')}\n className=\"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken transition-colors\"\n >\n <svg className=\"size-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z\"\n />\n </svg>\n Withdraw\n </button>\n )}\n <button\n type=\"button\"\n onClick={() => navigateTo('/checkout/credits')}\n className=\"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors\"\n >\n <svg className=\"size-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 4v16m8-8H4\"\n />\n </svg>\n Purchase Credits\n </button>\n </div>\n </div>\n\n {/* Balance Card */}\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4\">\n <EmphasisPanel className=\"p-6\">\n <p className=\"text-sm text-text-secondary\">Available Balance</p>\n <p className=\"text-3xl font-bold tabular-nums text-text-primary mt-2\">\n {creditBalance.toLocaleString()} Credits\n </p>\n {isFluidgrids && accountOptions.length > 1 ? (\n <ThemedSelect\n aria-label={tr('billing.credits.billingAccountLabel', 'Billing Account')}\n value={selectedAccountId ?? ''}\n onChange={(e) => {\n setChosenAccountId(e.target.value || null);\n setPage(1);\n }}\n className=\"mt-3 w-full min-w-0 truncate text-sm border border-border-subtle rounded-button bg-bg-surface text-text-primary px-3 py-2 focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n {accountOptions.map((account: BillingAccountItem) => (\n <option key={account.id ?? ''} value={account.id ?? ''}>\n {account.name ?? account.email ?? account.id}\n {account.isDefault ? tr('billing.invoices.defaultSuffix', ' (Default)') : ''}\n </option>\n ))}\n </ThemedSelect>\n ) : (\n <p className=\"text-sm text-text-secondary mt-2\">{billingAccount?.name}</p>\n )}\n </EmphasisPanel>\n\n <div className=\"border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 p-5\">\n <p className=\"text-sm text-text-secondary\">Transactions ({days}d)</p>\n <p className=\"text-2xl md:text-3xl font-semibold tracking-tight text-text-primary mt-2\">\n {pagination.totalCount}\n </p>\n <p className=\"text-sm text-text-secondary mt-2\">Total transactions</p>\n </div>\n </div>\n\n {/* Filters */}\n <div className=\"flex flex-wrap items-center gap-4 pb-4 border-b border-border-subtle\">\n {/* Time Range */}\n <div className=\"inline-flex rounded-lg border border-border-subtle p-1 bg-bg-sunken\">\n {[7, 30, 90].map((d) => (\n <button\n type=\"button\"\n key={d}\n onClick={() => setDays(d)}\n className={`px-3 py-1.5 text-sm font-medium rounded-button transition-colors ${\n days === d\n ? 'bg-bg-surface text-text-primary shadow-sm'\n : 'text-text-secondary hover:text-text-primary'\n }`}\n >\n {d}d\n </button>\n ))}\n </div>\n\n {/* Transaction Type Filter */}\n <div className=\"inline-flex rounded-lg border border-border-subtle p-1 bg-bg-sunken\">\n {(['all', 'purchase', 'usage', 'adjustment', 'granted'] as FilterType[]).map((type) => (\n <button\n type=\"button\"\n key={type}\n onClick={() => setFilterType(type)}\n className={`px-3 py-1.5 text-sm font-medium rounded-button transition-colors capitalize ${\n filterType === type\n ? 'bg-bg-surface text-text-primary shadow-sm'\n : 'text-text-secondary hover:text-text-primary'\n }`}\n >\n {type === 'all' ? 'All' : formatCreditTransactionType(type as CreditTransactionType)}\n </button>\n ))}\n </div>\n </div>\n\n {/* Transactions List */}\n {filteredTransactions.length === 0 ? (\n <IllustratedEmptyState\n illustration={filterType !== 'all' ? 'empty-search' : 'empty-data'}\n title=\"No transactions found\"\n description={\n filterType !== 'all'\n ? 'No transactions match your filter.'\n : 'No credit transactions in this period.'\n }\n />\n ) : (\n <div className=\"space-y-3\">\n {filteredTransactions.map((tx) => (\n <TransactionRow key={tx.id} transaction={tx} />\n ))}\n\n {/* Pagination */}\n {pagination.hasMore && (\n <div className=\"flex justify-center pt-4\">\n <button\n type=\"button\"\n onClick={() => setPage((p) => p + 1)}\n className=\"px-4 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken transition-colors\"\n >\n Load More\n </button>\n </div>\n )}\n </div>\n )}\n </div>\n );\n};\n\n// ============================================================================\n// Transaction Row Component\n// ============================================================================\n\ninterface TransactionRowProps {\n transaction: CreditTransaction;\n}\n\nconst TransactionRow: FC<TransactionRowProps> = ({ transaction }) => {\n const statusColor = getCreditTransactionStatusColor(transaction.status);\n const isCredit =\n transaction.type === 'purchase' ||\n transaction.type === 'adjustment' ||\n transaction.type === 'granted';\n\n return (\n <div className=\"flex items-center gap-4 p-4 border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 hover:shadow-sm transition-shadow\">\n {/* Icon */}\n <div\n className={`size-10 rounded-full flex items-center justify-center ${\n isCredit ? statusTokens.success.bg : statusTokens.warning.bg\n }`}\n >\n {isCredit ? (\n <svg\n className={`size-5 ${statusTokens.success.icon}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M12 4v16m8-8H4\" />\n </svg>\n ) : (\n <svg\n className={`size-5 ${statusTokens.warning.icon}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M20 12H4\" />\n </svg>\n )}\n </div>\n\n {/* Info */}\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2\">\n <p className=\"font-medium text-text-primary capitalize\">\n {formatCreditTransactionType(transaction.type)}\n </p>\n <span\n className={`px-2 py-0.5 text-xs font-medium rounded ${getStatusBadgeClasses(statusColor)}`}\n >\n {transaction.status}\n </span>\n </div>\n <p className=\"text-sm text-text-secondary mt-0.5\">\n {formatRelativeTime(transaction.createdAt)} • {formatDate(transaction.createdAt, 'short')}\n </p>\n </div>\n\n {/* Amount */}\n <div className=\"text-right\">\n <p\n className={`font-semibold ${isCredit ? statusTokens.success.text : 'text-text-primary'}`}\n >\n {isCredit ? '+' : '-'}\n {transaction.amount.toLocaleString()} credits\n </p>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAuCA,IAAaA,UAAwB;CACnC,IAAM,EAAE,SAAMC,EAAQ,GAChBC,KAAM,GAAa,MAA6B;EACpD,IAAMC,IAAaC,EAAEC,CAAG;EACxB,OAAOF,MAAeE,IAAMC,IAAWH;CACzC,GACMI,IAAaC,E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