@burdenoff/microfe-billing 2026.1114.3 → 2026.1114.4

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.
@@ -11,10 +11,10 @@ import "../../../shared/utils/index.js";
11
11
  import { useActorProfiles as c } from "../../../shared/hooks/useActorProfiles.js";
12
12
  import "../../../shared/hooks/index.js";
13
13
  import { useCallback as l, useEffect as u, useMemo as d, useState as f } from "react";
14
- import { AlertDialog as p, AlertDialogAction as m, AlertDialogCancel as h, AlertDialogContent as g, AlertDialogDescription as _, AlertDialogFooter as ee, AlertDialogHeader as te, AlertDialogTitle as v, IllustratedEmptyState as y, PagePurpose as b } from "@burdenoff/fe-libs/ui";
15
- import { jsx as x, jsxs as S } from "react/jsx-runtime";
14
+ import { AlertDialog as p, AlertDialogAction as m, AlertDialogCancel as h, AlertDialogContent as g, AlertDialogDescription as ee, AlertDialogFooter as te, AlertDialogHeader as ne, AlertDialogTitle as _, IllustratedEmptyState as re, PagePurpose as v } from "@burdenoff/fe-libs/ui";
15
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
16
16
  // src/billing/modules/settings/pages/TeamPermissionsPage.tsx
