@burdenoff/microfe-billing 2026.909.1 → 2026.909.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.
@@ -8,274 +8,295 @@ import { getStatusBadgeClasses as o, getTransactionStatusColor as s } from "../.
8
8
  import { isServerError as c } from "../../../shared/utils/error.js";
9
9
  import "../../../shared/utils/index.js";
10
10
  import { useBillingPermissions as l } from "../../../hooks/useBillingPermissions.js";
11
- import { nativeImpact as u, nativeOpenUrl as d } from "../../../../utils/nativeBridge.js";
12
- import { useBillingNavigate as f } from "../../../hooks/useBillingNavigate.js";
13
- import { useTransactions as p } from "../hooks/useTransactions.js";
11
+ import { nativeImpact as u, nativeNotify as d, nativeOpenUrl as f } from "../../../../utils/nativeBridge.js";
12
+ import { useBillingNavigate as p } from "../../../hooks/useBillingNavigate.js";
13
+ import { useInvoiceMutations as m } from "../hooks/useInvoices.js";
14
+ import { useTransactions as h } from "../hooks/useTransactions.js";
14
15
  import "../hooks/index.js";
15
- import { useEffect as m, useRef as h, useState as g } from "react";
16
- import { ArrowLeft as _, Calendar as v, CheckCircle as y, ChevronLeft as b, ChevronRight as x, CreditCard as S, Eye as C, FileText as w, Mail as T, MoreHorizontal as E, Wallet as D, XCircle as O } from "lucide-react";
17
- import { useParams as k } from "react-router";
18
- import { Fragment as A, jsx as j, jsxs as M } from "react/jsx-runtime";
19
- import { useI18n as ee } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
20
- import { Dialog as N, DialogContent as P, DialogFooter as F, DialogHeader as I, DialogTitle as L, EmphasisPanel as R, IllustratedEmptyState as z, PagePurpose as B, ResponsiveTable as V } from "@burdenoff/fe-libs/ui";
16
+ import { useEffect as g, useRef as _, useState as v } from "react";
17
+ import { ArrowLeft as y, Calendar as b, CheckCircle as x, ChevronLeft as S, ChevronRight as C, CreditCard as w, Eye as T, FileText as E, Mail as D, MoreHorizontal as O, Wallet as k, XCircle as A } from "lucide-react";
18
+ import { useParams as j } from "react-router";
19
+ import { Fragment as M, jsx as N, jsxs as P } from "react/jsx-runtime";
20
+ import { useI18n as F } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
21
+ import { Dialog as I, DialogContent as L, DialogFooter as R, DialogHeader as z, DialogTitle as B, EmphasisPanel as V, IllustratedEmptyState as H, PagePurpose as U, ResponsiveTable as ee } from "@burdenoff/fe-libs/ui";
21
22
  //#region src/billing/modules/billing/pages/TransactionsPage.tsx
