@burdenoff/microfe-billing 2026.1114.1 → 2026.1114.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.
@@ -23,19 +23,19 @@ var A = () => {
23
23
  y(() => {
24
24
  R(f);
25
25
  }, [f]);
26
- let ee = b(() => (g.find((e) => e.isDefault) ?? g[0])?.id ?? void 0, [g]), z = L === void 0 ? ee ?? null : L, [B, V] = S("all"), [H, U] = S(""), [W, G] = S(""), [K, q] = S(1), J = x(null);
27
- y(() => (J.current && clearTimeout(J.current), J.current = setTimeout(() => {
28
- G(H), q(1);
26
+ let z = b(() => (g.find((e) => e.isDefault) ?? g[0])?.id ?? void 0, [g]), B = L === void 0 ? z ?? null : L, [V, H] = S("all"), [U, ee] = S(""), [W, te] = S(""), [G, K] = S(1), q = x(null);
27
+ y(() => (q.current && clearTimeout(q.current), q.current = setTimeout(() => {
28
+ te(U), K(1);
29
29
  }, 400), () => {
30
- J.current && clearTimeout(J.current);
31
- }), [H]);
32
- let { invoices: Y, totalPages: X, isLoading: Z, error: Q, refetch: $ } = r({
33
- billingAccountId: z ?? void 0,
34
- status: B === "all" ? void 0 : B,
30
+ q.current && clearTimeout(q.current);
31
+ }), [U]);
32
+ let { invoices: J, totalPages: Y, isLoading: X, error: Z, refetch: Q } = r({
33
+ billingAccountId: B ?? void 0,
34
+ status: V === "all" ? void 0 : V,
35
35
  search: W || void 0,
36
- page: K,
36
+ page: G,
37
37
  pageSize: 20
38
- }), te = v(async (e) => {
38
+ }), ne = v(async (e) => {
39
39
  let t = e.billingAccountId, n = t ? g.find((e) => e.id === t)?.defaultPaymentMethod : void 0;
40
40
  if (!t) P("No billing account context");
41
41
  else if (!n) P("Add and set a default payment method before paying this invoice.");
@@ -45,7 +45,7 @@ var A = () => {
45
45
  action: "pay"
46
46
  });
47
47
  try {
48
- await A(e.id, n, t), await $(), _("success");
48
+ await A(e.id, n, t), await Q(), _("success");
49
49
  } catch (e) {
50
50
  P(e instanceof Error ? e.message : "Failed to pay invoice"), _("error");
51
51
  } finally {
@@ -55,8 +55,8 @@ var A = () => {
55
55
  }, [
56
56
  g,
57
57
  A,
58
- $
59
- ]), ne = v(async (e) => {
58
+ Q
59
+ ]), re = v(async (e) => {
60
60
  let t = e.billingAccountId;
61
61
  if (!t) P("No billing account context");
62
62
  else {
@@ -65,15 +65,46 @@ var A = () => {
65
65
  action: "void"
66
66
  });
67
67
  try {
68
- await M(e.id, t), await $(), _("success");
68
+ await M(e.id, t), await Q(), _("success");
69
69
  } catch (e) {
70
70
  P(e instanceof Error ? e.message : "Failed to void invoice"), _("error");
71
71
  } finally {
72
72
  I(null);
73
73
  }
74
74
  }
75
- }, [$, M]);
76
- return c.canViewInvoices ? Z && Y.length === 0 ? /* @__PURE__ */ k("div", {
75
+ }, [Q, M]);
76
+ if (!c.canViewInvoices) return /* @__PURE__ */ O("div", {
77
+ className: "flex items-center justify-center h-full min-h-[400px]",
78
+ children: /* @__PURE__ */ k("div", {
79
+ className: "text-center space-y-2",
80
+ children: [
81
+ /* @__PURE__ */ O("div", {
82
+ className: "size-12 mx-auto rounded-full bg-bg-sunken flex items-center justify-center",
83
+ children: /* @__PURE__ */ O("svg", {
84
+ className: "size-6 text-text-secondary",
85
+ fill: "none",
86
+ viewBox: "0 0 24 24",
87
+ stroke: "currentColor",
88
+ children: /* @__PURE__ */ O("path", {
89
+ strokeLinecap: "round",
90
+ strokeLinejoin: "round",
91
+ strokeWidth: 2,
92
+ 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"
93
+ })
94
+ })
95
+ }),
96
+ /* @__PURE__ */ O("h2", {
97
+ className: "text-lg font-semibold text-text-primary",
98
+ children: t("billing.accessDenied.title", "Access Denied")
99
+ }),
100
+ /* @__PURE__ */ O("p", {
101
+ className: "text-sm text-text-secondary max-w-sm",
102
+ children: t("billing.invoices.noViewPermission", "You don't have permission to view invoices.")
103
+ })
104
+ ]
105
+ })
106
+ });
107
+ if (X && J.length === 0) return /* @__PURE__ */ k("div", {
77
108
  className: "space-y-6 p-6",
78
109
  children: [/* @__PURE__ */ O("div", { className: "h-8 w-48 bg-bg-sunken animate-pulse rounded" }), /* @__PURE__ */ O("div", {
79
110
  className: "space-y-3",
@@ -94,7 +125,8 @@ var A = () => {
94
125
  })
95
126
  }, e))
96
127
  })]
97
- }) : Q ? /* @__PURE__ */ O("div", {
128
+ });
129
+ if (Z) return /* @__PURE__ */ O("div", {
98
130
  className: "flex items-center justify-center h-full min-h-[400px]",
99
131
  children: /* @__PURE__ */ k("div", {
100
132
  className: "text-center space-y-4",
@@ -120,17 +152,36 @@ var A = () => {
120
152
  }),
121
153
  /* @__PURE__ */ O("p", {
122
154
  className: "text-sm text-text-secondary",
123
- children: Q.message
155
+ children: Z.message
124
156
  }),
125
157
  /* @__PURE__ */ O("button", {
126
158
  type: "button",
127
- onClick: () => $(),
159
+ onClick: () => Q(),
128
160
  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",
129
161
  children: t("billing.common.tryAgain", "Try Again")
130
162
  })
131
163
  ]
132
164
  })
133
- }) : /* @__PURE__ */ k("div", {
165
+ });
166
+ let $ = g.length > 1 ? /* @__PURE__ */ k("div", {
167
+ className: i ? "flex w-full min-w-0 items-center gap-2 sm:w-auto" : "flex items-center gap-2",
168
+ children: [/* @__PURE__ */ O("label", {
169
+ className: "text-sm text-text-secondary whitespace-nowrap",
170
+ children: t("billing.invoices.billingAccountLabel", "Billing Account")
171
+ }), /* @__PURE__ */ k("select", {
172
+ value: B ?? "",
173
+ onChange: (e) => R(e.target.value || null),
174
+ className: `${i ? "min-w-0 flex-1 truncate sm:max-w-xs sm:flex-none " : ""}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`,
175
+ children: [/* @__PURE__ */ O("option", {
176
+ value: "",
177
+ children: t("billing.invoices.allAccounts", "All Accounts")
178
+ }), g.map((e) => /* @__PURE__ */ k("option", {
179
+ value: e.id ?? "",
180
+ children: [e.name ?? e.email ?? e.id, e.isDefault ? t("billing.invoices.defaultSuffix", " (Default)") : ""]
181
+ }, e.id ?? ""))]
182
+ })]
183
+ }) : null;
184
+ return /* @__PURE__ */ k("div", {
134
185
  className: "space-y-6 px-6 lg:px-8 py-6",
135
186
  children: [
136
187
  /* @__PURE__ */ k("div", {
@@ -158,65 +209,55 @@ var A = () => {
158
209
  onClick: () => s("/refunds"),
159
210
  className: "inline-flex items-center gap-2 whitespace-nowrap px-3 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken hover:border-border-strong transition-all duration-200",
160
211
  children: [/* @__PURE__ */ O(T, { className: "size-4" }), t("billing.invoices.myRefunds", "My Refunds")]
161
- }), g.length > 1 && /* @__PURE__ */ k("div", {
162
- className: i ? "flex w-full min-w-0 items-center gap-2 sm:w-auto" : "flex items-center gap-2",
163
- children: [/* @__PURE__ */ O("label", {
164
- className: "text-sm text-text-secondary whitespace-nowrap",
165
- children: t("billing.invoices.billingAccountLabel", "Billing Account")
166
- }), /* @__PURE__ */ k("select", {
167
- value: z ?? "",
168
- onChange: (e) => R(e.target.value || null),
169
- className: `${i ? "min-w-0 flex-1 truncate sm:max-w-xs sm:flex-none " : ""}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`,
170
- children: [/* @__PURE__ */ O("option", {
171
- value: "",
172
- children: t("billing.invoices.allAccounts", "All Accounts")
173
- }), g.map((e) => /* @__PURE__ */ k("option", {
174
- value: e.id ?? "",
175
- children: [e.name ?? e.email ?? e.id, e.isDefault ? t("billing.invoices.defaultSuffix", " (Default)") : ""]
176
- }, e.id ?? ""))]
177
- })]
178
- })]
212
+ }), !i && $]
179
213
  })]
180
214
  }),