17
- var C = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, w = "\n query BillingScopeRoles($scopeId: String!) {\n roles(scopeId: $scopeId) {\n id\n name\n description\n priority\n isSystem\n }\n }\n", T = "\n query BillingScopeActors($scopeId: String!) {\n actors(scopeId: $scopeId) {\n actorId\n actorType\n roleAssignments {\n id\n actorId\n actorType\n roleId\n scopeId\n isActive\n expiresAt\n role { id name priority }\n }\n }\n }\n", E = "\n mutation AssignBillingRole($input: AssignRoleInput!) {\n assignRoleToActor(input: $input) {\n id\n actorId\n roleId\n scopeId\n }\n }\n", D = "\n mutation RemoveBillingRole($assignmentId: String!) {\n removeRoleFromActor(assignmentId: $assignmentId)\n }\n", O = () => {
17
+ var S = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, C = "\n query BillingScopeRoles($scopeId: String!) {\n roles(scopeId: $scopeId) {\n id\n name\n description\n priority\n isSystem\n }\n }\n", w = "\n query BillingScopeActors($scopeId: String!) {\n actors(scopeId: $scopeId) {\n actorId\n actorType\n roleAssignments {\n id\n actorId\n actorType\n roleId\n scopeId\n isActive\n expiresAt\n role { id name priority }\n }\n }\n }\n", T = "\n mutation AssignBillingRole($input: AssignRoleInput!) {\n assignRoleToActor(input: $input) {\n id\n actorId\n roleId\n scopeId\n }\n }\n", E = "\n mutation RemoveBillingRole($assignmentId: String!) {\n removeRoleFromActor(assignmentId: $assignmentId)\n }\n", D = ({ embedded: D = !1 }) => {
18
18
  let { apiGatewayUrl: O, authToken: k, orgId: A } = e(), { billingAccounts: j } = s(), { selectedAccountId: M } = o({
19
19
  orgId: A,
20
20
  billingAccounts: j,
@@ -34,7 +34,7 @@ var C = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, w = "
34
34
  if (N) {
35
35
  B(!0), H(null);
36
36
  try {
37
- let [e, t] = await Promise.all([Z(w, { scopeId: N }), Z(T, { scopeId: N })]);
37
+ let [e, t] = await Promise.all([Z(C, { scopeId: N }), Z(w, { scopeId: N })]);
38
38
  I(e.roles ?? []), R(t.actors ?? []);
39
39
  let n = (e.roles ?? []).find((e) => /viewer/i.test(e.name));
40
40
  K(n?.id ?? e.roles?.[0]?.id ?? "");
@@ -51,19 +51,19 @@ var C = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, w = "
51
51
  let $ = d(() => [...L].sort((e, t) => {
52
52
  let n = Math.max(...e.roleAssignments.map((e) => e.role?.priority ?? 0), 0);
53
53
  return Math.max(...t.roleAssignments.map((e) => e.role?.priority ?? 0), 0) - n;
54
- }), [L]), ne = d(() => $.map((e) => ({
54
+ }), [L]), ie = d(() => $.map((e) => ({
55
55
  actorId: e.actorId,
56
56
  actorType: e.actorType
57
- })), [$]), re = c(ne), ie = d(() => {
57
+ })), [$]), ae = c(ie), oe = d(() => {
58
58
  if (N) return j.find((e) => e.id === N)?.name ?? void 0;
59
- }, [N, j]), ae = async (e) => {
59
+ }, [N, j]), se = async (e) => {
60
60
  if (e.preventDefault(), !N || !U.trim() || !G) return;
61
61
  let t = U.trim();
62
- if (!C.test(t)) H("User ID must be a UUID (e.g. 1a2b3c4d-...). Get it from the user profile page.");
62
+ if (!S.test(t)) H("User ID must be a UUID (e.g. 1a2b3c4d-...). Get it from the user profile page.");
63
63
  else {
64
64
  J(!0), H(null);
65
65
  try {
66
- await Z(E, { input: {
66
+ await Z(T, { input: {
67
67
  actorId: t,
68
68
  actorType: "USER",
69
69
  roleId: G,
@@ -75,72 +75,71 @@ var C = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, w = "
75
75
  J(!1);
76
76
  }
77
77
  }
78
- }, oe = async (e) => {
78
+ }, ce = async (e) => {
79
79
  H(null);
80
80
  try {
81
- await Z(D, { assignmentId: e }), await Q();
81
+ await Z(E, { assignmentId: e }), await Q();
82
82
  } catch (e) {
83
83
  H(e instanceof Error ? e.message : "Failed to remove role");
84
84
  }
85
85
  };
86
- return P.isLoading ? /* @__PURE__ */ x("div", {
86
+ return P.isLoading ? /* @__PURE__ */ b("div", {
87
87
  className: "flex min-h-[400px] items-center justify-center",
88
- children: /* @__PURE__ */ x("div", { className: "size-8 animate-spin rounded-full border-4 border-primary border-t-transparent" })
89
- }) : P.isBillingAdmin ? N ? /* @__PURE__ */ S("div", {
90
- className: "space-y-6 p-6",
88
+ children: /* @__PURE__ */ b("div", { className: "size-8 animate-spin rounded-full border-4 border-primary border-t-transparent" })
89
+ }) : P.isBillingAdmin ? N ? /* @__PURE__ */ x("div", {
90
+ className: D ? "space-y-6" : "space-y-6 p-6",
91
91
  children: [
92
- /* @__PURE__ */ x(n, {
92
+ D ? null : /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b(n, {
93
93
  title: "Team & Permissions",
94
94
  description: "Control who can manage this billing account and what they can do."
95
- }),
96
- /* @__PURE__ */ x(b, { children: "Decide who on your team can see and manage this billing account. Assign the Billing Admin role (full access) or Billing Viewer (read-only) to specific people, and revoke access when someone no longer needs it." }),
97
- /* @__PURE__ */ S("div", {
95
+ }), /* @__PURE__ */ b(v, { children: "Decide who on your team can see and manage this billing account. Assign the Billing Admin role (full access) or Billing Viewer (read-only) to specific people, and revoke access when someone no longer needs it." })] }),
96
+ /* @__PURE__ */ x("div", {
98
97
  className: "rounded-lg border border-border-subtle bg-bg-surface p-4 text-sm",
99
98
  children: [
100
- /* @__PURE__ */ x("span", {
99
+ /* @__PURE__ */ b("span", {
101
100
  className: "font-medium text-text-primary",
102
101
  children: "Billing account:"
103
102
  }),
104
103
  " ",
105
- /* @__PURE__ */ x("span", {
104
+ /* @__PURE__ */ b("span", {
106
105
  className: "text-text-primary",
107
- children: ie ?? "Unnamed account"
106
+ children: oe ?? "Unnamed account"
108
107
  }),
109
- N ? /* @__PURE__ */ S("details", {
108
+ N ? /* @__PURE__ */ x("details", {
110
109
  className: "mt-2 text-xs text-text-secondary",
111
- children: [/* @__PURE__ */ x("summary", {
110
+ children: [/* @__PURE__ */ b("summary", {
112
111
  className: "cursor-pointer",
113
112
  children: "Account ID"
114
- }), /* @__PURE__ */ x("span", {
113
+ }), /* @__PURE__ */ b("span", {
115
114
  className: "mt-1 inline-block font-mono",
116
115
  children: N
117
116
  })]
118
117
  }) : null
119
118
  ]
120
119
  }),
121
- V && /* @__PURE__ */ x("div", {
120
+ V && /* @__PURE__ */ b("div", {
122
121
  className: "rounded-lg border border-status-error-border/30 bg-status-error-bg/5 p-4 text-sm text-status-error-text",
123
122
  children: V
124
123
  }),
125
- /* @__PURE__ */ S("form", {
126
- onSubmit: (e) => void ae(e),
124
+ /* @__PURE__ */ x("form", {
125
+ onSubmit: (e) => void se(e),
127
126
  className: "rounded-lg border border-border-subtle bg-bg-surface p-4 space-y-3",
128
127
  children: [
129
- /* @__PURE__ */ x("h3", {
128
+ /* @__PURE__ */ b("h3", {
130
129
  className: "text-sm font-semibold text-text-primary",
131
130
  children: "Add member"
132
131
  }),
133
- /* @__PURE__ */ S("div", {
132
+ /* @__PURE__ */ x("div", {
134
133
  className: "grid grid-cols-1 gap-3 md:grid-cols-3",
135
- children: [/* @__PURE__ */ S("div", {
134
+ children: [/* @__PURE__ */ x("div", {
136
135
  className: "md:col-span-2",
137
136
  children: [
138
- /* @__PURE__ */ x("label", {
137
+ /* @__PURE__ */ b("label", {
139
138
  htmlFor: "newActorId",
140
139
  className: "block text-xs font-medium text-text-secondary",
141
140
  children: "User ID"
142
141
  }),
143
- /* @__PURE__ */ x("input", {
142
+ /* @__PURE__ */ b("input", {
144
143
  id: "newActorId",
145
144
  type: "text",
146
145
  value: U,
@@ -149,28 +148,28 @@ var C = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, w = "
149
148
  className: "mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm",
150
149
  required: !0
151
150
  }),
152
- /* @__PURE__ */ x("p", {
151
+ /* @__PURE__ */ b("p", {
153
152
  className: "mt-1 text-[11px] text-text-secondary",
154
153
  children: "Find this on the user's profile page."
155
154
  })
156
155
  ]
157
- }), /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
156
+ }), /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("label", {
158
157
  htmlFor: "newRoleId",
159
158
  className: "block text-xs font-medium text-text-secondary",
160
159
  children: "Role"
161
- }), /* @__PURE__ */ x("select", {
160
+ }), /* @__PURE__ */ b("select", {
162
161
  id: "newRoleId",
163
162
  value: G,
164
163
  onChange: (e) => K(e.target.value),
165
164
  className: "mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary",
166
165
  required: !0,
167
- children: F.map((e) => /* @__PURE__ */ x("option", {
166
+ children: F.map((e) => /* @__PURE__ */ b("option", {
168
167
  value: e.id,
169
168
  children: e.name
170
169
  }, e.id))
171
170
  })] })]
172
171
  }),
173
- /* @__PURE__ */ x("button", {
172
+ /* @__PURE__ */ b("button", {
174
173
  type: "submit",
175
174
  disabled: q || !U.trim() || !G,
176
175
  className: "rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text disabled:opacity-50",
@@ -178,52 +177,52 @@ var C = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, w = "
178
177
  })
179
178
  ]
180
179
  }),
181
- /* @__PURE__ */ S("div", {
180
+ /* @__PURE__ */ x("div", {
182
181
  className: "rounded-lg border border-border-subtle bg-bg-surface",
183
- children: [/* @__PURE__ */ S("div", {
182
+ children: [/* @__PURE__ */ x("div", {
184
183
  className: "border-b border-border-subtle px-4 py-3",
185
- children: [/* @__PURE__ */ x("h3", {
184
+ children: [/* @__PURE__ */ b("h3", {
186
185
  className: "text-sm font-semibold text-text-primary",
187
186
  children: "Members"
188
- }), /* @__PURE__ */ x("p", {
187
+ }), /* @__PURE__ */ b("p", {
189
188
  className: "text-xs text-text-secondary",
190
189
  children: "Each member's role applies only to this billing account."
191
190
  })]
192
- }), z ? /* @__PURE__ */ x("div", {
191
+ }), z ? /* @__PURE__ */ b("div", {
193
192
  className: "p-6 text-sm text-text-secondary",
194
193
  children: "Loading…"
195
- }) : $.length === 0 ? /* @__PURE__ */ x("div", {
194
+ }) : $.length === 0 ? /* @__PURE__ */ b("div", {
196
195
  className: "p-6 text-sm text-text-secondary",
197
196
  children: "No members assigned yet."
198
- }) : /* @__PURE__ */ S("table", {
197
+ }) : /* @__PURE__ */ x("table", {
199
198
  className: "w-full text-sm",
200
- children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", {
199
+ children: [/* @__PURE__ */ b("thead", { children: /* @__PURE__ */ x("tr", {
201
200
  className: "border-b border-border-subtle text-left text-xs text-text-secondary",
202
201
  children: [
203
- /* @__PURE__ */ x("th", {
202
+ /* @__PURE__ */ b("th", {
204
203
  className: "px-4 py-2",
205
204
  children: "Member"
206
205
  }),
207
- /* @__PURE__ */ x("th", {
206
+ /* @__PURE__ */ b("th", {
208
207
  className: "px-4 py-2",
209
208
  children: "Type"
210
209
  }),
211
- /* @__PURE__ */ x("th", {
210
+ /* @__PURE__ */ b("th", {
212
211
  className: "px-4 py-2",
213
212
  children: "Roles"
214
213
  }),
215
- /* @__PURE__ */ x("th", {
214
+ /* @__PURE__ */ b("th", {
216
215
  className: "px-4 py-2 text-right",
217
216
  children: "Actions"
218
217
  })
219
218
  ]
220
- }) }), /* @__PURE__ */ x("tbody", { children: $.map((e) => /* @__PURE__ */ S("tr", {
219
+ }) }), /* @__PURE__ */ b("tbody", { children: $.map((e) => /* @__PURE__ */ x("tr", {
221
220
  className: "border-b border-border-subtle last:border-0",
222
221
  children: [
223
- /* @__PURE__ */ x("td", {
222
+ /* @__PURE__ */ b("td", {
224
223
  className: "px-4 py-3",
225
- children: /* @__PURE__ */ x(r, {
226
- profile: re[e.actorId] ?? {
224
+ children: /* @__PURE__ */ b(r, {
225
+ profile: ae[e.actorId] ?? {
227
226
  actorId: e.actorId,
228
227
  actorType: e.actorType,
229
228
  displayName: e.actorType.toLowerCase() === "user" ? `User ${e.actorId.slice(0, 8)}…` : e.actorType,
@@ -233,17 +232,17 @@ var C = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, w = "
233
232
  variant: "cell"
234
233
  })
235
234
  }),
236
- /* @__PURE__ */ x("td", {
235
+ /* @__PURE__ */ b("td", {
237
236
  className: "px-4 py-3 text-xs capitalize text-text-secondary",
238
237
  children: e.actorType.toLowerCase()
239
238
  }),
240
- /* @__PURE__ */ x("td", {
239
+ /* @__PURE__ */ b("td", {
241
240
  className: "px-4 py-3",
242
- children: /* @__PURE__ */ x("div", {
241
+ children: /* @__PURE__ */ b("div", {
243
242
  className: "flex flex-wrap gap-1",
244
- children: e.roleAssignments.filter((e) => e.isActive).map((e) => /* @__PURE__ */ S("span", {
243
+ children: e.roleAssignments.filter((e) => e.isActive).map((e) => /* @__PURE__ */ x("span", {
245
244
  className: "inline-flex items-center gap-1 rounded-full border border-border-subtle bg-bg-sunken px-2 py-0.5 text-xs",
246
- children: [e.role?.name ?? e.roleId, /* @__PURE__ */ x("button", {
245
+ children: [e.role?.name ?? e.roleId, /* @__PURE__ */ b("button", {
247
246
  type: "button",
248
247
  onClick: () => X(e.id),
249
248
  className: "text-text-secondary hover:text-status-error-text",
@@ -253,9 +252,9 @@ var C = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, w = "
253
252
  }, e.id))
254
253
  })
255
254
  }),
256
- /* @__PURE__ */ x("td", {
255
+ /* @__PURE__ */ b("td", {
257
256
  className: "px-4 py-3 text-right",
258
- children: /* @__PURE__ */ S("span", {
257
+ children: /* @__PURE__ */ x("span", {
259
258
  className: "text-xs text-text-secondary",
260
259
  children: [e.effectivePermissionCount ?? "—", " permissions"]
261
260
  })
@@ -264,31 +263,31 @@ var C = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, w = "
264
263
  }, e.actorId)) })]
265
264
  })]
266
265
  }),
267
- /* @__PURE__ */ S("div", {
266
+ /* @__PURE__ */ x("div", {
268
267
  className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
269
268
  children: [
270
- /* @__PURE__ */ x("h3", {
269
+ /* @__PURE__ */ b("h3", {
271
270
  className: "text-sm font-semibold text-text-primary",
272
271
  children: "Available roles"
273
272
  }),
274
- /* @__PURE__ */ x("p", {
273
+ /* @__PURE__ */ b("p", {
275
274
  className: "mt-1 text-xs text-text-secondary",
276
275
  children: "Roles are cloned from the system templates when a billing account is created."
277
276
  }),
278
- /* @__PURE__ */ x("ul", {
277
+ /* @__PURE__ */ b("ul", {
279
278
  className: "mt-3 space-y-2",
280
- children: F.map((e) => /* @__PURE__ */ S("li", {
279
+ children: F.map((e) => /* @__PURE__ */ x("li", {
281
280
  className: "flex items-start gap-3 rounded-md border border-border-subtle bg-bg-surface p-3",
282
- children: [/* @__PURE__ */ S("div", {
281
+ children: [/* @__PURE__ */ x("div", {
283
282
  className: "flex-1",
284
- children: [/* @__PURE__ */ x("div", {
283
+ children: [/* @__PURE__ */ b("div", {
285
284
  className: "text-sm font-medium text-text-primary",
286
285
  children: e.name
287
- }), e.description && /* @__PURE__ */ x("p", {
286
+ }), e.description && /* @__PURE__ */ b("p", {
288
287
  className: "mt-1 text-xs text-text-secondary",
289
288
  children: e.description
290
289
  })]
291
- }), /* @__PURE__ */ S("span", {
290
+ }), /* @__PURE__ */ x("span", {
292
291
  className: "text-xs text-text-secondary",
293
292
  children: ["priority ", e.priority]
294
293
  })]
@@ -296,32 +295,32 @@ var C = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, w = "
296
295
  })
297
296
  ]
298
297
  }),
299
- /* @__PURE__ */ x(p, {
298
+ /* @__PURE__ */ b(p, {
300
299
  open: Y !== null,
301
300
  onOpenChange: (e) => {
302
301
  e || X(null);
303
302
  },
304
- children: /* @__PURE__ */ S(g, { children: [/* @__PURE__ */ S(te, { children: [/* @__PURE__ */ x(v, { children: "Remove role assignment?" }), /* @__PURE__ */ x(_, { children: "Remove this role assignment? The member will lose the access this role grants for this billing account." })] }), /* @__PURE__ */ S(ee, { children: [/* @__PURE__ */ x(h, { children: "Cancel" }), /* @__PURE__ */ x(m, {
303
+ children: /* @__PURE__ */ x(g, { children: [/* @__PURE__ */ x(ne, { children: [/* @__PURE__ */ b(_, { children: "Remove role assignment?" }), /* @__PURE__ */ b(ee, { children: "Remove this role assignment? The member will lose the access this role grants for this billing account." })] }), /* @__PURE__ */ x(te, { children: [/* @__PURE__ */ b(h, { children: "Cancel" }), /* @__PURE__ */ b(m, {
305
304
  onClick: () => {
306
305
  let e = Y;
307
- X(null), e && oe(e);
306
+ X(null), e && ce(e);
308
307
  },
309
308
  children: "Remove"
310
309
  })] })] })
311
310
  })
312
311
  ]
313
- }) : /* @__PURE__ */ S("div", {
312
+ }) : D ? null : /* @__PURE__ */ x("div", {
314
313
  className: "space-y-6 p-6",
315
- children: [/* @__PURE__ */ x(n, {
314
+ children: [/* @__PURE__ */ b(n, {
316
315
  title: "Team & Permissions",
317
316
  description: "Select a billing account to manage who can access it."
318
- }), /* @__PURE__ */ x(y, {
317
+ }), /* @__PURE__ */ b(re, {
319
318
  illustration: "empty-people",
320
319
  title: "No billing account selected",
321
320
  description: "Pick one from the billing account selector to manage its members and roles."
322
321
  })]
323
- }) : /* @__PURE__ */ x(t, { message: "You don't have permission to manage team and permissions for this billing account." });
322
+ }) : D ? null : /* @__PURE__ */ b(t, { message: "You don't have permission to manage team and permissions for this billing account." });
324
323
  };
325
- export { O as TeamPermissionsPage };
324
+ export { D as TeamPermissionsPage };
326
325
 
327
326
  //# sourceMappingURL=TeamPermissionsPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TeamPermissionsPage.js","names":["UUID_RE","ROLES_QUERY","ACTORS_QUERY","ASSIGN_ROLE_MUTATION","REMOVE_ROLE_MUTATION","TeamPermissionsPage","useBilling","useBillingAccounts","useBillingAccountSelection","billingAccountId","selectedAccountId","permissions","useBillingPermissions","roles","setRoles","useState","actors","setActors","isLoading","setIsLoading","error","setError","newActorId","setNewActorId","newRoleId","setNewRoleId","isAdding","setIsAdding","removeAssignmentId","setRemoveAssignmentId","gqlPost","useCallback","directBillingGraphqlRequest","apiGatewayUrl","authToken","orgId","loadData","rolesResp","actorsResp","viewer","r","err","sortedActors","useMemo","priA","a","ra","b","profileInputs","profileMap","useActorProfiles","billingAccountName","billingAccounts","acct","handleAddMember","trimmedActorId","handleRemoveAssignment","PageHeader","PagePurpose","ActorIdentity","actor","AlertDialog","open","AlertDialogContent","AlertDialogHeader","AlertDialogTitle","AlertDialogDescription","AlertDialogFooter","AlertDialogCancel","AlertDialogAction","id","IllustratedEmptyState","AccessDenied"],"sources":["../../../../../src/billing/modules/settings/pages/TeamPermissionsPage.tsx"],"sourcesContent":["/**\n * Settings Module - Team & Permissions Page\n *\n * Lets a Billing Admin manage billing-scope role assignments for a specific\n * billing account. Calls global-rbac-svc directly via the same gateway URL\n * used by the rest of the billing module.\n *\n * Scope: `scopeType: \"billing\"`, `scopeId: <billingAccountId>`\n * Roles cloned per billing account at creation time:\n * - Billing Admin (full access to this billing account)\n * - Billing Viewer (read-only access to this billing account)\n */\nimport { useCallback, useEffect, useMemo, useState, type FC } from 'react';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n PagePurpose,\n IllustratedEmptyState,\n} from '@burdenoff/fe-libs/ui';\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { AccessDenied, ActorIdentity, PageHeader } from '../../../shared/components';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useBillingAccountSelection } from '../../../hooks/useBillingAccountSelection';\nimport { useBillingAccounts } from '../../dashboard/hooks/useDashboard';\nimport { directBillingGraphqlRequest } from '../../../shared/utils';\nimport { useActorProfiles } from '../../../shared/hooks';\n\n// Basic UUID-v1-through-v5 shape — accept any 8-4-4-4-12 hex pattern.\n// We intentionally don't strictly validate the version nibble; the rbac\n// service is the authoritative ID validator.\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\ninterface Role {\n id: string;\n name: string;\n description?: string | null;\n priority: number;\n isSystem: boolean;\n}\n\ninterface ActorRoleAssignment {\n id: string;\n actorId: string;\n actorType: string;\n roleId: string;\n scopeId: string;\n isActive: boolean;\n expiresAt?: string | null;\n role?: Role;\n}\n\ninterface ActorRbacSummary {\n actorId: string;\n actorType: string;\n roleAssignments: ActorRoleAssignment[];\n effectivePermissionCount?: number;\n}\n\nconst ROLES_QUERY = `\n query BillingScopeRoles($scopeId: String!) {\n roles(scopeId: $scopeId) {\n id\n name\n description\n priority\n isSystem\n }\n }\n`;\n\nconst ACTORS_QUERY = `\n query BillingScopeActors($scopeId: String!) {\n actors(scopeId: $scopeId) {\n actorId\n actorType\n roleAssignments {\n id\n actorId\n actorType\n roleId\n scopeId\n isActive\n expiresAt\n role { id name priority }\n }\n }\n }\n`;\n\nconst ASSIGN_ROLE_MUTATION = `\n mutation AssignBillingRole($input: AssignRoleInput!) {\n assignRoleToActor(input: $input) {\n id\n actorId\n roleId\n scopeId\n }\n }\n`;\n\nconst REMOVE_ROLE_MUTATION = `\n mutation RemoveBillingRole($assignmentId: String!) {\n removeRoleFromActor(assignmentId: $assignmentId)\n }\n`;\n\nexport const TeamPermissionsPage: FC = () => {\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n\n // Resolution priority: URL `?billingAccountId=` → persisted localStorage →\n // default/first available account. Pass `billingAccounts` so first-time\n // users with empty localStorage still land on the default account\n // (without it the hook's auto-select effect can't fire and the page\n // dead-ends on \"No billing account selected\").\n const { billingAccounts } = useBillingAccounts();\n const { selectedAccountId } = useBillingAccountSelection({\n orgId,\n billingAccounts,\n syncFromUrl: true,\n urlParamName: 'billingAccountId',\n });\n const billingAccountId = selectedAccountId ?? undefined;\n\n // Share the resolved account with `useBillingPermissions` so its\n // billing-scope permissions fetch observes the same ID. Without this,\n // a first-time user (no URL param, empty localStorage) would see the\n // page resolve to the default account here while the permissions hook\n // still sat at null — billing-scope-only admins would see AccessDenied\n // until a navigation/reload propagated the localStorage write.\n const permissions = useBillingPermissions({ billingAccountIdOverride: billingAccountId });\n\n const [roles, setRoles] = useState<Role[]>([]);\n const [actors, setActors] = useState<ActorRbacSummary[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n // Add-member form\n const [newActorId, setNewActorId] = useState('');\n const [newRoleId, setNewRoleId] = useState('');\n const [isAdding, setIsAdding] = useState(false);\n const [removeAssignmentId, setRemoveAssignmentId] = useState<string | null>(null);\n\n const gqlPost = useCallback(\n async <T,>(query: string, variables: Record<string, unknown>): Promise<T> => {\n return directBillingGraphqlRequest<T>({\n apiGatewayUrl,\n authToken,\n orgId,\n query,\n variables,\n });\n },\n [apiGatewayUrl, authToken, orgId]\n );\n\n const loadData = useCallback(async () => {\n if (!billingAccountId) return;\n setIsLoading(true);\n setError(null);\n try {\n const [rolesResp, actorsResp] = await Promise.all([\n gqlPost<{ roles: Role[] }>(ROLES_QUERY, { scopeId: billingAccountId }),\n gqlPost<{ actors: ActorRbacSummary[] }>(ACTORS_QUERY, {\n scopeId: billingAccountId,\n }),\n ]);\n setRoles(rolesResp.roles ?? []);\n setActors(actorsResp.actors ?? []);\n // Default the role-picker to \"Billing Viewer\" if available, else first role\n const viewer = (rolesResp.roles ?? []).find((r) => /viewer/i.test(r.name));\n setNewRoleId(viewer?.id ?? rolesResp.roles?.[0]?.id ?? '');\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to load team data');\n } finally {\n setIsLoading(false);\n }\n }, [billingAccountId, gqlPost]);\n\n useEffect(() => {\n void loadData();\n }, [loadData]);\n\n const sortedActors = useMemo(\n () =>\n [...actors].sort((a, b) => {\n const priA = Math.max(...a.roleAssignments.map((ra) => ra.role?.priority ?? 0), 0);\n const priB = Math.max(...b.roleAssignments.map((ra) => ra.role?.priority ?? 0), 0);\n return priB - priA;\n }),\n [actors]\n );\n\n const profileInputs = useMemo(\n () =>\n sortedActors.map((a) => ({\n actorId: a.actorId,\n actorType: a.actorType,\n })),\n [sortedActors]\n );\n const profileMap = useActorProfiles(profileInputs);\n\n const billingAccountName = useMemo(() => {\n if (!billingAccountId) return undefined;\n return billingAccounts.find((acct) => acct.id === billingAccountId)?.name ?? undefined;\n }, [billingAccountId, billingAccounts]);\n\n const handleAddMember = async (e: React.FormEvent) => {\n e.preventDefault();\n if (!billingAccountId || !newActorId.trim() || !newRoleId) return;\n const trimmedActorId = newActorId.trim();\n if (!UUID_RE.test(trimmedActorId)) {\n setError('User ID must be a UUID (e.g. 1a2b3c4d-...). Get it from the user profile page.');\n return;\n }\n setIsAdding(true);\n setError(null);\n try {\n await gqlPost(ASSIGN_ROLE_MUTATION, {\n input: {\n actorId: trimmedActorId,\n actorType: 'USER',\n roleId: newRoleId,\n scopeId: billingAccountId,\n },\n });\n setNewActorId('');\n await loadData();\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to assign role');\n } finally {\n setIsAdding(false);\n }\n };\n\n const handleRemoveAssignment = async (assignmentId: string) => {\n setError(null);\n try {\n await gqlPost(REMOVE_ROLE_MUTATION, { assignmentId });\n await loadData();\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to remove role');\n }\n };\n\n if (permissions.isLoading) {\n return (\n <div className=\"flex min-h-[400px] items-center justify-center\">\n <div className=\"size-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n }\n\n if (!permissions.isBillingAdmin) {\n return (\n <AccessDenied message=\"You don't have permission to manage team and permissions for this billing account.\" />\n );\n }\n\n if (!billingAccountId) {\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title=\"Team & Permissions\"\n description=\"Select a billing account to manage who can access it.\"\n />\n <IllustratedEmptyState\n illustration=\"empty-people\"\n title=\"No billing account selected\"\n description=\"Pick one from the billing account selector to manage its members and roles.\"\n />\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title=\"Team & Permissions\"\n description=\"Control who can manage this billing account and what they can do.\"\n />\n\n <PagePurpose>\n Decide who on your team can see and manage this billing account. Assign the Billing Admin\n role (full access) or Billing Viewer (read-only) to specific people, and revoke access when\n someone no longer needs it.\n </PagePurpose>\n\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 text-sm\">\n <span className=\"font-medium text-text-primary\">Billing account:</span>{' '}\n <span className=\"text-text-primary\">{billingAccountName ?? 'Unnamed account'}</span>\n {billingAccountId ? (\n <details className=\"mt-2 text-xs text-text-secondary\">\n <summary className=\"cursor-pointer\">Account ID</summary>\n <span className=\"mt-1 inline-block font-mono\">{billingAccountId}</span>\n </details>\n ) : null}\n </div>\n\n {error && (\n <div className=\"rounded-lg border border-status-error-border/30 bg-status-error-bg/5 p-4 text-sm text-status-error-text\">\n {error}\n </div>\n )}\n\n {/* Add member form */}\n <form\n onSubmit={(e) => void handleAddMember(e)}\n className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 space-y-3\"\n >\n <h3 className=\"text-sm font-semibold text-text-primary\">Add member</h3>\n <div className=\"grid grid-cols-1 gap-3 md:grid-cols-3\">\n <div className=\"md:col-span-2\">\n <label htmlFor=\"newActorId\" className=\"block text-xs font-medium text-text-secondary\">\n User ID\n </label>\n <input\n id=\"newActorId\"\n type=\"text\"\n value={newActorId}\n onChange={(e) => setNewActorId(e.target.value)}\n placeholder=\"Paste the user ID from their profile page\"\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm\"\n required\n />\n <p className=\"mt-1 text-[11px] text-text-secondary\">\n Find this on the user&apos;s profile page.\n </p>\n </div>\n <div>\n <label htmlFor=\"newRoleId\" className=\"block text-xs font-medium text-text-secondary\">\n Role\n </label>\n <select\n id=\"newRoleId\"\n value={newRoleId}\n onChange={(e) => setNewRoleId(e.target.value)}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n required\n >\n {roles.map((r) => (\n <option key={r.id} value={r.id}>\n {r.name}\n </option>\n ))}\n </select>\n </div>\n </div>\n <button\n type=\"submit\"\n disabled={isAdding || !newActorId.trim() || !newRoleId}\n className=\"rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text disabled:opacity-50\"\n >\n {isAdding ? 'Adding…' : 'Add member'}\n </button>\n </form>\n\n {/* Members table */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface\">\n <div className=\"border-b border-border-subtle px-4 py-3\">\n <h3 className=\"text-sm font-semibold text-text-primary\">Members</h3>\n <p className=\"text-xs text-text-secondary\">\n Each member&apos;s role applies only to this billing account.\n </p>\n </div>\n {isLoading ? (\n <div className=\"p-6 text-sm text-text-secondary\">Loading…</div>\n ) : sortedActors.length === 0 ? (\n <div className=\"p-6 text-sm text-text-secondary\">No members assigned yet.</div>\n ) : (\n <table className=\"w-full text-sm\">\n <thead>\n <tr className=\"border-b border-border-subtle text-left text-xs text-text-secondary\">\n <th className=\"px-4 py-2\">Member</th>\n <th className=\"px-4 py-2\">Type</th>\n <th className=\"px-4 py-2\">Roles</th>\n <th className=\"px-4 py-2 text-right\">Actions</th>\n </tr>\n </thead>\n <tbody>\n {sortedActors.map((actor) => (\n <tr key={actor.actorId} className=\"border-b border-border-subtle last:border-0\">\n <td className=\"px-4 py-3\">\n <ActorIdentity\n profile={\n profileMap[actor.actorId] ?? {\n actorId: actor.actorId,\n actorType: actor.actorType,\n displayName:\n actor.actorType.toLowerCase() === 'user'\n ? `User ${actor.actorId.slice(0, 8)}…`\n : actor.actorType,\n secondaryLabel: actor.actorId.slice(0, 12),\n resolved: false,\n }\n }\n variant=\"cell\"\n />\n </td>\n <td className=\"px-4 py-3 text-xs capitalize text-text-secondary\">\n {actor.actorType.toLowerCase()}\n </td>\n <td className=\"px-4 py-3\">\n <div className=\"flex flex-wrap gap-1\">\n {actor.roleAssignments\n .filter((ra) => ra.isActive)\n .map((ra) => (\n <span\n key={ra.id}\n className=\"inline-flex items-center gap-1 rounded-full border border-border-subtle bg-bg-sunken px-2 py-0.5 text-xs\"\n >\n {ra.role?.name ?? ra.roleId}\n <button\n type=\"button\"\n onClick={() => setRemoveAssignmentId(ra.id)}\n className=\"text-text-secondary hover:text-status-error-text\"\n aria-label={`Remove ${ra.role?.name ?? 'role'}`}\n >\n ×\n </button>\n </span>\n ))}\n </div>\n </td>\n <td className=\"px-4 py-3 text-right\">\n <span className=\"text-xs text-text-secondary\">\n {actor.effectivePermissionCount ?? '—'} permissions\n </span>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n )}\n </div>\n\n {/* Roles reference */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h3 className=\"text-sm font-semibold text-text-primary\">Available roles</h3>\n <p className=\"mt-1 text-xs text-text-secondary\">\n Roles are cloned from the system templates when a billing account is created.\n </p>\n <ul className=\"mt-3 space-y-2\">\n {roles.map((r) => (\n <li\n key={r.id}\n className=\"flex items-start gap-3 rounded-md border border-border-subtle bg-bg-surface p-3\"\n >\n <div className=\"flex-1\">\n <div className=\"text-sm font-medium text-text-primary\">{r.name}</div>\n {r.description && (\n <p className=\"mt-1 text-xs text-text-secondary\">{r.description}</p>\n )}\n </div>\n <span className=\"text-xs text-text-secondary\">priority {r.priority}</span>\n </li>\n ))}\n </ul>\n </div>\n\n <AlertDialog\n open={removeAssignmentId !== null}\n onOpenChange={(open) => {\n if (!open) setRemoveAssignmentId(null);\n }}\n >\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Remove role assignment?</AlertDialogTitle>\n <AlertDialogDescription>\n Remove this role assignment? The member will lose the access this role grants for this\n billing account.\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>Cancel</AlertDialogCancel>\n <AlertDialogAction\n onClick={() => {\n const id = removeAssignmentId;\n setRemoveAssignmentId(null);\n if (id) void handleRemoveAssignment(id);\n }}\n >\n Remove\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </div>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ACC,GAAD;KACE,eAAe;MACb,IAAMC,IAAK1C;MAEX,AADAC,EAAsB,IAAI,GACtByC,KAAId,GAA4Bc,CAAE;KACxC;KACD,UAAA;IAEkB,CAAA,CACF,EAAA,CAAA,CACD,EAAA,CAAA;GACT,CAAA;EACV;C,KAnOH,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACb,GAAD;GACE,OAAM;GACN,aAAY;EACb,CAAA,GACD,kBAACc,GAAD;GACE,cAAa;GACb,OAAM;GACN,aAAY;EACb,CAAA,CACE;C,KAhBL,kBAACC,GAAD,EAAc,SAAQ,qFAAsF,CAAA;AA2OlH"}
1
+ {"version":3,"file":"TeamPermissionsPage.js","names":["_Fragment","Fragment$1","UUID_RE","ROLES_QUERY","ACTORS_QUERY","ASSIGN_ROLE_MUTATION","REMOVE_ROLE_MUTATION","TeamPermissionsPage","useBilling","useBillingAccounts","useBillingAccountSelection","billingAccountId","selectedAccountId","permissions","useBillingPermissions","roles","setRoles","useState","actors","setActors","isLoading","setIsLoading","error","setError","newActorId","setNewActorId","newRoleId","setNewRoleId","isAdding","setIsAdding","removeAssignmentId","setRemoveAssignmentId","gqlPost","useCallback","directBillingGraphqlRequest","apiGatewayUrl","authToken","orgId","loadData","rolesResp","actorsResp","viewer","r","err","sortedActors","useMemo","priA","a","ra","b","profileInputs","profileMap","useActorProfiles","billingAccountName","billingAccounts","acct","handleAddMember","trimmedActorId","handleRemoveAssignment","embedded","PageHeader","PagePurpose","ActorIdentity","actor","AlertDialog","open","AlertDialogContent","AlertDialogHeader","AlertDialogTitle","AlertDialogDescription","AlertDialogFooter","AlertDialogCancel","AlertDialogAction","id","IllustratedEmptyState","AccessDenied"],"sources":["../../../../../src/billing/modules/settings/pages/TeamPermissionsPage.tsx"],"sourcesContent":["/**\n * Settings Module - Team & Permissions Page\n *\n * Lets a Billing Admin manage billing-scope role assignments for a specific\n * billing account. Calls global-rbac-svc directly via the same gateway URL\n * used by the rest of the billing module.\n *\n * Scope: `scopeType: \"billing\"`, `scopeId: <billingAccountId>`\n * Roles cloned per billing account at creation time:\n * - Billing Admin (full access to this billing account)\n * - Billing Viewer (read-only access to this billing account)\n */\nimport { useCallback, useEffect, useMemo, useState, type FC } from 'react';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n PagePurpose,\n IllustratedEmptyState,\n} from '@burdenoff/fe-libs/ui';\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { AccessDenied, ActorIdentity, PageHeader } from '../../../shared/components';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useBillingAccountSelection } from '../../../hooks/useBillingAccountSelection';\nimport { useBillingAccounts } from '../../dashboard/hooks/useDashboard';\nimport { directBillingGraphqlRequest } from '../../../shared/utils';\nimport { useActorProfiles } from '../../../shared/hooks';\n\n// Basic UUID-v1-through-v5 shape — accept any 8-4-4-4-12 hex pattern.\n// We intentionally don't strictly validate the version nibble; the rbac\n// service is the authoritative ID validator.\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\ninterface Role {\n id: string;\n name: string;\n description?: string | null;\n priority: number;\n isSystem: boolean;\n}\n\ninterface ActorRoleAssignment {\n id: string;\n actorId: string;\n actorType: string;\n roleId: string;\n scopeId: string;\n isActive: boolean;\n expiresAt?: string | null;\n role?: Role;\n}\n\ninterface ActorRbacSummary {\n actorId: string;\n actorType: string;\n roleAssignments: ActorRoleAssignment[];\n effectivePermissionCount?: number;\n}\n\nconst ROLES_QUERY = `\n query BillingScopeRoles($scopeId: String!) {\n roles(scopeId: $scopeId) {\n id\n name\n description\n priority\n isSystem\n }\n }\n`;\n\nconst ACTORS_QUERY = `\n query BillingScopeActors($scopeId: String!) {\n actors(scopeId: $scopeId) {\n actorId\n actorType\n roleAssignments {\n id\n actorId\n actorType\n roleId\n scopeId\n isActive\n expiresAt\n role { id name priority }\n }\n }\n }\n`;\n\nconst ASSIGN_ROLE_MUTATION = `\n mutation AssignBillingRole($input: AssignRoleInput!) {\n assignRoleToActor(input: $input) {\n id\n actorId\n roleId\n scopeId\n }\n }\n`;\n\nconst REMOVE_ROLE_MUTATION = `\n mutation RemoveBillingRole($assignmentId: String!) {\n removeRoleFromActor(assignmentId: $assignmentId)\n }\n`;\n\ninterface TeamPermissionsPageProps {\n /** Rendered inside the Settings page: no page header or outer padding, and silent when not allowed. */\n embedded?: boolean;\n}\n\nexport const TeamPermissionsPage: FC<TeamPermissionsPageProps> = ({ embedded = false }) => {\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n\n // Resolution priority: URL `?billingAccountId=` → persisted localStorage →\n // default/first available account. Pass `billingAccounts` so first-time\n // users with empty localStorage still land on the default account\n // (without it the hook's auto-select effect can't fire and the page\n // dead-ends on \"No billing account selected\").\n const { billingAccounts } = useBillingAccounts();\n const { selectedAccountId } = useBillingAccountSelection({\n orgId,\n billingAccounts,\n syncFromUrl: true,\n urlParamName: 'billingAccountId',\n });\n const billingAccountId = selectedAccountId ?? undefined;\n\n // Share the resolved account with `useBillingPermissions` so its\n // billing-scope permissions fetch observes the same ID. Without this,\n // a first-time user (no URL param, empty localStorage) would see the\n // page resolve to the default account here while the permissions hook\n // still sat at null — billing-scope-only admins would see AccessDenied\n // until a navigation/reload propagated the localStorage write.\n const permissions = useBillingPermissions({ billingAccountIdOverride: billingAccountId });\n\n const [roles, setRoles] = useState<Role[]>([]);\n const [actors, setActors] = useState<ActorRbacSummary[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n // Add-member form\n const [newActorId, setNewActorId] = useState('');\n const [newRoleId, setNewRoleId] = useState('');\n const [isAdding, setIsAdding] = useState(false);\n const [removeAssignmentId, setRemoveAssignmentId] = useState<string | null>(null);\n\n const gqlPost = useCallback(\n async <T,>(query: string, variables: Record<string, unknown>): Promise<T> => {\n return directBillingGraphqlRequest<T>({\n apiGatewayUrl,\n authToken,\n orgId,\n query,\n variables,\n });\n },\n [apiGatewayUrl, authToken, orgId]\n );\n\n const loadData = useCallback(async () => {\n if (!billingAccountId) return;\n setIsLoading(true);\n setError(null);\n try {\n const [rolesResp, actorsResp] = await Promise.all([\n gqlPost<{ roles: Role[] }>(ROLES_QUERY, { scopeId: billingAccountId }),\n gqlPost<{ actors: ActorRbacSummary[] }>(ACTORS_QUERY, {\n scopeId: billingAccountId,\n }),\n ]);\n setRoles(rolesResp.roles ?? []);\n setActors(actorsResp.actors ?? []);\n // Default the role-picker to \"Billing Viewer\" if available, else first role\n const viewer = (rolesResp.roles ?? []).find((r) => /viewer/i.test(r.name));\n setNewRoleId(viewer?.id ?? rolesResp.roles?.[0]?.id ?? '');\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to load team data');\n } finally {\n setIsLoading(false);\n }\n }, [billingAccountId, gqlPost]);\n\n useEffect(() => {\n void loadData();\n }, [loadData]);\n\n const sortedActors = useMemo(\n () =>\n [...actors].sort((a, b) => {\n const priA = Math.max(...a.roleAssignments.map((ra) => ra.role?.priority ?? 0), 0);\n const priB = Math.max(...b.roleAssignments.map((ra) => ra.role?.priority ?? 0), 0);\n return priB - priA;\n }),\n [actors]\n );\n\n const profileInputs = useMemo(\n () =>\n sortedActors.map((a) => ({\n actorId: a.actorId,\n actorType: a.actorType,\n })),\n [sortedActors]\n );\n const profileMap = useActorProfiles(profileInputs);\n\n const billingAccountName = useMemo(() => {\n if (!billingAccountId) return undefined;\n return billingAccounts.find((acct) => acct.id === billingAccountId)?.name ?? undefined;\n }, [billingAccountId, billingAccounts]);\n\n const handleAddMember = async (e: React.FormEvent) => {\n e.preventDefault();\n if (!billingAccountId || !newActorId.trim() || !newRoleId) return;\n const trimmedActorId = newActorId.trim();\n if (!UUID_RE.test(trimmedActorId)) {\n setError('User ID must be a UUID (e.g. 1a2b3c4d-...). Get it from the user profile page.');\n return;\n }\n setIsAdding(true);\n setError(null);\n try {\n await gqlPost(ASSIGN_ROLE_MUTATION, {\n input: {\n actorId: trimmedActorId,\n actorType: 'USER',\n roleId: newRoleId,\n scopeId: billingAccountId,\n },\n });\n setNewActorId('');\n await loadData();\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to assign role');\n } finally {\n setIsAdding(false);\n }\n };\n\n const handleRemoveAssignment = async (assignmentId: string) => {\n setError(null);\n try {\n await gqlPost(REMOVE_ROLE_MUTATION, { assignmentId });\n await loadData();\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to remove role');\n }\n };\n\n if (permissions.isLoading) {\n return (\n <div className=\"flex min-h-[400px] items-center justify-center\">\n <div className=\"size-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n }\n\n if (!permissions.isBillingAdmin) {\n if (embedded) return null;\n return (\n <AccessDenied message=\"You don't have permission to manage team and permissions for this billing account.\" />\n );\n }\n\n if (!billingAccountId) {\n if (embedded) return null;\n return (\n <div className=\"space-y-6 p-6\">\n <PageHeader\n title=\"Team & Permissions\"\n description=\"Select a billing account to manage who can access it.\"\n />\n <IllustratedEmptyState\n illustration=\"empty-people\"\n title=\"No billing account selected\"\n description=\"Pick one from the billing account selector to manage its members and roles.\"\n />\n </div>\n );\n }\n\n return (\n <div className={embedded ? 'space-y-6' : 'space-y-6 p-6'}>\n {embedded ? null : (\n <>\n <PageHeader\n title=\"Team & Permissions\"\n description=\"Control who can manage this billing account and what they can do.\"\n />\n\n <PagePurpose>\n Decide who on your team can see and manage this billing account. Assign the Billing\n Admin role (full access) or Billing Viewer (read-only) to specific people, and revoke\n access when someone no longer needs it.\n </PagePurpose>\n </>\n )}\n\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 text-sm\">\n <span className=\"font-medium text-text-primary\">Billing account:</span>{' '}\n <span className=\"text-text-primary\">{billingAccountName ?? 'Unnamed account'}</span>\n {billingAccountId ? (\n <details className=\"mt-2 text-xs text-text-secondary\">\n <summary className=\"cursor-pointer\">Account ID</summary>\n <span className=\"mt-1 inline-block font-mono\">{billingAccountId}</span>\n </details>\n ) : null}\n </div>\n\n {error && (\n <div className=\"rounded-lg border border-status-error-border/30 bg-status-error-bg/5 p-4 text-sm text-status-error-text\">\n {error}\n </div>\n )}\n\n {/* Add member form */}\n <form\n onSubmit={(e) => void handleAddMember(e)}\n className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 space-y-3\"\n >\n <h3 className=\"text-sm font-semibold text-text-primary\">Add member</h3>\n <div className=\"grid grid-cols-1 gap-3 md:grid-cols-3\">\n <div className=\"md:col-span-2\">\n <label htmlFor=\"newActorId\" className=\"block text-xs font-medium text-text-secondary\">\n User ID\n </label>\n <input\n id=\"newActorId\"\n type=\"text\"\n value={newActorId}\n onChange={(e) => setNewActorId(e.target.value)}\n placeholder=\"Paste the user ID from their profile page\"\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm\"\n required\n />\n <p className=\"mt-1 text-[11px] text-text-secondary\">\n Find this on the user&apos;s profile page.\n </p>\n </div>\n <div>\n <label htmlFor=\"newRoleId\" className=\"block text-xs font-medium text-text-secondary\">\n Role\n </label>\n <select\n id=\"newRoleId\"\n value={newRoleId}\n onChange={(e) => setNewRoleId(e.target.value)}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n required\n >\n {roles.map((r) => (\n <option key={r.id} value={r.id}>\n {r.name}\n </option>\n ))}\n </select>\n </div>\n </div>\n <button\n type=\"submit\"\n disabled={isAdding || !newActorId.trim() || !newRoleId}\n className=\"rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text disabled:opacity-50\"\n >\n {isAdding ? 'Adding…' : 'Add member'}\n </button>\n </form>\n\n {/* Members table */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface\">\n <div className=\"border-b border-border-subtle px-4 py-3\">\n <h3 className=\"text-sm font-semibold text-text-primary\">Members</h3>\n <p className=\"text-xs text-text-secondary\">\n Each member&apos;s role applies only to this billing account.\n </p>\n </div>\n {isLoading ? (\n <div className=\"p-6 text-sm text-text-secondary\">Loading…</div>\n ) : sortedActors.length === 0 ? (\n <div className=\"p-6 text-sm text-text-secondary\">No members assigned yet.</div>\n ) : (\n <table className=\"w-full text-sm\">\n <thead>\n <tr className=\"border-b border-border-subtle text-left text-xs text-text-secondary\">\n <th className=\"px-4 py-2\">Member</th>\n <th className=\"px-4 py-2\">Type</th>\n <th className=\"px-4 py-2\">Roles</th>\n <th className=\"px-4 py-2 text-right\">Actions</th>\n </tr>\n </thead>\n <tbody>\n {sortedActors.map((actor) => (\n <tr key={actor.actorId} className=\"border-b border-border-subtle last:border-0\">\n <td className=\"px-4 py-3\">\n <ActorIdentity\n profile={\n profileMap[actor.actorId] ?? {\n actorId: actor.actorId,\n actorType: actor.actorType,\n displayName:\n actor.actorType.toLowerCase() === 'user'\n ? `User ${actor.actorId.slice(0, 8)}…`\n : actor.actorType,\n secondaryLabel: actor.actorId.slice(0, 12),\n resolved: false,\n }\n }\n variant=\"cell\"\n />\n </td>\n <td className=\"px-4 py-3 text-xs capitalize text-text-secondary\">\n {actor.actorType.toLowerCase()}\n </td>\n <td className=\"px-4 py-3\">\n <div className=\"flex flex-wrap gap-1\">\n {actor.roleAssignments\n .filter((ra) => ra.isActive)\n .map((ra) => (\n <span\n key={ra.id}\n className=\"inline-flex items-center gap-1 rounded-full border border-border-subtle bg-bg-sunken px-2 py-0.5 text-xs\"\n >\n {ra.role?.name ?? ra.roleId}\n <button\n type=\"button\"\n onClick={() => setRemoveAssignmentId(ra.id)}\n className=\"text-text-secondary hover:text-status-error-text\"\n aria-label={`Remove ${ra.role?.name ?? 'role'}`}\n >\n ×\n </button>\n </span>\n ))}\n </div>\n </td>\n <td className=\"px-4 py-3 text-right\">\n <span className=\"text-xs text-text-secondary\">\n {actor.effectivePermissionCount ?? '—'} permissions\n </span>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n )}\n </div>\n\n {/* Roles reference */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h3 className=\"text-sm font-semibold text-text-primary\">Available roles</h3>\n <p className=\"mt-1 text-xs text-text-secondary\">\n Roles are cloned from the system templates when a billing account is created.\n </p>\n <ul className=\"mt-3 space-y-2\">\n {roles.map((r) => (\n <li\n key={r.id}\n className=\"flex items-start gap-3 rounded-md border border-border-subtle bg-bg-surface p-3\"\n >\n <div className=\"flex-1\">\n <div className=\"text-sm font-medium text-text-primary\">{r.name}</div>\n {r.description && (\n <p className=\"mt-1 text-xs text-text-secondary\">{r.description}</p>\n )}\n </div>\n <span className=\"text-xs text-text-secondary\">priority {r.priority}</span>\n </li>\n ))}\n </ul>\n </div>\n\n <AlertDialog\n open={removeAssignmentId !== null}\n onOpenChange={(open) => {\n if (!open) setRemoveAssignmentId(null);\n }}\n >\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Remove role assignment?</AlertDialogTitle>\n <AlertDialogDescription>\n Remove this role assignment? The member will lose the access this role grants for this\n billing account.\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel>Cancel</AlertDialogCancel>\n <AlertDialogAction\n onClick={() => {\n const id = removeAssignmentId;\n setRemoveAssignmentId(null);\n if (id) void handleRemoveAssignment(id);\n }}\n >\n Remove\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,IAAME,IAAU,mEA4BVC,IAAc,2KAYdC,IAAe,+TAmBfC,IAAuB,0KAWvBC,IAAuB,yHAWhBC,KAAqD,EAAE,cAAW,SAAY;CACzF,IAAM,EAAE,kBAAe,cAAW,aAAUC,EAAW,GAOjD,EAAE,uBAAoBC,EAAmB,GACzC,EAAE,yBAAsBC,EAA2B;EACvD;EACA;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