@burdenoff/microfe-proserviceworld 2026.1026.2 → 2026.1028.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- import { useCancelInvoice as e, useClients as t, useCreateInvoice as n, useEngagements as r, useInvoice as i, useInvoices as a, useMarkInvoicePaid as o } from "../hooks/useProServiceWorldApi.js";
2
- import { cn as s } from "../utils/cn.js";
3
- import { Banner as c, Empty as l, ErrorState as u, Field as d, LoadingBlock as f, MetricCard as p, Modal as m, NativeSelect as h, PageHeader as g, SectionCard as _, StatusPill as v, TableWrap as y, Td as b, TextArea as x, TextInput as S, Th as C, enumOptions as w, fmtDate as T, fmtMoney as E } from "../components/ui.js";
4
- import { useAnalytics as D } from "../hooks/useAnalytics.js";
5
- import { useDeferredValue as O, useMemo as k, useState as A } from "react";
6
- import { AlertCircle as ee, CheckCircle2 as te, Eye as ne, Plus as j, Receipt as M, Search as N, Wallet as P, XCircle as F } from "lucide-react";
1
+ import { useCancelInvoice as e, useClients as t, useCreateInvoice as n, useEngagements as r, useInvoice as i, useInvoices as a, useMarkInvoicePaid as o, useSendInvoice as s } from "../hooks/useProServiceWorldApi.js";
2
+ import { cn as c } from "../utils/cn.js";
3
+ import { Banner as l, Empty as u, ErrorState as d, Field as f, LoadingBlock as p, MetricCard as m, Modal as h, NativeSelect as g, PageHeader as _, SectionCard as v, StatusPill as y, TableWrap as b, Td as x, TextArea as S, TextInput as C, Th as w, enumOptions as T, fmtDate as E, fmtMoney as D } from "../components/ui.js";
4
+ import { useAnalytics as O } from "../hooks/useAnalytics.js";
5
+ import { useDeferredValue as ee, useMemo as te, useState as k } from "react";
6
+ import { AlertCircle as ne, CheckCircle2 as re, Eye as ie, Plus as A, Receipt as j, Search as M, Send as N, Wallet as P, XCircle as F } from "lucide-react";
7
7
  import { Fragment as I, jsx as L, jsxs as R } from "react/jsx-runtime";
8
8
  import { Button as z } from "@burdenoff/fe-libs/ui";
9
9
  //#region src/proserviceworld/pages/InvoicesPage.tsx