181
215
  /* @__PURE__ */ k("div", {
182
216
  className: "flex flex-wrap items-center gap-4 pb-4 border-b border-border-subtle",
183
- children: [/* @__PURE__ */ O("div", {
184
- className: "inline-flex rounded-lg border border-border-subtle p-1 bg-bg-sunken flex-wrap",
185
- children: [
186
- "all",
187
- "OPEN",
188
- "PAID",
189
- "DRAFT",
190
- "VOID"
191
- ].map((e) => /* @__PURE__ */ O("button", {
192
- type: "button",
193
- onClick: () => {
194
- V(e), q(1);
195
- },
196
- className: `px-3 py-1.5 text-sm font-medium rounded-button transition-colors ${B === e ? "bg-bg-surface text-text-primary shadow-sm" : "text-text-secondary hover:text-text-primary"}`,
197
- children: e === "all" ? "All" : u(e)
198
- }, e))
199
- }), /* @__PURE__ */ k("div", {
200
- className: "relative flex-1 min-w-0 w-full sm:max-w-md",
201
- children: [/* @__PURE__ */ O("svg", {
202
- className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 text-text-secondary",
203
- fill: "none",
204
- viewBox: "0 0 24 24",
205
- stroke: "currentColor",
206
- children: /* @__PURE__ */ O("path", {
207
- strokeLinecap: "round",
208
- strokeLinejoin: "round",
209
- strokeWidth: 2,
210
- d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
211
- })
212
- }), /* @__PURE__ */ O("input", {
213
- type: "text",
214
- placeholder: t("billing.invoices.searchPlaceholder", "Search by invoice number..."),
215
- value: H,
216
- onChange: (e) => U(e.target.value),
217
- className: "w-full pl-[3.25rem] pr-4 py-2 text-sm border border-border-subtle rounded-button bg-bg-surface text-text-primary placeholder:text-text-placeholder focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] focus:border-transparent"
218
- })]
219
- })]
217
+ children: [
218
+ /* @__PURE__ */ O("div", {
219
+ className: "inline-flex rounded-lg border border-border-subtle p-1 bg-bg-sunken flex-wrap",
220
+ children: [
221
+ "all",
222
+ "OPEN",
223
+ "PAID",
224
+ "DRAFT",
225
+ "VOID"
226
+ ].map((e) => /* @__PURE__ */ O("button", {
227
+ type: "button",
228
+ onClick: () => {
229
+ H(e), K(1);
230
+ },
231
+ className: `px-3 py-1.5 text-sm font-medium rounded-button transition-colors ${V === e ? "bg-bg-surface text-text-primary shadow-sm" : "text-text-secondary hover:text-text-primary"}`,
232
+ children: e === "all" ? "All" : u(e)
233
+ }, e))
234
+ }),
235
+ /* @__PURE__ */ k("div", {
236
+ className: "relative flex-1 min-w-0 w-full sm:max-w-md",
237
+ children: [/* @__PURE__ */ O("svg", {
238
+ className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 text-text-secondary",
239
+ fill: "none",
240
+ viewBox: "0 0 24 24",
241
+ stroke: "currentColor",
242
+ children: /* @__PURE__ */ O("path", {
243
+ strokeLinecap: "round",
244
+ strokeLinejoin: "round",
245
+ strokeWidth: 2,
246
+ d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
247
+ })
248
+ }), /* @__PURE__ */ O("input", {
249
+ type: "text",
250
+ placeholder: t("billing.invoices.searchPlaceholder", "Search by invoice number..."),
251
+ value: U,
252
+ onChange: (e) => ee(e.target.value),
253
+ className: "w-full pl-[3.25rem] pr-4 py-2 text-sm border border-border-subtle rounded-button bg-bg-surface text-text-primary placeholder:text-text-placeholder focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] focus:border-transparent"
254
+ })]
255
+ }),
256
+ i && $ ? /* @__PURE__ */ O("div", {
257
+ className: "w-full sm:ml-auto sm:w-auto",
258
+ children: $
259
+ }) : null
260
+ ]
220
261
  }),
221
262
  N && /* @__PURE__ */ O("div", {
222
263
  className: "rounded-button border border-status-error-border bg-status-error-bg-subtle p-3",
@@ -225,10 +266,10 @@ var A = () => {
225
266
  children: N
226
267
  })
227
268
  }),
228
- !Z && Y.length === 0 ? /* @__PURE__ */ O(C, {
229
- illustration: B !== "all" || W ? "empty-search" : "empty-files",
269
+ !X && J.length === 0 ? /* @__PURE__ */ O(C, {
270
+ illustration: V !== "all" || W ? "empty-search" : "empty-files",
230
271
  title: t("billing.invoices.noInvoicesFound", "No invoices found"),
231
- description: B !== "all" || W ? t("billing.invoices.noInvoicesFiltered", "No invoices match your filters.") : t("billing.invoices.noInvoicesYet", "You don't have any invoices yet.")
272
+ description: V !== "all" || W ? t("billing.invoices.noInvoicesFiltered", "No invoices match your filters.") : t("billing.invoices.noInvoicesYet", "You don't have any invoices yet.")
232
273
  }) : /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O("div", {
233
274
  className: `border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 ${i ? "overflow-x-auto" : "overflow-hidden"}`,
234
275
  children: /* @__PURE__ */ k("table", {
@@ -244,7 +285,7 @@ var A = () => {
244
285
  className: "text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted",
245
286
  children: t("billing.common.status", "Status")
246
287
  }),
247
- !z && g.length > 1 && /* @__PURE__ */ O("th", {
288
+ !B && g.length > 1 && /* @__PURE__ */ O("th", {
248
289
  className: "text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted hidden lg:table-cell",
249
290
  children: t("billing.common.account", "Account")
250
291
  }),
@@ -267,76 +308,46 @@ var A = () => {
267
308
  ] })
268
309
  }), /* @__PURE__ */ O("tbody", {
269
310
  className: "divide-y divide-border-subtle",
270
- children: Y.map((e) => /* @__PURE__ */ O(j, {
311
+ children: J.map((e) => /* @__PURE__ */ O(j, {
271
312
  invoice: e,
272
313
  onView: () => s(d(`/invoices/${e.id}`, e.billingAccountId)),
273
314
  canPay: c.canPayInvoice,
274
315
  canVoid: c.canVoidInvoice,
275
- onPay: te,
276
- onVoid: ne,
316
+ onPay: ne,
317
+ onVoid: re,
277
318
  isProcessing: F?.invoiceId === e.id,
278
319
  processingAction: F?.invoiceId === e.id ? F.action : void 0,
279
- showAccount: !z && g.length > 1,
320
+ showAccount: !B && g.length > 1,
280
321
  accountName: g.find((t) => t.id === e.billingAccountId)?.name ?? null
281
322
  }, e.id))
282
323
  })]
283
324
  })
284
- }), X > 1 && /* @__PURE__ */ k("div", {
325
+ }), Y > 1 && /* @__PURE__ */ k("div", {
285
326
  className: "flex items-center justify-between pt-2",
286
327
  children: [/* @__PURE__ */ O("p", {
287
328
  className: "text-sm text-text-secondary",
288
329
  children: t("billing.common.pageOf", "Page {{page}} of {{totalPages}}", {
289
- page: K,
290
- totalPages: X
330
+ page: G,
331
+ totalPages: Y
291
332
  })
292
333
  }), /* @__PURE__ */ k("div", {
293
334
  className: "flex items-center gap-2",
294
335
  children: [/* @__PURE__ */ O("button", {
295
336
  type: "button",
296
- onClick: () => q((e) => Math.max(1, e - 1)),
297
- disabled: K <= 1,
337
+ onClick: () => K((e) => Math.max(1, e - 1)),
338
+ disabled: G <= 1,
298
339
  className: "px-3 py-1.5 text-sm font-medium border border-border-subtle rounded-button bg-bg-surface text-text-primary hover:bg-bg-sunken disabled:opacity-40 disabled:cursor-not-allowed transition-colors",
299
340
  children: t("billing.common.previous", "Previous")
300
341
  }), /* @__PURE__ */ O("button", {
301
342
  type: "button",
302
- onClick: () => q((e) => Math.min(X, e + 1)),
303
- disabled: K >= X,
343
+ onClick: () => K((e) => Math.min(Y, e + 1)),
344
+ disabled: G >= Y,
304
345
  className: "px-3 py-1.5 text-sm font-medium border border-border-subtle rounded-button bg-bg-surface text-text-primary hover:bg-bg-sunken disabled:opacity-40 disabled:cursor-not-allowed transition-colors",
305
346
  children: t("billing.common.next", "Next")
306
347
  })]
307
348
  })]
308
349
  })] })
309
350
  ]
310
- }) : /* @__PURE__ */ O("div", {
311
- className: "flex items-center justify-center h-full min-h-[400px]",
312
- children: /* @__PURE__ */ k("div", {
313
- className: "text-center space-y-2",
314
- children: [
315
- /* @__PURE__ */ O("div", {
316
- className: "size-12 mx-auto rounded-full bg-bg-sunken flex items-center justify-center",
317
- children: /* @__PURE__ */ O("svg", {
318
- className: "size-6 text-text-secondary",
319
- fill: "none",
320
- viewBox: "0 0 24 24",
321
- stroke: "currentColor",
322
- children: /* @__PURE__ */ O("path", {
323
- strokeLinecap: "round",
324
- strokeLinejoin: "round",
325
- strokeWidth: 2,
326
- 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"
327
- })
328
- })
329
- }),
330
- /* @__PURE__ */ O("h2", {
331
- className: "text-lg font-semibold text-text-primary",
332
- children: t("billing.accessDenied.title", "Access Denied")
333
- }),
334
- /* @__PURE__ */ O("p", {
335
- className: "text-sm text-text-secondary max-w-sm",
336
- children: t("billing.invoices.noViewPermission", "You don't have permission to view invoices.")
337
- })
338
- ]
339
- })
340
351
  });