22
- var H = {
23
+ var W = {
23
24
  payment: "Payment",
24
25
  refund: "Refund",
25
26
  adjustment: "Adjustment"
26
- }, U = (e) => H[e.toLowerCase()] ?? e, W = ({ transaction: e, onViewDetails: t, onViewInvoice: n, hasInvoiceUrl: r }) => {
27
- let [i, a] = g(!1), o = h(null);
28
- return m(() => {
27
+ }, G = (e) => W[e.toLowerCase()] ?? e, te = ({ transaction: e, onViewDetails: t, onViewInvoice: n, hasInvoiceUrl: r }) => {
28
+ let [i, a] = v(!1), o = _(null);
29
+ return g(() => {
29
30
  let e = (e) => {
30
31
  o.current && !o.current.contains(e.target) && a(!1);
31
32
  };
32
33
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
33
- }, []), /* @__PURE__ */ M("div", {
34
+ }, []), /* @__PURE__ */ P("div", {
34
35
  className: "relative overflow-visible",
35
36
  ref: o,
36
- children: [/* @__PURE__ */ j("button", {
37
+ children: [/* @__PURE__ */ N("button", {
37
38
  type: "button",
38
39
  onClick: () => a(!i),
39
40
  className: "p-1.5 rounded-md hover:bg-bg-sunken/50 transition-colors",
40
41
  "aria-label": "Transaction actions",
41
- children: /* @__PURE__ */ j(E, { className: "size-4 text-text-secondary" })
42
- }), i && /* @__PURE__ */ M("div", {
42
+ children: /* @__PURE__ */ N(O, { className: "size-4 text-text-secondary" })
43
+ }), i && /* @__PURE__ */ P("div", {
43
44
  className: "absolute right-0 top-full mt-1 z-50 min-w-[160px] bg-popover border border-border-subtle rounded-md shadow-lg py-1",
44
- children: [/* @__PURE__ */ M("button", {
45
+ children: [/* @__PURE__ */ P("button", {
45
46
  type: "button",
46
47
  onClick: () => {
47
48
  t(), a(!1);
48
49
  },
49
50
  className: "w-full flex items-center gap-2 px-3 py-2 text-sm text-text-primary hover:bg-bg-sunken/50 transition-colors whitespace-nowrap",
50
- children: [/* @__PURE__ */ j(C, { className: "size-4" }), "View Details"]
51
- }), e.type === "payment" && r && /* @__PURE__ */ M("button", {
51
+ children: [/* @__PURE__ */ N(T, { className: "size-4" }), "View Details"]
52
+ }), e.type === "payment" && r && /* @__PURE__ */ P("button", {
52
53
  type: "button",
53
54
  onClick: () => {
54
55
  n(), a(!1);
55
56
  },
56
57
  className: "w-full flex items-center gap-2 px-3 py-2 text-sm text-text-primary hover:bg-bg-sunken/50 transition-colors whitespace-nowrap",
57
- children: [/* @__PURE__ */ j(w, { className: "size-4" }), "View Invoice"]
58
+ children: [/* @__PURE__ */ N(E, { className: "size-4" }), "View Invoice"]
58
59
  })]
59
60
  })]
60
61
  });
61
- }, G = ({ transaction: e, onClose: t, onViewInvoice: n, invoiceUrl: r, invoiceProvider: c }) => {
62
+ }, ne = ({ transaction: e, onClose: t, onViewInvoice: n, onRetryInvoice: r, isRetryingInvoice: c, retryInvoiceError: l, invoiceUrl: d, invoiceProvider: p }) => {
62
63
  if (!e) return null;
63
- let l = e.metadata, f = l?.subtotal, p = l?.taxAmount, m = l?.taxRate, h = l?.taxType, g = l?.total, _ = l?.invoiceNumber, v = l?.invoiceStatus, y = e.type === "refund", b = l?.refundRecordId, x = l?.originalTransactionId, S = l?.creditNoteId, C = l?.creditNoteNumber, T = l?.creditNotePdfUrl, E = l?.reason, D = l?.purchaseType, O = l?.purchaseDetail, k = g && p !== void 0 && p > 0;
64
- return /* @__PURE__ */ j(N, {
64
+ let m = e.metadata, h = m?.subtotal, g = m?.taxAmount, _ = m?.taxRate, v = m?.taxType, y = m?.total, b = m?.invoiceNumber, x = m?.invoiceStatus, S = m?.invoiceCreationError, C = !b && e.type === "payment" && e.status === "success", w = e.type === "refund", T = m?.refundRecordId, D = m?.originalTransactionId, O = m?.creditNoteId, k = m?.creditNoteNumber, A = m?.creditNotePdfUrl, j = m?.reason, F = m?.purchaseType, V = m?.purchaseDetail, H = y && g !== void 0 && g > 0;
65
+ return /* @__PURE__ */ N(I, {
65
66
  open: !!e,
66
67
  onOpenChange: (e) => !e && t(),
67
- children: /* @__PURE__ */ M(P, {
68
+ children: /* @__PURE__ */ P(L, {
68
69
  className: "max-w-md max-h-[90vh] overflow-auto p-0",
69
70
  children: [
70
- /* @__PURE__ */ j(I, {
71
+ /* @__PURE__ */ N(z, {
71
72
  className: "p-4 border-b border-border-subtle",
72
- children: /* @__PURE__ */ j(L, {
73
+ children: /* @__PURE__ */ N(B, {
73
74
  className: "text-lg font-semibold",
74
75
  children: "Transaction Details"
75
76
  })
76
77
  }),
77
- /* @__PURE__ */ M("div", {
78
+ /* @__PURE__ */ P("div", {
78
79
  className: "p-4 space-y-4",
79
80
  children: [
80
- /* @__PURE__ */ M("div", {
81
+ /* @__PURE__ */ P("div", {
81
82
  className: "grid grid-cols-2 gap-4",
82
- children: [/* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
83
+ children: [/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
83
84
  className: "text-xs text-text-secondary mb-1",
84
85
  children: "Transaction ID"
85
- }), /* @__PURE__ */ j("p", {
86
+ }), /* @__PURE__ */ N("p", {
86
87
  className: "text-sm font-mono break-all",
87
88
  children: e.id
88
- })] }), /* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
89
+ })] }), /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
89
90
  className: "text-xs text-text-secondary mb-1",
90
91
  children: "Type"
91
- }), /* @__PURE__ */ j("p", {
92
+ }), /* @__PURE__ */ N("p", {
92
93
  className: "text-sm capitalize",
93
- children: U(e.type)
94
+ children: G(e.type)
94
95
  })] })]
95
96
  }),
96
- /* @__PURE__ */ j("div", {
97
+ /* @__PURE__ */ N("div", {
97
98
  className: "space-y-2",
98
- children: k ? /* @__PURE__ */ M(A, { children: [
99
- /* @__PURE__ */ M("div", {
99
+ children: H ? /* @__PURE__ */ P(M, { children: [
100
+ /* @__PURE__ */ P("div", {
100
101
  className: "flex justify-between text-sm",
101
- children: [/* @__PURE__ */ j("span", {
102
+ children: [/* @__PURE__ */ N("span", {
102
103
  className: "text-text-secondary",
103
104
  children: "Subtotal"
104
- }), /* @__PURE__ */ j("span", { children: i(f || e.amount, e.currency) })]
105
+ }), /* @__PURE__ */ N("span", { children: i(h || e.amount, e.currency) })]
105
106
  }),
106
- p > 0 && /* @__PURE__ */ M("div", {
107
+ g > 0 && /* @__PURE__ */ P("div", {
107
108
  className: "flex justify-between text-sm",
108
- children: [/* @__PURE__ */ M("span", {
109
+ children: [/* @__PURE__ */ P("span", {
109
110
  className: "text-text-secondary",
110
111
  children: [
111
- h || "Tax",
112
+ v || "Tax",
112
113
  " ",
113
- m ? `(${(m * 100).toFixed(0)}%)` : ""
114
+ _ ? `(${(_ * 100).toFixed(0)}%)` : ""
114
115
  ]
115
- }), /* @__PURE__ */ j("span", { children: i(p, e.currency) })]
116
+ }), /* @__PURE__ */ N("span", { children: i(g, e.currency) })]
116
117
  }),
117
- /* @__PURE__ */ M("div", {
118
+ /* @__PURE__ */ P("div", {
118
119
  className: "flex justify-between text-sm font-semibold border-t border-border-subtle pt-2",
119
- children: [/* @__PURE__ */ j("span", { children: "Total" }), /* @__PURE__ */ M("span", {
120
+ children: [/* @__PURE__ */ N("span", { children: "Total" }), /* @__PURE__ */ P("span", {
120
121
  className: e.type === "refund" ? "text-status-error-text" : "",
121
- children: [e.type === "refund" ? "-" : "", i(g, e.currency)]
122
+ children: [e.type === "refund" ? "-" : "", i(y, e.currency)]
122
123
  })]
123
124
  })
124
- ] }) : /* @__PURE__ */ M("div", {
125
+ ] }) : /* @__PURE__ */ P("div", {
125
126
  className: "grid grid-cols-2 gap-4",
126
- children: [/* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
127
+ children: [/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
127
128
  className: "text-xs text-text-secondary mb-1",
128
129
  children: "Amount"
129
- }), /* @__PURE__ */ M("p", {
130
+ }), /* @__PURE__ */ P("p", {
130
131
  className: `text-sm font-medium ${e.type === "refund" ? "text-status-error-text" : ""}`,
131
- children: [e.type === "refund" ? "-" : "", i(g || e.amount, e.currency)]
132
- })] }), /* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
132
+ children: [e.type === "refund" ? "-" : "", i(y || e.amount, e.currency)]
133
+ })] }), /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
133
134
  className: "text-xs text-text-secondary mb-1",
134
135
  children: "Status"
135
- }), /* @__PURE__ */ j("span", {
136
+ }), /* @__PURE__ */ N("span", {
136
137
  className: `px-2 py-0.5 text-xs font-medium rounded ${o(s(e.status))}`,
137
138
  children: e.status
138
139
  })] })]
139
140
  })
140
141
  }),
141
- k && /* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
142
+ H && /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
142
143
  className: "text-xs text-text-secondary mb-1",
143
144
  children: "Status"
144
- }), /* @__PURE__ */ j("span", {
145
+ }), /* @__PURE__ */ N("span", {
145
146
  className: `px-2 py-0.5 text-xs font-medium rounded ${o(s(e.status))}`,
146
147
  children: e.status
147
148
  })] }),
148
- /* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
149
+ /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
149
150
  className: "text-xs text-text-secondary mb-1",
150
151
  children: "Date & Time"
151
- }), /* @__PURE__ */ j("p", {
152
+ }), /* @__PURE__ */ N("p", {
152
153
  className: "text-sm",
153
154
  children: a(e.createdAt)
154
155
  })] }),
155
- e.description && /* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
156
+ e.description && /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
156
157
  className: "text-xs text-text-secondary mb-1",
157
158
  children: "Description"
158
- }), /* @__PURE__ */ j("p", {
159
+ }), /* @__PURE__ */ N("p", {
159
160
  className: "text-sm",
160
161
  children: e.description
161
162
  })] }),
162
- _ && /* @__PURE__ */ M("div", {
163
+ b && /* @__PURE__ */ P("div", {
163
164
  className: "p-3 bg-bg-sunken/50 rounded-lg space-y-2",
164
165
  children: [
165
- /* @__PURE__ */ M("div", {
166
+ /* @__PURE__ */ P("div", {
166
167
  className: "flex items-center justify-between",
167
- children: [/* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
168
+ children: [/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
168
169
  className: "text-xs text-text-secondary mb-1",
169
170
  children: "Invoice"
170
- }), /* @__PURE__ */ j("p", {
171
+ }), /* @__PURE__ */ N("p", {
171
172
  className: "text-sm font-mono",
172
- children: _
173
- })] }), v && /* @__PURE__ */ j("span", {
174
- className: `px-2 py-0.5 text-xs font-medium rounded ${v === "PAID" ? "bg-status-success-bg-subtle text-status-success-text" : "bg-status-warning-bg-subtle text-status-warning-text"}`,
175
- children: v
173
+ children: b
174
+ })] }), x && /* @__PURE__ */ N("span", {
175
+ className: `px-2 py-0.5 text-xs font-medium rounded ${x === "PAID" ? "bg-status-success-bg-subtle text-status-success-text" : "bg-status-warning-bg-subtle text-status-warning-text"}`,
176
+ children: x
176
177
  })]
177
178
  }),
178
- c && /* @__PURE__ */ M("p", {
179
+ p && /* @__PURE__ */ P("p", {
179
180
  className: "text-xs text-text-secondary",
180
- children: ["Provider: ", c]
181
+ children: ["Provider: ", p]
181
182
  }),
182
- r && n && /* @__PURE__ */ M("button", {
183
+ d && n && /* @__PURE__ */ P("button", {
183
184
  type: "button",
184
185
  onClick: () => n(e),
185
186
  className: "flex items-center gap-2 text-sm text-primary hover:underline",
186
- children: [/* @__PURE__ */ j(w, { className: "size-4" }), "View Invoice"]
187
+ children: [/* @__PURE__ */ N(E, { className: "size-4" }), "View Invoice"]
187
188
  })
188
189
  ]
189
190
  }),
190
- !_ && r && n && /* @__PURE__ */ j("div", {
191
+ !b && d && n && /* @__PURE__ */ N("div", {
191
192
  className: "p-3 bg-bg-sunken/50 rounded-lg",
192
- children: /* @__PURE__ */ M("button", {
193
+ children: /* @__PURE__ */ P("button", {
193
194
  type: "button",
194
195
  onClick: () => n(e),
195
196
  className: "flex items-center gap-2 text-sm text-primary hover:underline",
196
197
  children: [
197
- /* @__PURE__ */ j(w, { className: "size-4" }),
198
+ /* @__PURE__ */ N(E, { className: "size-4" }),
198
199
  "View Invoice ",
199
- c && `(${c})`
200
+ p && `(${p})`
200
201
  ]
201
202
  })
202
203
  }),
203
- y && (S || E || D) && /* @__PURE__ */ M("div", {
204
+ C && !d && r && /* @__PURE__ */ P("div", {
205
+ className: "p-3 bg-status-warning-bg-subtle border border-status-warning-border rounded-lg space-y-2",
206
+ children: [
207
+ /* @__PURE__ */ N("p", {
208
+ className: "text-sm text-status-warning-text",
209
+ children: S ? "Invoice generation failed for this payment." : "This payment doesn't have an invoice yet."
210
+ }),
211
+ /* @__PURE__ */ P("button", {
212
+ type: "button",
213
+ onClick: () => r(e),
214
+ disabled: c,
215
+ className: "flex items-center gap-2 text-sm font-medium text-primary hover:underline disabled:cursor-not-allowed disabled:opacity-50",
216
+ children: [/* @__PURE__ */ N(E, { className: "size-4" }), c ? "Generating…" : "Generate Invoice"]
217
+ }),
218
+ l && /* @__PURE__ */ N("p", {
219
+ className: "text-sm text-status-error-text",
220
+ children: l
221
+ })
222
+ ]
223
+ }),
224
+ w && (O || j || F) && /* @__PURE__ */ P("div", {
204
225
  className: "p-3 bg-status-error-bg-subtle/20 border border-border-subtle rounded-lg space-y-3",
205
226
  children: [
206
- /* @__PURE__ */ M("div", {
227
+ /* @__PURE__ */ P("div", {
207
228
  className: "flex items-center gap-2",
208
- children: [/* @__PURE__ */ j("div", { className: "size-1.5 rounded-full bg-status-error-bg" }), /* @__PURE__ */ j("p", {
229
+ children: [/* @__PURE__ */ N("div", { className: "size-1.5 rounded-full bg-status-error-bg" }), /* @__PURE__ */ N("p", {
209
230
  className: "text-sm font-semibold text-status-error-text",
210
231
  children: "Refund Information"
211
232
  })]
212
233
  }),
213
- C && /* @__PURE__ */ M("div", {
234
+ k && /* @__PURE__ */ P("div", {
214
235
  className: "space-y-2",
215
- children: [/* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
236
+ children: [/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
216
237
  className: "text-xs text-status-error-text mb-1",
217
238
  children: "Credit Note"
218
- }), /* @__PURE__ */ j("p", {
239
+ }), /* @__PURE__ */ N("p", {
219
240
  className: "text-sm font-mono text-status-error-text",
220
- children: C
221
- })] }), T && /* @__PURE__ */ M("button", {
241
+ children: k
242
+ })] }), A && /* @__PURE__ */ P("button", {
222
243
  type: "button",
223
244
  onClick: () => {
224
- u("light"), d(T);
245
+ u("light"), f(A);
225
246
  },
226
247
  className: "flex items-center gap-2 text-sm text-status-error-text hover:underline",
227
- children: [/* @__PURE__ */ j(w, { className: "size-4" }), "Download Credit Note PDF"]
248
+ children: [/* @__PURE__ */ N(E, { className: "size-4" }), "Download Credit Note PDF"]
228
249
  })]
229
250
  }),
230
- D && /* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
251
+ F && /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
231
252
  className: "text-xs text-status-error-text mb-1",
232
253
  children: "Purchase Type"
233
- }), /* @__PURE__ */ M("p", {
254
+ }), /* @__PURE__ */ P("p", {
234
255
  className: "text-sm text-status-error-text",
235
- children: [D, O && ` - ${O}`]
256
+ children: [F, V && ` - ${V}`]
236
257
  })] }),
237
- E && /* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
258
+ j && /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
238
259
  className: "text-xs text-status-error-text mb-1",
239
260
  children: "Reason"
240
- }), /* @__PURE__ */ j("p", {
261
+ }), /* @__PURE__ */ N("p", {
241
262
  className: "text-sm text-status-error-text",
242
- children: E
263
+ children: j
243
264
  })] }),
244
- x && /* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
265
+ D && /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
245
266
  className: "text-xs text-status-error-text mb-1",
246
267
  children: "Original Transaction"
247
- }), /* @__PURE__ */ j("p", {
268
+ }), /* @__PURE__ */ N("p", {
248
269
  className: "text-sm font-mono text-status-error-text break-all",
249
- children: x
270
+ children: D
250
271
  })] }),
251
- b && /* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
272
+ T && /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
252
273
  className: "text-xs text-status-error-text mb-1",
253
274
  children: "Refund Record ID"
254
- }), /* @__PURE__ */ j("p", {
275
+ }), /* @__PURE__ */ N("p", {
255
276
  className: "text-sm font-mono text-status-error-text break-all",
256
- children: b
277
+ children: T
257
278
  })] })
258
279
  ]
259
280
  }),
260
- e.stripePaymentId && /* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
281
+ e.stripePaymentId && /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
261
282
  className: "text-xs text-text-secondary mb-1",
262
283
  children: "Stripe Payment ID"
263
- }), /* @__PURE__ */ j("p", {
284
+ }), /* @__PURE__ */ N("p", {
264
285
  className: "text-sm font-mono break-all",
265
286
  children: e.stripePaymentId
266
287
  })] }),
267
- e.razorpayPaymentId && /* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
288
+ e.razorpayPaymentId && /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
268
289
  className: "text-xs text-text-secondary mb-1",
269
290
  children: "Razorpay Payment ID"
270
- }), /* @__PURE__ */ j("p", {
291
+ }), /* @__PURE__ */ N("p", {
271
292
  className: "text-sm font-mono break-all",
272
293
  children: e.razorpayPaymentId
273
294
  })] })
274
295
  ]
275
296
  }),
276
- /* @__PURE__ */ j(F, {
297
+ /* @__PURE__ */ N(R, {
277
298
  className: "p-4 border-t border-border-subtle",
278
- children: /* @__PURE__ */ j("button", {
299
+ children: /* @__PURE__ */ N("button", {
279
300
  type: "button",
280
301
  onClick: t,
281
302
  className: "w-full py-2 px-4 bg-action-primary-bg text-action-primary-text rounded-md hover:bg-action-primary-bg/90 transition-colors",
@@ -286,55 +307,61 @@ var H = {
286
307
  })
287
308
  });
288
309
  }, K = () => {
289
- let { t: m } = ee(), h = (e, t) => {
290
- let n = m(e);
310
+ let { t: g } = F(), _ = (e, t) => {
311
+ let n = g(e);
291
312
  return n === e ? t : n;
292
- }, { billingAccountId: C } = k(), E = l(), A = f(), { billingAccount: N, transactions: P, pagination: F, isLoading: I, error: L, refetch: K, goToNextPage: q, goToPreviousPage: te } = p(C), [J, ne] = g("all"), [Y, X] = g(null), Z = (e) => {
293
- let t = e.metadata;
294
- return t?.zohoBooksInvoiceUrl ? t.zohoBooksInvoiceUrl : t?.invoiceUrl ? t.invoiceUrl : t?.invoicePdf ? t.invoicePdf : null;
295
- }, re = (e) => {
313
+ }, { billingAccountId: T } = j(), O = l(), M = p(), { billingAccount: I, transactions: L, pagination: R, isLoading: z, error: B, refetch: K, goToNextPage: re, goToPreviousPage: ie } = h(T), [q, ae] = v("all"), [oe, J] = v(null), Y = L.find((e) => e.id === oe) ?? null, { retryInvoiceGeneration: se, isRetrying: ce } = m(), [le, X] = v(null), ue = async (e) => {
314
+ if (T) {
315
+ X(null);
316
+ try {
317
+ await se(e.id, T), d("success");
318
+ } catch (e) {
319
+ X(e instanceof Error ? e.message : "Failed to generate invoice"), d("error");
320
+ }
321
+ }
322
+ }, Z = (e) => e.metadata?.invoiceUrl ?? null, de = (e) => {
296
323
  let t = e.metadata;
297
324
  return t?.total && typeof t.total == "number" ? t.total : e.amount;
298
- }, ie = (e) => {
299
- let t = e.metadata;
300
- return t?.zohoBooksInvoiceUrl ? "Zoho Books" : t?.invoiceUrl || t?.invoicePdf ? "Stripe" : null;
325
+ }, fe = (e) => {
326
+ let t = e.metadata?.invoiceProvider;
327
+ return t === "ZOHO_BOOKS" ? "Zoho Books" : t === "STRIPE" ? "Stripe" : null;
301
328
  }, Q = (e) => {
302
329
  let t = Z(e);
303
- t && (u("light"), d(t));
330
+ t && (u("light"), f(t));
304
331
  };
305
- if (!E.canViewPayments) return /* @__PURE__ */ j(e, { message: h("billing.transactions.noPermission", "You don't have permission to view transaction history.") });
306
- if (!C) return /* @__PURE__ */ j("div", {
332
+ if (!O.canViewPayments) return /* @__PURE__ */ N(e, { message: _("billing.transactions.noPermission", "You don't have permission to view transaction history.") });
333
+ if (!T) return /* @__PURE__ */ N("div", {
307
334
  className: "p-6",
308
- children: /* @__PURE__ */ j(n, {
309
- icon: /* @__PURE__ */ j("svg", {
335
+ children: /* @__PURE__ */ N(n, {
336
+ icon: /* @__PURE__ */ N("svg", {
310
337
  className: "size-6 text-text-secondary",
311
338
  fill: "none",
312
339
  viewBox: "0 0 24 24",
313
340
  stroke: "currentColor",
314
- children: /* @__PURE__ */ j("path", {
341
+ children: /* @__PURE__ */ N("path", {
315
342
  strokeLinecap: "round",
316
343
  strokeLinejoin: "round",
317
344
  strokeWidth: 2,
318
345
  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"
319
346
  })
320
347
  }),
321
- title: h("billing.transactions.noAccountSelected", "No billing account selected"),
322
- description: h("billing.transactions.noAccountSelectedDesc", "Please select a billing account from the overview page to view transactions.")
348
+ title: _("billing.transactions.noAccountSelected", "No billing account selected"),
349
+ description: _("billing.transactions.noAccountSelectedDesc", "Please select a billing account from the overview page to view transactions.")
323
350
  })
324
351
  });
325
- if (L && c(L)) return /* @__PURE__ */ j("div", {
352
+ if (B && c(B)) return /* @__PURE__ */ N("div", {
326
353
  className: "p-6",
327
- children: /* @__PURE__ */ j(r, {
328
- title: h("billing.transactions.serverUnavailable", "Server Unavailable"),
329
- message: h("billing.transactions.serverUnavailableMessage", "Unable to load transactions. The server might be down or experiencing issues."),
354
+ children: /* @__PURE__ */ N(r, {
355
+ title: _("billing.transactions.serverUnavailable", "Server Unavailable"),
356
+ message: _("billing.transactions.serverUnavailableMessage", "Unable to load transactions. The server might be down or experiencing issues."),
330
357
  onRetry: () => K(),
331
358
  showRetry: !0
332
359
  })
333
360
  });
334
- let $ = J === "all" ? P : P.filter((e) => e.type === J);
335
- return I ? /* @__PURE__ */ M("div", {
361
+ let $ = q === "all" ? L : L.filter((e) => e.type === q);
362
+ return z ? /* @__PURE__ */ P("div", {
336
363
  className: "space-y-6 p-6",
337
- children: [/* @__PURE__ */ j("div", { className: "h-8 w-48 bg-bg-sunken animate-pulse rounded" }), /* @__PURE__ */ j("div", {
364
+ children: [/* @__PURE__ */ N("div", { className: "h-8 w-48 bg-bg-sunken animate-pulse rounded" }), /* @__PURE__ */ N("div", {
338
365
  className: "space-y-2",
339
366
  children: [
340
367
  1,
@@ -342,121 +369,121 @@ var H = {
342
369
  3,
343
370
  4,
344
371
  5
345
- ].map((e) => /* @__PURE__ */ j("div", { className: "h-16 bg-bg-sunken animate-pulse rounded" }, e))
372
+ ].map((e) => /* @__PURE__ */ N("div", { className: "h-16 bg-bg-sunken animate-pulse rounded" }, e))
346
373
  })]
347
- }) : /* @__PURE__ */ M("div", {
374
+ }) : /* @__PURE__ */ P("div", {
348
375
  className: "space-y-6 p-6",
349
376
  children: [
350
- /* @__PURE__ */ M("button", {
377
+ /* @__PURE__ */ P("button", {
351
378
  type: "button",
352
- onClick: () => A("/overview"),
379
+ onClick: () => M("/overview"),
353
380
  className: "inline-flex items-center gap-2 text-sm text-text-secondary hover:text-text-primary transition-colors",
354
- children: [/* @__PURE__ */ j(_, { className: "size-4" }), "Back to Overview"]
381
+ children: [/* @__PURE__ */ N(y, { className: "size-4" }), "Back to Overview"]
355
382
  }),
356
- /* @__PURE__ */ j(t, {
357
- title: h("billing.transactions.title", "Transaction History"),
358
- description: N ? `Transactions for ${N.name}` : "View all your billing transactions"
383
+ /* @__PURE__ */ N(t, {
384
+ title: _("billing.transactions.title", "Transaction History"),
385
+ description: I ? `Transactions for ${I.name}` : "View all your billing transactions"
359
386
  }),
360
- /* @__PURE__ */ j(B, { children: h("billing.transactions.purpose", "A complete, time-ordered ledger of money movements on this billing account — payments, refunds and adjustments. Use it to reconcile what you were charged, open the linked invoice or credit note, and see tax breakdowns for each transaction.") }),
361
- N && /* @__PURE__ */ j(R, {
387
+ /* @__PURE__ */ N(U, { children: _("billing.transactions.purpose", "A complete, time-ordered ledger of money movements on this billing account — payments, refunds and adjustments. Use it to reconcile what you were charged, open the linked invoice or credit note, and see tax breakdowns for each transaction.") }),
388
+ I && /* @__PURE__ */ N(V, {
362
389
  className: "p-4",
363
- children: /* @__PURE__ */ M("div", {
390
+ children: /* @__PURE__ */ P("div", {
364
391
  className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",
365
392
  children: [
366
- /* @__PURE__ */ M("div", {
393
+ /* @__PURE__ */ P("div", {
367
394
  className: "flex items-start gap-2",
368
- children: [/* @__PURE__ */ j(S, { className: "size-4 text-text-secondary mt-0.5" }), /* @__PURE__ */ M("div", { children: [
369
- /* @__PURE__ */ j("p", {
395
+ children: [/* @__PURE__ */ N(w, { className: "size-4 text-text-secondary mt-0.5" }), /* @__PURE__ */ P("div", { children: [
396
+ /* @__PURE__ */ N("p", {
370
397
  className: "text-xs text-text-secondary mb-0.5",
371
398
  children: "Account"
372
399
  }),
373
- /* @__PURE__ */ j("p", {
400
+ /* @__PURE__ */ N("p", {
374
401
  className: "text-sm font-medium",
375
- children: N.name
402
+ children: I.name
376
403
  }),
377
- N.isActive ? /* @__PURE__ */ M("span", {
404
+ I.isActive ? /* @__PURE__ */ P("span", {
378
405
  className: "inline-flex items-center gap-1 mt-1 px-1.5 py-0.5 text-xs font-medium rounded bg-status-success-bg-subtle text-status-success-text",
379
- children: [/* @__PURE__ */ j(y, { className: "size-3" }), "Active"]
380
- }) : /* @__PURE__ */ M("span", {
406
+ children: [/* @__PURE__ */ N(x, { className: "size-3" }), "Active"]
407
+ }) : /* @__PURE__ */ P("span", {
381
408
  className: "inline-flex items-center gap-1 mt-1 px-1.5 py-0.5 text-xs font-medium rounded bg-status-error-bg-subtle text-status-error-text",
382
- children: [/* @__PURE__ */ j(O, { className: "size-3" }), "Inactive"]
409
+ children: [/* @__PURE__ */ N(A, { className: "size-3" }), "Inactive"]
383
410
  })
384
411
  ] })]
385
412
  }),
386
- /* @__PURE__ */ M("div", {
413
+ /* @__PURE__ */ P("div", {
387
414
  className: "flex items-start gap-2",
388
- children: [/* @__PURE__ */ j(T, { className: "size-4 text-text-secondary mt-0.5" }), /* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
415
+ children: [/* @__PURE__ */ N(D, { className: "size-4 text-text-secondary mt-0.5" }), /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
389
416
  className: "text-xs text-text-secondary mb-0.5",
390
417
  children: "Email"
391
- }), /* @__PURE__ */ j("p", {
418
+ }), /* @__PURE__ */ N("p", {
392
419
  className: "text-sm font-medium break-all",
393
- children: N.billingEmail || N.email
420
+ children: I.billingEmail || I.email
394
421
  })] })]
395
422
  }),
396
- /* @__PURE__ */ M("div", {
423
+ /* @__PURE__ */ P("div", {
397
424
  className: "flex items-start gap-2",
398
- children: [/* @__PURE__ */ j(D, { className: "size-4 text-text-secondary mt-0.5" }), /* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
425
+ children: [/* @__PURE__ */ N(k, { className: "size-4 text-text-secondary mt-0.5" }), /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
399
426
  className: "text-xs text-text-secondary mb-0.5",
400
427
  children: "Credits Balance"
401
- }), /* @__PURE__ */ M("p", {
428
+ }), /* @__PURE__ */ P("p", {
402
429
  className: "text-sm font-semibold text-text-primary",
403
- children: [(N.creditAmount || 0).toLocaleString(), " Credits"]
430
+ children: [(I.creditAmount || 0).toLocaleString(), " Credits"]
404
431
  })] })]
405
432
  }),
406
- /* @__PURE__ */ M("div", {
433
+ /* @__PURE__ */ P("div", {
407
434
  className: "flex items-start gap-2",
408
- children: [/* @__PURE__ */ j(w, { className: "size-4 text-text-secondary mt-0.5" }), /* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
435
+ children: [/* @__PURE__ */ N(E, { className: "size-4 text-text-secondary mt-0.5" }), /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
409
436
  className: "text-xs text-text-secondary mb-0.5",
410
437
  children: "Tax ID"
411
- }), /* @__PURE__ */ j("p", {
438
+ }), /* @__PURE__ */ N("p", {
412
439
  className: "text-sm font-medium",
413
- children: N.taxId || "-"
440
+ children: I.taxId || "-"
414
441
  })] })]
415
442
  }),
416
- /* @__PURE__ */ M("div", {
443
+ /* @__PURE__ */ P("div", {
417
444
  className: "flex items-start gap-2",
418
- children: [/* @__PURE__ */ j(v, { className: "size-4 text-text-secondary mt-0.5" }), /* @__PURE__ */ M("div", { children: [/* @__PURE__ */ j("p", {
445
+ children: [/* @__PURE__ */ N(b, { className: "size-4 text-text-secondary mt-0.5" }), /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("p", {
419
446
  className: "text-xs text-text-secondary mb-0.5",
420
447
  children: "Member Since"
421
- }), /* @__PURE__ */ j("p", {
448
+ }), /* @__PURE__ */ N("p", {
422
449
  className: "text-sm font-medium",
423
- children: N.createdAt ? a(N.createdAt) : "-"
450
+ children: I.createdAt ? a(I.createdAt) : "-"
424
451
  })] })]
425
452
  })
426
453
  ]
427
454
  })
428
455
  }),
429
- /* @__PURE__ */ j("div", {
456
+ /* @__PURE__ */ N("div", {
430
457
  className: "flex items-center gap-4",
431
- children: /* @__PURE__ */ j("div", {
458
+ children: /* @__PURE__ */ N("div", {
432
459
  className: "inline-flex rounded-lg border border-border-subtle p-1 bg-bg-sunken/50",
433
460
  children: [
434
461
  "all",
435
462
  "payment",
436
463
  "refund",
437
464
  "adjustment"
438
- ].map((e) => /* @__PURE__ */ j("button", {
465
+ ].map((e) => /* @__PURE__ */ N("button", {
439
466
  type: "button",
440
- onClick: () => ne(e),
441
- className: `px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${J === e ? "bg-bg-surface text-text-primary shadow-sm" : "text-text-secondary hover:text-text-primary"}`,
442
- children: e === "all" ? "All" : H[e]
467
+ onClick: () => ae(e),
468
+ className: `px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${q === e ? "bg-bg-surface text-text-primary shadow-sm" : "text-text-secondary hover:text-text-primary"}`,
469
+ children: e === "all" ? "All" : W[e]
443
470
  }, e))
444
471
  })
445
472
  }),
446
- $.length === 0 ? /* @__PURE__ */ j(z, {
447
- illustration: J === "all" ? "empty-data" : "empty-search",
448
- title: h("billing.transactions.noTransactionsFound", "No transactions found"),
449
- description: J === "all" ? h("billing.transactions.noTransactionsYet", "Your transaction history will appear here.") : h("billing.transactions.noTransactionsFiltered", "No transactions match your filter.")
450
- }) : /* @__PURE__ */ j("div", {
473
+ $.length === 0 ? /* @__PURE__ */ N(H, {
474
+ illustration: q === "all" ? "empty-data" : "empty-search",
475
+ title: _("billing.transactions.noTransactionsFound", "No transactions found"),
476
+ description: q === "all" ? _("billing.transactions.noTransactionsYet", "Your transaction history will appear here.") : _("billing.transactions.noTransactionsFiltered", "No transactions match your filter.")
477
+ }) : /* @__PURE__ */ N("div", {
451
478
  className: "border border-border-subtle rounded-lg overflow-visible",
452
- children: /* @__PURE__ */ j(V, {
479
+ children: /* @__PURE__ */ N(ee, {
453
480
  columns: [
454
481
  {
455
482
  key: "date",
456
483
  header: "Date",
457
484
  priority: "primary",
458
485
  cellClassName: "whitespace-nowrap",
459
- cell: (e) => /* @__PURE__ */ j("span", {
486
+ cell: (e) => /* @__PURE__ */ N("span", {
460
487
  className: "text-sm text-text-primary",
461
488
  children: a(e.createdAt)
462
489
  })
@@ -465,15 +492,15 @@ var H = {
465
492
  key: "type",
466
493
  header: "Type",
467
494
  cellClassName: "whitespace-nowrap",
468
- cell: (e) => /* @__PURE__ */ j("span", {
495
+ cell: (e) => /* @__PURE__ */ N("span", {
469
496
  className: "text-sm text-text-primary capitalize",
470
- children: U(e.type)
497
+ children: G(e.type)
471
498
  })
472
499
  },
473
500
  {
474
501
  key: "description",
475
502
  header: "Description",
476
- cell: (e) => /* @__PURE__ */ j("span", {
503
+ cell: (e) => /* @__PURE__ */ N("span", {
477
504
  className: "text-sm text-text-secondary",
478
505
  children: e.description ?? "-"
479
506
  })
@@ -483,9 +510,9 @@ var H = {
483
510
  header: "Amount",
484
511
  headerClassName: "text-right",
485
512
  cellClassName: "text-right whitespace-nowrap",
486
- cell: (e) => /* @__PURE__ */ M("span", {
513
+ cell: (e) => /* @__PURE__ */ P("span", {
487
514
  className: `text-sm font-medium tabular-nums ${e.type === "refund" ? "text-status-error-text" : "text-text-primary"}`,
488
- children: [e.type === "refund" ? "-" : "", i(re(e), e.currency)]
515
+ children: [e.type === "refund" ? "-" : "", i(de(e), e.currency)]
489
516
  })
490
517
  },
491
518
  {
@@ -493,7 +520,7 @@ var H = {
493
520
  header: "Status",
494
521
  headerClassName: "text-center",
495
522
  cellClassName: "text-center whitespace-nowrap",
496
- cell: (e) => /* @__PURE__ */ j("span", {
523
+ cell: (e) => /* @__PURE__ */ N("span", {
497
524
  className: `px-1.5 py-0.5 text-xs font-medium rounded ${o(s(e.status))}`,
498
525
  children: e.status
499
526
  })
@@ -501,64 +528,69 @@ var H = {
501
528
  ],
502
529
  data: $,
503
530
  rowKey: (e) => e.id,
504
- rowActions: (e) => /* @__PURE__ */ j(W, {
531
+ rowActions: (e) => /* @__PURE__ */ N(te, {
505
532
  transaction: e,
506
- onViewDetails: () => X(e),
533
+ onViewDetails: () => J(e.id),
507
534
  onViewInvoice: () => Q(e),
508
535
  hasInvoiceUrl: !!Z(e)
509
536
  })
510
537
  })
511
538
  }),
512
- F.totalCount > 0 && /* @__PURE__ */ M("div", {
539
+ R.totalCount > 0 && /* @__PURE__ */ P("div", {
513
540
  className: "flex items-center justify-between border-t border-border-subtle pt-4",
514
- children: [/* @__PURE__ */ M("p", {
541
+ children: [/* @__PURE__ */ P("p", {
515
542
  className: "text-sm text-text-secondary",
516
543
  children: [
517
544
  "Showing ",
518
- F.page * F.pageSize + 1,
545
+ R.page * R.pageSize + 1,
519
546
  " to",
520
547
  " ",
521
- Math.min((F.page + 1) * F.pageSize, F.totalCount),
548
+ Math.min((R.page + 1) * R.pageSize, R.totalCount),
522
549
  " of",
523
550
  " ",
524
- F.totalCount,
551
+ R.totalCount,
525
552
  " transactions"
526
553
  ]
527
- }), /* @__PURE__ */ M("div", {
554
+ }), /* @__PURE__ */ P("div", {
528
555
  className: "flex items-center gap-2",
529
556
  children: [
530
- /* @__PURE__ */ M("button", {
557
+ /* @__PURE__ */ P("button", {
531
558
  type: "button",
532
- onClick: te,
533
- disabled: !F.hasPrevious,
559
+ onClick: ie,
560
+ disabled: !R.hasPrevious,
534
561
  className: "inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-md border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
535
- children: [/* @__PURE__ */ j(b, { className: "size-4" }), "Previous"]
562
+ children: [/* @__PURE__ */ N(S, { className: "size-4" }), "Previous"]
536
563
  }),
537
- /* @__PURE__ */ M("span", {
564
+ /* @__PURE__ */ P("span", {
538
565
  className: "text-sm text-text-secondary px-2",
539
566
  children: [
540
567
  "Page ",
541
- F.page + 1,
568
+ R.page + 1,
542
569
  " of ",
543
- Math.ceil(F.totalCount / F.pageSize)
570
+ Math.ceil(R.totalCount / R.pageSize)
544
571
  ]
545
572
  }),
546
- /* @__PURE__ */ M("button", {
573
+ /* @__PURE__ */ P("button", {
547
574
  type: "button",
548
- onClick: q,
549
- disabled: !F.hasMore,
575
+ onClick: re,
576
+ disabled: !R.hasMore,
550
577
  className: "inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-md border border-border-subtle bg-bg-surface hover:bg-bg-sunken/50 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
551
- children: ["Next", /* @__PURE__ */ j(x, { className: "size-4" })]
578
+ children: ["Next", /* @__PURE__ */ N(C, { className: "size-4" })]
552
579
  })
553
580
  ]
554
581
  })]
555
582
  }),
556
- /* @__PURE__ */ j(G, {
583
+ /* @__PURE__ */ N(ne, {
557
584
  transaction: Y,
558
- onClose: () => X(null),
585
+ onClose: () => {
586
+ J(null), X(null);
587
+ },
559
588
  onViewInvoice: Q,
589
+ onRetryInvoice: ue,
590
+ isRetryingInvoice: ce,
591
+ retryInvoiceError: le,
560
592
  invoiceUrl: Y ? Z(Y) : null,
561
- invoiceProvider: Y ? ie(Y) : null
593
+ invoiceProvider: Y ? fe(Y) : null
562
594
  })
563
595
  ]
564
596
  });