@burdenoff/microfe-billing 2026.1112.3 → 2026.1113.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,89 +1,70 @@
1
- import { useBillingEventEmitter as e } from "../../../hooks/useBillingEventEmitter.js";
2
- import { useBillingPermissions as t } from "../../../hooks/useBillingPermissions.js";
3
- import { AccessDenied as n } from "../../../shared/components/AccessDenied.js";
4
- import { PageHeader as ee } from "../../../shared/components/PageHeader.js";
5
- import { useBilling as te } from "../../../providers/BillingProvider.js";
1
+ import { EMPTY_SETTINGS_FORM as e, formFromAccount as t, hasFormChanges as n, toUpdateInput as ee } from "../utils/accountForm.js";
2
+ import { useIsFluidgridsVariant as te } from "../../../hooks/useBillingVariant.js";
3
+ import { AccessDenied as ne } from "../../../shared/components/AccessDenied.js";
4
+ import { PageHeader as re } from "../../../shared/components/PageHeader.js";
5
+ import { useBillingEventEmitter as ie } from "../../../hooks/useBillingEventEmitter.js";
6
+ import { useBillingPermissions as ae } from "../../../hooks/useBillingPermissions.js";
7
+ import { directBillingGraphqlRequest as oe } from "../../../shared/utils/directBillingGraphql.js";
8
+ import { useBilling as se } from "../../../providers/BillingProvider.js";
6
9
  import "../../../shared/components/index.js";
7
- import { directBillingGraphqlRequest as r } from "../../../shared/utils/directBillingGraphql.js";
8
10
  import "../../../shared/utils/index.js";
9
- import { ArchiveBillingAccountSettingsDocument as i, useGetBillingAccountSettingsQuery as ne, useGetBillingAccountsSettingsQuery as re, useGetDefaultBillingAccountSettingsQuery as ie, useSetDefaultBillingAccountSettingsMutation as ae, useUpdateBillingAccountSettingsMutation as a } from "../../../../generated/global-operations.js";
10
- import { useTr as oe } from "../../../shared/hooks/useTr.js";
11
- import { useCallback as o, useEffect as se, useMemo as s, useState as c } from "react";
12
- import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
13
- import { AlertDialog as ce, AlertDialogAction as le, AlertDialogCancel as ue, AlertDialogContent as de, AlertDialogDescription as fe, AlertDialogFooter as pe, AlertDialogHeader as me, AlertDialogTitle as f, OptionalFields as he, PagePurpose as ge } from "@burdenoff/fe-libs/ui";
11
+ import { ArchiveBillingAccountSettingsDocument as ce, useGetBillingAccountSettingsQuery as le, useGetBillingAccountsSettingsQuery as r, useGetDefaultBillingAccountSettingsQuery as ue, useSetDefaultBillingAccountSettingsMutation as de, useUpdateBillingAccountSettingsMutation as fe } from "../../../../generated/global-operations.js";
12
+ import { useTr as pe } from "../../../shared/hooks/useTr.js";
13
+ import { useCallback as i, useEffect as me, useMemo as a, useState as o } from "react";
14
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
15
+ import { AccessGate as he, AlertDialog as ge, AlertDialogAction as _e, AlertDialogCancel as ve, AlertDialogContent as ye, AlertDialogDescription as be, AlertDialogFooter as xe, AlertDialogHeader as Se, AlertDialogTitle as Ce, OptionalFields as u, PagePurpose as d } from "@burdenoff/fe-libs/ui";
14
16
  // src/billing/modules/settings/pages/SettingsPage.tsx