341
352
  }, j = ({ invoice: e, onView: n, onPay: r, onVoid: a, canPay: o, canVoid: d, isProcessing: _, processingAction: v, showAccount: y = !1, accountName: b }) => {
342
353
  let x = m(), C = p(), [w, T] = S(!1), [E, D] = S(!1), A = f(e.status), j = e.status === "OPEN", M = e.status === "DRAFT", N = async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"InvoicesListPage.js","names":["_Fragment","Fragment$1","InvoicesListPage","tr","useTr","isFluidgrids","useIsFluidgridsVariant","navigateTo","useBillingNavigate","permissions","useBillingPermissions","searchParams","useSearchParams","urlBillingAccountId","accountsData","useGetBillingAccountsByOrgQuery","billingAccounts","useMemo","useInvoiceMutations","actionError","setActionError","useState","activeAction","setActiveAction","explicitAccountId","setExplicitAccountId","defaultAccountId","a","selectedAccountId","filterStatus","setFilterStatus","searchQuery","setSearchQuery","debouncedSearch","setDebouncedSearch","page","setPage","debounceTimer","useRef","usePaginatedInvoices","handlePayInvoice","useCallback","billingAccountId","invoice","paymentMethodId","account","payInvoice","refetch","nativeNotify","actionErrorValue","handleVoidInvoice","voidInvoice","isLoading","invoices","i","error","PagePurpose","RotateCcw","status","formatInvoiceStatus","IllustratedEmptyState","InvoiceRow","withBillingAccountId","totalPages","p","isConfirmingVoid","setIsConfirmingVoid","isReviewingPay","setIsReviewingPay","statusColor","getInvoiceStatusColor","isOpen","isDraft","handleVoidRequest","confirmed","nativeConfirm","onVoid","handlePayRequest","onPay","handlePayConfirmed","handleVoidConfirmed","invoicePdfBackupUrl","formatInvoiceNumber","onView","StatusPill","showAccount","accountName","formatDate","formatCurrency","canPay","isProcessing","processingAction","MoneyActionDialog","canVoid"],"sources":["../../../../../src/billing/modules/billing/pages/InvoicesListPage.tsx"],"sourcesContent":["/**\n * Billing Module - Invoices List Page\n * Displays all invoices for the current tenant\n */\n\nimport { useEffect, useState, useMemo, useRef, useCallback, type FC } from 'react';\nimport { RotateCcw } from 'lucide-react';\nimport { useSearchParams } from 'react-router';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { useInvoiceMutations, usePaginatedInvoices } from '../hooks/useInvoices';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport {\n useGetBillingAccountsByOrgQuery,\n type GetBillingAccountsByOrgQuery,\n} from '../../../../generated/global-operations';\n\ntype BillingAccountItem = GetBillingAccountsByOrgQuery['getBillingAccountsByOrg'][number];\nimport {\n formatCurrency,\n formatDate,\n formatInvoiceStatus,\n formatInvoiceNumber,\n} from '../../../shared/utils/format';\nimport { withBillingAccountId } from '../../../shared/utils/navigation';\nimport { getInvoiceStatusColor } from '../../../shared/utils/status';\nimport { StatusPill } from '../../../shared/ui';\nimport { MoneyActionDialog } from '../../../shared/components';\nimport { useIsFluidgridsVariant } from '../../../hooks/useBillingVariant';\nimport type { Invoice, InvoiceStatus } from '../../../shared/types';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { nativeConfirm, nativeImpact, nativeNotify } from '../../../../utils/nativeBridge';\nimport { PagePurpose, IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\n\ntype FilterStatus = 'all' | InvoiceStatus;\ntype InvoiceAction = { invoiceId: string; action: 'pay' | 'void' } | null;\n\nexport const InvoicesListPage: FC = () => {\n const tr = useTr();\n const isFluidgrids = useIsFluidgridsVariant();\n const navigateTo = useBillingNavigate();\n const permissions = useBillingPermissions();\n const [searchParams] = useSearchParams();\n const urlBillingAccountId = searchParams.get('billingAccountId') ?? undefined;\n\n const { data: accountsData } = useGetBillingAccountsByOrgQuery({ fetchPolicy: 'cache-first' });\n const billingAccounts = useMemo(\n () => accountsData?.getBillingAccountsByOrg ?? [],\n [accountsData]\n );\n const { payInvoice, voidInvoice } = useInvoiceMutations();\n const [actionError, setActionError] = useState<string | null>(null);\n const [activeAction, setActiveAction] = useState<InvoiceAction>(null);\n\n // undefined = user hasn't explicitly chosen yet → auto-pick default\n // null = user explicitly chose \"All Accounts\"\n // string = user explicitly chose a specific account\n const [explicitAccountId, setExplicitAccountId] = useState<string | null | undefined>(\n urlBillingAccountId\n );\n\n useEffect(() => {\n setExplicitAccountId(urlBillingAccountId);\n }, [urlBillingAccountId]);\n\n const defaultAccountId = useMemo(\n () =>\n (billingAccounts.find((a: BillingAccountItem) => a.isDefault) ?? billingAccounts[0])?.id ??\n undefined,\n [billingAccounts]\n );\n\n // Resolved selection: explicit choice wins; before any choice, use the default\n const selectedAccountId: string | null =\n explicitAccountId !== undefined ? explicitAccountId : (defaultAccountId ?? null);\n\n const [filterStatus, setFilterStatus] = useState<FilterStatus>('all');\n const [searchQuery, setSearchQuery] = useState('');\n const [debouncedSearch, setDebouncedSearch] = useState('');\n const [page, setPage] = useState(1);\n const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n if (debounceTimer.current) clearTimeout(debounceTimer.current);\n debounceTimer.current = setTimeout(() => {\n setDebouncedSearch(searchQuery);\n setPage(1);\n }, 400);\n return () => {\n if (debounceTimer.current) clearTimeout(debounceTimer.current);\n };\n }, [searchQuery]);\n\n const { invoices, totalPages, isLoading, error, refetch } = usePaginatedInvoices({\n billingAccountId: selectedAccountId ?? undefined,\n status: filterStatus !== 'all' ? (filterStatus as InvoiceStatus) : undefined,\n search: debouncedSearch || undefined,\n page,\n pageSize: 20,\n });\n\n const handlePayInvoice = useCallback(\n async (invoice: Invoice): Promise<void> => {\n const billingAccountId = invoice.billingAccountId;\n const paymentMethodId = billingAccountId\n ? billingAccounts.find((account: BillingAccountItem) => account.id === billingAccountId)\n ?.defaultPaymentMethod\n : undefined;\n\n if (!billingAccountId) {\n setActionError('No billing account context');\n return;\n }\n if (!paymentMethodId) {\n setActionError('Add and set a default payment method before paying this invoice.');\n return;\n }\n\n setActionError(null);\n setActiveAction({ invoiceId: invoice.id, action: 'pay' });\n try {\n await payInvoice(invoice.id, paymentMethodId, billingAccountId);\n await refetch();\n void nativeNotify('success');\n } catch (actionErrorValue) {\n setActionError(\n actionErrorValue instanceof Error ? actionErrorValue.message : 'Failed to pay invoice'\n );\n void nativeNotify('error');\n } finally {\n setActiveAction(null);\n }\n },\n [billingAccounts, payInvoice, refetch]\n );\n\n const handleVoidInvoice = useCallback(\n async (invoice: Invoice): Promise<void> => {\n const billingAccountId = invoice.billingAccountId;\n if (!billingAccountId) {\n setActionError('No billing account context');\n return;\n }\n\n setActionError(null);\n setActiveAction({ invoiceId: invoice.id, action: 'void' });\n try {\n await voidInvoice(invoice.id, billingAccountId);\n await refetch();\n void nativeNotify('success');\n } catch (actionErrorValue) {\n setActionError(\n actionErrorValue instanceof Error ? actionErrorValue.message : 'Failed to void invoice'\n );\n void nativeNotify('error');\n } finally {\n setActiveAction(null);\n }\n },\n [refetch, voidInvoice]\n );\n\n // Permission check\n if (!permissions.canViewInvoices) {\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\">\n {tr('billing.accessDenied.title', 'Access Denied')}\n </h2>\n <p className=\"text-sm text-text-secondary max-w-sm\">\n {tr('billing.invoices.noViewPermission', \"You don't have permission to view invoices.\")}\n </p>\n </div>\n </div>\n );\n }\n\n // Loading state\n if (isLoading && invoices.length === 0) {\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"h-8 w-48 bg-bg-sunken animate-pulse rounded\" />\n <div className=\"space-y-3\">\n {[1, 2, 3, 4, 5].map((i) => (\n <div key={i} className=\"border border-border-subtle rounded-lg p-4\">\n <div className=\"flex items-center gap-4\">\n <div className=\"size-10 bg-bg-sunken animate-pulse rounded\" />\n <div className=\"flex-1 space-y-2\">\n <div className=\"h-4 w-32 bg-bg-sunken animate-pulse rounded\" />\n <div className=\"h-3 w-48 bg-bg-sunken animate-pulse rounded\" />\n </div>\n </div>\n </div>\n ))}\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\">\n {tr('billing.invoices.failedToLoad', 'Failed to load invoices')}\n </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 {tr('billing.common.tryAgain', 'Try Again')}\n </button>\n </div>\n </div>\n );\n }\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 xl:flex-row xl:items-start xl: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 xl:max-w-3xl' : undefined}>\n <h1 className=\"text-2xl md:text-3xl font-semibold tracking-tight text-text-primary\">\n {tr('billing.invoices.title', 'Invoices')}\n </h1>\n <p className=\"text-sm text-text-secondary mt-1\">\n {tr('billing.invoices.subtitle', 'View and manage your billing invoices')}\n </p>\n <PagePurpose className=\"mt-3\">\n {tr(\n 'billing.invoices.purpose',\n 'A record of everything you have been billed for — subscriptions, add-ons and one-off charges. Open an invoice to see line items, download the PDF, pay an outstanding amount, or request a refund.'\n )}\n </PagePurpose>\n </div>\n <div\n className={\n isFluidgrids\n ? 'flex flex-wrap items-center gap-3 xl:shrink-0 xl:justify-end'\n : 'flex items-center gap-3'\n }\n >\n <button\n type=\"button\"\n onClick={() => navigateTo('/refunds')}\n className=\"inline-flex items-center gap-2 whitespace-nowrap px-3 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken hover:border-border-strong transition-all duration-200\"\n >\n <RotateCcw className=\"size-4\" />\n {tr('billing.invoices.myRefunds', 'My Refunds')}\n </button>\n {billingAccounts.length > 1 && (\n <div\n className={\n isFluidgrids\n ? 'flex w-full min-w-0 items-center gap-2 sm:w-auto'\n : 'flex items-center gap-2'\n }\n >\n <label className=\"text-sm text-text-secondary whitespace-nowrap\">\n {tr('billing.invoices.billingAccountLabel', 'Billing Account')}\n </label>\n <select\n value={selectedAccountId ?? ''}\n onChange={(e) => setExplicitAccountId(e.target.value || null)}\n className={`${isFluidgrids ? 'min-w-0 flex-1 truncate sm:max-w-xs sm:flex-none ' : ''}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 <option value=\"\">{tr('billing.invoices.allAccounts', 'All Accounts')}</option>\n {billingAccounts.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 </div>\n )}\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 {/* Status Filter */}\n <div className=\"inline-flex rounded-lg border border-border-subtle p-1 bg-bg-sunken flex-wrap\">\n {(['all', 'OPEN', 'PAID', 'DRAFT', 'VOID'] as FilterStatus[]).map((status) => (\n <button\n type=\"button\"\n key={status}\n onClick={() => {\n setFilterStatus(status);\n setPage(1);\n }}\n className={`px-3 py-1.5 text-sm font-medium rounded-button transition-colors ${\n filterStatus === status\n ? 'bg-bg-surface text-text-primary shadow-sm'\n : 'text-text-secondary hover:text-text-primary'\n }`}\n >\n {status === 'all' ? 'All' : formatInvoiceStatus(status as InvoiceStatus)}\n </button>\n ))}\n </div>\n\n {/* Search */}\n <div className=\"relative flex-1 min-w-0 w-full sm:max-w-md\">\n <svg\n className=\"absolute left-3 top-1/2 -translate-y-1/2 size-4 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=\"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z\"\n />\n </svg>\n <input\n type=\"text\"\n placeholder={tr('billing.invoices.searchPlaceholder', 'Search by invoice number...')}\n value={searchQuery}\n onChange={(e) => setSearchQuery(e.target.value)}\n className=\"w-full pl-[3.25rem] pr-4 py-2 text-sm border border-border-subtle rounded-button bg-bg-surface text-text-primary placeholder:text-text-placeholder focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] focus:border-transparent\"\n />\n </div>\n </div>\n\n {actionError && (\n <div className=\"rounded-button border border-status-error-border bg-status-error-bg-subtle p-3\">\n <p className=\"text-sm text-status-error-text\">{actionError}</p>\n </div>\n )}\n\n {/* Invoices Table */}\n {!isLoading && invoices.length === 0 ? (\n <IllustratedEmptyState\n illustration={filterStatus !== 'all' || debouncedSearch ? 'empty-search' : 'empty-files'}\n title={tr('billing.invoices.noInvoicesFound', 'No invoices found')}\n description={\n filterStatus !== 'all' || debouncedSearch\n ? tr('billing.invoices.noInvoicesFiltered', 'No invoices match your filters.')\n : tr('billing.invoices.noInvoicesYet', \"You don't have any invoices yet.\")\n }\n />\n ) : (\n <>\n <div\n className={`border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 ${isFluidgrids ? 'overflow-x-auto' : 'overflow-hidden'}`}\n >\n <table className=\"w-full\">\n <thead className=\"bg-bg-sunken\">\n <tr>\n <th className=\"text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted\">\n {tr('billing.invoices.invoice', 'Invoice')}\n </th>\n <th className=\"text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted\">\n {tr('billing.common.status', 'Status')}\n </th>\n {!selectedAccountId && billingAccounts.length > 1 && (\n <th className=\"text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted hidden lg:table-cell\">\n {tr('billing.common.account', 'Account')}\n </th>\n )}\n <th className=\"text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted hidden sm:table-cell\">\n {tr('billing.common.date', 'Date')}\n </th>\n <th className=\"text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted hidden md:table-cell\">\n {tr('billing.common.dueDate', 'Due Date')}\n </th>\n <th className=\"text-right px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted\">\n {tr('billing.common.amount', 'Amount')}\n </th>\n <th className=\"text-right px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted\">\n {tr('billing.common.actions', 'Actions')}\n </th>\n </tr>\n </thead>\n <tbody className=\"divide-y divide-border-subtle\">\n {invoices.map((invoice) => (\n <InvoiceRow\n key={invoice.id}\n invoice={invoice}\n onView={() =>\n navigateTo(\n withBillingAccountId(`/invoices/${invoice.id}`, invoice.billingAccountId)\n )\n }\n canPay={permissions.canPayInvoice}\n canVoid={permissions.canVoidInvoice}\n onPay={handlePayInvoice}\n onVoid={handleVoidInvoice}\n isProcessing={activeAction?.invoiceId === invoice.id}\n processingAction={\n activeAction?.invoiceId === invoice.id ? activeAction.action : undefined\n }\n showAccount={!selectedAccountId && billingAccounts.length > 1}\n accountName={\n billingAccounts.find(\n (a: BillingAccountItem) => a.id === invoice.billingAccountId\n )?.name ?? null\n }\n />\n ))}\n </tbody>\n </table>\n </div>\n\n {totalPages > 1 && (\n <div className=\"flex items-center justify-between pt-2\">\n <p className=\"text-sm text-text-secondary\">\n {tr('billing.common.pageOf', 'Page {{page}} of {{totalPages}}', {\n page,\n totalPages,\n })}\n </p>\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => setPage((p) => Math.max(1, p - 1))}\n disabled={page <= 1}\n className=\"px-3 py-1.5 text-sm font-medium border border-border-subtle rounded-button bg-bg-surface text-text-primary hover:bg-bg-sunken disabled:opacity-40 disabled:cursor-not-allowed transition-colors\"\n >\n {tr('billing.common.previous', 'Previous')}\n </button>\n <button\n type=\"button\"\n onClick={() => setPage((p) => Math.min(totalPages, p + 1))}\n disabled={page >= totalPages}\n className=\"px-3 py-1.5 text-sm font-medium border border-border-subtle rounded-button bg-bg-surface text-text-primary hover:bg-bg-sunken disabled:opacity-40 disabled:cursor-not-allowed transition-colors\"\n >\n {tr('billing.common.next', 'Next')}\n </button>\n </div>\n </div>\n )}\n </>\n )}\n </div>\n );\n};\n\n// ============================================================================\n// Invoice Row Component\n// ============================================================================\n\ninterface InvoiceRowProps {\n invoice: Invoice;\n onView: () => void;\n onPay: (invoice: Invoice) => Promise<void>;\n onVoid: (invoice: Invoice) => Promise<void>;\n canPay: boolean;\n canVoid: boolean;\n isProcessing: boolean;\n processingAction?: 'pay' | 'void';\n showAccount?: boolean;\n accountName?: string | null;\n}\n\nconst InvoiceRow: FC<InvoiceRowProps> = ({\n invoice,\n onView,\n onPay,\n onVoid,\n canPay,\n canVoid,\n isProcessing,\n processingAction,\n showAccount = false,\n accountName,\n}) => {\n const tr = useTr();\n const isFluidgrids = useIsFluidgridsVariant();\n const [isConfirmingVoid, setIsConfirmingVoid] = useState(false);\n const [isReviewingPay, setIsReviewingPay] = useState(false);\n const statusColor = getInvoiceStatusColor(invoice.status);\n const isOpen = invoice.status === ('OPEN' as InvoiceStatus);\n const isDraft = invoice.status === ('DRAFT' as InvoiceStatus);\n\n const handleVoidRequest = async () => {\n void nativeImpact('medium');\n const confirmed = await nativeConfirm({\n title: 'Void invoice',\n message: 'Are you sure you want to void this invoice?',\n okButtonTitle: 'Void',\n cancelButtonTitle: 'Cancel',\n });\n if (confirmed === true) {\n await onVoid(invoice);\n } else if (confirmed === null) {\n setIsConfirmingVoid(true);\n }\n };\n\n // FluidGrids: Pay opens a review step (invoice, amount, card) before it charges.\n const handlePayRequest = () => {\n if (isFluidgrids) {\n setIsReviewingPay(true);\n return;\n }\n void onPay(invoice);\n };\n\n const handlePayConfirmed = async () => {\n await onPay(invoice);\n setIsReviewingPay(false);\n };\n\n const handleVoidConfirmed = async () => {\n await onVoid(invoice);\n setIsConfirmingVoid(false);\n };\n\n const invoicePdfBackupUrl = (invoice.metadata as Record<string, unknown> | undefined)\n ?.invoicePdfBackupUrl as string | undefined;\n\n return (\n <tr className=\"hover:bg-bg-sunken transition-colors\">\n <td className=\"p-4\">\n {invoice.invoiceUrl ? (\n <a\n href={invoice.invoiceUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"font-medium text-text-primary hover:text-text-link transition-colors\"\n >\n {formatInvoiceNumber(invoice.invoiceNumber)}\n </a>\n ) : (\n <button\n type=\"button\"\n onClick={onView}\n className=\"font-medium text-text-primary hover:text-text-link transition-colors\"\n >\n {formatInvoiceNumber(invoice.invoiceNumber)}\n </button>\n )}\n {(invoice.itemDescription ?? invoice.subscription?.plan?.name) && (\n <p className=\"text-sm text-text-secondary mt-0.5\">\n {invoice.itemDescription ?? invoice.subscription?.plan?.name}\n </p>\n )}\n </td>\n <td className=\"p-4\">\n <StatusPill status={statusColor} dot>\n {formatInvoiceStatus(invoice.status)}\n </StatusPill>\n </td>\n {showAccount && (\n <td className=\"p-4 hidden lg:table-cell\">\n {accountName ? (\n <span className=\"inline-flex items-center px-2 py-0.5 text-xs font-medium rounded-full bg-bg-sunken text-text-secondary border border-border-subtle\">\n {accountName}\n </span>\n ) : (\n <span className=\"text-sm text-text-secondary\">, </span>\n )}\n </td>\n )}\n <td className=\"p-4 text-sm text-text-secondary hidden sm:table-cell\">\n {formatDate(invoice.createdAt, 'short')}\n </td>\n <td className=\"p-4 text-sm text-text-secondary hidden md:table-cell\">\n {invoice.dueDate ? formatDate(invoice.dueDate, 'short') : '—'}\n </td>\n <td\n className={`p-4 text-right font-medium text-text-primary ${isFluidgrids ? 'whitespace-nowrap' : ''}`}\n >\n {formatCurrency(invoice.total, invoice.currency)}\n </td>\n <td className=\"p-4 text-right\">\n <div\n className={`relative flex items-center justify-end ${isFluidgrids ? 'flex-wrap gap-1' : 'gap-2'}`}\n >\n {invoice.invoiceUrl ? (\n <a\n href={invoice.invoiceUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-sunken rounded-button transition-colors duration-200\"\n >\n {tr('billing.common.view', 'View')}\n </a>\n ) : (\n <button\n type=\"button\"\n onClick={onView}\n className=\"px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-sunken rounded-button transition-colors duration-200\"\n >\n {tr('billing.common.view', 'View')}\n </button>\n )}\n {invoice.pdfUrl && (\n <a\n href={invoice.pdfUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"px-3 py-1.5 text-sm font-medium text-text-link hover:bg-[var(--color-accent-softHover)] rounded-button transition-colors duration-200\"\n >\n {tr('billing.common.pdf', 'PDF')}\n </a>\n )}\n {/* Our own durable backup copy, shown alongside the provider's —\n not a replacement, so this still works if the provider link\n ever breaks. */}\n {invoicePdfBackupUrl && (\n <a\n href={invoicePdfBackupUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"px-3 py-1.5 text-sm font-medium text-text-link hover:bg-[var(--color-accent-softHover)] rounded-button transition-colors duration-200\"\n >\n {tr('billing.common.pdfBackup', 'PDF (backup)')}\n </a>\n )}\n {isOpen && canPay && (\n <button\n type=\"button\"\n onClick={handlePayRequest}\n disabled={isProcessing}\n className=\"px-3 py-1.5 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors duration-200 disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {isProcessing && processingAction === 'pay'\n ? tr('billing.common.paying', 'Paying…')\n : tr('billing.common.pay', 'Pay')}\n </button>\n )}\n {isFluidgrids && (\n <MoneyActionDialog\n open={isReviewingPay}\n title={tr('billing.invoices.payReview.title', 'Review and pay')}\n description={tr(\n 'billing.invoices.payReview.description',\n 'Your default card is charged as soon as you confirm.'\n )}\n details={[\n {\n label: tr('billing.invoices.payReview.invoice', 'Invoice'),\n value: formatInvoiceNumber(invoice.invoiceNumber),\n },\n ...(accountName\n ? [\n {\n label: tr('billing.invoices.payReview.account', 'Billing account'),\n value: accountName,\n },\n ]\n : []),\n {\n label: tr('billing.invoices.payReview.card', 'Paid with'),\n value: tr('billing.invoices.payReview.defaultCard', 'Your default card'),\n },\n {\n label: tr('billing.invoices.payReview.amount', 'Amount'),\n value: formatCurrency(invoice.total, invoice.currency),\n },\n ]}\n confirmLabel={tr('billing.invoices.payReview.confirm', 'Pay {{amount}}', {\n amount: formatCurrency(invoice.total, invoice.currency),\n })}\n busyLabel={tr('billing.common.paying', 'Paying…')}\n isBusy={isProcessing && processingAction === 'pay'}\n onConfirm={() => void handlePayConfirmed()}\n onCancel={() => setIsReviewingPay(false)}\n />\n )}\n {(isOpen || isDraft) && canVoid && (\n <button\n type=\"button\"\n onClick={() => void handleVoidRequest()}\n disabled={isProcessing}\n className=\"px-3 py-1.5 text-sm font-medium text-status-error-text hover:bg-status-error-bg-subtle rounded-button transition-colors duration-200 disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {isProcessing && processingAction === 'void'\n ? tr('billing.common.voiding', 'Voiding…')\n : tr('billing.common.void', 'Void')}\n </button>\n )}\n {isConfirmingVoid && (\n <div className=\"absolute right-4 mt-12 z-10 w-64 rounded-card border border-status-error-border bg-bg-elevated p-3 text-left shadow-elevation-2\">\n <p className=\"text-sm font-medium text-text-primary\">Void this invoice?</p>\n <div className=\"mt-3 flex justify-end gap-2\">\n <button\n type=\"button\"\n onClick={() => setIsConfirmingVoid(false)}\n className=\"rounded-button border border-border-subtle bg-bg-surface px-2.5 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n onClick={() => void handleVoidConfirmed()}\n disabled={isProcessing}\n className=\"rounded-button bg-action-danger-bg px-2.5 py-1.5 text-xs font-medium text-action-primary-text hover:bg-action-danger-bgHover disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {isProcessing ? 'Voiding…' : 'Confirm'}\n </button>\n </div>\n </div>\n )}\n </div>\n </td>\n </tr>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,IAAaE,UAA6B;CACxC,IAAMC,IAAKC,EAAM,GACXC,IAAeC,EAAuB,GACtCC,IAAaC,EAAmB,GAChCC,IAAcC,EAAsB,GACpC,C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,CACF,IACA,CAAC;QACL;SACE,OAAOnF,EAAG,mCAAmC,WAAW;SACxD,OAAOA,EAAG,0CAA0C,mBAAmB;QACzE;QACA;SACE,OAAOA,EAAG,qCAAqC,QAAQ;SACvD,OAAOqF,EAAe7C,EAAQ,OAAOA,EAAQ,QAAQ;QACvD;OACF;OACA,cAAcxC,EAAG,sCAAsC,kBAAkB,EACvE,QAAQqF,EAAe7C,EAAQ,OAAOA,EAAQ,QAAQ,EACxD,CAAC;OACD,WAAWxC,EAAG,yBAAyB,SAAS;OAChD,QAAQuF,KAAgBC,MAAqB;OAC7C,iBAAiB,KAAKZ,EAAmB;OACzC,gBAAgBX,EAAkB,EAAK;MACxC,CAAA;OAEDG,KAAUC,MAAYqB,KACtB,kBAAC,UAAD;OACE,MAAK;OACL,eAAe,KAAKpB,EAAkB;OACtC,UAAUiB;OACV,WAAU;OAET,UAAAA,KAAgBC,MAAqB,SAClCxF,EAAG,0BAA0B,UAAU,IACvCA,EAAG,uBAAuB,MAAM;MAC9B,CAAA;MAET8D,KACC,kBAAC,OAAD;OAAK,WAAU;OAAf,UAAA,CACE,kBAAC,KAAD;QAAG,WAAU;QAAwC,UAAA;OAAqB,CAAA,GAC1E,kBAAC,OAAD;QAAK,WAAU;QAAf,UAAA,CACE,kBAAC,UAAD;SACE,MAAK;SACL,eAAeC,EAAoB,EAAK;SACxC,WAAU;SACX,UAAA;QAEO,CAAA,GACR,kBAAC,UAAD;SACE,MAAK;SACL,eAAe,KAAKc,EAAoB;SACxC,UAAUU;SACV,WAAU;SAET,UAAAA,IAAe,aAAa;QACvB,CAAA,CACL;OACF,CAAA,CAAA;;KAEJ;;GACH,CAAA;EACF;;AAER"}
1
+ {"version":3,"file":"InvoicesListPage.js","names":["_Fragment","Fragment$1","InvoicesListPage","tr","useTr","isFluidgrids","useIsFluidgridsVariant","navigateTo","useBillingNavigate","permissions","useBillingPermissions","searchParams","useSearchParams","urlBillingAccountId","accountsData","useGetBillingAccountsByOrgQuery","billingAccounts","useMemo","useInvoiceMutations","actionError","setActionError","useState","activeAction","setActiveAction","explicitAccountId","setExplicitAccountId","defaultAccountId","a","selectedAccountId","filterStatus","setFilterStatus","searchQuery","setSearchQuery","debouncedSearch","setDebouncedSearch","page","setPage","debounceTimer","useRef","usePaginatedInvoices","handlePayInvoice","useCallback","billingAccountId","invoice","paymentMethodId","account","payInvoice","refetch","nativeNotify","actionErrorValue","handleVoidInvoice","voidInvoice","isLoading","invoices","i","error","accountSelect","PagePurpose","RotateCcw","status","formatInvoiceStatus","IllustratedEmptyState","InvoiceRow","withBillingAccountId","totalPages","p","isConfirmingVoid","setIsConfirmingVoid","isReviewingPay","setIsReviewingPay","statusColor","getInvoiceStatusColor","isOpen","isDraft","handleVoidRequest","confirmed","nativeConfirm","onVoid","handlePayRequest","onPay","handlePayConfirmed","handleVoidConfirmed","invoicePdfBackupUrl","formatInvoiceNumber","onView","StatusPill","showAccount","accountName","formatDate","formatCurrency","canPay","isProcessing","processingAction","MoneyActionDialog","canVoid"],"sources":["../../../../../src/billing/modules/billing/pages/InvoicesListPage.tsx"],"sourcesContent":["/**\n * Billing Module - Invoices List Page\n * Displays all invoices for the current tenant\n */\n\nimport { useEffect, useState, useMemo, useRef, useCallback, type FC } from 'react';\nimport { RotateCcw } from 'lucide-react';\nimport { useSearchParams } from 'react-router';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { useInvoiceMutations, usePaginatedInvoices } from '../hooks/useInvoices';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport {\n useGetBillingAccountsByOrgQuery,\n type GetBillingAccountsByOrgQuery,\n} from '../../../../generated/global-operations';\n\ntype BillingAccountItem = GetBillingAccountsByOrgQuery['getBillingAccountsByOrg'][number];\nimport {\n formatCurrency,\n formatDate,\n formatInvoiceStatus,\n formatInvoiceNumber,\n} from '../../../shared/utils/format';\nimport { withBillingAccountId } from '../../../shared/utils/navigation';\nimport { getInvoiceStatusColor } from '../../../shared/utils/status';\nimport { StatusPill } from '../../../shared/ui';\nimport { MoneyActionDialog } from '../../../shared/components';\nimport { useIsFluidgridsVariant } from '../../../hooks/useBillingVariant';\nimport type { Invoice, InvoiceStatus } from '../../../shared/types';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { nativeConfirm, nativeImpact, nativeNotify } from '../../../../utils/nativeBridge';\nimport { PagePurpose, IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\n\ntype FilterStatus = 'all' | InvoiceStatus;\ntype InvoiceAction = { invoiceId: string; action: 'pay' | 'void' } | null;\n\nexport const InvoicesListPage: FC = () => {\n const tr = useTr();\n const isFluidgrids = useIsFluidgridsVariant();\n const navigateTo = useBillingNavigate();\n const permissions = useBillingPermissions();\n const [searchParams] = useSearchParams();\n const urlBillingAccountId = searchParams.get('billingAccountId') ?? undefined;\n\n const { data: accountsData } = useGetBillingAccountsByOrgQuery({ fetchPolicy: 'cache-first' });\n const billingAccounts = useMemo(\n () => accountsData?.getBillingAccountsByOrg ?? [],\n [accountsData]\n );\n const { payInvoice, voidInvoice } = useInvoiceMutations();\n const [actionError, setActionError] = useState<string | null>(null);\n const [activeAction, setActiveAction] = useState<InvoiceAction>(null);\n\n // undefined = user hasn't explicitly chosen yet → auto-pick default\n // null = user explicitly chose \"All Accounts\"\n // string = user explicitly chose a specific account\n const [explicitAccountId, setExplicitAccountId] = useState<string | null | undefined>(\n urlBillingAccountId\n );\n\n useEffect(() => {\n setExplicitAccountId(urlBillingAccountId);\n }, [urlBillingAccountId]);\n\n const defaultAccountId = useMemo(\n () =>\n (billingAccounts.find((a: BillingAccountItem) => a.isDefault) ?? billingAccounts[0])?.id ??\n undefined,\n [billingAccounts]\n );\n\n // Resolved selection: explicit choice wins; before any choice, use the default\n const selectedAccountId: string | null =\n explicitAccountId !== undefined ? explicitAccountId : (defaultAccountId ?? null);\n\n const [filterStatus, setFilterStatus] = useState<FilterStatus>('all');\n const [searchQuery, setSearchQuery] = useState('');\n const [debouncedSearch, setDebouncedSearch] = useState('');\n const [page, setPage] = useState(1);\n const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n if (debounceTimer.current) clearTimeout(debounceTimer.current);\n debounceTimer.current = setTimeout(() => {\n setDebouncedSearch(searchQuery);\n setPage(1);\n }, 400);\n return () => {\n if (debounceTimer.current) clearTimeout(debounceTimer.current);\n };\n }, [searchQuery]);\n\n const { invoices, totalPages, isLoading, error, refetch } = usePaginatedInvoices({\n billingAccountId: selectedAccountId ?? undefined,\n status: filterStatus !== 'all' ? (filterStatus as InvoiceStatus) : undefined,\n search: debouncedSearch || undefined,\n page,\n pageSize: 20,\n });\n\n const handlePayInvoice = useCallback(\n async (invoice: Invoice): Promise<void> => {\n const billingAccountId = invoice.billingAccountId;\n const paymentMethodId = billingAccountId\n ? billingAccounts.find((account: BillingAccountItem) => account.id === billingAccountId)\n ?.defaultPaymentMethod\n : undefined;\n\n if (!billingAccountId) {\n setActionError('No billing account context');\n return;\n }\n if (!paymentMethodId) {\n setActionError('Add and set a default payment method before paying this invoice.');\n return;\n }\n\n setActionError(null);\n setActiveAction({ invoiceId: invoice.id, action: 'pay' });\n try {\n await payInvoice(invoice.id, paymentMethodId, billingAccountId);\n await refetch();\n void nativeNotify('success');\n } catch (actionErrorValue) {\n setActionError(\n actionErrorValue instanceof Error ? actionErrorValue.message : 'Failed to pay invoice'\n );\n void nativeNotify('error');\n } finally {\n setActiveAction(null);\n }\n },\n [billingAccounts, payInvoice, refetch]\n );\n\n const handleVoidInvoice = useCallback(\n async (invoice: Invoice): Promise<void> => {\n const billingAccountId = invoice.billingAccountId;\n if (!billingAccountId) {\n setActionError('No billing account context');\n return;\n }\n\n setActionError(null);\n setActiveAction({ invoiceId: invoice.id, action: 'void' });\n try {\n await voidInvoice(invoice.id, billingAccountId);\n await refetch();\n void nativeNotify('success');\n } catch (actionErrorValue) {\n setActionError(\n actionErrorValue instanceof Error ? actionErrorValue.message : 'Failed to void invoice'\n );\n void nativeNotify('error');\n } finally {\n setActiveAction(null);\n }\n },\n [refetch, voidInvoice]\n );\n\n // Permission check\n if (!permissions.canViewInvoices) {\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\">\n {tr('billing.accessDenied.title', 'Access Denied')}\n </h2>\n <p className=\"text-sm text-text-secondary max-w-sm\">\n {tr('billing.invoices.noViewPermission', \"You don't have permission to view invoices.\")}\n </p>\n </div>\n </div>\n );\n }\n\n // Loading state\n if (isLoading && invoices.length === 0) {\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"h-8 w-48 bg-bg-sunken animate-pulse rounded\" />\n <div className=\"space-y-3\">\n {[1, 2, 3, 4, 5].map((i) => (\n <div key={i} className=\"border border-border-subtle rounded-lg p-4\">\n <div className=\"flex items-center gap-4\">\n <div className=\"size-10 bg-bg-sunken animate-pulse rounded\" />\n <div className=\"flex-1 space-y-2\">\n <div className=\"h-4 w-32 bg-bg-sunken animate-pulse rounded\" />\n <div className=\"h-3 w-48 bg-bg-sunken animate-pulse rounded\" />\n </div>\n </div>\n </div>\n ))}\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\">\n {tr('billing.invoices.failedToLoad', 'Failed to load invoices')}\n </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 {tr('billing.common.tryAgain', 'Try Again')}\n </button>\n </div>\n </div>\n );\n }\n\n const accountSelect =\n billingAccounts.length > 1 ? (\n <div\n className={\n isFluidgrids\n ? 'flex w-full min-w-0 items-center gap-2 sm:w-auto'\n : 'flex items-center gap-2'\n }\n >\n <label className=\"text-sm text-text-secondary whitespace-nowrap\">\n {tr('billing.invoices.billingAccountLabel', 'Billing Account')}\n </label>\n <select\n value={selectedAccountId ?? ''}\n onChange={(e) => setExplicitAccountId(e.target.value || null)}\n className={`${isFluidgrids ? 'min-w-0 flex-1 truncate sm:max-w-xs sm:flex-none ' : ''}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 <option value=\"\">{tr('billing.invoices.allAccounts', 'All Accounts')}</option>\n {billingAccounts.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 </div>\n ) : null;\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 xl:flex-row xl:items-start xl: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 xl:max-w-3xl' : undefined}>\n <h1 className=\"text-2xl md:text-3xl font-semibold tracking-tight text-text-primary\">\n {tr('billing.invoices.title', 'Invoices')}\n </h1>\n <p className=\"text-sm text-text-secondary mt-1\">\n {tr('billing.invoices.subtitle', 'View and manage your billing invoices')}\n </p>\n <PagePurpose className=\"mt-3\">\n {tr(\n 'billing.invoices.purpose',\n 'A record of everything you have been billed for — subscriptions, add-ons and one-off charges. Open an invoice to see line items, download the PDF, pay an outstanding amount, or request a refund.'\n )}\n </PagePurpose>\n </div>\n <div\n className={\n isFluidgrids\n ? 'flex flex-wrap items-center gap-3 xl:shrink-0 xl:justify-end'\n : 'flex items-center gap-3'\n }\n >\n <button\n type=\"button\"\n onClick={() => navigateTo('/refunds')}\n className=\"inline-flex items-center gap-2 whitespace-nowrap px-3 py-2 text-sm font-medium border border-border-subtle text-text-primary rounded-button hover:bg-bg-sunken hover:border-border-strong transition-all duration-200\"\n >\n <RotateCcw className=\"size-4\" />\n {tr('billing.invoices.myRefunds', 'My Refunds')}\n </button>\n {!isFluidgrids && accountSelect}\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 {/* Status Filter */}\n <div className=\"inline-flex rounded-lg border border-border-subtle p-1 bg-bg-sunken flex-wrap\">\n {(['all', 'OPEN', 'PAID', 'DRAFT', 'VOID'] as FilterStatus[]).map((status) => (\n <button\n type=\"button\"\n key={status}\n onClick={() => {\n setFilterStatus(status);\n setPage(1);\n }}\n className={`px-3 py-1.5 text-sm font-medium rounded-button transition-colors ${\n filterStatus === status\n ? 'bg-bg-surface text-text-primary shadow-sm'\n : 'text-text-secondary hover:text-text-primary'\n }`}\n >\n {status === 'all' ? 'All' : formatInvoiceStatus(status as InvoiceStatus)}\n </button>\n ))}\n </div>\n\n {/* Search */}\n <div className=\"relative flex-1 min-w-0 w-full sm:max-w-md\">\n <svg\n className=\"absolute left-3 top-1/2 -translate-y-1/2 size-4 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=\"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z\"\n />\n </svg>\n <input\n type=\"text\"\n placeholder={tr('billing.invoices.searchPlaceholder', 'Search by invoice number...')}\n value={searchQuery}\n onChange={(e) => setSearchQuery(e.target.value)}\n className=\"w-full pl-[3.25rem] pr-4 py-2 text-sm border border-border-subtle rounded-button bg-bg-surface text-text-primary placeholder:text-text-placeholder focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)] focus:border-transparent\"\n />\n </div>\n {isFluidgrids && accountSelect ? (\n <div className=\"w-full sm:ml-auto sm:w-auto\">{accountSelect}</div>\n ) : null}\n </div>\n\n {actionError && (\n <div className=\"rounded-button border border-status-error-border bg-status-error-bg-subtle p-3\">\n <p className=\"text-sm text-status-error-text\">{actionError}</p>\n </div>\n )}\n\n {/* Invoices Table */}\n {!isLoading && invoices.length === 0 ? (\n <IllustratedEmptyState\n illustration={filterStatus !== 'all' || debouncedSearch ? 'empty-search' : 'empty-files'}\n title={tr('billing.invoices.noInvoicesFound', 'No invoices found')}\n description={\n filterStatus !== 'all' || debouncedSearch\n ? tr('billing.invoices.noInvoicesFiltered', 'No invoices match your filters.')\n : tr('billing.invoices.noInvoicesYet', \"You don't have any invoices yet.\")\n }\n />\n ) : (\n <>\n <div\n className={`border border-border-seam rounded-card bg-bg-surface shadow-elevation-1 ${isFluidgrids ? 'overflow-x-auto' : 'overflow-hidden'}`}\n >\n <table className=\"w-full\">\n <thead className=\"bg-bg-sunken\">\n <tr>\n <th className=\"text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted\">\n {tr('billing.invoices.invoice', 'Invoice')}\n </th>\n <th className=\"text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted\">\n {tr('billing.common.status', 'Status')}\n </th>\n {!selectedAccountId && billingAccounts.length > 1 && (\n <th className=\"text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted hidden lg:table-cell\">\n {tr('billing.common.account', 'Account')}\n </th>\n )}\n <th className=\"text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted hidden sm:table-cell\">\n {tr('billing.common.date', 'Date')}\n </th>\n <th className=\"text-left px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted hidden md:table-cell\">\n {tr('billing.common.dueDate', 'Due Date')}\n </th>\n <th className=\"text-right px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted\">\n {tr('billing.common.amount', 'Amount')}\n </th>\n <th className=\"text-right px-4 py-3 text-xs font-medium uppercase tracking-wide text-text-muted\">\n {tr('billing.common.actions', 'Actions')}\n </th>\n </tr>\n </thead>\n <tbody className=\"divide-y divide-border-subtle\">\n {invoices.map((invoice) => (\n <InvoiceRow\n key={invoice.id}\n invoice={invoice}\n onView={() =>\n navigateTo(\n withBillingAccountId(`/invoices/${invoice.id}`, invoice.billingAccountId)\n )\n }\n canPay={permissions.canPayInvoice}\n canVoid={permissions.canVoidInvoice}\n onPay={handlePayInvoice}\n onVoid={handleVoidInvoice}\n isProcessing={activeAction?.invoiceId === invoice.id}\n processingAction={\n activeAction?.invoiceId === invoice.id ? activeAction.action : undefined\n }\n showAccount={!selectedAccountId && billingAccounts.length > 1}\n accountName={\n billingAccounts.find(\n (a: BillingAccountItem) => a.id === invoice.billingAccountId\n )?.name ?? null\n }\n />\n ))}\n </tbody>\n </table>\n </div>\n\n {totalPages > 1 && (\n <div className=\"flex items-center justify-between pt-2\">\n <p className=\"text-sm text-text-secondary\">\n {tr('billing.common.pageOf', 'Page {{page}} of {{totalPages}}', {\n page,\n totalPages,\n })}\n </p>\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => setPage((p) => Math.max(1, p - 1))}\n disabled={page <= 1}\n className=\"px-3 py-1.5 text-sm font-medium border border-border-subtle rounded-button bg-bg-surface text-text-primary hover:bg-bg-sunken disabled:opacity-40 disabled:cursor-not-allowed transition-colors\"\n >\n {tr('billing.common.previous', 'Previous')}\n </button>\n <button\n type=\"button\"\n onClick={() => setPage((p) => Math.min(totalPages, p + 1))}\n disabled={page >= totalPages}\n className=\"px-3 py-1.5 text-sm font-medium border border-border-subtle rounded-button bg-bg-surface text-text-primary hover:bg-bg-sunken disabled:opacity-40 disabled:cursor-not-allowed transition-colors\"\n >\n {tr('billing.common.next', 'Next')}\n </button>\n </div>\n </div>\n )}\n </>\n )}\n </div>\n );\n};\n\n// ============================================================================\n// Invoice Row Component\n// ============================================================================\n\ninterface InvoiceRowProps {\n invoice: Invoice;\n onView: () => void;\n onPay: (invoice: Invoice) => Promise<void>;\n onVoid: (invoice: Invoice) => Promise<void>;\n canPay: boolean;\n canVoid: boolean;\n isProcessing: boolean;\n processingAction?: 'pay' | 'void';\n showAccount?: boolean;\n accountName?: string | null;\n}\n\nconst InvoiceRow: FC<InvoiceRowProps> = ({\n invoice,\n onView,\n onPay,\n onVoid,\n canPay,\n canVoid,\n isProcessing,\n processingAction,\n showAccount = false,\n accountName,\n}) => {\n const tr = useTr();\n const isFluidgrids = useIsFluidgridsVariant();\n const [isConfirmingVoid, setIsConfirmingVoid] = useState(false);\n const [isReviewingPay, setIsReviewingPay] = useState(false);\n const statusColor = getInvoiceStatusColor(invoice.status);\n const isOpen = invoice.status === ('OPEN' as InvoiceStatus);\n const isDraft = invoice.status === ('DRAFT' as InvoiceStatus);\n\n const handleVoidRequest = async () => {\n void nativeImpact('medium');\n const confirmed = await nativeConfirm({\n title: 'Void invoice',\n message: 'Are you sure you want to void this invoice?',\n okButtonTitle: 'Void',\n cancelButtonTitle: 'Cancel',\n });\n if (confirmed === true) {\n await onVoid(invoice);\n } else if (confirmed === null) {\n setIsConfirmingVoid(true);\n }\n };\n\n // FluidGrids: Pay opens a review step (invoice, amount, card) before it charges.\n const handlePayRequest = () => {\n if (isFluidgrids) {\n setIsReviewingPay(true);\n return;\n }\n void onPay(invoice);\n };\n\n const handlePayConfirmed = async () => {\n await onPay(invoice);\n setIsReviewingPay(false);\n };\n\n const handleVoidConfirmed = async () => {\n await onVoid(invoice);\n setIsConfirmingVoid(false);\n };\n\n const invoicePdfBackupUrl = (invoice.metadata as Record<string, unknown> | undefined)\n ?.invoicePdfBackupUrl as string | undefined;\n\n return (\n <tr className=\"hover:bg-bg-sunken transition-colors\">\n <td className=\"p-4\">\n {invoice.invoiceUrl ? (\n <a\n href={invoice.invoiceUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"font-medium text-text-primary hover:text-text-link transition-colors\"\n >\n {formatInvoiceNumber(invoice.invoiceNumber)}\n </a>\n ) : (\n <button\n type=\"button\"\n onClick={onView}\n className=\"font-medium text-text-primary hover:text-text-link transition-colors\"\n >\n {formatInvoiceNumber(invoice.invoiceNumber)}\n </button>\n )}\n {(invoice.itemDescription ?? invoice.subscription?.plan?.name) && (\n <p className=\"text-sm text-text-secondary mt-0.5\">\n {invoice.itemDescription ?? invoice.subscription?.plan?.name}\n </p>\n )}\n </td>\n <td className=\"p-4\">\n <StatusPill status={statusColor} dot>\n {formatInvoiceStatus(invoice.status)}\n </StatusPill>\n </td>\n {showAccount && (\n <td className=\"p-4 hidden lg:table-cell\">\n {accountName ? (\n <span className=\"inline-flex items-center px-2 py-0.5 text-xs font-medium rounded-full bg-bg-sunken text-text-secondary border border-border-subtle\">\n {accountName}\n </span>\n ) : (\n <span className=\"text-sm text-text-secondary\">, </span>\n )}\n </td>\n )}\n <td className=\"p-4 text-sm text-text-secondary hidden sm:table-cell\">\n {formatDate(invoice.createdAt, 'short')}\n </td>\n <td className=\"p-4 text-sm text-text-secondary hidden md:table-cell\">\n {invoice.dueDate ? formatDate(invoice.dueDate, 'short') : '—'}\n </td>\n <td\n className={`p-4 text-right font-medium text-text-primary ${isFluidgrids ? 'whitespace-nowrap' : ''}`}\n >\n {formatCurrency(invoice.total, invoice.currency)}\n </td>\n <td className=\"p-4 text-right\">\n <div\n className={`relative flex items-center justify-end ${isFluidgrids ? 'flex-wrap gap-1' : 'gap-2'}`}\n >\n {invoice.invoiceUrl ? (\n <a\n href={invoice.invoiceUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-sunken rounded-button transition-colors duration-200\"\n >\n {tr('billing.common.view', 'View')}\n </a>\n ) : (\n <button\n type=\"button\"\n onClick={onView}\n className=\"px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-sunken rounded-button transition-colors duration-200\"\n >\n {tr('billing.common.view', 'View')}\n </button>\n )}\n {invoice.pdfUrl && (\n <a\n href={invoice.pdfUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"px-3 py-1.5 text-sm font-medium text-text-link hover:bg-[var(--color-accent-softHover)] rounded-button transition-colors duration-200\"\n >\n {tr('billing.common.pdf', 'PDF')}\n </a>\n )}\n {/* Our own durable backup copy, shown alongside the provider's —\n not a replacement, so this still works if the provider link\n ever breaks. */}\n {invoicePdfBackupUrl && (\n <a\n href={invoicePdfBackupUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"px-3 py-1.5 text-sm font-medium text-text-link hover:bg-[var(--color-accent-softHover)] rounded-button transition-colors duration-200\"\n >\n {tr('billing.common.pdfBackup', 'PDF (backup)')}\n </a>\n )}\n {isOpen && canPay && (\n <button\n type=\"button\"\n onClick={handlePayRequest}\n disabled={isProcessing}\n className=\"px-3 py-1.5 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-button hover:bg-action-primary-bgHover transition-colors duration-200 disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {isProcessing && processingAction === 'pay'\n ? tr('billing.common.paying', 'Paying…')\n : tr('billing.common.pay', 'Pay')}\n </button>\n )}\n {isFluidgrids && (\n <MoneyActionDialog\n open={isReviewingPay}\n title={tr('billing.invoices.payReview.title', 'Review and pay')}\n description={tr(\n 'billing.invoices.payReview.description',\n 'Your default card is charged as soon as you confirm.'\n )}\n details={[\n {\n label: tr('billing.invoices.payReview.invoice', 'Invoice'),\n value: formatInvoiceNumber(invoice.invoiceNumber),\n },\n ...(accountName\n ? [\n {\n label: tr('billing.invoices.payReview.account', 'Billing account'),\n value: accountName,\n },\n ]\n : []),\n {\n label: tr('billing.invoices.payReview.card', 'Paid with'),\n value: tr('billing.invoices.payReview.defaultCard', 'Your default card'),\n },\n {\n label: tr('billing.invoices.payReview.amount', 'Amount'),\n value: formatCurrency(invoice.total, invoice.currency),\n },\n ]}\n confirmLabel={tr('billing.invoices.payReview.confirm', 'Pay {{amount}}', {\n amount: formatCurrency(invoice.total, invoice.currency),\n })}\n busyLabel={tr('billing.common.paying', 'Paying…')}\n isBusy={isProcessing && processingAction === 'pay'}\n onConfirm={() => void handlePayConfirmed()}\n onCancel={() => setIsReviewingPay(false)}\n />\n )}\n {(isOpen || isDraft) && canVoid && (\n <button\n type=\"button\"\n onClick={() => void handleVoidRequest()}\n disabled={isProcessing}\n className=\"px-3 py-1.5 text-sm font-medium text-status-error-text hover:bg-status-error-bg-subtle rounded-button transition-colors duration-200 disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {isProcessing && processingAction === 'void'\n ? tr('billing.common.voiding', 'Voiding…')\n : tr('billing.common.void', 'Void')}\n </button>\n )}\n {isConfirmingVoid && (\n <div className=\"absolute right-4 mt-12 z-10 w-64 rounded-card border border-status-error-border bg-bg-elevated p-3 text-left shadow-elevation-2\">\n <p className=\"text-sm font-medium text-text-primary\">Void this invoice?</p>\n <div className=\"mt-3 flex justify-end gap-2\">\n <button\n type=\"button\"\n onClick={() => setIsConfirmingVoid(false)}\n className=\"rounded-button border border-border-subtle bg-bg-surface px-2.5 py-1.5 text-xs font-medium text-text-primary hover:bg-bg-sunken\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n onClick={() => void handleVoidConfirmed()}\n disabled={isProcessing}\n className=\"rounded-button bg-action-danger-bg px-2.5 py-1.5 text-xs font-medium text-action-primary-text hover:bg-action-danger-bgHover disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {isProcessing ? 'Voiding…' : 'Confirm'}\n </button>\n </div>\n </div>\n )}\n </div>\n </td>\n </tr>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,IAAaE,UAA6B;CACxC,IAAMC,IAAKC,EAAM,GACXC,IAAeC,EAAuB,GACtCC,IAAaC,EAAmB,GAChCC,IAAcC,EAAsB,GACpC,CAACC,KAAgBC,EAAgB,GACjCC,IAAsBF,EAAa,IAAI,kBAAkB,KAAK,KAAA,GAE9D,EAAE,MAAMG,MAAiBC,EAAgC,EAAE,aAAa,cAAc,CAAC,GACvFC,IAAkBC,QAChBH,GAAc,2BAA2B,CAAC,GAChD,CAACA,CAAY,CACf,GACM,EAAE,eAAY,mBAAgBI,EAAoB,GAClD,CAACC,GAAaC,KAAkBC,EAAwB,IAAI,GAC5D,CAACC,GAAcC,KAAmBF,EAAwB,IAAI,GAK9D,CAACG,GAAmBC,KAAwBJ,EAChDR,CACF;CAEA,QAAgB;EACd,EAAqBA,CAAmB;CAC1C,GAAG,CAACA,CAAmB,CAAC;CAExB,IAAMa,IAAmBT,SAEpBD,EAAgB,MAAM,MAA0BW,EAAE,SAAS,KAAKX,EAAgB,GAAA,EAAK,MACtF,KAAA,GACF,CAACA,CAAe,CAClB,GAGMY,IACJJ,MAAsB,KAAA,IAAiCE,KAAoB,OAAzCF,GAE9B,CAACK,GAAcC,KAAmBT,EAAuB,KAAK,GAC9D,CAACU,GAAaC,MAAkBX,EAAS,EAAE,GAC3C,CAACY,GAAiBC,MAAsBb,EAAS,EAAE,GACnD,CAACc,GAAMC,KAAWf,EAAS,CAAC,GAC5BgB,IAAgB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