@@ -14,45 +14,45 @@ var B = [
14
14
  "OVERDUE",
15
15
  "CANCELLED"
16
16
  ], V = () => {
17
- let [n, r] = A(""), [i, d] = A(""), m = O(i), [x, I] = A(!1), [V, U] = A(null), [W, G] = A(null), { data: K, isLoading: ie, error: q, refetch: ae } = a({
17
+ let [n, r] = k(""), [i, f] = k(""), h = ee(i), [S, I] = k(!1), [V, H] = k(null), [U, W] = k(null), { data: G, isLoading: se, error: K, refetch: ce } = a({
18
18
  status: n || void 0,
19
- search: m.trim() || void 0
20
- }), { emitFact: oe } = D(), J = o(), Y = e(), X = t({ pagination: { limit: 100 } }), Z = k(() => new Map((X.data?.items ?? []).map((e) => [e.id, e.name])), [X.data]), Q = (K?.items ?? []).filter((e) => e.status === "SENT" || e.status === "OVERDUE"), $ = (K?.items ?? []).filter((e) => e.status === "PAID"), se = Q.reduce((e, t) => e + t.total, 0), ce = $.reduce((e, t) => e + t.total, 0);
19
+ search: h.trim() || void 0
20
+ }), { emitFact: le } = O(), q = s(), J = o(), Y = e(), X = t({ pagination: { limit: 100 } }), Z = te(() => new Map((X.data?.items ?? []).map((e) => [e.id, e.name])), [X.data]), Q = (G?.items ?? []).filter((e) => e.status === "SENT" || e.status === "OVERDUE"), $ = (G?.items ?? []).filter((e) => e.status === "PAID"), ue = Q.reduce((e, t) => e + t.total, 0), de = $.reduce((e, t) => e + t.total, 0);
21
21
  return /* @__PURE__ */ R("div", {
22
22
  className: "space-y-6",
23
23
  children: [
24
- /* @__PURE__ */ L(g, {
24
+ /* @__PURE__ */ L(_, {
25
25
  title: "Invoices",
26
26
  subtitle: "Assemble invoices from time, milestones and fixed-fee schedules — and track what's outstanding.",
27
- icon: /* @__PURE__ */ L(M, { className: "h-6 w-6" }),
27
+ icon: /* @__PURE__ */ L(j, { className: "h-6 w-6" }),
28
28
  actions: /* @__PURE__ */ R(z, {
29
29
  onClick: () => I(!0),
30
- children: [/* @__PURE__ */ L(j, { className: "mr-1.5 h-4 w-4" }), "New invoice"]
30
+ children: [/* @__PURE__ */ L(A, { className: "mr-1.5 h-4 w-4" }), "New invoice"]
31
31
  })
32
32
  }),
33
- W && /* @__PURE__ */ L(c, {
34
- tone: W.tone,
35
- onClose: () => G(null),
36
- children: W.text
33
+ U && /* @__PURE__ */ L(l, {
34
+ tone: U.tone,
35
+ onClose: () => W(null),
36
+ children: U.text
37
37
  }),
38
38
  /* @__PURE__ */ R("div", {
39
39
  className: "grid grid-cols-1 gap-3 sm:grid-cols-3",
40
40
  children: [
41
- /* @__PURE__ */ L(p, {
41
+ /* @__PURE__ */ L(m, {
42
42
  label: "Invoices",
43
- value: K?.totalCount ?? 0,
44
- icon: /* @__PURE__ */ L(M, { className: "h-4 w-4" })
43
+ value: G?.totalCount ?? 0,
44
+ icon: /* @__PURE__ */ L(j, { className: "h-4 w-4" })
45
45
  }),
46
- /* @__PURE__ */ L(p, {
46
+ /* @__PURE__ */ L(m, {
47
47
  label: "Outstanding",
48
- value: E(se),
48
+ value: D(ue),
49
49
  hint: `${Q.length} sent + overdue`,
50
- icon: /* @__PURE__ */ L(ee, { className: "h-4 w-4" }),
50
+ icon: /* @__PURE__ */ L(ne, { className: "h-4 w-4" }),
51
51
  tone: "warning"
52
52
  }),
53
- /* @__PURE__ */ L(p, {
53
+ /* @__PURE__ */ L(m, {
54
54
  label: "Collected",
55
- value: E(ce),
55
+ value: D(de),
56
56
  hint: `${$.length} paid`,
57
57
  icon: /* @__PURE__ */ L(P, { className: "h-4 w-4" }),
58
58
  tone: "success"
@@ -63,72 +63,72 @@ var B = [
63
63
  className: "flex flex-col gap-2 sm:flex-row sm:items-center",
64
64
  children: [/* @__PURE__ */ R("div", {
65
65
  className: "relative flex-1",
66
- children: [/* @__PURE__ */ L(N, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-tertiary" }), /* @__PURE__ */ L(S, {
66
+ children: [/* @__PURE__ */ L(M, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-tertiary" }), /* @__PURE__ */ L(C, {
67
67
  placeholder: "Search invoices…",
68
68
  value: i,
69
- onChange: (e) => d(e.target.value),
69
+ onChange: (e) => f(e.target.value),
70
70
  onKeyDown: (e) => {
71
- e.key === "Enter" && i.trim() && oe("psw.search.performed", {
71
+ e.key === "Enter" && i.trim() && le("psw.search.performed", {
72
72
  entityType: "invoice",
73
73
  queryLength: i.trim().length
74
74
  });
75
75
  },
76
76
  className: "pl-9"
77
77
  })]
78
- }), /* @__PURE__ */ R(h, {
78
+ }), /* @__PURE__ */ R(g, {
79
79
  value: n,
80
80
  onChange: (e) => r(e.target.value),
81
81
  className: "sm:w-48",
82
82
  children: [/* @__PURE__ */ L("option", {
83
83
  value: "",
84
84
  children: "All statuses"
85
- }), w(B)]
85
+ }), T(B)]
86
86
  })]
87
87
  }),
88
- ie ? /* @__PURE__ */ L(f, {}) : q ? /* @__PURE__ */ L(u, {
89
- error: q,
90
- onRetry: () => void ae()
91
- }) : !K || K.items.length === 0 ? /* @__PURE__ */ L(l, {
88
+ se ? /* @__PURE__ */ L(p, {}) : K ? /* @__PURE__ */ L(d, {
89
+ error: K,
90
+ onRetry: () => void ce()
91
+ }) : !G || G.items.length === 0 ? /* @__PURE__ */ L(u, {
92
92
  title: "No invoices yet",
93
93
  description: "Raise an invoice for a client to start tracking receivables.",
94
- icon: /* @__PURE__ */ L(M, { className: "h-8 w-8" }),
94
+ icon: /* @__PURE__ */ L(j, { className: "h-8 w-8" }),
95
95
  action: /* @__PURE__ */ R(z, {
96
96
  onClick: () => I(!0),
97
- children: [/* @__PURE__ */ L(j, { className: "mr-1.5 h-4 w-4" }), "New invoice"]
97
+ children: [/* @__PURE__ */ L(A, { className: "mr-1.5 h-4 w-4" }), "New invoice"]
98
98
  })
99
- }) : /* @__PURE__ */ L(_, {
99
+ }) : /* @__PURE__ */ L(v, {
100
100
  title: "Invoices",
101
- children: /* @__PURE__ */ R(y, { children: [/* @__PURE__ */ L("thead", { children: /* @__PURE__ */ R("tr", { children: [
102
- /* @__PURE__ */ L(C, { children: "Number" }),
103
- /* @__PURE__ */ L(C, { children: "Client" }),
104
- /* @__PURE__ */ L(C, { children: "Total" }),
105
- /* @__PURE__ */ L(C, { children: "Status" }),
106
- /* @__PURE__ */ L(C, { children: "Due" }),
107
- /* @__PURE__ */ L(C, {
101
+ children: /* @__PURE__ */ R(b, { children: [/* @__PURE__ */ L("thead", { children: /* @__PURE__ */ R("tr", { children: [
102
+ /* @__PURE__ */ L(w, { children: "Number" }),
103
+ /* @__PURE__ */ L(w, { children: "Client" }),
104
+ /* @__PURE__ */ L(w, { children: "Total" }),
105
+ /* @__PURE__ */ L(w, { children: "Status" }),
106
+ /* @__PURE__ */ L(w, { children: "Due" }),
107
+ /* @__PURE__ */ L(w, {
108
108
  className: "text-right",
109
109
  children: "Actions"
110
110
  })
111
- ] }) }), /* @__PURE__ */ L("tbody", { children: K.items.map((e) => /* @__PURE__ */ R("tr", {
111
+ ] }) }), /* @__PURE__ */ L("tbody", { children: G.items.map((e) => /* @__PURE__ */ R("tr", {
112
112
  className: "transition-colors hover:bg-bg-sunken/60",
113
113
  children: [
114
- /* @__PURE__ */ L(b, { children: /* @__PURE__ */ L("span", {
114
+ /* @__PURE__ */ L(x, { children: /* @__PURE__ */ L("span", {
115
115
  className: "font-medium text-text-primary",
116
116
  children: e.number
117
117
  }) }),
118
- /* @__PURE__ */ L(b, {
118
+ /* @__PURE__ */ L(x, {
119
119
  className: "text-text-primary",
120
120
  children: Z.get(e.clientId) ?? "—"
121
121
  }),
122
- /* @__PURE__ */ L(b, {
122
+ /* @__PURE__ */ L(x, {
123
123
  className: "whitespace-nowrap font-semibold text-text-primary",
124
- children: E(e.total, e.currency)
124
+ children: D(e.total, e.currency)
125
125
  }),
126
- /* @__PURE__ */ L(b, { children: /* @__PURE__ */ L(v, { status: e.status }) }),
127
- /* @__PURE__ */ L(b, {
128
- className: s("whitespace-nowrap", e.status === "OVERDUE" && "font-medium text-status-error-text"),
129
- children: T(e.dueDate)
126
+ /* @__PURE__ */ L(x, { children: /* @__PURE__ */ L(y, { status: e.status }) }),
127
+ /* @__PURE__ */ L(x, {
128
+ className: c("whitespace-nowrap", e.status === "OVERDUE" && "font-medium text-status-error-text"),
129
+ children: E(e.dueDate)
130
130
  }),
131
- /* @__PURE__ */ L(b, {
131
+ /* @__PURE__ */ L(x, {
132
132
  className: "text-right",
133
133
  children: /* @__PURE__ */ R("div", {
134
134
  className: "flex items-center justify-end gap-1",
@@ -136,35 +136,51 @@ var B = [
136
136
  /* @__PURE__ */ R(z, {
137
137
  variant: "ghost",
138
138
  size: "sm",
139
- onClick: () => U(e.id),
140
- children: [/* @__PURE__ */ L(ne, { className: "mr-1 h-4 w-4" }), "View"]
139
+ onClick: () => H(e.id),
140
+ children: [/* @__PURE__ */ L(ie, { className: "mr-1 h-4 w-4" }), "View"]
141
141
  }),
142
- e.status !== "PAID" && e.status !== "CANCELLED" && /* @__PURE__ */ R(z, {
142
+ e.status === "DRAFT" && /* @__PURE__ */ R(z, {
143
+ variant: "ghost",
144
+ size: "sm",
145
+ disabled: q.isPending,
146
+ onClick: () => q.mutate(e.id, {
147
+ onSuccess: () => W({
148
+ tone: "success",
149
+ text: `${e.number} sent.`
150
+ }),
151
+ onError: (e) => W({
152
+ tone: "danger",
153
+ text: e instanceof Error ? e.message : "Failed."
154
+ })
155
+ }),
156
+ children: [/* @__PURE__ */ L(N, { className: "mr-1 h-4 w-4" }), "Send"]
157
+ }),
158
+ (e.status === "SENT" || e.status === "OVERDUE") && /* @__PURE__ */ R(z, {
143
159
  variant: "ghost",
144
160
  size: "sm",
145
161
  disabled: J.isPending,
146
162
  onClick: () => J.mutate(e.id, {
147
- onSuccess: () => G({
163
+ onSuccess: () => W({
148
164
  tone: "success",
149
165
  text: `${e.number} marked paid.`
150
166
  }),
151
- onError: (e) => G({
167
+ onError: (e) => W({
152
168
  tone: "danger",
153
169
  text: e instanceof Error ? e.message : "Failed."
154
170
  })
155
171
  }),
156
- children: [/* @__PURE__ */ L(te, { className: "mr-1 h-4 w-4" }), "Mark paid"]
172
+ children: [/* @__PURE__ */ L(re, { className: "mr-1 h-4 w-4" }), "Mark paid"]
157
173
  }),
158
174
  (e.status === "DRAFT" || e.status === "SENT") && /* @__PURE__ */ R(z, {
159
175
  variant: "ghost",
160
176
  size: "sm",
161
177
  disabled: Y.isPending,
162
178
  onClick: () => Y.mutate(e.id, {
163
- onSuccess: () => G({
179
+ onSuccess: () => W({
164
180
  tone: "success",
165
181
  text: `${e.number} cancelled.`
166
182
  }),
167
- onError: (e) => G({
183
+ onError: (e) => W({
168
184
  tone: "danger",
169
185
  text: e instanceof Error ? e.message : "Failed."
170
186
  })
@@ -177,19 +193,19 @@ var B = [
177
193
  ]
178
194
  }, e.id)) })] })
179
195
  }),
180
- x && /* @__PURE__ */ L(re, {
196
+ S && /* @__PURE__ */ L(oe, {
181
197
  onClose: () => I(!1),
182
- onSaved: (e) => G({
198
+ onSaved: (e) => W({
183
199
  tone: "success",
184
200
  text: `${e} created.`
185
201
  })
186
202
  }),
187
- V && /* @__PURE__ */ L(H, {
203
+ V && /* @__PURE__ */ L(ae, {
188
204
  id: V,
189
205
  clientName: Z,
190
- onClose: () => U(null),
206
+ onClose: () => H(null),
191
207
  onCancelled: (e) => {
192
- U(null), G({
208
+ H(null), W({
193
209
  tone: "success",
194
210
  text: `${e} cancelled.`
195
211
  });
@@ -197,9 +213,9 @@ var B = [
197
213
  })
198
214
  ]
199
215
  });
200
- }, H = ({ id: t, clientName: n, onClose: r, onCancelled: a }) => {
201
- let { data: o, isLoading: s, error: d } = i(t), p = e(), [h, g] = A(null);
202
- return /* @__PURE__ */ L(m, {
216
+ }, ae = ({ id: t, clientName: n, onClose: r, onCancelled: a }) => {
217
+ let { data: o, isLoading: s, error: c } = i(t), f = e(), [m, g] = k(null);
218
+ return /* @__PURE__ */ L(h, {
203
219
  open: !0,
204
220
  onClose: r,
205
221
  title: o ? `Invoice ${o.number}` : "Invoice",
@@ -209,21 +225,21 @@ var B = [
209
225
  children: "Close"
210
226
  }), o && (o.status === "DRAFT" || o.status === "SENT") && /* @__PURE__ */ R(z, {
211
227
  variant: "destructive",
212
- disabled: p.isPending,
228
+ disabled: f.isPending,
213
229
  onClick: () => {
214
- g(null), p.mutate(o.id, {
230
+ g(null), f.mutate(o.id, {
215
231
  onSuccess: () => a(o.number),
216
232
  onError: (e) => g(e instanceof Error ? e.message : "Failed.")
217
233
  });
218
234
  },
219
- children: [/* @__PURE__ */ L(F, { className: "mr-1.5 h-4 w-4" }), p.isPending ? "Cancelling…" : "Cancel invoice"]
235
+ children: [/* @__PURE__ */ L(F, { className: "mr-1.5 h-4 w-4" }), f.isPending ? "Cancelling…" : "Cancel invoice"]
220
236
  })] }),
221
237
  children: /* @__PURE__ */ R("div", {
222
238
  className: "space-y-3",
223
- children: [h && /* @__PURE__ */ L(c, {
239
+ children: [m && /* @__PURE__ */ L(l, {
224
240
  tone: "danger",
225
- children: h
226
- }), s ? /* @__PURE__ */ L(f, {}) : d ? /* @__PURE__ */ L(u, { error: d }) : o ? /* @__PURE__ */ R(I, { children: [
241
+ children: m
242
+ }), s ? /* @__PURE__ */ L(p, {}) : c ? /* @__PURE__ */ L(d, { error: c }) : o ? /* @__PURE__ */ R(I, { children: [
227
243
  /* @__PURE__ */ R("div", {
228
244
  className: "grid grid-cols-2 gap-3 text-sm",
229
245
  children: [
@@ -237,50 +253,50 @@ var B = [
237
253
  /* @__PURE__ */ R("div", { children: [/* @__PURE__ */ L("div", {
238
254
  className: "text-text-tertiary",
239
255
  children: "Status"
240
- }), /* @__PURE__ */ L(v, { status: o.status })] }),
256
+ }), /* @__PURE__ */ L(y, { status: o.status })] }),
241
257
  /* @__PURE__ */ R("div", { children: [/* @__PURE__ */ L("div", {
242
258
  className: "text-text-tertiary",
243
259
  children: "Issue date"
244
260
  }), /* @__PURE__ */ L("div", {
245
261
  className: "text-text-primary",
246
- children: T(o.issueDate)
262
+ children: E(o.issueDate)
247
263
  })] }),
248
264
  /* @__PURE__ */ R("div", { children: [/* @__PURE__ */ L("div", {
249
265
  className: "text-text-tertiary",
250
266
  children: "Due date"
251
267
  }), /* @__PURE__ */ L("div", {
252
268
  className: "text-text-primary",
253
- children: T(o.dueDate)
269
+ children: E(o.dueDate)
254
270
  })] }),
255
271
  /* @__PURE__ */ R("div", { children: [/* @__PURE__ */ L("div", {
256
272
  className: "text-text-tertiary",
257
273
  children: "Sent"
258
274
  }), /* @__PURE__ */ L("div", {
259
275
  className: "text-text-primary",
260
- children: T(o.sentAt)
276
+ children: E(o.sentAt)
261
277
  })] }),
262
278
  /* @__PURE__ */ R("div", { children: [/* @__PURE__ */ L("div", {
263
279
  className: "text-text-tertiary",
264
280
  children: "Paid"
265
281
  }), /* @__PURE__ */ L("div", {
266
282
  className: "text-text-primary",
267
- children: T(o.paidAt)
283
+ children: E(o.paidAt)
268
284
  })] })
269
285
  ]
270
286
  }),
271
- o.lineItems && o.lineItems.length > 0 && /* @__PURE__ */ R(y, { children: [/* @__PURE__ */ L("thead", { children: /* @__PURE__ */ R("tr", { children: [
272
- /* @__PURE__ */ L(C, { children: "Source" }),
273
- /* @__PURE__ */ L(C, { children: "Description" }),
274
- /* @__PURE__ */ L(C, {
287
+ o.lineItems && o.lineItems.length > 0 && /* @__PURE__ */ R(b, { children: [/* @__PURE__ */ L("thead", { children: /* @__PURE__ */ R("tr", { children: [
288
+ /* @__PURE__ */ L(w, { children: "Source" }),
289
+ /* @__PURE__ */ L(w, { children: "Description" }),
290
+ /* @__PURE__ */ L(w, {
275
291
  className: "text-right",
276
292
  children: "Amount"
277
293
  })
278
294
  ] }) }), /* @__PURE__ */ L("tbody", { children: o.lineItems.map((e, t) => /* @__PURE__ */ R("tr", { children: [
279
- /* @__PURE__ */ L(b, { children: e.sourceType }),
280
- /* @__PURE__ */ L(b, { children: e.description ?? e.sourceId }),
281
- /* @__PURE__ */ L(b, {
295
+ /* @__PURE__ */ L(x, { children: e.sourceType }),
296
+ /* @__PURE__ */ L(x, { children: e.description ?? e.sourceId }),
297
+ /* @__PURE__ */ L(x, {
282
298
  className: "text-right",
283
- children: E(e.amount, o.currency)
299
+ children: D(e.amount, o.currency)
284
300
  })
285
301
  ] }, `${e.sourceType}-${e.sourceId}-${t}`)) })] }),
286
302
  /* @__PURE__ */ R("div", {
@@ -288,15 +304,15 @@ var B = [
288
304
  children: [
289
305
  /* @__PURE__ */ R("div", {
290
306
  className: "flex justify-between",
291
- children: [/* @__PURE__ */ L("span", { children: "Subtotal" }), /* @__PURE__ */ L("span", { children: E(o.subtotal, o.currency) })]
307
+ children: [/* @__PURE__ */ L("span", { children: "Subtotal" }), /* @__PURE__ */ L("span", { children: D(o.subtotal, o.currency) })]
292
308
  }),
293
309
  /* @__PURE__ */ R("div", {
294
310
  className: "flex justify-between",
295
- children: [/* @__PURE__ */ L("span", { children: "Tax" }), /* @__PURE__ */ L("span", { children: E(o.taxAmount, o.currency) })]
311
+ children: [/* @__PURE__ */ L("span", { children: "Tax" }), /* @__PURE__ */ L("span", { children: D(o.taxAmount, o.currency) })]
296
312
  }),
297
313
  /* @__PURE__ */ R("div", {
298
314
  className: "flex justify-between font-semibold text-text-primary",
299
- children: [/* @__PURE__ */ L("span", { children: "Total" }), /* @__PURE__ */ L("span", { children: E(o.total, o.currency) })]
315
+ children: [/* @__PURE__ */ L("span", { children: "Total" }), /* @__PURE__ */ L("span", { children: D(o.total, o.currency) })]
300
316
  })
301
317
  ]
302
318
  }),
@@ -307,14 +323,14 @@ var B = [
307
323
  className: "text-sm text-text-primary",
308
324
  children: o.notes
309
325
  })] })
310
- ] }) : /* @__PURE__ */ L(l, {
326
+ ] }) : /* @__PURE__ */ L(u, {
311
327
  title: "Invoice not found",
312
- icon: /* @__PURE__ */ L(M, { className: "h-8 w-8" })
328
+ icon: /* @__PURE__ */ L(j, { className: "h-8 w-8" })
313
329
  })]
314
330
  })
315
331
  });
316
- }, re = ({ onClose: e, onSaved: i }) => {
317
- let a = n(), o = t({ pagination: { limit: 100 } }), [s, l] = A({
332
+ }, oe = ({ onClose: e, onSaved: i }) => {
333
+ let a = n(), o = t({ pagination: { limit: 100 } }), [s, c] = k({
318
334
  clientId: "",
319
335
  engagementId: "",
320
336
  number: "",
@@ -324,14 +340,14 @@ var B = [
324
340
  issueDate: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
325
341
  dueDate: "",
326
342
  notes: ""
327
- }), [u, f] = A(null), p = r({
343
+ }), [u, d] = k(null), p = r({
328
344
  clientId: s.clientId || void 0,
329
345
  pagination: { limit: 100 }
330
- }), g = (e) => (t) => l((n) => ({
346
+ }), m = (e) => (t) => c((n) => ({
331
347
  ...n,
332
348
  [e]: t.target.value
333
349
  })), _ = (Number(s.subtotal) || 0) + (Number(s.taxAmount) || 0);
334
- return /* @__PURE__ */ L(m, {
350
+ return /* @__PURE__ */ L(h, {
335
351
  open: !0,
336
352
  onClose: e,
337
353
  title: "New invoice",
@@ -342,8 +358,8 @@ var B = [
342
358
  children: "Cancel"
343
359
  }), /* @__PURE__ */ L(z, {
344
360
  onClick: () => {
345
- if (f(null), !s.clientId) return f("Select a client.");
346
- if (!s.number.trim()) return f("Invoice number is required.");
361
+ if (d(null), !s.clientId) return d("Select a client.");
362
+ if (!s.number.trim()) return d("Invoice number is required.");
347
363
  a.mutate({
348
364
  clientId: s.clientId,
349
365
  engagementId: s.engagementId || null,
@@ -359,7 +375,7 @@ var B = [
359
375
  onSuccess: () => {
360
376
  i(s.number.trim()), e();
361
377
  },
362
- onError: (e) => f(e instanceof Error ? e.message : "Failed.")
378
+ onError: (e) => d(e instanceof Error ? e.message : "Failed.")
363
379
  });
364
380
  },
365
381
  disabled: a.isPending,
@@ -368,18 +384,18 @@ var B = [
368
384
  children: /* @__PURE__ */ R("div", {
369
385
  className: "space-y-3",
370
386
  children: [
371
- u && /* @__PURE__ */ L(c, {
387
+ u && /* @__PURE__ */ L(l, {
372
388
  tone: "danger",
373
389
  children: u
374
390
  }),
375
391
  /* @__PURE__ */ R("div", {
376
392
  className: "grid grid-cols-2 gap-3",
377
- children: [/* @__PURE__ */ L(d, {
393
+ children: [/* @__PURE__ */ L(f, {
378
394
  label: "Client",
379
395
  required: !0,
380
- children: /* @__PURE__ */ R(h, {
396
+ children: /* @__PURE__ */ R(g, {
381
397
  value: s.clientId,
382
- onChange: g("clientId"),
398
+ onChange: m("clientId"),
383
399
  children: [/* @__PURE__ */ L("option", {
384
400
  value: "",
385
401
  children: "Select…"
@@ -388,21 +404,21 @@ var B = [
388
404
  children: e.name
389
405
  }, e.id))]
390
406
  })
391
- }), /* @__PURE__ */ L(d, {
407
+ }), /* @__PURE__ */ L(f, {
392
408
  label: "Number",
393
409
  required: !0,
394
- children: /* @__PURE__ */ L(S, {
410
+ children: /* @__PURE__ */ L(C, {
395
411
  value: s.number,
396
- onChange: g("number"),
412
+ onChange: m("number"),
397
413
  placeholder: "INV-2026-014"
398
414
  })
399
415
  })]
400
416
  }),
401
- /* @__PURE__ */ L(d, {
417
+ /* @__PURE__ */ L(f, {
402
418
  label: "Engagement (optional)",
403
- children: /* @__PURE__ */ R(h, {
419
+ children: /* @__PURE__ */ R(g, {
404
420
  value: s.engagementId,
405
- onChange: g("engagementId"),
421
+ onChange: m("engagementId"),
406
422
  disabled: !s.clientId,
407
423
  children: [/* @__PURE__ */ L("option", {
408
424
  value: "",
@@ -416,29 +432,29 @@ var B = [
416
432
  /* @__PURE__ */ R("div", {
417
433
  className: "grid grid-cols-3 gap-3",
418
434
  children: [
419
- /* @__PURE__ */ L(d, {
435
+ /* @__PURE__ */ L(f, {
420
436
  label: "Subtotal",
421
- children: /* @__PURE__ */ L(S, {
437
+ children: /* @__PURE__ */ L(C, {
422
438
  type: "number",
423
439
  min: "0",
424
440
  value: s.subtotal,
425
- onChange: g("subtotal")
441
+ onChange: m("subtotal")
426
442
  })
427
443
  }),
428
- /* @__PURE__ */ L(d, {
444
+ /* @__PURE__ */ L(f, {
429
445
  label: "Tax",
430
- children: /* @__PURE__ */ L(S, {
446
+ children: /* @__PURE__ */ L(C, {
431
447
  type: "number",
432
448
  min: "0",
433
449
  value: s.taxAmount,
434
- onChange: g("taxAmount")
450
+ onChange: m("taxAmount")
435
451
  })
436
452
  }),
437
- /* @__PURE__ */ L(d, {
453
+ /* @__PURE__ */ L(f, {
438
454
  label: "Currency",
439
- children: /* @__PURE__ */ L(S, {
455
+ children: /* @__PURE__ */ L(C, {
440
456
  value: s.currency,
441
- onChange: g("currency"),
457
+ onChange: m("currency"),
442
458
  maxLength: 3
443
459
  })
444
460
  })
@@ -451,33 +467,33 @@ var B = [
451
467
  " ",
452
468
  /* @__PURE__ */ L("span", {
453
469
  className: "font-semibold text-text-primary",
454
- children: E(_, s.currency)
470
+ children: D(_, s.currency)
455
471
  })
456
472
  ]
457
473
  }),
458
474
  /* @__PURE__ */ R("div", {
459
475
  className: "grid grid-cols-2 gap-3",
460
- children: [/* @__PURE__ */ L(d, {
476
+ children: [/* @__PURE__ */ L(f, {
461
477
  label: "Issue date",
462
- children: /* @__PURE__ */ L(S, {
478
+ children: /* @__PURE__ */ L(C, {
463
479
  type: "date",
464
480
  value: s.issueDate,
465
- onChange: g("issueDate")
481
+ onChange: m("issueDate")
466
482
  })
467
- }), /* @__PURE__ */ L(d, {
483
+ }), /* @__PURE__ */ L(f, {
468
484
  label: "Due date",
469
- children: /* @__PURE__ */ L(S, {
485
+ children: /* @__PURE__ */ L(C, {
470
486
  type: "date",
471
487
  value: s.dueDate,
472
- onChange: g("dueDate")
488
+ onChange: m("dueDate")
473
489
  })
474
490
  })]
475
491
  }),
476
- /* @__PURE__ */ L(d, {
492
+ /* @__PURE__ */ L(f, {
477
493
  label: "Notes",
478
- children: /* @__PURE__ */ L(x, {
494
+ children: /* @__PURE__ */ L(S, {
479
495
  value: s.notes,
480
- onChange: g("notes")
496
+ onChange: m("notes")
481
497
  })
482
498
  })
483
499
  ]