15
- var _e = () => {
17
+ var f = () => {
16
18
  if (typeof window < "u") return new URLSearchParams(window.location.search).get("billingAccountId") || void 0;
17
19
  }, p = () => {
18
- let p = oe(), m = t(), { apiGatewayUrl: h, authToken: g, orgId: _ } = te(), { emit: v } = e(), [y, b] = c(_e), [x, S] = c(!1), [C, w] = c(!1), [T, E] = c(!1), [ve, D] = c(!1), [O, k] = c(null), [ye, A] = c(!1), [j, M] = c(!1), [N, P] = c(!1), [F, I] = c({
19
- name: "",
20
- email: "",
21
- billingEmail: "",
22
- currency: "USD",
23
- taxId: "",
24
- isDefault: !1
25
- }), { data: L, loading: be, refetch: R } = re({}), z = s(() => L?.getBillingAccountsByOrg || [], [L?.getBillingAccountsByOrg]), { data: xe, loading: Se, refetch: B } = ie({}), V = xe?.getDefaultBillingAccount || null, { data: Ce, loading: H, refetch: U } = ne({
26
- variables: { id: y },
27
- skip: !y
28
- }), W = Ce?.getBillingAccount || null, [G] = a(), [K] = ae(), q = s(() => {
29
- if (y) {
20
+ let p = pe(), m = ae(), h = te(), { apiGatewayUrl: g, authToken: _, orgId: v } = se(), { emit: y } = ie(), [b, x] = o(f), [S, C] = o(!1), [w, T] = o(!1), [E, D] = o(!1), [O, k] = o(!1), [A, j] = o(null), [we, M] = o(!1), [Te, N] = o(!1), [Ee, P] = o(!1), [F, I] = o(e), { data: L, loading: De, refetch: R } = r({}), z = a(() => L?.getBillingAccountsByOrg || [], [L?.getBillingAccountsByOrg]), { data: Oe, loading: ke, refetch: B } = ue({}), V = Oe?.getDefaultBillingAccount || null, { data: Ae, loading: H, refetch: U } = le({
21
+ variables: { id: b },
22
+ skip: !b
23
+ }), W = Ae?.getBillingAccount || null, [G] = fe(), [K] = de(), q = a(() => {
24
+ if (b) {
30
25
  if (W) return W;
31
- let e = z.find((e) => e.id === y);
26
+ let e = z.find((e) => e.id === b);
32
27
  if (e) return e;
33
28
  if (H) return null;
34
29
  }
35
30
  return V;
36
31
  }, [
37
- y,
32
+ b,
38
33
  W,
39
34
  z,
40
35
  H,
41
36
  V
42
- ]), we = be || Se || y && H;
43
- se(() => {
44
- q && I({
45
- name: q.name || "",
46
- email: q.email || "",
47
- billingEmail: q.billingEmail || "",
48
- currency: q.currency || "USD",
49
- taxId: q.taxId || "",
50
- isDefault: q.isDefault || !1
51
- });
37
+ ]), je = De || ke || b && H;
38
+ me(() => {
39
+ q && I(t(q));
52
40
  }, [q]);
53
- let Te = (e) => {
54
- b(e.id), S(!1), A(!1), k(null);
41
+ let Me = (e) => {
42
+ x(e.id), C(!1), M(!1), j(null);
55
43
  }, J = (e, t) => {
56
44
  I((n) => ({
57
45
  ...n,
58
46
  [e]: t
59
- })), A(!1), k(null);
60
- }, Y = s(() => z.find((e) => e.isDefault) || null, [z]), Ee = s(() => q ? F.name !== (q.name || "") || F.email !== (q.email || "") || F.billingEmail !== (q.billingEmail || "") || F.currency !== (q.currency || "USD") || F.taxId !== (q.taxId || "") || F.isDefault !== (q.isDefault || !1) : !1, [F, q]), X = F.isDefault && !q?.isDefault, Z = X && Y && Y.id !== q?.id, Q = o(async () => {
47
+ })), M(!1), j(null);
48
+ }, Y = a(() => z.find((e) => e.isDefault) || null, [z]), Ne = a(() => n(F, q), [F, q]), X = F.isDefault && !q?.isDefault, Z = X && Y && Y.id !== q?.id, Q = i(async () => {
61
49
  if (q?.id) {
62
- w(!0), k(null), A(!1), M(!1), P(!1);
50
+ T(!0), j(null), M(!1), N(!1), P(!1);
63
51
  try {
64
- await G({ variables: { input: {
65
- id: q.id,
66
- name: F.name,
67
- email: F.email,
68
- billingEmail: F.billingEmail || null,
69
- currency: F.currency,
70
- taxId: F.taxId || null
71
- } } }), v("billing.billing_account.updated", {
52
+ await G({ variables: { input: ee(q.id, F) } }), y("billing.billing_account.updated", {
72
53
  route: "/billing/settings",
73
54
  entityId: q.id,
74
55
  source: "settings"
75
56
  }), X && (await K({
76
57
  variables: { id: q.id },
77
58
  refetchQueries: ["GetBillingAccountsByTenant", "GetDefaultBillingAccount"]
78
- }), v("billing.billing_account.updated", {
59
+ }), y("billing.billing_account.updated", {
79
60
  route: "/billing/settings",
80
61
  entityId: q.id,
81
62
  source: "settings.default"
82
- })), y ? await U() : await B(), A(!0), setTimeout(() => A(!1), 3e3);
63
+ })), b ? await U() : await B(), M(!0), setTimeout(() => M(!1), 3e3);
83
64
  } catch (e) {
84
- k(e instanceof Error ? e.message : "Failed to save changes");
65
+ j(e instanceof Error ? e.message : "Failed to save changes");
85
66
  } finally {
86
- w(!1);
67
+ T(!1);
87
68
  }
88
69
  }
89
70
  }, [
@@ -92,157 +73,157 @@ var _e = () => {
92
73
  X,
93
74
  G,
94
75
  K,
95
- y,
76
+ b,
96
77
  U,
97
78
  B,
98
- v
99
- ]), De = o(() => {
100
- q?.id && (Z ? (P(!0), M(!0)) : Q());
79
+ y
80
+ ]), Pe = i(() => {
81
+ q?.id && (Z ? (P(!0), N(!0)) : Q());
101
82
  }, [
102
83
  q?.id,
103
84
  Z,
104
85
  Q
105
- ]), $ = s(() => q ? z.find((e) => e.id !== q.id && e.isActive) : void 0, [q, z]), Oe = q ? q.isDefault ? $ ? p("billing.settings.archiveDefaultConfirm", "Archive {{accountName}}? {{replacementName}} will become the default account.", {
86
+ ]), $ = a(() => q ? z.find((e) => e.id !== q.id && e.isActive) : void 0, [q, z]), Fe = q ? q.isDefault ? $ ? p("billing.settings.archiveDefaultConfirm", "Archive {{accountName}}? {{replacementName}} will become the default account.", {
106
87
  accountName: q.name,
107
88
  replacementName: $.name
108
- }) : p("billing.settings.archiveDefaultNoReplacementConfirm", "Archive {{accountName}}? No replacement default account is available.", { accountName: q.name }) : p("billing.settings.archiveConfirm", "Archive {{accountName}}?", { accountName: q.name }) : "", ke = o(async () => {
89
+ }) : p("billing.settings.archiveDefaultNoReplacementConfirm", "Archive {{accountName}}? No replacement default account is available.", { accountName: q.name }) : p("billing.settings.archiveConfirm", "Archive {{accountName}}?", { accountName: q.name }) : "", Ie = i(async () => {
109
90
  if (q?.id && q.isActive) {
110
- E(!0), k(null), A(!1);
91
+ D(!0), j(null), M(!1);
111
92
  try {
112
- await r({
113
- apiGatewayUrl: h,
114
- authToken: g,
115
- orgId: _,
116
- query: i,
93
+ await oe({
94
+ apiGatewayUrl: g,
95
+ authToken: _,
96
+ orgId: v,
97
+ query: ce,
117
98
  variables: {
118
99
  id: q.id,
119
100
  reason: "Archived from billing settings",
120
101
  replacementDefaultBillingAccountId: q.isDefault ? $?.id ?? null : null
121
102
  }
122
- }), v("billing.billing_account.archived", {
103
+ }), y("billing.billing_account.archived", {
123
104
  route: "/billing/settings",
124
105
  entityId: q.id,
125
106
  source: "settings"
126
- }), await Promise.all([R(), B()]), b($?.id), A(!0), setTimeout(() => A(!1), 3e3);
107
+ }), await Promise.all([R(), B()]), x($?.id), M(!0), setTimeout(() => M(!1), 3e3);
127
108
  } catch (e) {
128
- k(e instanceof Error ? e.message : "Failed to archive billing account");
109
+ j(e instanceof Error ? e.message : "Failed to archive billing account");
129
110
  } finally {
130
- E(!1);
111
+ D(!1);
131
112
  }
132
113
  }
133
114
  }, [
134
- h,
135
115
  g,
116
+ _,
136
117
  q,
137
118
  $,
138
- _,
119
+ v,
139
120
  R,
140
121
  B,
141
- v
122
+ y
142
123
  ]);
143
- return m.canManageBillingAccount ? we && !q ? /* @__PURE__ */ d("div", {
124
+ return m.canManageBillingAccount ? je && !q ? /* @__PURE__ */ l("div", {
144
125
  className: "space-y-6 p-6",
145
- children: [/* @__PURE__ */ u("div", { className: "h-8 w-48 bg-bg-sunken animate-pulse rounded" }), /* @__PURE__ */ u("div", {
126
+ children: [/* @__PURE__ */ c("div", { className: "h-8 w-48 bg-bg-sunken animate-pulse rounded" }), /* @__PURE__ */ c("div", {
146
127
  className: "border border-border-subtle rounded-lg p-6 space-y-4",
147
128
  children: [
148
129
  1,
149
130
  2,
150
131
  3
151
- ].map((e) => /* @__PURE__ */ u("div", { className: "h-10 bg-bg-sunken animate-pulse rounded" }, e))
132
+ ].map((e) => /* @__PURE__ */ c("div", { className: "h-10 bg-bg-sunken animate-pulse rounded" }, e))
152
133
  })]
153
- }) : /* @__PURE__ */ d("div", {
134
+ }) : /* @__PURE__ */ l("div", {
154
135
  className: "space-y-6 p-6",
155
136
  children: [
156
- /* @__PURE__ */ u(ee, {
137
+ /* @__PURE__ */ c(re, {
157
138
  title: p("billing.settings.billingSettings", "Billing Settings"),
158
139
  description: p("billing.settings.description", "Manage your billing account configuration")
159
140
  }),
160
- /* @__PURE__ */ u(ge, { children: p("billing.settings.purpose", "Configure how a billing account behaves — its name and contact details, default currency, tax information and whether it's your default account. Changes here affect how invoices are generated and which account new purchases bill to.") }),
161
- z.length > 1 && /* @__PURE__ */ d("div", {
141
+ /* @__PURE__ */ c(d, { children: p("billing.settings.purpose", "Configure how a billing account behaves — its name and contact details, default currency, tax information and whether it's your default account. Changes here affect how invoices are generated and which account new purchases bill to.") }),
142
+ z.length > 1 && /* @__PURE__ */ l("div", {
162
143
  className: "relative",
163
- children: [/* @__PURE__ */ d("button", {
144
+ children: [/* @__PURE__ */ l("button", {
164
145
  type: "button",
165
- onClick: () => S(!x),
146
+ onClick: () => C(!S),
166
147
  className: "w-full sm:w-auto flex items-center justify-between gap-3 px-4 py-3 border border-border-subtle rounded-lg bg-bg-surface hover:bg-bg-sunken/50 transition-colors",
167
- children: [/* @__PURE__ */ d("div", {
148
+ children: [/* @__PURE__ */ l("div", {
168
149
  className: "flex items-center gap-3",
169
- children: [/* @__PURE__ */ u("div", {
150
+ children: [/* @__PURE__ */ c("div", {
170
151
  className: "size-8 rounded-lg bg-action-primary-bg/10 flex items-center justify-center",
171
- children: /* @__PURE__ */ u("svg", {
152
+ children: /* @__PURE__ */ c("svg", {
172
153
  className: "size-4 text-primary",
173
154
  fill: "none",
174
155
  viewBox: "0 0 24 24",
175
156
  stroke: "currentColor",
176
- children: /* @__PURE__ */ u("path", {
157
+ children: /* @__PURE__ */ c("path", {
177
158
  strokeLinecap: "round",
178
159
  strokeLinejoin: "round",
179
160
  strokeWidth: 2,
180
161
  d: "M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"
181
162
  })
182
163
  })
183
- }), /* @__PURE__ */ d("div", {
164
+ }), /* @__PURE__ */ l("div", {
184
165
  className: "text-left",
185
- children: [/* @__PURE__ */ u("p", {
166
+ children: [/* @__PURE__ */ c("p", {
186
167
  className: "text-sm font-medium text-text-primary",
187
168
  children: q?.name || p("billing.settings.selectAccount", "Select Account")
188
- }), /* @__PURE__ */ u("p", {
169
+ }), /* @__PURE__ */ c("p", {
189
170
  className: "text-xs text-text-secondary",
190
171
  children: q?.email
191
172
  })]
192
173
  })]
193
- }), /* @__PURE__ */ u("svg", {
194
- className: `size-4 text-text-secondary transition-transform ${x ? "rotate-180" : ""}`,
174
+ }), /* @__PURE__ */ c("svg", {
175
+ className: `size-4 text-text-secondary transition-transform ${S ? "rotate-180" : ""}`,
195
176
  fill: "none",
196
177
  viewBox: "0 0 24 24",
197
178
  stroke: "currentColor",
198
- children: /* @__PURE__ */ u("path", {
179
+ children: /* @__PURE__ */ c("path", {
199
180
  strokeLinecap: "round",
200
181
  strokeLinejoin: "round",
201
182
  strokeWidth: 2,
202
183
  d: "M19 9l-7 7-7-7"
203
184
  })
204
185
  })]
205
- }), x && /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("div", {
186
+ }), S && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("div", {
206
187
  className: "fixed inset-0 z-10",
207
- onClick: () => S(!1)
208
- }), /* @__PURE__ */ u("div", {
188
+ onClick: () => C(!1)
189
+ }), /* @__PURE__ */ c("div", {
209
190
  className: "absolute top-full left-0 right-0 sm:right-auto mt-1 w-full sm:w-80 bg-popover border border-border-subtle rounded-lg shadow-lg z-20 py-1 max-h-60 overflow-y-auto",
210
- children: z.map((e) => /* @__PURE__ */ d("button", {
191
+ children: z.map((e) => /* @__PURE__ */ l("button", {
211
192
  type: "button",
212
- onClick: () => Te(e),
193
+ onClick: () => Me(e),
213
194
  className: "w-full flex items-center justify-between gap-3 px-4 py-3 hover:bg-bg-sunken transition-colors",
214
- children: [/* @__PURE__ */ d("div", {
195
+ children: [/* @__PURE__ */ l("div", {
215
196
  className: "flex items-center gap-3 min-w-0",
216
- children: [/* @__PURE__ */ u("div", {
197
+ children: [/* @__PURE__ */ c("div", {
217
198
  className: "size-8 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0",
218
- children: /* @__PURE__ */ u("svg", {
199
+ children: /* @__PURE__ */ c("svg", {
219
200
  className: "size-4 text-text-secondary",
220
201
  fill: "none",
221
202
  viewBox: "0 0 24 24",
222
203
  stroke: "currentColor",
223
- children: /* @__PURE__ */ u("path", {
204
+ children: /* @__PURE__ */ c("path", {
224
205
  strokeLinecap: "round",
225
206
  strokeLinejoin: "round",
226
207
  strokeWidth: 2,
227
208
  d: "M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"
228
209
  })
229
210
  })
230
- }), /* @__PURE__ */ d("div", {
211
+ }), /* @__PURE__ */ l("div", {
231
212
  className: "text-left min-w-0",
232
- children: [/* @__PURE__ */ u("p", {
213
+ children: [/* @__PURE__ */ c("p", {
233
214
  className: "text-sm font-medium text-text-primary truncate",
234
215
  children: e.name
235
- }), /* @__PURE__ */ u("p", {
216
+ }), /* @__PURE__ */ c("p", {
236
217
  className: "text-xs text-text-secondary truncate",
237
218
  children: e.email
238
219
  })]
239
220
  })]
240
- }), q?.id === e.id && /* @__PURE__ */ u("svg", {
221
+ }), q?.id === e.id && /* @__PURE__ */ c("svg", {
241
222
  className: "size-4 text-primary flex-shrink-0",
242
223
  fill: "none",
243
224
  viewBox: "0 0 24 24",
244
225
  stroke: "currentColor",
245
- children: /* @__PURE__ */ u("path", {
226
+ children: /* @__PURE__ */ c("path", {
246
227
  strokeLinecap: "round",
247
228
  strokeLinejoin: "round",
248
229
  strokeWidth: 2,
@@ -252,25 +233,25 @@ var _e = () => {
252
233
  }, e.id))
253
234
  })] })]
254
235
  }),
255
- /* @__PURE__ */ d("div", {
236
+ /* @__PURE__ */ l("div", {
256
237
  className: "border border-border-subtle rounded-lg bg-bg-surface",
257
- children: [/* @__PURE__ */ u("div", {
238
+ children: [/* @__PURE__ */ c("div", {
258
239
  className: "p-6 border-b border-border-subtle",
259
- children: /* @__PURE__ */ d("div", {
240
+ children: /* @__PURE__ */ l("div", {
260
241
  className: "flex items-center justify-between",
261
- children: [/* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("h2", {
242
+ children: [/* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("h2", {
262
243
  className: "text-lg font-semibold text-text-primary",
263
244
  children: p("billing.settings.accountInfo", "Account Information")
264
- }), /* @__PURE__ */ u("p", {
245
+ }), /* @__PURE__ */ c("p", {
265
246
  className: "text-sm text-text-secondary mt-1",
266
247
  children: p("billing.settings.accountInfoDescription", "Update your billing contact details and tax information")
267
- })] }), q?.isDefault && /* @__PURE__ */ d("span", {
248
+ })] }), q?.isDefault && /* @__PURE__ */ l("span", {
268
249
  className: "inline-flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium bg-action-primary-bg/10 text-primary rounded-full",
269
- children: [/* @__PURE__ */ u("svg", {
250
+ children: [/* @__PURE__ */ c("svg", {
270
251
  className: "size-3",
271
252
  fill: "currentColor",
272
253
  viewBox: "0 0 20 20",
273
- children: /* @__PURE__ */ u("path", {
254
+ children: /* @__PURE__ */ c("path", {
274
255
  fillRule: "evenodd",
275
256
  d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
276
257
  clipRule: "evenodd"
@@ -278,23 +259,23 @@ var _e = () => {
278
259
  }), p("billing.settings.defaultAccount", "Default Account")]
279
260
  })]
280
261
  })
281
- }), /* @__PURE__ */ d("div", {
262
+ }), /* @__PURE__ */ l("div", {
282
263
  className: "p-6 space-y-6",
283
264
  children: [
284
- q && /* @__PURE__ */ d("div", {
265
+ q && /* @__PURE__ */ l("div", {
285
266
  className: "grid grid-cols-2 sm:grid-cols-4 gap-4 text-sm pb-4 border-b border-border-subtle",
286
267
  children: [
287
- /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("p", {
268
+ /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("p", {
288
269
  className: "text-text-secondary",
289
270
  children: p("billing.settings.status", "Status")
290
- }), /* @__PURE__ */ u("p", {
271
+ }), /* @__PURE__ */ c("p", {
291
272
  className: `font-medium ${q.isActive ? "text-status-success-text" : "text-status-error-text"}`,
292
273
  children: q.isActive ? p("billing.settings.active", "Active") : p("billing.settings.inactive", "Inactive")
293
274
  })] }),
294
- /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("p", {
275
+ /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("p", {
295
276
  className: "text-text-secondary",
296
277
  children: p("billing.settings.creditBalance", "Credit Balance")
297
- }), /* @__PURE__ */ d("p", {
278
+ }), /* @__PURE__ */ l("p", {
298
279
  className: "font-medium text-text-primary",
299
280
  children: [
300
281
  (q.creditAmount || 0).toLocaleString(),
@@ -302,57 +283,57 @@ var _e = () => {
302
283
  p("billing.common.credits", "Credits")
303
284
  ]
304
285
  })] }),
305
- /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("p", {
286
+ /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("p", {
306
287
  className: "text-text-secondary",
307
288
  children: p("billing.settings.accountId", "Account ID")
308
- }), /* @__PURE__ */ u("p", {
289
+ }), /* @__PURE__ */ c("p", {
309
290
  className: "font-mono text-xs text-text-primary truncate",
310
291
  title: q.id,
311
292
  children: q.id
312
293
  })] }),
313
- /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("p", {
294
+ /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("p", {
314
295
  className: "text-text-secondary",
315
296
  children: p("billing.settings.created", "Created")
316
- }), /* @__PURE__ */ u("p", {
297
+ }), /* @__PURE__ */ c("p", {
317
298
  className: "font-medium text-text-primary",
318
299
  children: q.createdAt ? new Date(q.createdAt).toLocaleDateString() : p("billing.settings.notAvailable", "N/A")
319
300
  })] })
320
301
  ]
321
302
  }),
322
- /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("h3", {
303
+ /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("h3", {
323
304
  className: "text-sm font-medium text-text-primary mb-4",
324
305
  children: p("billing.settings.contactDetails", "Contact Details")
325
- }), /* @__PURE__ */ d("div", {
306
+ }), /* @__PURE__ */ l("div", {
326
307
  className: "grid grid-cols-1 sm:grid-cols-2 gap-4",
327
- children: [/* @__PURE__ */ d("div", { children: [/* @__PURE__ */ d("label", {
308
+ children: [/* @__PURE__ */ l("div", { children: [/* @__PURE__ */ l("label", {
328
309
  htmlFor: "billing-account-name",
329
310
  className: "block text-sm font-medium text-text-primary mb-1",
330
311
  children: [
331
312
  p("billing.settings.accountName", "Account Name"),
332
313
  " ",
333
- /* @__PURE__ */ u("span", {
314
+ /* @__PURE__ */ c("span", {
334
315
  className: "text-status-error-text",
335
316
  children: "*"
336
317
  })
337
318
  ]
338
- }), /* @__PURE__ */ u("input", {
319
+ }), /* @__PURE__ */ c("input", {
339
320
  id: "billing-account-name",
340
321
  type: "text",
341
322
  value: F.name,
342
323
  onChange: (e) => J("name", e.target.value),
343
324
  className: "w-full px-3 py-2 text-sm border border-border-subtle rounded-md bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
344
- })] }), /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ d("label", {
325
+ })] }), /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ l("label", {
345
326
  htmlFor: "billing-account-email",
346
327
  className: "block text-sm font-medium text-text-primary mb-1",
347
328
  children: [
348
329
  p("billing.settings.email", "Email"),
349
330
  " ",
350
- /* @__PURE__ */ u("span", {
331
+ /* @__PURE__ */ c("span", {
351
332
  className: "text-status-error-text",
352
333
  children: "*"
353
334
  })
354
335
  ]
355
- }), /* @__PURE__ */ u("input", {
336
+ }), /* @__PURE__ */ c("input", {
356
337
  id: "billing-account-email",
357
338
  type: "email",
358
339
  value: F.email,
@@ -360,19 +341,23 @@ var _e = () => {
360
341
  className: "w-full px-3 py-2 text-sm border border-border-subtle rounded-md bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
361
342
  })] })]
362
343
  })] }),
363
- /* @__PURE__ */ u(he, {
344
+ /* @__PURE__ */ c(u, {
345
+ ...h ? {
346
+ storageKey: "billing.settings.account",
347
+ label: p("billing.settings.moreOptions", "More options")
348
+ } : {},
364
349
  title: p("billing.settings.advancedTitle", "Advanced settings"),
365
350
  description: p("billing.settings.advancedDescription", "Billing email override, currency, and tax identification."),
366
- children: /* @__PURE__ */ d("div", {
351
+ children: /* @__PURE__ */ l("div", {
367
352
  className: "grid grid-cols-1 sm:grid-cols-2 gap-4",
368
353
  children: [
369
- /* @__PURE__ */ d("div", { children: [
370
- /* @__PURE__ */ u("label", {
354
+ /* @__PURE__ */ l("div", { children: [
355
+ /* @__PURE__ */ c("label", {
371
356
  htmlFor: "billing-account-billing-email",
372
357
  className: "block text-sm font-medium text-text-primary mb-1",
373
358
  children: p("billing.settings.billingEmail", "Billing Email")
374
359
  }),
375
- /* @__PURE__ */ u("input", {
360
+ /* @__PURE__ */ c("input", {
376
361
  id: "billing-account-billing-email",
377
362
  type: "email",
378
363
  value: F.billingEmail,
@@ -380,48 +365,48 @@ var _e = () => {
380
365
  placeholder: p("billing.settings.billingEmailPlaceholder", "Optional - defaults to account email"),
381
366
  className: "w-full px-3 py-2 text-sm border border-border-subtle rounded-md bg-bg-surface text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
382
367
  }),
383
- /* @__PURE__ */ u("p", {
368
+ /* @__PURE__ */ c("p", {
384
369
  className: "text-xs text-text-secondary mt-1",
385
370
  children: p("billing.settings.billingEmailHelp", "Invoices will be sent to this email if provided")
386
371
  })
387
372
  ] }),
388
- /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("label", {
373
+ /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("label", {
389
374
  htmlFor: "billing-account-currency",
390
375
  className: "block text-sm font-medium text-text-primary mb-1",
391
376
  children: p("billing.settings.currency", "Currency")
392
- }), /* @__PURE__ */ d("select", {
377
+ }), /* @__PURE__ */ l("select", {
393
378
  id: "billing-account-currency",
394
379
  value: F.currency,
395
380
  onChange: (e) => J("currency", e.target.value),
396
381
  className: "w-full px-3 py-2 text-sm border border-border-subtle rounded-md bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary",
397
382
  children: [
398
- /* @__PURE__ */ u("option", {
383
+ /* @__PURE__ */ c("option", {
399
384
  value: "USD",
400
385
  children: "USD - US Dollar"
401
386
  }),
402
- /* @__PURE__ */ u("option", {
387
+ /* @__PURE__ */ c("option", {
403
388
  value: "EUR",
404
389
  children: "EUR - Euro"
405
390
  }),
406
- /* @__PURE__ */ u("option", {
391
+ /* @__PURE__ */ c("option", {
407
392
  value: "GBP",
408
393
  children: "GBP - British Pound"
409
394
  }),
410
- /* @__PURE__ */ u("option", {
395
+ /* @__PURE__ */ c("option", {
411
396
  value: "INR",
412
397
  children: "INR - Indian Rupee"
413
398
  })
414
399
  ]
415
400
  })] }),
416
- /* @__PURE__ */ d("div", {
401
+ /* @__PURE__ */ l("div", {
417
402
  className: "sm:col-span-2 max-w-md",
418
403
  children: [
419
- /* @__PURE__ */ u("label", {
404
+ /* @__PURE__ */ c("label", {
420
405
  htmlFor: "billing-account-tax-id",
421
406
  className: "block text-sm font-medium text-text-primary mb-1",
422
407
  children: p("billing.settings.taxId", "Tax ID / VAT Number")
423
408
  }),
424
- /* @__PURE__ */ u("input", {
409
+ /* @__PURE__ */ c("input", {
425
410
  id: "billing-account-tax-id",
426
411
  type: "text",
427
412
  value: F.taxId,
@@ -429,7 +414,7 @@ var _e = () => {
429
414
  placeholder: p("billing.settings.taxIdPlaceholder", "Enter your tax identification number"),
430
415
  className: "w-full px-3 py-2 text-sm border border-border-subtle rounded-md bg-bg-surface text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
431
416
  }),
432
- /* @__PURE__ */ u("p", {
417
+ /* @__PURE__ */ c("p", {
433
418
  className: "text-xs text-text-secondary mt-1",
434
419
  children: p("billing.settings.taxIdHelp", "Used for invoices and tax compliance (e.g., GST, VAT number)")
435
420
  })
@@ -438,13 +423,13 @@ var _e = () => {
438
423
  ]
439
424
  })
440
425
  }),
441
- q?.isActive && z.length > 1 && /* @__PURE__ */ u("div", {
426
+ q?.isActive && z.length > 1 && /* @__PURE__ */ c("div", {
442
427
  className: "pt-4 border-t border-border-subtle",
443
- children: /* @__PURE__ */ d("div", {
428
+ children: /* @__PURE__ */ l("div", {
444
429
  className: "flex items-start gap-3",
445
- children: [/* @__PURE__ */ u("div", {
430
+ children: [/* @__PURE__ */ c("div", {
446
431
  className: "flex items-center h-6",
447
- children: /* @__PURE__ */ u("input", {
432
+ children: /* @__PURE__ */ c("input", {
448
433
  type: "checkbox",
449
434
  id: "isDefault",
450
435
  checked: F.isDefault,
@@ -455,188 +440,191 @@ var _e = () => {
455
440
  disabled: q?.isDefault,
456
441
  className: "size-4 rounded border-border-subtle text-primary focus:ring-primary focus:ring-offset-0 disabled:opacity-50 disabled:cursor-not-allowed"
457
442
  })
458
- }), /* @__PURE__ */ d("div", {
443
+ }), /* @__PURE__ */ l("div", {
459
444
  className: "flex-1",
460
- children: [/* @__PURE__ */ u("label", {
445
+ children: [/* @__PURE__ */ c("label", {
461
446
  htmlFor: "isDefault",
462
447
  className: "text-sm font-medium text-text-primary cursor-pointer",
463
448
  children: p("billing.settings.setDefault", "Set as default billing account")
464
- }), /* @__PURE__ */ u("p", {
449
+ }), /* @__PURE__ */ c("p", {
465
450
  className: "text-xs text-text-secondary mt-0.5",
466
451
  children: q?.isDefault ? p("billing.settings.currentDefaultDescription", "This is currently your default billing account") : p("billing.settings.makePrimaryDescription", "Make this your primary billing account for new subscriptions")
467
452
  })]
468
453
  })]
469
454
  })
470
455
  }),
471
- /* @__PURE__ */ d("div", {
456
+ /* @__PURE__ */ l("div", {
472
457
  className: "pt-4 border-t border-border-subtle flex items-center justify-between",
473
- children: [/* @__PURE__ */ d("div", {
458
+ children: [/* @__PURE__ */ l("div", {
474
459
  className: "flex items-center gap-2",
475
- children: [ye && /* @__PURE__ */ d("div", {
460
+ children: [we && /* @__PURE__ */ l("div", {
476
461
  className: "flex items-center gap-2 text-sm text-status-success-text",
477
- children: [/* @__PURE__ */ u("svg", {
462
+ children: [/* @__PURE__ */ c("svg", {
478
463
  className: "size-4",
479
464
  fill: "none",
480
465
  viewBox: "0 0 24 24",
481
466
  stroke: "currentColor",
482
- children: /* @__PURE__ */ u("path", {
467
+ children: /* @__PURE__ */ c("path", {
483
468
  strokeLinecap: "round",
484
469
  strokeLinejoin: "round",
485
470
  strokeWidth: 2,
486
471
  d: "M5 13l4 4L19 7"
487
472
  })
488
473
  }), p("billing.settings.saveSuccess", "Changes saved successfully")]
489
- }), O && /* @__PURE__ */ d("div", {
474
+ }), A && /* @__PURE__ */ l("div", {
490
475
  className: "flex items-center gap-2 text-sm text-status-error-text",
491
- children: [/* @__PURE__ */ u("svg", {
476
+ children: [/* @__PURE__ */ c("svg", {
492
477
  className: "size-4",
493
478
  fill: "none",
494
479
  viewBox: "0 0 24 24",
495
480
  stroke: "currentColor",
496
- children: /* @__PURE__ */ u("path", {
481
+ children: /* @__PURE__ */ c("path", {
497
482
  strokeLinecap: "round",
498
483
  strokeLinejoin: "round",
499
484
  strokeWidth: 2,
500
485
  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"
501
486
  })
502
- }), O]
487
+ }), A]
503
488
  })]
504
- }), /* @__PURE__ */ d("div", {
489
+ }), /* @__PURE__ */ l("div", {
505
490
  className: "flex items-center gap-3",
506
- children: [m.canArchiveBillingAccount && q?.isActive ? /* @__PURE__ */ u("button", {
491
+ children: [m.canArchiveBillingAccount && q?.isActive ? /* @__PURE__ */ c("button", {
507
492
  type: "button",
508
- onClick: () => D(!0),
509
- disabled: C || T,
493
+ onClick: () => k(!0),
494
+ disabled: w || E,
510
495
  className: "px-4 py-2 text-sm font-medium border border-border-subtle text-status-error-text rounded-md hover:bg-status-error-bg-subtle disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
511
- children: T ? p("billing.settings.archiving", "Archiving...") : p("billing.settings.archiveAccount", "Archive Account")
512
- }) : null, /* @__PURE__ */ d("button", {
496
+ children: E ? p("billing.settings.archiving", "Archiving...") : p("billing.settings.archiveAccount", "Archive Account")
497
+ }) : null, /* @__PURE__ */ l("button", {
513
498
  type: "button",
514
- onClick: De,
515
- disabled: !Ee || C || T || !F.name || !F.email,
499
+ onClick: Pe,
500
+ disabled: !Ne || w || E || !F.name || !F.email,
516
501
  className: "px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-md hover:bg-action-primary-bg/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-2",
517
- children: [C && /* @__PURE__ */ d("svg", {
502
+ children: [w && /* @__PURE__ */ l("svg", {
518
503
  className: "size-4 animate-spin",
519
504
  fill: "none",
520
505
  viewBox: "0 0 24 24",
521
- children: [/* @__PURE__ */ u("circle", {
506
+ children: [/* @__PURE__ */ c("circle", {
522
507
  className: "opacity-25",
523
508
  cx: "12",
524
509
  cy: "12",
525
510
  r: "10",
526
511
  stroke: "currentColor",
527
512
  strokeWidth: "4"
528
- }), /* @__PURE__ */ u("path", {
513
+ }), /* @__PURE__ */ c("path", {
529
514
  className: "opacity-75",
530
515
  fill: "currentColor",
531
516
  d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
532
517
  })]
533
- }), C ? p("billing.common.saving", "Saving...") : p("billing.common.saveChanges", "Save Changes")]
518
+ }), w ? p("billing.common.saving", "Saving...") : p("billing.common.saveChanges", "Save Changes")]
534
519
  })]
535
520
  })]
536
521
  })
537
522
  ]
538
523
  })]
539
524
  }),
540
- j && N && /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("div", {
525
+ Te && Ee && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("div", {
541
526
  className: "fixed inset-0 bg-overlay-scrim z-40",
542
527
  onClick: () => {
543
- C || (M(!1), P(!1), I((e) => ({
528
+ w || (N(!1), P(!1), I((e) => ({
544
529
  ...e,
545
530
  isDefault: q?.isDefault || !1
546
531
  })));
547
532
  }
548
- }), /* @__PURE__ */ u("div", {
533
+ }), /* @__PURE__ */ c("div", {
549
534
  className: "fixed inset-0 flex items-center justify-center z-50 p-4",
550
- children: /* @__PURE__ */ d("div", {
535
+ children: /* @__PURE__ */ l("div", {
551
536
  className: "bg-bg-surface border border-border-subtle rounded-lg shadow-xl max-w-md w-full p-6",
552
537
  children: [
553
- /* @__PURE__ */ u("h3", {
538
+ /* @__PURE__ */ c("h3", {
554
539
  className: "text-lg font-semibold text-text-primary mb-2",
555
540
  children: p("billing.settings.confirmDefaultTitle", "Confirm Default Account Change")
556
541
  }),
557
- /* @__PURE__ */ u("p", {
542
+ /* @__PURE__ */ c("p", {
558
543
  className: "text-sm text-text-secondary mb-4",
559
544
  children: p("billing.settings.confirmDefaultDescription", "You are about to set {{accountName}} as your default billing account and save your changes.", { accountName: q?.name ?? "" })
560
545
  }),
561
- Y && Y.id !== q?.id && /* @__PURE__ */ u("div", {
546
+ Y && Y.id !== q?.id && /* @__PURE__ */ c("div", {
562
547
  className: "mb-4 p-3 bg-status-warning-bg-subtle border border-border-subtle rounded-md",
563
- children: /* @__PURE__ */ d("div", {
548
+ children: /* @__PURE__ */ l("div", {
564
549
  className: "flex items-start gap-2",
565
- children: [/* @__PURE__ */ u("svg", {
550
+ children: [/* @__PURE__ */ c("svg", {
566
551
  className: "size-5 text-status-warning-text flex-shrink-0 mt-0.5",
567
552
  fill: "none",
568
553
  viewBox: "0 0 24 24",
569
554
  stroke: "currentColor",
570
- children: /* @__PURE__ */ u("path", {
555
+ children: /* @__PURE__ */ c("path", {
571
556
  strokeLinecap: "round",
572
557
  strokeLinejoin: "round",
573
558
  strokeWidth: 2,
574
559
  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"
575
560
  })
576
- }), /* @__PURE__ */ d("div", {
561
+ }), /* @__PURE__ */ l("div", {
577
562
  className: "text-sm",
578
- children: [/* @__PURE__ */ u("p", {
563
+ children: [/* @__PURE__ */ c("p", {
579
564
  className: "font-medium text-status-warning-text",
580
565
  children: p("billing.settings.currentDefaultWillChange", "Current default will change")
581
- }), /* @__PURE__ */ u("p", {
566
+ }), /* @__PURE__ */ c("p", {
582
567
  className: "text-status-warning-text mt-0.5",
583
568
  children: p("billing.settings.currentDefaultWillChangeDescription", "{{accountName}} will no longer be the default account.", { accountName: Y.name })
584
569
  })]
585
570
  })]
586
571
  })
587
572
  }),
588
- /* @__PURE__ */ d("div", {
573
+ /* @__PURE__ */ l("div", {
589
574
  className: "flex justify-end gap-3",
590
- children: [/* @__PURE__ */ u("button", {
575
+ children: [/* @__PURE__ */ c("button", {
591
576
  type: "button",
592
577
  onClick: () => {
593
- M(!1), P(!1), I((e) => ({
578
+ N(!1), P(!1), I((e) => ({
594
579
  ...e,
595
580
  isDefault: q?.isDefault || !1
596
581
  }));
597
582
  },
598
- disabled: C,
583
+ disabled: w,
599
584
  className: "px-4 py-2 text-sm font-medium text-text-primary border border-border-subtle rounded-md hover:bg-bg-sunken transition-colors disabled:opacity-50",
600
585
  children: p("billing.common.cancel", "Cancel")
601
- }), /* @__PURE__ */ d("button", {
586
+ }), /* @__PURE__ */ l("button", {
602
587
  type: "button",
603
588
  onClick: Q,
604
- disabled: C,
589
+ disabled: w,
605
590
  className: "px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-md hover:bg-action-primary-bg/90 disabled:opacity-50 transition-colors flex items-center gap-2",
606
- children: [C && /* @__PURE__ */ d("svg", {
591
+ children: [w && /* @__PURE__ */ l("svg", {
607
592
  className: "size-4 animate-spin",
608
593
  fill: "none",
609
594
  viewBox: "0 0 24 24",
610
- children: [/* @__PURE__ */ u("circle", {
595
+ children: [/* @__PURE__ */ c("circle", {
611
596
  className: "opacity-25",
612
597
  cx: "12",
613
598
  cy: "12",
614
599
  r: "10",
615
600
  stroke: "currentColor",
616
601
  strokeWidth: "4"
617
- }), /* @__PURE__ */ u("path", {
602
+ }), /* @__PURE__ */ c("path", {
618
603
  className: "opacity-75",
619
604
  fill: "currentColor",
620
605
  d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
621
606
  })]
622
- }), C ? p("billing.common.saving", "Saving...") : p("billing.common.saveChanges", "Save Changes")]
607
+ }), w ? p("billing.common.saving", "Saving...") : p("billing.common.saveChanges", "Save Changes")]
623
608
  })]
624
609
  })
625
610
  ]
626
611
  })
627
612
  })] }),
628
- /* @__PURE__ */ u(ce, {
629
- open: ve,
630
- onOpenChange: D,
631
- children: /* @__PURE__ */ d(de, { children: [/* @__PURE__ */ d(me, { children: [/* @__PURE__ */ u(f, { children: p("billing.settings.archiveDialogTitle", "Archive billing account?") }), /* @__PURE__ */ u(fe, { children: Oe })] }), /* @__PURE__ */ d(pe, { children: [/* @__PURE__ */ u(ue, { children: p("billing.common.cancel", "Cancel") }), /* @__PURE__ */ u(le, {
613
+ /* @__PURE__ */ c(ge, {
614
+ open: O,
615
+ onOpenChange: k,
616
+ children: /* @__PURE__ */ l(ye, { children: [/* @__PURE__ */ l(Se, { children: [/* @__PURE__ */ c(Ce, { children: p("billing.settings.archiveDialogTitle", "Archive billing account?") }), /* @__PURE__ */ c(be, { children: Fe })] }), /* @__PURE__ */ l(xe, { children: [/* @__PURE__ */ c(ve, { children: p("billing.common.cancel", "Cancel") }), /* @__PURE__ */ c(_e, {
632
617
  onClick: () => {
633
- D(!1), ke();
618
+ k(!1), Ie();
634
619
  },
635
620
  children: p("billing.settings.archiveAccount", "Archive Account")
636
621
  })] })] })
637
622
  })
638
623
  ]
639
- }) : /* @__PURE__ */ u(n, { message: p("billing.settings.noManagePermission", "You don't have permission to manage billing settings.") });
624
+ }) : h ? /* @__PURE__ */ c(he, {
625
+ message: p("billing.settings.needAccess", "You need access to billing settings"),
626
+ granterHint: p("billing.settings.needAccessHint", "Ask a billing admin of this organization to give you access.")
627
+ }) : /* @__PURE__ */ c(ne, { message: p("billing.settings.noManagePermission", "You don't have permission to manage billing settings.") });
640
628
  };
641
629
  export { p as SettingsPage };
642
630
 
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsPage.js","names":["_Fragment","Fragment$1","getInitialBillingAccountId","SettingsPage","tr","useTr","permissions","useBillingPermissions","useBilling","useBillingEventEmitter","selectedBillingAccountId","setSelectedBillingAccountId","useState","isAccountSelectorOpen","setIsAccountSelectorOpen","isSaving","setIsSaving","isArchiving","setIsArchiving","isArchiveConfirmOpen","setIsArchiveConfirmOpen","saveError","setSaveError","saveSuccess","setSaveSuccess","isSetDefaultModalOpen","setIsSetDefaultModalOpen","pendingSave","setPendingSave","formData","setFormData","accountsData","isLoadingAccounts","refetchAccounts","useGetBillingAccountsSettingsQuery","billingAccounts","useMemo","defaultData","isLoadingDefault","refetchDefault","useGetDefaultBillingAccountSettingsQuery","defaultBillingAccount","selectedData","isLoadingSelected","refetchSelected","useGetBillingAccountSettingsQuery","selectedAccountData","updateBillingAccountMutation","useUpdateBillingAccountSettingsMutation","setDefaultBillingAccountMutation","useSetDefaultBillingAccountSettingsMutation","billingAccount","fromList","a","isLoading","handleSelectAccount","account","handleInputChange","prev","field","value","currentDefaultAccount","hasChanges","isChangingDefault","needsDefaultConfirmation","performSave","useCallback","emit","error","handleSave","replacementDefaultAccount","archiveConfirmMessage","handleArchiveAccount","directBillingGraphqlRequest","ArchiveBillingAccountSettingsDocument","apiGatewayUrl","authToken","orgId","i","PageHeader","PagePurpose","OptionalFields","AlertDialog","AlertDialogContent","AlertDialogHeader","AlertDialogTitle","AlertDialogDescription","AlertDialogFooter","AlertDialogCancel","AlertDialogAction","AccessDenied"],"sources":["../../../../../src/billing/modules/settings/pages/SettingsPage.tsx"],"sourcesContent":["/**\n * Settings Module - Settings Page\n * Billing account settings and configuration\n */\n\nimport { useState, useMemo, useEffect, useCallback, type FC } from 'react';\nimport { useBillingEventEmitter } from '../../../hooks/useBillingEventEmitter';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { AccessDenied, PageHeader } from '../../../shared/components';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n OptionalFields,\n PagePurpose,\n} from '@burdenoff/fe-libs/ui';\nimport { directBillingGraphqlRequest } from '../../../shared/utils';\nimport {\n useGetBillingAccountSettingsQuery,\n useGetBillingAccountsSettingsQuery,\n useGetDefaultBillingAccountSettingsQuery,\n useUpdateBillingAccountSettingsMutation,\n useSetDefaultBillingAccountSettingsMutation,\n ArchiveBillingAccountSettingsDocument,\n} from '../../../../generated/global-operations';\nimport type { BillingAccount } from '../../../shared/types';\nimport { useTr } from '../../../shared/hooks/useTr';\n\n// Helper to get billing account ID from URL (for navigation from Overview page)\nconst getInitialBillingAccountId = (): string | undefined => {\n if (typeof window === 'undefined') return undefined;\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get('billingAccountId') || undefined;\n};\n\nexport const SettingsPage: FC = () => {\n const tr = useTr();\n const permissions = useBillingPermissions();\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n const { emit } = useBillingEventEmitter();\n\n // State - initialize with URL param if present\n const [selectedBillingAccountId, setSelectedBillingAccountId] = useState<string | undefined>(\n getInitialBillingAccountId\n );\n const [isAccountSelectorOpen, setIsAccountSelectorOpen] = useState(false);\n const [isSaving, setIsSaving] = useState(false);\n const [isArchiving, setIsArchiving] = useState(false);\n const [isArchiveConfirmOpen, setIsArchiveConfirmOpen] = useState(false);\n const [saveError, setSaveError] = useState<string | null>(null);\n const [saveSuccess, setSaveSuccess] = useState(false);\n\n // Set default confirmation modal state\n const [isSetDefaultModalOpen, setIsSetDefaultModalOpen] = useState(false);\n const [pendingSave, setPendingSave] = useState(false);\n\n // Form state - includes isDefault toggle\n const [formData, setFormData] = useState({\n name: '',\n email: '',\n billingEmail: '',\n currency: 'USD',\n taxId: '',\n isDefault: false,\n });\n\n // Fetch all billing accounts for the selector (lightweight query without subscriptions)\n const {\n data: accountsData,\n loading: isLoadingAccounts,\n refetch: refetchAccounts,\n } = useGetBillingAccountsSettingsQuery({});\n const billingAccounts = useMemo<BillingAccount[]>(\n () => accountsData?.getBillingAccountsByOrg || [],\n [accountsData?.getBillingAccountsByOrg]\n );\n\n // Fetch default billing account (without subscriptions)\n const {\n data: defaultData,\n loading: isLoadingDefault,\n refetch: refetchDefault,\n } = useGetDefaultBillingAccountSettingsQuery({});\n const defaultBillingAccount: BillingAccount | null =\n defaultData?.getDefaultBillingAccount || null;\n\n // Always fetch selected billing account if we have an ID from URL (without subscriptions)\n const {\n data: selectedData,\n loading: isLoadingSelected,\n refetch: refetchSelected,\n } = useGetBillingAccountSettingsQuery({\n variables: { id: selectedBillingAccountId! },\n skip: !selectedBillingAccountId,\n });\n const selectedAccountData: BillingAccount | null = selectedData?.getBillingAccount || null;\n\n // Mutation for updating billing account\n const [updateBillingAccountMutation] = useUpdateBillingAccountSettingsMutation();\n\n // Mutation for setting default billing account\n const [setDefaultBillingAccountMutation] = useSetDefaultBillingAccountSettingsMutation();\n\n // Determine which account to use - prioritize URL param\n const billingAccount = useMemo(() => {\n // If we have a selected account ID from URL\n if (selectedBillingAccountId) {\n // First try to use the fetched selected account data\n if (selectedAccountData) {\n return selectedAccountData;\n }\n // While loading, try to find from the accounts list\n const fromList = billingAccounts.find((a) => a.id === selectedBillingAccountId);\n if (fromList) {\n return fromList;\n }\n // If still loading and not in list, return null to show loading state\n if (isLoadingSelected) {\n return null;\n }\n }\n // No URL param - use default account\n return defaultBillingAccount;\n }, [\n selectedBillingAccountId,\n selectedAccountData,\n billingAccounts,\n isLoadingSelected,\n defaultBillingAccount,\n ]);\n\n const isLoading =\n isLoadingAccounts || isLoadingDefault || (selectedBillingAccountId && isLoadingSelected);\n\n // Update form when billing account changes\n useEffect(() => {\n if (billingAccount) {\n setFormData({\n name: billingAccount.name || '',\n email: billingAccount.email || '',\n billingEmail: billingAccount.billingEmail || '',\n currency: billingAccount.currency || 'USD',\n taxId: billingAccount.taxId || '',\n isDefault: billingAccount.isDefault || false,\n });\n }\n }, [billingAccount]);\n\n // Handle account selection\n const handleSelectAccount = (account: BillingAccount) => {\n setSelectedBillingAccountId(account.id);\n setIsAccountSelectorOpen(false);\n setSaveSuccess(false);\n setSaveError(null);\n };\n\n // Handle form input changes\n const handleInputChange = (field: keyof typeof formData, value: string) => {\n setFormData((prev) => ({ ...prev, [field]: value }));\n setSaveSuccess(false);\n setSaveError(null);\n };\n\n // Find the current default account\n const currentDefaultAccount = useMemo(() => {\n return billingAccounts.find((a) => a.isDefault) || null;\n }, [billingAccounts]);\n\n // Check if form has changes\n const hasChanges = useMemo(() => {\n if (!billingAccount) return false;\n return (\n formData.name !== (billingAccount.name || '') ||\n formData.email !== (billingAccount.email || '') ||\n formData.billingEmail !== (billingAccount.billingEmail || '') ||\n formData.currency !== (billingAccount.currency || 'USD') ||\n formData.taxId !== (billingAccount.taxId || '') ||\n formData.isDefault !== (billingAccount.isDefault || false)\n );\n }, [formData, billingAccount]);\n\n // Check if trying to change default status to another account\n const isChangingDefault = formData.isDefault && !billingAccount?.isDefault;\n const needsDefaultConfirmation =\n isChangingDefault && currentDefaultAccount && currentDefaultAccount.id !== billingAccount?.id;\n\n // Perform the actual save operation\n const performSave = useCallback(async () => {\n if (!billingAccount?.id) return;\n\n setIsSaving(true);\n setSaveError(null);\n setSaveSuccess(false);\n setIsSetDefaultModalOpen(false);\n setPendingSave(false);\n\n try {\n // Update billing account details\n await updateBillingAccountMutation({\n variables: {\n input: {\n id: billingAccount.id,\n name: formData.name,\n email: formData.email,\n billingEmail: formData.billingEmail || null,\n currency: formData.currency,\n taxId: formData.taxId || null,\n },\n },\n });\n emit('billing.billing_account.updated', {\n route: '/billing/settings',\n entityId: billingAccount.id,\n source: 'settings',\n });\n\n // If setting as default, call the separate mutation\n if (isChangingDefault) {\n await setDefaultBillingAccountMutation({\n variables: { id: billingAccount.id },\n refetchQueries: ['GetBillingAccountsByTenant', 'GetDefaultBillingAccount'],\n });\n emit('billing.billing_account.updated', {\n route: '/billing/settings',\n entityId: billingAccount.id,\n source: 'settings.default',\n });\n }\n\n // Refetch to update cache\n if (selectedBillingAccountId) {\n await refetchSelected();\n } else {\n await refetchDefault();\n }\n\n setSaveSuccess(true);\n // Clear success message after 3 seconds\n setTimeout(() => setSaveSuccess(false), 3000);\n } catch (error) {\n setSaveError(error instanceof Error ? error.message : 'Failed to save changes');\n } finally {\n setIsSaving(false);\n }\n }, [\n billingAccount?.id,\n formData,\n isChangingDefault,\n updateBillingAccountMutation,\n setDefaultBillingAccountMutation,\n selectedBillingAccountId,\n refetchSelected,\n refetchDefault,\n emit,\n ]);\n\n // Handle save button click\n const handleSave = useCallback(() => {\n if (!billingAccount?.id) return;\n\n // If changing default and there's an existing default, show confirmation\n if (needsDefaultConfirmation) {\n setPendingSave(true);\n setIsSetDefaultModalOpen(true);\n } else {\n performSave();\n }\n }, [billingAccount?.id, needsDefaultConfirmation, performSave]);\n\n const replacementDefaultAccount = useMemo(\n () =>\n billingAccount\n ? billingAccounts.find((account) => account.id !== billingAccount.id && account.isActive)\n : undefined,\n [billingAccount, billingAccounts]\n );\n\n const archiveConfirmMessage = billingAccount\n ? billingAccount.isDefault\n ? replacementDefaultAccount\n ? tr(\n 'billing.settings.archiveDefaultConfirm',\n 'Archive {{accountName}}? {{replacementName}} will become the default account.',\n { accountName: billingAccount.name, replacementName: replacementDefaultAccount.name }\n )\n : tr(\n 'billing.settings.archiveDefaultNoReplacementConfirm',\n 'Archive {{accountName}}? No replacement default account is available.',\n { accountName: billingAccount.name }\n )\n : tr('billing.settings.archiveConfirm', 'Archive {{accountName}}?', {\n accountName: billingAccount.name,\n })\n : '';\n\n const handleArchiveAccount = useCallback(async () => {\n if (!billingAccount?.id || !billingAccount.isActive) {\n return;\n }\n\n setIsArchiving(true);\n setSaveError(null);\n setSaveSuccess(false);\n\n try {\n await directBillingGraphqlRequest<\n { archiveBillingAccount: { id: string; isActive: boolean; isDefault: boolean } },\n { id: string; reason: string; replacementDefaultBillingAccountId: string | null }\n >({\n apiGatewayUrl,\n authToken,\n orgId,\n query: ArchiveBillingAccountSettingsDocument,\n variables: {\n id: billingAccount.id,\n reason: 'Archived from billing settings',\n replacementDefaultBillingAccountId: billingAccount.isDefault\n ? (replacementDefaultAccount?.id ?? null)\n : null,\n },\n });\n emit('billing.billing_account.archived', {\n route: '/billing/settings',\n entityId: billingAccount.id,\n source: 'settings',\n });\n\n await Promise.all([refetchAccounts(), refetchDefault()]);\n setSelectedBillingAccountId(replacementDefaultAccount?.id);\n setSaveSuccess(true);\n setTimeout(() => setSaveSuccess(false), 3000);\n } catch (error) {\n setSaveError(error instanceof Error ? error.message : 'Failed to archive billing account');\n } finally {\n setIsArchiving(false);\n }\n }, [\n apiGatewayUrl,\n authToken,\n billingAccount,\n replacementDefaultAccount,\n orgId,\n refetchAccounts,\n refetchDefault,\n emit,\n ]);\n\n if (!permissions.canManageBillingAccount) {\n return (\n <AccessDenied\n message={tr(\n 'billing.settings.noManagePermission',\n \"You don't have permission to manage billing settings.\"\n )}\n />\n );\n }\n\n if (isLoading && !billingAccount) {\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=\"border border-border-subtle rounded-lg p-6 space-y-4\">\n {[1, 2, 3].map((i) => (\n <div key={i} className=\"h-10 bg-bg-sunken animate-pulse rounded\" />\n ))}\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title={tr('billing.settings.billingSettings', 'Billing Settings')}\n description={tr(\n 'billing.settings.description',\n 'Manage your billing account configuration'\n )}\n />\n\n <PagePurpose>\n {tr(\n 'billing.settings.purpose',\n \"Configure how a billing account behaves — its name and contact details, default currency, tax information and whether it's your default account. Changes here affect how invoices are generated and which account new purchases bill to.\"\n )}\n </PagePurpose>\n\n {/* Account Selector (if multiple accounts) */}\n {billingAccounts.length > 1 && (\n <div className=\"relative\">\n <button\n type=\"button\"\n onClick={() => setIsAccountSelectorOpen(!isAccountSelectorOpen)}\n className=\"w-full sm:w-auto flex items-center justify-between gap-3 px-4 py-3 border border-border-subtle rounded-lg bg-bg-surface hover:bg-bg-sunken/50 transition-colors\"\n >\n <div className=\"flex items-center gap-3\">\n <div className=\"size-8 rounded-lg bg-action-primary-bg/10 flex items-center justify-center\">\n <svg\n className=\"size-4 text-primary\"\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=\"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4\"\n />\n </svg>\n </div>\n <div className=\"text-left\">\n <p className=\"text-sm font-medium text-text-primary\">\n {billingAccount?.name || tr('billing.settings.selectAccount', 'Select Account')}\n </p>\n <p className=\"text-xs text-text-secondary\">{billingAccount?.email}</p>\n </div>\n </div>\n <svg\n className={`size-4 text-text-secondary transition-transform ${isAccountSelectorOpen ? 'rotate-180' : ''}`}\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=\"M19 9l-7 7-7-7\"\n />\n </svg>\n </button>\n\n {isAccountSelectorOpen && (\n <>\n <div className=\"fixed inset-0 z-10\" onClick={() => setIsAccountSelectorOpen(false)} />\n <div className=\"absolute top-full left-0 right-0 sm:right-auto mt-1 w-full sm:w-80 bg-popover border border-border-subtle rounded-lg shadow-lg z-20 py-1 max-h-60 overflow-y-auto\">\n {billingAccounts.map((account) => (\n <button\n type=\"button\"\n key={account.id}\n onClick={() => handleSelectAccount(account)}\n className=\"w-full flex items-center justify-between gap-3 px-4 py-3 hover:bg-bg-sunken transition-colors\"\n >\n <div className=\"flex items-center gap-3 min-w-0\">\n <div className=\"size-8 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0\">\n <svg\n className=\"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=\"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4\"\n />\n </svg>\n </div>\n <div className=\"text-left min-w-0\">\n <p className=\"text-sm font-medium text-text-primary truncate\">\n {account.name}\n </p>\n <p className=\"text-xs text-text-secondary truncate\">{account.email}</p>\n </div>\n </div>\n {billingAccount?.id === account.id && (\n <svg\n className=\"size-4 text-primary flex-shrink-0\"\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=\"M5 13l4 4L19 7\"\n />\n </svg>\n )}\n </button>\n ))}\n </div>\n </>\n )}\n </div>\n )}\n\n {/* Account Settings */}\n <div className=\"border border-border-subtle rounded-lg bg-bg-surface\">\n <div className=\"p-6 border-b border-border-subtle\">\n <div className=\"flex items-center justify-between\">\n <div>\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {tr('billing.settings.accountInfo', 'Account Information')}\n </h2>\n <p className=\"text-sm text-text-secondary mt-1\">\n {tr(\n 'billing.settings.accountInfoDescription',\n 'Update your billing contact details and tax information'\n )}\n </p>\n </div>\n {billingAccount?.isDefault && (\n <span className=\"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium bg-action-primary-bg/10 text-primary rounded-full\">\n <svg className=\"size-3\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path\n fillRule=\"evenodd\"\n d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z\"\n clipRule=\"evenodd\"\n />\n </svg>\n {tr('billing.settings.defaultAccount', 'Default Account')}\n </span>\n )}\n </div>\n </div>\n <div className=\"p-6 space-y-6\">\n {/* Account Status Summary */}\n {billingAccount && (\n <div className=\"grid grid-cols-2 sm:grid-cols-4 gap-4 text-sm pb-4 border-b border-border-subtle\">\n <div>\n <p className=\"text-text-secondary\">{tr('billing.settings.status', 'Status')}</p>\n <p\n className={`font-medium ${billingAccount.isActive ? 'text-status-success-text' : 'text-status-error-text'}`}\n >\n {billingAccount.isActive\n ? tr('billing.settings.active', 'Active')\n : tr('billing.settings.inactive', 'Inactive')}\n </p>\n </div>\n <div>\n <p className=\"text-text-secondary\">\n {tr('billing.settings.creditBalance', 'Credit Balance')}\n </p>\n <p className=\"font-medium text-text-primary\">\n {(billingAccount.creditAmount || 0).toLocaleString()}{' '}\n {tr('billing.common.credits', 'Credits')}\n </p>\n </div>\n <div>\n <p className=\"text-text-secondary\">\n {tr('billing.settings.accountId', 'Account ID')}\n </p>\n <p\n className=\"font-mono text-xs text-text-primary truncate\"\n title={billingAccount.id}\n >\n {billingAccount.id}\n </p>\n </div>\n <div>\n <p className=\"text-text-secondary\">{tr('billing.settings.created', 'Created')}</p>\n <p className=\"font-medium text-text-primary\">\n {billingAccount.createdAt\n ? new Date(billingAccount.createdAt).toLocaleDateString()\n : tr('billing.settings.notAvailable', 'N/A')}\n </p>\n </div>\n </div>\n )}\n\n {/* Contact Details Section — Required fields above-the-fold */}\n <div>\n <h3 className=\"text-sm font-medium text-text-primary mb-4\">\n {tr('billing.settings.contactDetails', 'Contact Details')}\n </h3>\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-4\">\n <div>\n <label\n htmlFor=\"billing-account-name\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.settings.accountName', 'Account Name')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n id=\"billing-account-name\"\n type=\"text\"\n value={formData.name}\n onChange={(e) => handleInputChange('name', e.target.value)}\n className=\"w-full px-3 py-2 text-sm border border-border-subtle rounded-md bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent\"\n />\n </div>\n <div>\n <label\n htmlFor=\"billing-account-email\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.settings.email', 'Email')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n id=\"billing-account-email\"\n type=\"email\"\n value={formData.email}\n onChange={(e) => handleInputChange('email', e.target.value)}\n className=\"w-full px-3 py-2 text-sm border border-border-subtle rounded-md bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent\"\n />\n </div>\n </div>\n </div>\n\n {/* Advanced billing settings — currency / billing email / tax ID. Most accounts keep defaults. */}\n <OptionalFields\n title={tr('billing.settings.advancedTitle', 'Advanced settings')}\n description={tr(\n 'billing.settings.advancedDescription',\n 'Billing email override, currency, and tax identification.'\n )}\n >\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-4\">\n <div>\n <label\n htmlFor=\"billing-account-billing-email\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.settings.billingEmail', 'Billing Email')}\n </label>\n <input\n id=\"billing-account-billing-email\"\n type=\"email\"\n value={formData.billingEmail}\n onChange={(e) => handleInputChange('billingEmail', e.target.value)}\n placeholder={tr(\n 'billing.settings.billingEmailPlaceholder',\n 'Optional - defaults to account email'\n )}\n className=\"w-full px-3 py-2 text-sm border border-border-subtle rounded-md bg-bg-surface text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent\"\n />\n <p className=\"text-xs text-text-secondary mt-1\">\n {tr(\n 'billing.settings.billingEmailHelp',\n 'Invoices will be sent to this email if provided'\n )}\n </p>\n </div>\n <div>\n <label\n htmlFor=\"billing-account-currency\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.settings.currency', 'Currency')}\n </label>\n <select\n id=\"billing-account-currency\"\n value={formData.currency}\n onChange={(e) => handleInputChange('currency', e.target.value)}\n className=\"w-full px-3 py-2 text-sm border border-border-subtle rounded-md bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"USD\">USD - US Dollar</option>\n <option value=\"EUR\">EUR - Euro</option>\n <option value=\"GBP\">GBP - British Pound</option>\n <option value=\"INR\">INR - Indian Rupee</option>\n </select>\n </div>\n <div className=\"sm:col-span-2 max-w-md\">\n <label\n htmlFor=\"billing-account-tax-id\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.settings.taxId', 'Tax ID / VAT Number')}\n </label>\n <input\n id=\"billing-account-tax-id\"\n type=\"text\"\n value={formData.taxId}\n onChange={(e) => handleInputChange('taxId', e.target.value)}\n placeholder={tr(\n 'billing.settings.taxIdPlaceholder',\n 'Enter your tax identification number'\n )}\n className=\"w-full px-3 py-2 text-sm border border-border-subtle rounded-md bg-bg-surface text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent\"\n />\n <p className=\"text-xs text-text-secondary mt-1\">\n {tr(\n 'billing.settings.taxIdHelp',\n 'Used for invoices and tax compliance (e.g., GST, VAT number)'\n )}\n </p>\n </div>\n </div>\n </OptionalFields>\n\n {/* Default Account Setting */}\n {billingAccount?.isActive && billingAccounts.length > 1 && (\n <div className=\"pt-4 border-t border-border-subtle\">\n <div className=\"flex items-start gap-3\">\n <div className=\"flex items-center h-6\">\n <input\n type=\"checkbox\"\n id=\"isDefault\"\n checked={formData.isDefault}\n onChange={(e) =>\n setFormData((prev) => ({ ...prev, isDefault: e.target.checked }))\n }\n disabled={billingAccount?.isDefault}\n className=\"size-4 rounded border-border-subtle text-primary focus:ring-primary focus:ring-offset-0 disabled:opacity-50 disabled:cursor-not-allowed\"\n />\n </div>\n <div className=\"flex-1\">\n <label\n htmlFor=\"isDefault\"\n className=\"text-sm font-medium text-text-primary cursor-pointer\"\n >\n {tr('billing.settings.setDefault', 'Set as default billing account')}\n </label>\n <p className=\"text-xs text-text-secondary mt-0.5\">\n {billingAccount?.isDefault\n ? tr(\n 'billing.settings.currentDefaultDescription',\n 'This is currently your default billing account'\n )\n : tr(\n 'billing.settings.makePrimaryDescription',\n 'Make this your primary billing account for new subscriptions'\n )}\n </p>\n </div>\n </div>\n </div>\n )}\n\n {/* Save Button and Status */}\n <div className=\"pt-4 border-t border-border-subtle flex items-center justify-between\">\n <div className=\"flex items-center gap-2\">\n {saveSuccess && (\n <div className=\"flex items-center gap-2 text-sm text-status-success-text\">\n <svg className=\"size-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M5 13l4 4L19 7\"\n />\n </svg>\n {tr('billing.settings.saveSuccess', 'Changes saved successfully')}\n </div>\n )}\n {saveError && (\n <div className=\"flex items-center gap-2 text-sm text-status-error-text\">\n <svg className=\"size-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 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 {saveError}\n </div>\n )}\n </div>\n <div className=\"flex items-center gap-3\">\n {permissions.canArchiveBillingAccount && billingAccount?.isActive ? (\n <button\n type=\"button\"\n onClick={() => setIsArchiveConfirmOpen(true)}\n disabled={isSaving || isArchiving}\n className=\"px-4 py-2 text-sm font-medium border border-border-subtle text-status-error-text rounded-md hover:bg-status-error-bg-subtle disabled:opacity-50 disabled:cursor-not-allowed transition-colors\"\n >\n {isArchiving\n ? tr('billing.settings.archiving', 'Archiving...')\n : tr('billing.settings.archiveAccount', 'Archive Account')}\n </button>\n ) : null}\n <button\n type=\"button\"\n onClick={handleSave}\n disabled={\n !hasChanges || isSaving || isArchiving || !formData.name || !formData.email\n }\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-md hover:bg-action-primary-bg/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-2\"\n >\n {isSaving && (\n <svg className=\"size-4 animate-spin\" fill=\"none\" viewBox=\"0 0 24 24\">\n <circle\n className=\"opacity-25\"\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n />\n <path\n className=\"opacity-75\"\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n />\n </svg>\n )}\n {isSaving\n ? tr('billing.common.saving', 'Saving...')\n : tr('billing.common.saveChanges', 'Save Changes')}\n </button>\n </div>\n </div>\n </div>\n </div>\n\n {/* Set as Default Confirmation Modal */}\n {isSetDefaultModalOpen && pendingSave && (\n <>\n <div\n className=\"fixed inset-0 bg-overlay-scrim z-40\"\n onClick={() => {\n if (!isSaving) {\n setIsSetDefaultModalOpen(false);\n setPendingSave(false);\n // Reset the checkbox if cancelled\n setFormData((prev) => ({ ...prev, isDefault: billingAccount?.isDefault || false }));\n }\n }}\n />\n <div className=\"fixed inset-0 flex items-center justify-center z-50 p-4\">\n <div className=\"bg-bg-surface border border-border-subtle rounded-lg shadow-xl max-w-md w-full p-6\">\n <h3 className=\"text-lg font-semibold text-text-primary mb-2\">\n {tr('billing.settings.confirmDefaultTitle', 'Confirm Default Account Change')}\n </h3>\n <p className=\"text-sm text-text-secondary mb-4\">\n {tr(\n 'billing.settings.confirmDefaultDescription',\n 'You are about to set {{accountName}} as your default billing account and save your changes.',\n { accountName: billingAccount?.name ?? '' }\n )}\n </p>\n\n {currentDefaultAccount && currentDefaultAccount.id !== billingAccount?.id && (\n <div className=\"mb-4 p-3 bg-status-warning-bg-subtle border border-border-subtle rounded-md\">\n <div className=\"flex items-start gap-2\">\n <svg\n className=\"size-5 text-status-warning-text flex-shrink-0 mt-0.5\"\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 className=\"text-sm\">\n <p className=\"font-medium text-status-warning-text\">\n {tr(\n 'billing.settings.currentDefaultWillChange',\n 'Current default will change'\n )}\n </p>\n <p className=\"text-status-warning-text mt-0.5\">\n {tr(\n 'billing.settings.currentDefaultWillChangeDescription',\n '{{accountName}} will no longer be the default account.',\n { accountName: currentDefaultAccount.name }\n )}\n </p>\n </div>\n </div>\n </div>\n )}\n\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={() => {\n setIsSetDefaultModalOpen(false);\n setPendingSave(false);\n // Reset the checkbox if cancelled\n setFormData((prev) => ({\n ...prev,\n isDefault: billingAccount?.isDefault || false,\n }));\n }}\n disabled={isSaving}\n className=\"px-4 py-2 text-sm font-medium text-text-primary border border-border-subtle rounded-md hover:bg-bg-sunken transition-colors disabled:opacity-50\"\n >\n {tr('billing.common.cancel', 'Cancel')}\n </button>\n <button\n type=\"button\"\n onClick={performSave}\n disabled={isSaving}\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-md hover:bg-action-primary-bg/90 disabled:opacity-50 transition-colors flex items-center gap-2\"\n >\n {isSaving && (\n <svg className=\"size-4 animate-spin\" fill=\"none\" viewBox=\"0 0 24 24\">\n <circle\n className=\"opacity-25\"\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n />\n <path\n className=\"opacity-75\"\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n />\n </svg>\n )}\n {isSaving\n ? tr('billing.common.saving', 'Saving...')\n : tr('billing.common.saveChanges', 'Save Changes')}\n </button>\n </div>\n </div>\n </div>\n </>\n )}\n\n <AlertDialog open={isArchiveConfirmOpen} onOpenChange={setIsArchiveConfirmOpen}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>\n {tr('billing.settings.archiveDialogTitle', 'Archive billing account?')}\n </AlertDialogTitle>\n <AlertDialogDescription>{archiveConfirmMessage}</AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>{tr('billing.common.cancel', 'Cancel')}</AlertDialogCancel>\n <AlertDialogAction\n onClick={() => {\n setIsArchiveConfirmOpen(false);\n void handleArchiveAccount();\n }}\n >\n {tr('billing.settings.archiveAccount', 'Archive Account')}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAmCA,IAAME,WAAuD;CAC3D,IAAI,OAAO,SAAW,KAEtB,OAAO,IADe,gBAAgB,OAAO,SAAS,MAC/C,CAAA,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0B,EACrD,CAAA,GAClB,kBAACkF,IAAD,EAAA,UAAyBf,GAA8C,CAAA,CACtD,EAAA,CAAA,GACnB,kBAACgB,IAAD,EAAA,UAAA,CACE,kBAACC,IAAD,EAAA,UAAoBpF,EAAG,yBAAyB,QAAQ,EAAqB,CAAA,GAC7E,kBAACqF,IAAD;KACE,eAAe;MAEb,AADArE,EAAwB,EAAK,GAC7BoD,GAA0B;KAC5B;KAEC,UAAApE,EAAG,mCAAmC,iBAAiB;IACvC,CAAA,CACF,EAAA,CAAA,CACD,EAAA,CAAA;GACT,CAAA;EACV;C,KA3kBH,kBAACsF,GAAD,EACE,SAAStF,EACP,uCACA,uDACF,EACD,CAAA;AAwkBP"}
1
+ {"version":3,"file":"SettingsPage.js","names":["_Fragment","Fragment$1","getInitialBillingAccountId","SettingsPage","tr","useTr","permissions","useBillingPermissions","isFluidgrids","useIsFluidgridsVariant","useBilling","useBillingEventEmitter","selectedBillingAccountId","setSelectedBillingAccountId","useState","isAccountSelectorOpen","setIsAccountSelectorOpen","isSaving","setIsSaving","isArchiving","setIsArchiving","isArchiveConfirmOpen","setIsArchiveConfirmOpen","saveError","setSaveError","saveSuccess","setSaveSuccess","isSetDefaultModalOpen","setIsSetDefaultModalOpen","pendingSave","setPendingSave","formData","setFormData","EMPTY_SETTINGS_FORM","accountsData","isLoadingAccounts","refetchAccounts","useGetBillingAccountsSettingsQuery","billingAccounts","useMemo","defaultData","isLoadingDefault","refetchDefault","useGetDefaultBillingAccountSettingsQuery","defaultBillingAccount","selectedData","isLoadingSelected","refetchSelected","useGetBillingAccountSettingsQuery","selectedAccountData","updateBillingAccountMutation","useUpdateBillingAccountSettingsMutation","setDefaultBillingAccountMutation","useSetDefaultBillingAccountSettingsMutation","billingAccount","fromList","a","isLoading","formFromAccount","handleSelectAccount","account","handleInputChange","prev","field","value","currentDefaultAccount","hasChanges","hasFormChanges","isChangingDefault","needsDefaultConfirmation","performSave","useCallback","toUpdateInput","emit","error","handleSave","replacementDefaultAccount","archiveConfirmMessage","handleArchiveAccount","directBillingGraphqlRequest","ArchiveBillingAccountSettingsDocument","apiGatewayUrl","authToken","orgId","i","PageHeader","PagePurpose","OptionalFields","AlertDialog","AlertDialogContent","AlertDialogHeader","AlertDialogTitle","AlertDialogDescription","AlertDialogFooter","AlertDialogCancel","AlertDialogAction","AccessGate","AccessDenied"],"sources":["../../../../../src/billing/modules/settings/pages/SettingsPage.tsx"],"sourcesContent":["/**\n * Settings Module - Settings Page\n * Billing account settings and configuration\n */\n\nimport { useState, useMemo, useEffect, useCallback, type FC } from 'react';\nimport {\n EMPTY_SETTINGS_FORM,\n formFromAccount,\n hasFormChanges,\n toUpdateInput,\n type SettingsFormData,\n} from '../utils/accountForm';\nimport { useIsFluidgridsVariant } from '../../../hooks/useBillingVariant';\nimport { useBillingEventEmitter } from '../../../hooks/useBillingEventEmitter';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { AccessDenied, PageHeader } from '../../../shared/components';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AccessGate,\n AlertDialogTitle,\n OptionalFields,\n PagePurpose,\n} from '@burdenoff/fe-libs/ui';\nimport { directBillingGraphqlRequest } from '../../../shared/utils';\nimport {\n useGetBillingAccountSettingsQuery,\n useGetBillingAccountsSettingsQuery,\n useGetDefaultBillingAccountSettingsQuery,\n useUpdateBillingAccountSettingsMutation,\n useSetDefaultBillingAccountSettingsMutation,\n ArchiveBillingAccountSettingsDocument,\n} from '../../../../generated/global-operations';\nimport type { BillingAccount } from '../../../shared/types';\nimport { useTr } from '../../../shared/hooks/useTr';\n\n// Helper to get billing account ID from URL (for navigation from Overview page)\nconst getInitialBillingAccountId = (): string | undefined => {\n if (typeof window === 'undefined') return undefined;\n const urlParams = new URLSearchParams(window.location.search);\n return urlParams.get('billingAccountId') || undefined;\n};\n\nexport const SettingsPage: FC = () => {\n const tr = useTr();\n const permissions = useBillingPermissions();\n const isFluidgrids = useIsFluidgridsVariant();\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n const { emit } = useBillingEventEmitter();\n\n // State - initialize with URL param if present\n const [selectedBillingAccountId, setSelectedBillingAccountId] = useState<string | undefined>(\n getInitialBillingAccountId\n );\n const [isAccountSelectorOpen, setIsAccountSelectorOpen] = useState(false);\n const [isSaving, setIsSaving] = useState(false);\n const [isArchiving, setIsArchiving] = useState(false);\n const [isArchiveConfirmOpen, setIsArchiveConfirmOpen] = useState(false);\n const [saveError, setSaveError] = useState<string | null>(null);\n const [saveSuccess, setSaveSuccess] = useState(false);\n\n // Set default confirmation modal state\n const [isSetDefaultModalOpen, setIsSetDefaultModalOpen] = useState(false);\n const [pendingSave, setPendingSave] = useState(false);\n\n // Form state - includes isDefault toggle\n const [formData, setFormData] = useState<SettingsFormData>(EMPTY_SETTINGS_FORM);\n\n // Fetch all billing accounts for the selector (lightweight query without subscriptions)\n const {\n data: accountsData,\n loading: isLoadingAccounts,\n refetch: refetchAccounts,\n } = useGetBillingAccountsSettingsQuery({});\n const billingAccounts = useMemo<BillingAccount[]>(\n () => accountsData?.getBillingAccountsByOrg || [],\n [accountsData?.getBillingAccountsByOrg]\n );\n\n // Fetch default billing account (without subscriptions)\n const {\n data: defaultData,\n loading: isLoadingDefault,\n refetch: refetchDefault,\n } = useGetDefaultBillingAccountSettingsQuery({});\n const defaultBillingAccount: BillingAccount | null =\n defaultData?.getDefaultBillingAccount || null;\n\n // Always fetch selected billing account if we have an ID from URL (without subscriptions)\n const {\n data: selectedData,\n loading: isLoadingSelected,\n refetch: refetchSelected,\n } = useGetBillingAccountSettingsQuery({\n variables: { id: selectedBillingAccountId! },\n skip: !selectedBillingAccountId,\n });\n const selectedAccountData: BillingAccount | null = selectedData?.getBillingAccount || null;\n\n // Mutation for updating billing account\n const [updateBillingAccountMutation] = useUpdateBillingAccountSettingsMutation();\n\n // Mutation for setting default billing account\n const [setDefaultBillingAccountMutation] = useSetDefaultBillingAccountSettingsMutation();\n\n // Determine which account to use - prioritize URL param\n const billingAccount = useMemo(() => {\n // If we have a selected account ID from URL\n if (selectedBillingAccountId) {\n // First try to use the fetched selected account data\n if (selectedAccountData) {\n return selectedAccountData;\n }\n // While loading, try to find from the accounts list\n const fromList = billingAccounts.find((a) => a.id === selectedBillingAccountId);\n if (fromList) {\n return fromList;\n }\n // If still loading and not in list, return null to show loading state\n if (isLoadingSelected) {\n return null;\n }\n }\n // No URL param - use default account\n return defaultBillingAccount;\n }, [\n selectedBillingAccountId,\n selectedAccountData,\n billingAccounts,\n isLoadingSelected,\n defaultBillingAccount,\n ]);\n\n const isLoading =\n isLoadingAccounts || isLoadingDefault || (selectedBillingAccountId && isLoadingSelected);\n\n // Update form when billing account changes\n useEffect(() => {\n if (billingAccount) {\n setFormData(formFromAccount(billingAccount));\n }\n }, [billingAccount]);\n\n // Handle account selection\n const handleSelectAccount = (account: BillingAccount) => {\n setSelectedBillingAccountId(account.id);\n setIsAccountSelectorOpen(false);\n setSaveSuccess(false);\n setSaveError(null);\n };\n\n // Handle form input changes\n const handleInputChange = (field: keyof SettingsFormData, value: string) => {\n setFormData((prev) => ({ ...prev, [field]: value }));\n setSaveSuccess(false);\n setSaveError(null);\n };\n\n // Find the current default account\n const currentDefaultAccount = useMemo(() => {\n return billingAccounts.find((a) => a.isDefault) || null;\n }, [billingAccounts]);\n\n // Check if form has changes\n const hasChanges = useMemo(\n () => hasFormChanges(formData, billingAccount),\n [formData, billingAccount]\n );\n\n // Check if trying to change default status to another account\n const isChangingDefault = formData.isDefault && !billingAccount?.isDefault;\n const needsDefaultConfirmation =\n isChangingDefault && currentDefaultAccount && currentDefaultAccount.id !== billingAccount?.id;\n\n // Perform the actual save operation\n const performSave = useCallback(async () => {\n if (!billingAccount?.id) return;\n\n setIsSaving(true);\n setSaveError(null);\n setSaveSuccess(false);\n setIsSetDefaultModalOpen(false);\n setPendingSave(false);\n\n try {\n // Update billing account details\n await updateBillingAccountMutation({\n variables: {\n input: toUpdateInput(billingAccount.id, formData),\n },\n });\n emit('billing.billing_account.updated', {\n route: '/billing/settings',\n entityId: billingAccount.id,\n source: 'settings',\n });\n\n // If setting as default, call the separate mutation\n if (isChangingDefault) {\n await setDefaultBillingAccountMutation({\n variables: { id: billingAccount.id },\n refetchQueries: ['GetBillingAccountsByTenant', 'GetDefaultBillingAccount'],\n });\n emit('billing.billing_account.updated', {\n route: '/billing/settings',\n entityId: billingAccount.id,\n source: 'settings.default',\n });\n }\n\n // Refetch to update cache\n if (selectedBillingAccountId) {\n await refetchSelected();\n } else {\n await refetchDefault();\n }\n\n setSaveSuccess(true);\n // Clear success message after 3 seconds\n setTimeout(() => setSaveSuccess(false), 3000);\n } catch (error) {\n setSaveError(error instanceof Error ? error.message : 'Failed to save changes');\n } finally {\n setIsSaving(false);\n }\n }, [\n billingAccount?.id,\n formData,\n isChangingDefault,\n updateBillingAccountMutation,\n setDefaultBillingAccountMutation,\n selectedBillingAccountId,\n refetchSelected,\n refetchDefault,\n emit,\n ]);\n\n // Handle save button click\n const handleSave = useCallback(() => {\n if (!billingAccount?.id) return;\n\n // If changing default and there's an existing default, show confirmation\n if (needsDefaultConfirmation) {\n setPendingSave(true);\n setIsSetDefaultModalOpen(true);\n } else {\n performSave();\n }\n }, [billingAccount?.id, needsDefaultConfirmation, performSave]);\n\n const replacementDefaultAccount = useMemo(\n () =>\n billingAccount\n ? billingAccounts.find((account) => account.id !== billingAccount.id && account.isActive)\n : undefined,\n [billingAccount, billingAccounts]\n );\n\n const archiveConfirmMessage = billingAccount\n ? billingAccount.isDefault\n ? replacementDefaultAccount\n ? tr(\n 'billing.settings.archiveDefaultConfirm',\n 'Archive {{accountName}}? {{replacementName}} will become the default account.',\n { accountName: billingAccount.name, replacementName: replacementDefaultAccount.name }\n )\n : tr(\n 'billing.settings.archiveDefaultNoReplacementConfirm',\n 'Archive {{accountName}}? No replacement default account is available.',\n { accountName: billingAccount.name }\n )\n : tr('billing.settings.archiveConfirm', 'Archive {{accountName}}?', {\n accountName: billingAccount.name,\n })\n : '';\n\n const handleArchiveAccount = useCallback(async () => {\n if (!billingAccount?.id || !billingAccount.isActive) {\n return;\n }\n\n setIsArchiving(true);\n setSaveError(null);\n setSaveSuccess(false);\n\n try {\n await directBillingGraphqlRequest<\n { archiveBillingAccount: { id: string; isActive: boolean; isDefault: boolean } },\n { id: string; reason: string; replacementDefaultBillingAccountId: string | null }\n >({\n apiGatewayUrl,\n authToken,\n orgId,\n query: ArchiveBillingAccountSettingsDocument,\n variables: {\n id: billingAccount.id,\n reason: 'Archived from billing settings',\n replacementDefaultBillingAccountId: billingAccount.isDefault\n ? (replacementDefaultAccount?.id ?? null)\n : null,\n },\n });\n emit('billing.billing_account.archived', {\n route: '/billing/settings',\n entityId: billingAccount.id,\n source: 'settings',\n });\n\n await Promise.all([refetchAccounts(), refetchDefault()]);\n setSelectedBillingAccountId(replacementDefaultAccount?.id);\n setSaveSuccess(true);\n setTimeout(() => setSaveSuccess(false), 3000);\n } catch (error) {\n setSaveError(error instanceof Error ? error.message : 'Failed to archive billing account');\n } finally {\n setIsArchiving(false);\n }\n }, [\n apiGatewayUrl,\n authToken,\n billingAccount,\n replacementDefaultAccount,\n orgId,\n refetchAccounts,\n refetchDefault,\n emit,\n ]);\n\n if (!permissions.canManageBillingAccount) {\n // FluidGrids: say what is needed and who can grant it, instead of a dead-end denial.\n if (isFluidgrids) {\n return (\n <AccessGate\n message={tr('billing.settings.needAccess', 'You need access to billing settings')}\n granterHint={tr(\n 'billing.settings.needAccessHint',\n 'Ask a billing admin of this organization to give you access.'\n )}\n />\n );\n }\n return (\n <AccessDenied\n message={tr(\n 'billing.settings.noManagePermission',\n \"You don't have permission to manage billing settings.\"\n )}\n />\n );\n }\n\n if (isLoading && !billingAccount) {\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=\"border border-border-subtle rounded-lg p-6 space-y-4\">\n {[1, 2, 3].map((i) => (\n <div key={i} className=\"h-10 bg-bg-sunken animate-pulse rounded\" />\n ))}\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title={tr('billing.settings.billingSettings', 'Billing Settings')}\n description={tr(\n 'billing.settings.description',\n 'Manage your billing account configuration'\n )}\n />\n\n <PagePurpose>\n {tr(\n 'billing.settings.purpose',\n \"Configure how a billing account behaves — its name and contact details, default currency, tax information and whether it's your default account. Changes here affect how invoices are generated and which account new purchases bill to.\"\n )}\n </PagePurpose>\n\n {/* Account Selector (if multiple accounts) */}\n {billingAccounts.length > 1 && (\n <div className=\"relative\">\n <button\n type=\"button\"\n onClick={() => setIsAccountSelectorOpen(!isAccountSelectorOpen)}\n className=\"w-full sm:w-auto flex items-center justify-between gap-3 px-4 py-3 border border-border-subtle rounded-lg bg-bg-surface hover:bg-bg-sunken/50 transition-colors\"\n >\n <div className=\"flex items-center gap-3\">\n <div className=\"size-8 rounded-lg bg-action-primary-bg/10 flex items-center justify-center\">\n <svg\n className=\"size-4 text-primary\"\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=\"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4\"\n />\n </svg>\n </div>\n <div className=\"text-left\">\n <p className=\"text-sm font-medium text-text-primary\">\n {billingAccount?.name || tr('billing.settings.selectAccount', 'Select Account')}\n </p>\n <p className=\"text-xs text-text-secondary\">{billingAccount?.email}</p>\n </div>\n </div>\n <svg\n className={`size-4 text-text-secondary transition-transform ${isAccountSelectorOpen ? 'rotate-180' : ''}`}\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=\"M19 9l-7 7-7-7\"\n />\n </svg>\n </button>\n\n {isAccountSelectorOpen && (\n <>\n <div className=\"fixed inset-0 z-10\" onClick={() => setIsAccountSelectorOpen(false)} />\n <div className=\"absolute top-full left-0 right-0 sm:right-auto mt-1 w-full sm:w-80 bg-popover border border-border-subtle rounded-lg shadow-lg z-20 py-1 max-h-60 overflow-y-auto\">\n {billingAccounts.map((account) => (\n <button\n type=\"button\"\n key={account.id}\n onClick={() => handleSelectAccount(account)}\n className=\"w-full flex items-center justify-between gap-3 px-4 py-3 hover:bg-bg-sunken transition-colors\"\n >\n <div className=\"flex items-center gap-3 min-w-0\">\n <div className=\"size-8 rounded-lg bg-bg-sunken flex items-center justify-center flex-shrink-0\">\n <svg\n className=\"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=\"M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4\"\n />\n </svg>\n </div>\n <div className=\"text-left min-w-0\">\n <p className=\"text-sm font-medium text-text-primary truncate\">\n {account.name}\n </p>\n <p className=\"text-xs text-text-secondary truncate\">{account.email}</p>\n </div>\n </div>\n {billingAccount?.id === account.id && (\n <svg\n className=\"size-4 text-primary flex-shrink-0\"\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=\"M5 13l4 4L19 7\"\n />\n </svg>\n )}\n </button>\n ))}\n </div>\n </>\n )}\n </div>\n )}\n\n {/* Account Settings */}\n <div className=\"border border-border-subtle rounded-lg bg-bg-surface\">\n <div className=\"p-6 border-b border-border-subtle\">\n <div className=\"flex items-center justify-between\">\n <div>\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {tr('billing.settings.accountInfo', 'Account Information')}\n </h2>\n <p className=\"text-sm text-text-secondary mt-1\">\n {tr(\n 'billing.settings.accountInfoDescription',\n 'Update your billing contact details and tax information'\n )}\n </p>\n </div>\n {billingAccount?.isDefault && (\n <span className=\"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium bg-action-primary-bg/10 text-primary rounded-full\">\n <svg className=\"size-3\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path\n fillRule=\"evenodd\"\n d=\"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z\"\n clipRule=\"evenodd\"\n />\n </svg>\n {tr('billing.settings.defaultAccount', 'Default Account')}\n </span>\n )}\n </div>\n </div>\n <div className=\"p-6 space-y-6\">\n {/* Account Status Summary */}\n {billingAccount && (\n <div className=\"grid grid-cols-2 sm:grid-cols-4 gap-4 text-sm pb-4 border-b border-border-subtle\">\n <div>\n <p className=\"text-text-secondary\">{tr('billing.settings.status', 'Status')}</p>\n <p\n className={`font-medium ${billingAccount.isActive ? 'text-status-success-text' : 'text-status-error-text'}`}\n >\n {billingAccount.isActive\n ? tr('billing.settings.active', 'Active')\n : tr('billing.settings.inactive', 'Inactive')}\n </p>\n </div>\n <div>\n <p className=\"text-text-secondary\">\n {tr('billing.settings.creditBalance', 'Credit Balance')}\n </p>\n <p className=\"font-medium text-text-primary\">\n {(billingAccount.creditAmount || 0).toLocaleString()}{' '}\n {tr('billing.common.credits', 'Credits')}\n </p>\n </div>\n <div>\n <p className=\"text-text-secondary\">\n {tr('billing.settings.accountId', 'Account ID')}\n </p>\n <p\n className=\"font-mono text-xs text-text-primary truncate\"\n title={billingAccount.id}\n >\n {billingAccount.id}\n </p>\n </div>\n <div>\n <p className=\"text-text-secondary\">{tr('billing.settings.created', 'Created')}</p>\n <p className=\"font-medium text-text-primary\">\n {billingAccount.createdAt\n ? new Date(billingAccount.createdAt).toLocaleDateString()\n : tr('billing.settings.notAvailable', 'N/A')}\n </p>\n </div>\n </div>\n )}\n\n {/* Contact Details Section — Required fields above-the-fold */}\n <div>\n <h3 className=\"text-sm font-medium text-text-primary mb-4\">\n {tr('billing.settings.contactDetails', 'Contact Details')}\n </h3>\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-4\">\n <div>\n <label\n htmlFor=\"billing-account-name\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.settings.accountName', 'Account Name')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n id=\"billing-account-name\"\n type=\"text\"\n value={formData.name}\n onChange={(e) => handleInputChange('name', e.target.value)}\n className=\"w-full px-3 py-2 text-sm border border-border-subtle rounded-md bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent\"\n />\n </div>\n <div>\n <label\n htmlFor=\"billing-account-email\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.settings.email', 'Email')}{' '}\n <span className=\"text-status-error-text\">*</span>\n </label>\n <input\n id=\"billing-account-email\"\n type=\"email\"\n value={formData.email}\n onChange={(e) => handleInputChange('email', e.target.value)}\n className=\"w-full px-3 py-2 text-sm border border-border-subtle rounded-md bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent\"\n />\n </div>\n </div>\n </div>\n\n {/* Advanced billing settings — currency / billing email / tax ID. Most accounts keep defaults. */}\n <OptionalFields\n {...(isFluidgrids\n ? {\n storageKey: 'billing.settings.account',\n label: tr('billing.settings.moreOptions', 'More options'),\n }\n : {})}\n title={tr('billing.settings.advancedTitle', 'Advanced settings')}\n description={tr(\n 'billing.settings.advancedDescription',\n 'Billing email override, currency, and tax identification.'\n )}\n >\n <div className=\"grid grid-cols-1 sm:grid-cols-2 gap-4\">\n <div>\n <label\n htmlFor=\"billing-account-billing-email\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.settings.billingEmail', 'Billing Email')}\n </label>\n <input\n id=\"billing-account-billing-email\"\n type=\"email\"\n value={formData.billingEmail}\n onChange={(e) => handleInputChange('billingEmail', e.target.value)}\n placeholder={tr(\n 'billing.settings.billingEmailPlaceholder',\n 'Optional - defaults to account email'\n )}\n className=\"w-full px-3 py-2 text-sm border border-border-subtle rounded-md bg-bg-surface text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent\"\n />\n <p className=\"text-xs text-text-secondary mt-1\">\n {tr(\n 'billing.settings.billingEmailHelp',\n 'Invoices will be sent to this email if provided'\n )}\n </p>\n </div>\n <div>\n <label\n htmlFor=\"billing-account-currency\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.settings.currency', 'Currency')}\n </label>\n <select\n id=\"billing-account-currency\"\n value={formData.currency}\n onChange={(e) => handleInputChange('currency', e.target.value)}\n className=\"w-full px-3 py-2 text-sm border border-border-subtle rounded-md bg-bg-surface text-text-primary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n <option value=\"USD\">USD - US Dollar</option>\n <option value=\"EUR\">EUR - Euro</option>\n <option value=\"GBP\">GBP - British Pound</option>\n <option value=\"INR\">INR - Indian Rupee</option>\n </select>\n </div>\n <div className=\"sm:col-span-2 max-w-md\">\n <label\n htmlFor=\"billing-account-tax-id\"\n className=\"block text-sm font-medium text-text-primary mb-1\"\n >\n {tr('billing.settings.taxId', 'Tax ID / VAT Number')}\n </label>\n <input\n id=\"billing-account-tax-id\"\n type=\"text\"\n value={formData.taxId}\n onChange={(e) => handleInputChange('taxId', e.target.value)}\n placeholder={tr(\n 'billing.settings.taxIdPlaceholder',\n 'Enter your tax identification number'\n )}\n className=\"w-full px-3 py-2 text-sm border border-border-subtle rounded-md bg-bg-surface text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent\"\n />\n <p className=\"text-xs text-text-secondary mt-1\">\n {tr(\n 'billing.settings.taxIdHelp',\n 'Used for invoices and tax compliance (e.g., GST, VAT number)'\n )}\n </p>\n </div>\n </div>\n </OptionalFields>\n\n {/* Default Account Setting */}\n {billingAccount?.isActive && billingAccounts.length > 1 && (\n <div className=\"pt-4 border-t border-border-subtle\">\n <div className=\"flex items-start gap-3\">\n <div className=\"flex items-center h-6\">\n <input\n type=\"checkbox\"\n id=\"isDefault\"\n checked={formData.isDefault}\n onChange={(e) =>\n setFormData((prev) => ({ ...prev, isDefault: e.target.checked }))\n }\n disabled={billingAccount?.isDefault}\n className=\"size-4 rounded border-border-subtle text-primary focus:ring-primary focus:ring-offset-0 disabled:opacity-50 disabled:cursor-not-allowed\"\n />\n </div>\n <div className=\"flex-1\">\n <label\n htmlFor=\"isDefault\"\n className=\"text-sm font-medium text-text-primary cursor-pointer\"\n >\n {tr('billing.settings.setDefault', 'Set as default billing account')}\n </label>\n <p className=\"text-xs text-text-secondary mt-0.5\">\n {billingAccount?.isDefault\n ? tr(\n 'billing.settings.currentDefaultDescription',\n 'This is currently your default billing account'\n )\n : tr(\n 'billing.settings.makePrimaryDescription',\n 'Make this your primary billing account for new subscriptions'\n )}\n </p>\n </div>\n </div>\n </div>\n )}\n\n {/* Save Button and Status */}\n <div className=\"pt-4 border-t border-border-subtle flex items-center justify-between\">\n <div className=\"flex items-center gap-2\">\n {saveSuccess && (\n <div className=\"flex items-center gap-2 text-sm text-status-success-text\">\n <svg className=\"size-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M5 13l4 4L19 7\"\n />\n </svg>\n {tr('billing.settings.saveSuccess', 'Changes saved successfully')}\n </div>\n )}\n {saveError && (\n <div className=\"flex items-center gap-2 text-sm text-status-error-text\">\n <svg className=\"size-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 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 {saveError}\n </div>\n )}\n </div>\n <div className=\"flex items-center gap-3\">\n {permissions.canArchiveBillingAccount && billingAccount?.isActive ? (\n <button\n type=\"button\"\n onClick={() => setIsArchiveConfirmOpen(true)}\n disabled={isSaving || isArchiving}\n className=\"px-4 py-2 text-sm font-medium border border-border-subtle text-status-error-text rounded-md hover:bg-status-error-bg-subtle disabled:opacity-50 disabled:cursor-not-allowed transition-colors\"\n >\n {isArchiving\n ? tr('billing.settings.archiving', 'Archiving...')\n : tr('billing.settings.archiveAccount', 'Archive Account')}\n </button>\n ) : null}\n <button\n type=\"button\"\n onClick={handleSave}\n disabled={\n !hasChanges || isSaving || isArchiving || !formData.name || !formData.email\n }\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-md hover:bg-action-primary-bg/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-2\"\n >\n {isSaving && (\n <svg className=\"size-4 animate-spin\" fill=\"none\" viewBox=\"0 0 24 24\">\n <circle\n className=\"opacity-25\"\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n />\n <path\n className=\"opacity-75\"\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n />\n </svg>\n )}\n {isSaving\n ? tr('billing.common.saving', 'Saving...')\n : tr('billing.common.saveChanges', 'Save Changes')}\n </button>\n </div>\n </div>\n </div>\n </div>\n\n {/* Set as Default Confirmation Modal */}\n {isSetDefaultModalOpen && pendingSave && (\n <>\n <div\n className=\"fixed inset-0 bg-overlay-scrim z-40\"\n onClick={() => {\n if (!isSaving) {\n setIsSetDefaultModalOpen(false);\n setPendingSave(false);\n // Reset the checkbox if cancelled\n setFormData((prev) => ({ ...prev, isDefault: billingAccount?.isDefault || false }));\n }\n }}\n />\n <div className=\"fixed inset-0 flex items-center justify-center z-50 p-4\">\n <div className=\"bg-bg-surface border border-border-subtle rounded-lg shadow-xl max-w-md w-full p-6\">\n <h3 className=\"text-lg font-semibold text-text-primary mb-2\">\n {tr('billing.settings.confirmDefaultTitle', 'Confirm Default Account Change')}\n </h3>\n <p className=\"text-sm text-text-secondary mb-4\">\n {tr(\n 'billing.settings.confirmDefaultDescription',\n 'You are about to set {{accountName}} as your default billing account and save your changes.',\n { accountName: billingAccount?.name ?? '' }\n )}\n </p>\n\n {currentDefaultAccount && currentDefaultAccount.id !== billingAccount?.id && (\n <div className=\"mb-4 p-3 bg-status-warning-bg-subtle border border-border-subtle rounded-md\">\n <div className=\"flex items-start gap-2\">\n <svg\n className=\"size-5 text-status-warning-text flex-shrink-0 mt-0.5\"\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 className=\"text-sm\">\n <p className=\"font-medium text-status-warning-text\">\n {tr(\n 'billing.settings.currentDefaultWillChange',\n 'Current default will change'\n )}\n </p>\n <p className=\"text-status-warning-text mt-0.5\">\n {tr(\n 'billing.settings.currentDefaultWillChangeDescription',\n '{{accountName}} will no longer be the default account.',\n { accountName: currentDefaultAccount.name }\n )}\n </p>\n </div>\n </div>\n </div>\n )}\n\n <div className=\"flex justify-end gap-3\">\n <button\n type=\"button\"\n onClick={() => {\n setIsSetDefaultModalOpen(false);\n setPendingSave(false);\n // Reset the checkbox if cancelled\n setFormData((prev) => ({\n ...prev,\n isDefault: billingAccount?.isDefault || false,\n }));\n }}\n disabled={isSaving}\n className=\"px-4 py-2 text-sm font-medium text-text-primary border border-border-subtle rounded-md hover:bg-bg-sunken transition-colors disabled:opacity-50\"\n >\n {tr('billing.common.cancel', 'Cancel')}\n </button>\n <button\n type=\"button\"\n onClick={performSave}\n disabled={isSaving}\n className=\"px-4 py-2 text-sm font-medium bg-action-primary-bg text-action-primary-text rounded-md hover:bg-action-primary-bg/90 disabled:opacity-50 transition-colors flex items-center gap-2\"\n >\n {isSaving && (\n <svg className=\"size-4 animate-spin\" fill=\"none\" viewBox=\"0 0 24 24\">\n <circle\n className=\"opacity-25\"\n cx=\"12\"\n cy=\"12\"\n r=\"10\"\n stroke=\"currentColor\"\n strokeWidth=\"4\"\n />\n <path\n className=\"opacity-75\"\n fill=\"currentColor\"\n d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n />\n </svg>\n )}\n {isSaving\n ? tr('billing.common.saving', 'Saving...')\n : tr('billing.common.saveChanges', 'Save Changes')}\n </button>\n </div>\n </div>\n </div>\n </>\n )}\n\n <AlertDialog open={isArchiveConfirmOpen} onOpenChange={setIsArchiveConfirmOpen}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>\n {tr('billing.settings.archiveDialogTitle', 'Archive billing account?')}\n </AlertDialogTitle>\n <AlertDialogDescription>{archiveConfirmMessage}</AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>{tr('billing.common.cancel', 'Cancel')}</AlertDialogCancel>\n <AlertDialogAction\n onClick={() => {\n setIsArchiveConfirmOpen(false);\n void handleArchiveAccount();\n }}\n >\n {tr('billing.settings.archiveAccount', 'Archive Account')}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AA4CA,IAAME,UAAuD;CAC3D,IAAI,OAAO,SAAW,KAEtB,OAAO,IADe,gBAAgB,OAAO,SAAS,MAC/C,CAAA,CAAU,IAAI,kBAAkB,KAAK,KAAA;AAC9C,GAEaC,UAAyB;CACpC,IAAMC,IAAKC,GAAM,GACXC,IAAcC,GAAsB,GACpCC,IAAeC,GAAuB,GACtC,EAAE,kBAAe,cAAW,aAAUC,GAAW,GACjD,EAAE,YAASC,GAAuB,GAGlC,CAACC,GAA0BC,KAA+BC,EAC9DZ,CACF,GACM,CAACa,GAAuBC,KAA4BF,EAAS,EAAK,GAClE,CAACG,GAAUC,KAAeJ,EAAS,EAAK,GACxC,CAACK,GAAaC,KAAkBN,EAAS,EAAK,GAC9C,CAACO,GAAsBC,KAA2BR,EAAS,EAAK,GAChE,CAACS,GAAWC,KAAgBV,EAAwB,IAAI,GACxD,CAACW,IAAaC,KAAkBZ,EAAS,EAAK,GAG9C,CAACa,IAAuBC,KAA4Bd,EAAS,EAAK,GAClE,CAACe,IAAaC,KAAkBhB,EAAS,EAAK,GAG9C,CAACiB,GAAUC,KAAelB,EAA2BmB,CAAmB,GAGxE,EACJ,MAAMC,GACN,SAASC,IACT,SAASC,MACPC,EAAmC,CAAC,CAAC,GACnCC,IAAkBC,QAChBL,GAAc,2BAA2B,CAAC,GAChD,CAACA,GAAc,uBAAuB,CACxC,GAGM,EACJ,MAAMM,IACN,SAASC,IACT,SAASC,MACPC,GAAyC,CAAC,CAAC,GACzCC,IACJJ,IAAa,4BAA4B,MAGrC,EACJ,MAAMK,IACN,SAASC,GACT,SAASC,MACPC,GAAkC;EACpC,WAAW,EAAE,IAAIpC,EAA0B;EAC3C,MAAM,CAACA;CACT,CAA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,EAAG,yBAAyB,QAAQ,EAAqB,CAAA,GAC7E,kBAAC2F,IAAD;KACE,eAAe;MAEb,AADAzE,EAAwB,EAAK,GAC7BwD,GAA0B;KAC5B;KAEC,UAAA1E,EAAG,mCAAmC,iBAAiB;IACvC,CAAA,CACF,EAAA,CAAA,CACD,EAAA,CAAA;GACT,CAAA;EACV;C,KA7lBDI,IAEA,kBAACwF,IAAD;EACE,SAAS5F,EAAG,+BAA+B,qCAAqC;EAChF,aAAaA,EACX,mCACA,8DACF;CACD,CAAA,IAIH,kBAAC6F,IAAD,EACE,SAAS7F,EACP,uCACA,uDACF,EACD,CAAA;AA8kBP"}
@@ -0,0 +1,23 @@
1
+ import { BillingAccount } from '../../../shared/types';
2
+ export interface SettingsFormData {
3
+ name: string;
4
+ email: string;
5
+ billingEmail: string;
6
+ currency: string;
7
+ taxId: string;
8
+ isDefault: boolean;
9
+ }
10
+ export declare const EMPTY_SETTINGS_FORM: SettingsFormData;
11
+ /** The form as it should read for an account (empty text and USD where the account has none). */
12
+ export declare function formFromAccount(account: Pick<BillingAccount, 'name' | 'email' | 'billingEmail' | 'currency' | 'taxId' | 'isDefault'>): SettingsFormData;
13
+ /** True when any field, fold open or not, differs from the saved account. */
14
+ export declare function hasFormChanges(form: SettingsFormData, account: Parameters<typeof formFromAccount>[0] | null | undefined): boolean;
15
+ /** What the update mutation receives. An empty optional field is sent as null, as before. */
16
+ export declare function toUpdateInput(id: string, form: SettingsFormData): {
17
+ id: string;
18
+ name: string;
19
+ email: string;
20
+ billingEmail: string | null;
21
+ currency: string;
22
+ taxId: string | null;
23
+ };
@@ -0,0 +1,37 @@
1
+ // src/billing/modules/settings/utils/accountForm.ts
2
+ var e = {
3
+ name: "",
4
+ email: "",
5
+ billingEmail: "",
6
+ currency: "USD",
7
+ taxId: "",
8
+ isDefault: !1
9
+ };
10
+ function t(e) {
11
+ return {
12
+ name: e.name || "",
13
+ email: e.email || "",
14
+ billingEmail: e.billingEmail || "",
15
+ currency: e.currency || "USD",
16
+ taxId: e.taxId || "",
17
+ isDefault: e.isDefault || !1
18
+ };
19
+ }
20
+ function n(e, n) {
21
+ if (!n) return !1;
22
+ let r = t(n);
23
+ return Object.keys(r).some((t) => e[t] !== r[t]);
24
+ }
25
+ function r(e, t) {
26
+ return {
27
+ id: e,
28
+ name: t.name,
29
+ email: t.email,
30
+ billingEmail: t.billingEmail || null,
31
+ currency: t.currency,
32
+ taxId: t.taxId || null
33
+ };
34
+ }
35
+ export { e as EMPTY_SETTINGS_FORM, t as formFromAccount, n as hasFormChanges, r as toUpdateInput };
36
+
37
+ //# sourceMappingURL=accountForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accountForm.js","names":["EMPTY_SETTINGS_FORM","formFromAccount","account","hasFormChanges","saved","form","field","toUpdateInput"],"sources":["../../../../../src/billing/modules/settings/utils/accountForm.ts"],"sourcesContent":["/**\n * The billing Settings form, kept apart from the page so what it saves can be\n * tested (BOFF-11860). The optional fields (billing email, currency, tax ID)\n * sit in a fold under the FluidGrids variant, but a closed fold changes nothing\n * here: every field is always part of the form state and of what is saved.\n */\nimport type { BillingAccount } from '../../../shared/types';\n\nexport interface SettingsFormData {\n name: string;\n email: string;\n billingEmail: string;\n currency: string;\n taxId: string;\n isDefault: boolean;\n}\n\nexport const EMPTY_SETTINGS_FORM: SettingsFormData = {\n name: '',\n email: '',\n billingEmail: '',\n currency: 'USD',\n taxId: '',\n isDefault: false,\n};\n\n/** The form as it should read for an account (empty text and USD where the account has none). */\nexport function formFromAccount(\n account: Pick<\n BillingAccount,\n 'name' | 'email' | 'billingEmail' | 'currency' | 'taxId' | 'isDefault'\n >\n): SettingsFormData {\n return {\n name: account.name || '',\n email: account.email || '',\n billingEmail: account.billingEmail || '',\n currency: account.currency || 'USD',\n taxId: account.taxId || '',\n isDefault: account.isDefault || false,\n };\n}\n\n/** True when any field, fold open or not, differs from the saved account. */\nexport function hasFormChanges(\n form: SettingsFormData,\n account: Parameters<typeof formFromAccount>[0] | null | undefined\n): boolean {\n if (!account) return false;\n const saved = formFromAccount(account);\n return (Object.keys(saved) as Array<keyof SettingsFormData>).some(\n (field) => form[field] !== saved[field]\n );\n}\n\n/** What the update mutation receives. An empty optional field is sent as null, as before. */\nexport function toUpdateInput(id: string, form: SettingsFormData) {\n return {\n id,\n name: form.name,\n email: form.email,\n billingEmail: form.billingEmail || null,\n currency: form.currency,\n taxId: form.taxId || null,\n };\n}\n"],"mappings":";AAiBA,IAAaA,IAAwC;CACnD,MAAM;CACN,OAAO;CACP,cAAc;CACd,UAAU;CACV,OAAO;CACP,WAAW;AACb;AAGA,SAAgBC,EACd,GAIkB;CAClB,OAAO;EACL,MAAMC,EAAQ,QAAQ;EACtB,OAAOA,EAAQ,SAAS;EACxB,cAAcA,EAAQ,gBAAgB;EACtC,UAAUA,EAAQ,YAAY;EAC9B,OAAOA,EAAQ,SAAS;EACxB,WAAWA,EAAQ,aAAa;CAClC;AACF;AAGA,SAAgBC,EACd,GACA,GACS;CACT,IAAI,CAACD,GAAS,OAAO;CACrB,IAAME,IAAQH,EAAgBC,CAAO;CACrC,OAAQ,OAAO,KAAKE,CAAK,CAAC,CAAmC,MAC1D,MAAUC,EAAKC,OAAWF,EAAME,EACnC;AACF;AAGA,SAAgBC,EAAc,GAAY,GAAwB;CAChE,OAAO;EACL;EACA,MAAMF,EAAK;EACX,OAAOA,EAAK;EACZ,cAAcA,EAAK,gBAAgB;EACnC,UAAUA,EAAK;EACf,OAAOA,EAAK,SAAS;CACvB;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-billing",
3
- "version": "2026.1112.3",
3
+ "version": "2026.1113.1",
4
4
  "description": "Billing microfrontend for Burdenoff products",
5
5
  "type": "module",
6
6
  "files": [
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@apollo/client": "^4.3.6",
50
- "@burdenoff/fe-libs": "2026.1102.4",
50
+ "@burdenoff/fe-libs": "2026.1113.6",
51
51
  "@tanstack/react-query": "^5.106.1",
52
52
  "clsx": "^2.1.1",
53
53
  "graphql": "^16.15.0",
@@ -100,7 +100,7 @@
100
100
  "fast-xml-parser": ">=4.5.5",
101
101
  "@xmldom/xmldom": ">=0.8.12",
102
102
  "swiper": ">=12.1.2",
103
- "brace-expansion": "5.0.9",
103
+ "brace-expansion": "5.0.12",
104
104
  "follow-redirects": ">=1.15.12",
105
105
  "smol-toml": ">=1.6.1",
106
106
  "axios": ">=1.15.0",
@@ -111,7 +111,8 @@
111
111
  "minimatch": ">=3.1.3",
112
112
  "ajv": "^6.15.0",
113
113
  "js-yaml": ">=4.3.1",
114
- "nanoid@^3.3.0": "3.3.16"
114
+ "nanoid@^3.3.0": "3.3.20",
115
+ "@graphql-tools/utils": "12.1.0"
115
116
  },
116
117
  "packageManager": "bun@1.4.4",
117
118
  "engines": {