@sudobility/entity_pages 0.0.51 → 0.0.53
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.
- package/dist/index.esm.js +615 -215
- package/dist/index.umd.js +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsxs as t,
|
|
2
|
-
import * as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { Section as
|
|
5
|
-
import { EntityList as
|
|
6
|
-
import { useEntities as
|
|
7
|
-
function
|
|
8
|
-
title:
|
|
9
|
-
titleId:
|
|
10
|
-
...
|
|
11
|
-
},
|
|
12
|
-
return /* @__PURE__ */
|
|
1
|
+
import { jsx as e, jsxs as t, Fragment as R } from "react/jsx-runtime";
|
|
2
|
+
import * as M from "react";
|
|
3
|
+
import { useState as k } from "react";
|
|
4
|
+
import { Section as I } from "@sudobility/components";
|
|
5
|
+
import { EntityList as E, InvitationForm as K, InvitationList as S, MemberList as Y } from "@sudobility/entity-components";
|
|
6
|
+
import { useEntities as $, useCreateEntity as q, useEntityMembers as U, useUpdateMemberRole as B, useRemoveMember as G, useEntityInvitations as H, useCreateInvitation as J, useCancelInvitation as Q, useMyInvitations as V, useAcceptInvitation as X, useDeclineInvitation as Z } from "@sudobility/entity_client";
|
|
7
|
+
function _({
|
|
8
|
+
title: n,
|
|
9
|
+
titleId: a,
|
|
10
|
+
...l
|
|
11
|
+
}, r) {
|
|
12
|
+
return /* @__PURE__ */ M.createElement("svg", Object.assign({
|
|
13
13
|
xmlns: "http://www.w3.org/2000/svg",
|
|
14
14
|
fill: "none",
|
|
15
15
|
viewBox: "0 0 24 24",
|
|
@@ -17,288 +17,688 @@ function T({
|
|
|
17
17
|
stroke: "currentColor",
|
|
18
18
|
"aria-hidden": "true",
|
|
19
19
|
"data-slot": "icon",
|
|
20
|
-
ref:
|
|
21
|
-
"aria-labelledby":
|
|
22
|
-
},
|
|
23
|
-
id:
|
|
24
|
-
},
|
|
20
|
+
ref: r,
|
|
21
|
+
"aria-labelledby": a
|
|
22
|
+
}, l), n ? /* @__PURE__ */ M.createElement("title", {
|
|
23
|
+
id: a
|
|
24
|
+
}, n) : null, /* @__PURE__ */ M.createElement("path", {
|
|
25
25
|
strokeLinecap: "round",
|
|
26
26
|
strokeLinejoin: "round",
|
|
27
27
|
d: "M12 4.5v15m7.5-7.5h-15"
|
|
28
28
|
}));
|
|
29
29
|
}
|
|
30
|
-
const
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const ee = /* @__PURE__ */ M.forwardRef(_);
|
|
31
|
+
function te() {
|
|
32
|
+
return /* @__PURE__ */ t("div", { className: "space-y-3", role: "status", "aria-label": "Loading workspaces", children: [
|
|
33
|
+
[1, 2, 3].map((n) => /* @__PURE__ */ e(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
className: "h-16 sm:h-20 rounded-lg bg-muted animate-pulse"
|
|
37
|
+
},
|
|
38
|
+
n
|
|
39
|
+
)),
|
|
40
|
+
/* @__PURE__ */ e("span", { className: "sr-only", children: "Loading workspaces..." })
|
|
41
|
+
] });
|
|
42
|
+
}
|
|
43
|
+
function de({
|
|
44
|
+
client: n,
|
|
45
|
+
onSelectEntity: a
|
|
34
46
|
}) {
|
|
35
|
-
const [
|
|
47
|
+
const [l, r] = k(!1), [i, o] = k({
|
|
36
48
|
displayName: "",
|
|
37
49
|
description: ""
|
|
38
|
-
}), [
|
|
39
|
-
|
|
50
|
+
}), [g, m] = k(null), {
|
|
51
|
+
data: v = [],
|
|
52
|
+
isLoading: u,
|
|
53
|
+
isError: y,
|
|
54
|
+
error: x,
|
|
55
|
+
refetch: N
|
|
56
|
+
} = $(n), p = q(n), b = v.filter((s) => s.entityType === "personal"), c = v.filter(
|
|
57
|
+
(s) => s.entityType === "organization"
|
|
40
58
|
);
|
|
41
|
-
return /* @__PURE__ */
|
|
42
|
-
/* @__PURE__ */ t("div", { className: "flex items-center justify-between mb-8", children: [
|
|
59
|
+
return /* @__PURE__ */ e(I, { spacing: "lg", maxWidth: "4xl", children: /* @__PURE__ */ t("div", { role: "main", "aria-label": "Workspaces", children: [
|
|
60
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-6 sm:mb-8", children: [
|
|
43
61
|
/* @__PURE__ */ t("div", { children: [
|
|
44
|
-
/* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground", children: "Workspaces" }),
|
|
45
|
-
/* @__PURE__ */ e("p", { className: "text-muted-foreground", children: "Manage your personal and organization workspaces" })
|
|
62
|
+
/* @__PURE__ */ e("h1", { className: "text-xl sm:text-2xl font-bold text-foreground", children: "Workspaces" }),
|
|
63
|
+
/* @__PURE__ */ e("p", { className: "text-sm sm:text-base text-muted-foreground", children: "Manage your personal and organization workspaces" })
|
|
46
64
|
] }),
|
|
47
65
|
/* @__PURE__ */ t(
|
|
48
66
|
"button",
|
|
49
67
|
{
|
|
50
68
|
type: "button",
|
|
51
|
-
onClick: () =>
|
|
52
|
-
|
|
69
|
+
onClick: () => r(!0),
|
|
70
|
+
"aria-label": "Create new organization",
|
|
71
|
+
className: "flex items-center justify-center gap-2 px-4 py-2 rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 w-full sm:w-auto",
|
|
53
72
|
children: [
|
|
54
|
-
/* @__PURE__ */ e(
|
|
73
|
+
/* @__PURE__ */ e(ee, { className: "h-4 w-4", "aria-hidden": "true" }),
|
|
55
74
|
/* @__PURE__ */ e("span", { children: "New Organization" })
|
|
56
75
|
]
|
|
57
76
|
}
|
|
58
77
|
)
|
|
59
78
|
] }),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
/* @__PURE__ */ e("label", { className: "block text-sm font-medium mb-1", children: "Display Name" }),
|
|
78
|
-
/* @__PURE__ */ e(
|
|
79
|
-
"input",
|
|
79
|
+
l && /* @__PURE__ */ e(
|
|
80
|
+
"div",
|
|
81
|
+
{
|
|
82
|
+
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",
|
|
83
|
+
role: "dialog",
|
|
84
|
+
"aria-modal": "true",
|
|
85
|
+
"aria-label": "Create organization",
|
|
86
|
+
onClick: (s) => {
|
|
87
|
+
s.target === s.currentTarget && (r(!1), o({ displayName: "", description: "" }), m(null));
|
|
88
|
+
},
|
|
89
|
+
onKeyDown: (s) => {
|
|
90
|
+
s.key === "Escape" && (r(!1), o({ displayName: "", description: "" }), m(null));
|
|
91
|
+
},
|
|
92
|
+
children: /* @__PURE__ */ t("div", { className: "w-full max-w-md rounded-lg bg-background p-4 sm:p-6 shadow-lg", children: [
|
|
93
|
+
/* @__PURE__ */ e("h2", { className: "text-lg font-semibold mb-4", children: "Create Organization" }),
|
|
94
|
+
/* @__PURE__ */ t(
|
|
95
|
+
"form",
|
|
80
96
|
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
97
|
+
onSubmit: async (s) => {
|
|
98
|
+
if (s.preventDefault(), m(null), !i.displayName.trim()) {
|
|
99
|
+
m("Display name is required");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
await p.mutateAsync({
|
|
104
|
+
displayName: i.displayName.trim(),
|
|
105
|
+
description: i.description.trim() || void 0
|
|
106
|
+
}), r(!1), o({ displayName: "", description: "" });
|
|
107
|
+
} catch (f) {
|
|
108
|
+
m(f.message || "Failed to create organization");
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
className: "space-y-4",
|
|
112
|
+
"aria-label": "Create organization form",
|
|
113
|
+
children: [
|
|
114
|
+
/* @__PURE__ */ t("div", { children: [
|
|
115
|
+
/* @__PURE__ */ e(
|
|
116
|
+
"label",
|
|
117
|
+
{
|
|
118
|
+
htmlFor: "create-org-name",
|
|
119
|
+
className: "block text-sm font-medium mb-1",
|
|
120
|
+
children: "Display Name"
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ e(
|
|
124
|
+
"input",
|
|
125
|
+
{
|
|
126
|
+
id: "create-org-name",
|
|
127
|
+
type: "text",
|
|
128
|
+
value: i.displayName,
|
|
129
|
+
onChange: (s) => o((f) => ({
|
|
130
|
+
...f,
|
|
131
|
+
displayName: s.target.value
|
|
132
|
+
})),
|
|
133
|
+
placeholder: "My Organization",
|
|
134
|
+
"aria-required": "true",
|
|
135
|
+
"aria-invalid": g ? "true" : void 0,
|
|
136
|
+
className: "w-full px-3 py-2 rounded-lg border bg-background focus:outline-none focus:ring-2 focus:ring-primary"
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
] }),
|
|
140
|
+
/* @__PURE__ */ t("div", { children: [
|
|
141
|
+
/* @__PURE__ */ e(
|
|
142
|
+
"label",
|
|
143
|
+
{
|
|
144
|
+
htmlFor: "create-org-description",
|
|
145
|
+
className: "block text-sm font-medium mb-1",
|
|
146
|
+
children: "Description (optional)"
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
/* @__PURE__ */ e(
|
|
150
|
+
"textarea",
|
|
151
|
+
{
|
|
152
|
+
id: "create-org-description",
|
|
153
|
+
value: i.description,
|
|
154
|
+
onChange: (s) => o((f) => ({
|
|
155
|
+
...f,
|
|
156
|
+
description: s.target.value
|
|
157
|
+
})),
|
|
158
|
+
placeholder: "What is this organization for?",
|
|
159
|
+
rows: 3,
|
|
160
|
+
className: "w-full px-3 py-2 rounded-lg border bg-background focus:outline-none focus:ring-2 focus:ring-primary resize-y"
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
] }),
|
|
164
|
+
g && /* @__PURE__ */ e(
|
|
165
|
+
"p",
|
|
166
|
+
{
|
|
167
|
+
className: "text-sm text-destructive",
|
|
168
|
+
role: "alert",
|
|
169
|
+
"aria-live": "polite",
|
|
170
|
+
children: g
|
|
171
|
+
}
|
|
172
|
+
),
|
|
173
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", children: [
|
|
174
|
+
/* @__PURE__ */ e(
|
|
175
|
+
"button",
|
|
176
|
+
{
|
|
177
|
+
type: "button",
|
|
178
|
+
onClick: () => {
|
|
179
|
+
r(!1), o({
|
|
180
|
+
displayName: "",
|
|
181
|
+
description: ""
|
|
182
|
+
}), m(null);
|
|
183
|
+
},
|
|
184
|
+
className: "px-4 py-2 rounded-lg border hover:bg-muted transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 w-full sm:w-auto",
|
|
185
|
+
children: "Cancel"
|
|
186
|
+
}
|
|
187
|
+
),
|
|
188
|
+
/* @__PURE__ */ e(
|
|
189
|
+
"button",
|
|
190
|
+
{
|
|
191
|
+
type: "submit",
|
|
192
|
+
disabled: p.isPending,
|
|
193
|
+
"aria-busy": p.isPending,
|
|
194
|
+
className: "px-4 py-2 rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 w-full sm:w-auto",
|
|
195
|
+
children: p.isPending ? "Creating..." : "Create"
|
|
196
|
+
}
|
|
197
|
+
)
|
|
198
|
+
] })
|
|
199
|
+
]
|
|
89
200
|
}
|
|
90
201
|
)
|
|
91
|
-
] })
|
|
92
|
-
|
|
93
|
-
|
|
202
|
+
] })
|
|
203
|
+
}
|
|
204
|
+
),
|
|
205
|
+
y && /* @__PURE__ */ t(
|
|
206
|
+
"div",
|
|
207
|
+
{
|
|
208
|
+
className: "rounded-lg border border-destructive/50 bg-destructive/10 p-4 sm:p-6 text-center mb-6 sm:mb-8",
|
|
209
|
+
role: "alert",
|
|
210
|
+
"aria-live": "polite",
|
|
211
|
+
children: [
|
|
212
|
+
/* @__PURE__ */ e("p", { className: "text-destructive font-medium mb-2", children: "Failed to load workspaces" }),
|
|
213
|
+
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-4", children: x?.message || "An unexpected error occurred" }),
|
|
94
214
|
/* @__PURE__ */ e(
|
|
95
|
-
"
|
|
215
|
+
"button",
|
|
96
216
|
{
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
placeholder: "What is this organization for?",
|
|
103
|
-
rows: 3,
|
|
104
|
-
className: "w-full px-3 py-2 rounded-lg border bg-background focus:outline-none focus:ring-2 focus:ring-primary resize-y"
|
|
217
|
+
type: "button",
|
|
218
|
+
onClick: () => N(),
|
|
219
|
+
"aria-label": "Retry loading workspaces",
|
|
220
|
+
className: "px-4 py-2 rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",
|
|
221
|
+
children: "Retry"
|
|
105
222
|
}
|
|
106
223
|
)
|
|
107
|
-
]
|
|
108
|
-
|
|
109
|
-
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
),
|
|
227
|
+
u && /* @__PURE__ */ e(te, {}),
|
|
228
|
+
!u && !y && /* @__PURE__ */ t(R, { children: [
|
|
229
|
+
b.length > 0 && /* @__PURE__ */ t("section", { className: "mb-6 sm:mb-8", "aria-label": "Personal workspace", children: [
|
|
230
|
+
/* @__PURE__ */ e("h2", { className: "text-base sm:text-lg font-semibold mb-3", children: "Personal Workspace" }),
|
|
231
|
+
/* @__PURE__ */ e(
|
|
232
|
+
E,
|
|
233
|
+
{
|
|
234
|
+
entities: b,
|
|
235
|
+
onSelect: a,
|
|
236
|
+
isLoading: u
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
] }),
|
|
240
|
+
/* @__PURE__ */ t("section", { "aria-label": "Organizations", children: [
|
|
241
|
+
/* @__PURE__ */ e("h2", { className: "text-base sm:text-lg font-semibold mb-3", children: "Organizations" }),
|
|
242
|
+
c.length === 0 ? /* @__PURE__ */ t(
|
|
243
|
+
"div",
|
|
244
|
+
{
|
|
245
|
+
className: "text-center py-6 sm:py-8 text-muted-foreground border border-dashed rounded-lg",
|
|
246
|
+
role: "status",
|
|
247
|
+
children: [
|
|
248
|
+
/* @__PURE__ */ e("p", { children: "No organizations yet" }),
|
|
249
|
+
/* @__PURE__ */ e(
|
|
250
|
+
"button",
|
|
251
|
+
{
|
|
252
|
+
type: "button",
|
|
253
|
+
onClick: () => r(!0),
|
|
254
|
+
className: "mt-2 text-primary hover:underline focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 rounded",
|
|
255
|
+
"aria-label": "Create your first organization",
|
|
256
|
+
children: "Create your first organization"
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
) : /* @__PURE__ */ e(
|
|
262
|
+
E,
|
|
263
|
+
{
|
|
264
|
+
entities: c,
|
|
265
|
+
onSelect: a,
|
|
266
|
+
isLoading: u
|
|
267
|
+
}
|
|
268
|
+
)
|
|
269
|
+
] }),
|
|
270
|
+
v.length === 0 && /* @__PURE__ */ t(
|
|
271
|
+
"div",
|
|
272
|
+
{
|
|
273
|
+
className: "text-center py-8 sm:py-12 text-muted-foreground",
|
|
274
|
+
role: "status",
|
|
275
|
+
children: [
|
|
276
|
+
/* @__PURE__ */ e("p", { className: "text-base sm:text-lg font-medium mb-2", children: "No workspaces found" }),
|
|
277
|
+
/* @__PURE__ */ e("p", { className: "text-sm", children: "Create an organization to get started." })
|
|
278
|
+
]
|
|
279
|
+
}
|
|
280
|
+
)
|
|
281
|
+
] })
|
|
282
|
+
] }) });
|
|
283
|
+
}
|
|
284
|
+
function z() {
|
|
285
|
+
return /* @__PURE__ */ t("div", { className: "space-y-3", role: "status", "aria-label": "Loading members", children: [
|
|
286
|
+
[1, 2, 3].map((n) => /* @__PURE__ */ e(
|
|
287
|
+
"div",
|
|
288
|
+
{
|
|
289
|
+
className: "h-14 sm:h-16 rounded-lg bg-muted animate-pulse"
|
|
290
|
+
},
|
|
291
|
+
n
|
|
292
|
+
)),
|
|
293
|
+
/* @__PURE__ */ e("span", { className: "sr-only", children: "Loading members..." })
|
|
294
|
+
] });
|
|
295
|
+
}
|
|
296
|
+
function ne({
|
|
297
|
+
title: n,
|
|
298
|
+
message: a,
|
|
299
|
+
confirmLabel: l,
|
|
300
|
+
onConfirm: r,
|
|
301
|
+
onCancel: i
|
|
302
|
+
}) {
|
|
303
|
+
return /* @__PURE__ */ e(
|
|
304
|
+
"div",
|
|
305
|
+
{
|
|
306
|
+
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",
|
|
307
|
+
role: "dialog",
|
|
308
|
+
"aria-modal": "true",
|
|
309
|
+
"aria-label": n,
|
|
310
|
+
onClick: (o) => {
|
|
311
|
+
o.target === o.currentTarget && i();
|
|
312
|
+
},
|
|
313
|
+
onKeyDown: (o) => {
|
|
314
|
+
o.key === "Escape" && i();
|
|
315
|
+
},
|
|
316
|
+
children: /* @__PURE__ */ t("div", { className: "w-full max-w-sm rounded-lg bg-background p-4 sm:p-6 shadow-lg", children: [
|
|
317
|
+
/* @__PURE__ */ e("h3", { className: "text-lg font-semibold mb-2", children: n }),
|
|
318
|
+
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-4", children: a }),
|
|
319
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", children: [
|
|
110
320
|
/* @__PURE__ */ e(
|
|
111
321
|
"button",
|
|
112
322
|
{
|
|
113
323
|
type: "button",
|
|
114
|
-
onClick:
|
|
115
|
-
|
|
116
|
-
},
|
|
117
|
-
className: "px-4 py-2 rounded-lg border hover:bg-muted transition-colors",
|
|
324
|
+
onClick: i,
|
|
325
|
+
className: "px-4 py-2 rounded-lg border hover:bg-muted transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 w-full sm:w-auto",
|
|
118
326
|
children: "Cancel"
|
|
119
327
|
}
|
|
120
328
|
),
|
|
121
329
|
/* @__PURE__ */ e(
|
|
122
330
|
"button",
|
|
123
331
|
{
|
|
124
|
-
type: "
|
|
125
|
-
|
|
126
|
-
className: "px-4 py-2 rounded-lg bg-
|
|
127
|
-
children: l
|
|
332
|
+
type: "button",
|
|
333
|
+
onClick: r,
|
|
334
|
+
className: "px-4 py-2 rounded-lg bg-destructive text-destructive-foreground font-medium hover:bg-destructive/90 transition-colors focus:outline-none focus:ring-2 focus:ring-destructive focus:ring-offset-2 w-full sm:w-auto",
|
|
335
|
+
children: l
|
|
128
336
|
}
|
|
129
337
|
)
|
|
130
338
|
] })
|
|
131
339
|
] })
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
/* @__PURE__ */ e("h2", { className: "text-lg font-semibold mb-3", children: "Personal Workspace" }),
|
|
135
|
-
/* @__PURE__ */ e(
|
|
136
|
-
C,
|
|
137
|
-
{
|
|
138
|
-
entities: y,
|
|
139
|
-
onSelect: n,
|
|
140
|
-
isLoading: r
|
|
141
|
-
}
|
|
142
|
-
)
|
|
143
|
-
] }),
|
|
144
|
-
/* @__PURE__ */ t("div", { children: [
|
|
145
|
-
/* @__PURE__ */ e("h2", { className: "text-lg font-semibold mb-3", children: "Organizations" }),
|
|
146
|
-
f.length === 0 && !r ? /* @__PURE__ */ t("div", { className: "text-center py-8 text-muted-foreground border border-dashed rounded-lg", children: [
|
|
147
|
-
/* @__PURE__ */ e("p", { children: "No organizations yet" }),
|
|
148
|
-
/* @__PURE__ */ e(
|
|
149
|
-
"button",
|
|
150
|
-
{
|
|
151
|
-
type: "button",
|
|
152
|
-
onClick: () => i(!0),
|
|
153
|
-
className: "mt-2 text-primary hover:underline",
|
|
154
|
-
children: "Create your first organization"
|
|
155
|
-
}
|
|
156
|
-
)
|
|
157
|
-
] }) : /* @__PURE__ */ e(
|
|
158
|
-
C,
|
|
159
|
-
{
|
|
160
|
-
entities: f,
|
|
161
|
-
onSelect: n,
|
|
162
|
-
isLoading: r
|
|
163
|
-
}
|
|
164
|
-
)
|
|
165
|
-
] })
|
|
166
|
-
] });
|
|
340
|
+
}
|
|
341
|
+
);
|
|
167
342
|
}
|
|
168
|
-
function
|
|
169
|
-
client:
|
|
170
|
-
entity:
|
|
171
|
-
currentUserId:
|
|
343
|
+
function me({
|
|
344
|
+
client: n,
|
|
345
|
+
entity: a,
|
|
346
|
+
currentUserId: l
|
|
172
347
|
}) {
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
348
|
+
const r = a.userRole === "owner", [i, o] = k(null), {
|
|
349
|
+
data: g = [],
|
|
350
|
+
isLoading: m,
|
|
351
|
+
isError: v,
|
|
352
|
+
error: u,
|
|
353
|
+
refetch: y
|
|
354
|
+
} = U(n, a.entitySlug), x = B(n), N = G(n), {
|
|
355
|
+
data: p = [],
|
|
356
|
+
isLoading: b,
|
|
357
|
+
isError: c,
|
|
358
|
+
error: w,
|
|
359
|
+
refetch: s
|
|
360
|
+
} = H(n, r ? a.entitySlug : null), f = J(n), A = Q(n), D = async (d, h) => {
|
|
177
361
|
try {
|
|
178
|
-
await
|
|
179
|
-
entitySlug:
|
|
180
|
-
memberId:
|
|
181
|
-
role:
|
|
362
|
+
await x.mutateAsync({
|
|
363
|
+
entitySlug: a.entitySlug,
|
|
364
|
+
memberId: d,
|
|
365
|
+
role: h
|
|
182
366
|
});
|
|
183
|
-
} catch (
|
|
184
|
-
console.error("Failed to update role:",
|
|
367
|
+
} catch (C) {
|
|
368
|
+
console.error("Failed to update role:", C);
|
|
185
369
|
}
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
370
|
+
}, F = (d) => {
|
|
371
|
+
const h = g.find((L) => L.id === d), C = h?.user?.displayName || h?.user?.email || "this member";
|
|
372
|
+
o({
|
|
373
|
+
type: "removeMember",
|
|
374
|
+
id: d,
|
|
375
|
+
displayLabel: C
|
|
376
|
+
});
|
|
377
|
+
}, j = async (d) => {
|
|
378
|
+
try {
|
|
379
|
+
await N.mutateAsync({
|
|
380
|
+
entitySlug: a.entitySlug,
|
|
381
|
+
memberId: d
|
|
382
|
+
});
|
|
383
|
+
} catch (h) {
|
|
384
|
+
console.error("Failed to remove member:", h);
|
|
385
|
+
}
|
|
386
|
+
}, P = async (d) => {
|
|
387
|
+
await f.mutateAsync({
|
|
388
|
+
entitySlug: a.entitySlug,
|
|
389
|
+
request: d
|
|
390
|
+
});
|
|
391
|
+
}, T = (d) => {
|
|
392
|
+
const C = p.find((L) => L.id === d)?.email || "this invitation";
|
|
393
|
+
o({
|
|
394
|
+
type: "cancelInvitation",
|
|
395
|
+
id: d,
|
|
396
|
+
displayLabel: C
|
|
200
397
|
});
|
|
201
|
-
},
|
|
398
|
+
}, W = async (d) => {
|
|
202
399
|
try {
|
|
203
|
-
await
|
|
204
|
-
entitySlug:
|
|
205
|
-
invitationId:
|
|
400
|
+
await A.mutateAsync({
|
|
401
|
+
entitySlug: a.entitySlug,
|
|
402
|
+
invitationId: d
|
|
206
403
|
});
|
|
207
|
-
} catch (
|
|
208
|
-
console.error("Failed to cancel invitation:",
|
|
404
|
+
} catch (h) {
|
|
405
|
+
console.error("Failed to cancel invitation:", h);
|
|
209
406
|
}
|
|
407
|
+
}, O = async () => {
|
|
408
|
+
i && (i.type === "removeMember" ? await j(i.id) : i.type === "cancelInvitation" && await W(i.id), o(null));
|
|
210
409
|
};
|
|
211
|
-
return
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
410
|
+
return a.entityType === "personal" ? /* @__PURE__ */ e(I, { spacing: "lg", maxWidth: "4xl", children: /* @__PURE__ */ t(
|
|
411
|
+
"div",
|
|
412
|
+
{
|
|
413
|
+
className: "text-center py-8 sm:py-12 text-muted-foreground",
|
|
414
|
+
role: "status",
|
|
415
|
+
"aria-label": "Personal workspace notice",
|
|
416
|
+
children: [
|
|
417
|
+
/* @__PURE__ */ e("p", { children: "Personal workspaces cannot have additional members." }),
|
|
418
|
+
/* @__PURE__ */ e("p", { className: "mt-2", children: "Create an organization to collaborate with others." })
|
|
419
|
+
]
|
|
420
|
+
}
|
|
421
|
+
) }) : /* @__PURE__ */ e(I, { spacing: "lg", maxWidth: "4xl", children: /* @__PURE__ */ t("div", { role: "main", "aria-label": "Members management", children: [
|
|
422
|
+
i && /* @__PURE__ */ e(
|
|
423
|
+
ne,
|
|
424
|
+
{
|
|
425
|
+
title: i.type === "removeMember" ? "Remove Member" : "Cancel Invitation",
|
|
426
|
+
message: i.type === "removeMember" ? `Are you sure you want to remove ${i.displayLabel}? They will lose access to this organization.` : `Are you sure you want to cancel the invitation to ${i.displayLabel}?`,
|
|
427
|
+
confirmLabel: i.type === "removeMember" ? "Remove" : "Cancel Invitation",
|
|
428
|
+
onConfirm: O,
|
|
429
|
+
onCancel: () => o(null)
|
|
430
|
+
}
|
|
431
|
+
),
|
|
432
|
+
/* @__PURE__ */ t("div", { className: "mb-6 sm:mb-8", children: [
|
|
433
|
+
/* @__PURE__ */ e("h1", { className: "text-xl sm:text-2xl font-bold text-foreground", children: "Members" }),
|
|
434
|
+
/* @__PURE__ */ t("p", { className: "text-sm sm:text-base text-muted-foreground", children: [
|
|
218
435
|
"Manage members and invitations for ",
|
|
219
|
-
|
|
436
|
+
a.displayName
|
|
220
437
|
] })
|
|
221
438
|
] }),
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
439
|
+
r && /* @__PURE__ */ t(
|
|
440
|
+
"section",
|
|
441
|
+
{
|
|
442
|
+
className: "rounded-lg border p-3 sm:p-4 mb-6 sm:mb-8",
|
|
443
|
+
"aria-label": "Invite members",
|
|
444
|
+
children: [
|
|
445
|
+
/* @__PURE__ */ e("h2", { className: "text-base sm:text-lg font-semibold mb-3 sm:mb-4", children: "Invite Members" }),
|
|
446
|
+
/* @__PURE__ */ e(
|
|
447
|
+
K,
|
|
448
|
+
{
|
|
449
|
+
onSubmit: P,
|
|
450
|
+
isSubmitting: f.isPending
|
|
451
|
+
}
|
|
452
|
+
)
|
|
453
|
+
]
|
|
454
|
+
}
|
|
455
|
+
),
|
|
456
|
+
r && /* @__PURE__ */ t("section", { className: "mb-6 sm:mb-8", "aria-label": "Pending invitations", children: [
|
|
457
|
+
/* @__PURE__ */ e("h2", { className: "text-base sm:text-lg font-semibold mb-3", children: "Pending Invitations" }),
|
|
458
|
+
c ? /* @__PURE__ */ t(
|
|
459
|
+
"div",
|
|
226
460
|
{
|
|
227
|
-
|
|
228
|
-
|
|
461
|
+
className: "rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-center",
|
|
462
|
+
role: "alert",
|
|
463
|
+
"aria-live": "polite",
|
|
464
|
+
children: [
|
|
465
|
+
/* @__PURE__ */ e("p", { className: "text-destructive font-medium mb-2", children: "Failed to load invitations" }),
|
|
466
|
+
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-3", children: w?.message || "An unexpected error occurred" }),
|
|
467
|
+
/* @__PURE__ */ e(
|
|
468
|
+
"button",
|
|
469
|
+
{
|
|
470
|
+
type: "button",
|
|
471
|
+
onClick: () => s(),
|
|
472
|
+
"aria-label": "Retry loading invitations",
|
|
473
|
+
className: "px-3 py-1.5 text-sm rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",
|
|
474
|
+
children: "Retry"
|
|
475
|
+
}
|
|
476
|
+
)
|
|
477
|
+
]
|
|
229
478
|
}
|
|
230
|
-
)
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
479
|
+
) : b ? /* @__PURE__ */ e(z, {}) : p.length === 0 ? /* @__PURE__ */ e(
|
|
480
|
+
"div",
|
|
481
|
+
{
|
|
482
|
+
className: "text-center py-4 sm:py-6 text-muted-foreground border border-dashed rounded-lg",
|
|
483
|
+
role: "status",
|
|
484
|
+
children: /* @__PURE__ */ e("p", { children: "No pending invitations" })
|
|
485
|
+
}
|
|
486
|
+
) : /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ e(
|
|
487
|
+
S,
|
|
236
488
|
{
|
|
237
|
-
invitations:
|
|
489
|
+
invitations: p,
|
|
238
490
|
mode: "admin",
|
|
239
|
-
onCancel:
|
|
240
|
-
isLoading:
|
|
491
|
+
onCancel: T,
|
|
492
|
+
isLoading: b,
|
|
241
493
|
emptyMessage: "No pending invitations"
|
|
242
494
|
}
|
|
243
|
-
)
|
|
495
|
+
) })
|
|
244
496
|
] }),
|
|
245
|
-
/* @__PURE__ */ t("
|
|
246
|
-
/* @__PURE__ */ t("h2", { className: "text-lg font-semibold mb-3", children: [
|
|
497
|
+
/* @__PURE__ */ t("section", { "aria-label": "Current members", children: [
|
|
498
|
+
/* @__PURE__ */ t("h2", { className: "text-base sm:text-lg font-semibold mb-3", children: [
|
|
247
499
|
"Current Members (",
|
|
248
|
-
|
|
500
|
+
g.length,
|
|
249
501
|
")"
|
|
250
502
|
] }),
|
|
251
|
-
/* @__PURE__ */
|
|
252
|
-
|
|
503
|
+
v ? /* @__PURE__ */ t(
|
|
504
|
+
"div",
|
|
253
505
|
{
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
506
|
+
className: "rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-center",
|
|
507
|
+
role: "alert",
|
|
508
|
+
"aria-live": "polite",
|
|
509
|
+
children: [
|
|
510
|
+
/* @__PURE__ */ e("p", { className: "text-destructive font-medium mb-2", children: "Failed to load members" }),
|
|
511
|
+
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-3", children: u?.message || "An unexpected error occurred" }),
|
|
512
|
+
/* @__PURE__ */ e(
|
|
513
|
+
"button",
|
|
514
|
+
{
|
|
515
|
+
type: "button",
|
|
516
|
+
onClick: () => y(),
|
|
517
|
+
"aria-label": "Retry loading members",
|
|
518
|
+
className: "px-3 py-1.5 text-sm rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",
|
|
519
|
+
children: "Retry"
|
|
520
|
+
}
|
|
521
|
+
)
|
|
522
|
+
]
|
|
260
523
|
}
|
|
261
|
-
)
|
|
524
|
+
) : m ? /* @__PURE__ */ e(z, {}) : g.length === 0 ? /* @__PURE__ */ t(
|
|
525
|
+
"div",
|
|
526
|
+
{
|
|
527
|
+
className: "text-center py-4 sm:py-6 text-muted-foreground border border-dashed rounded-lg",
|
|
528
|
+
role: "status",
|
|
529
|
+
children: [
|
|
530
|
+
/* @__PURE__ */ e("p", { children: "No members yet" }),
|
|
531
|
+
r && /* @__PURE__ */ e("p", { className: "text-sm mt-1", children: "Use the invite form above to add members." })
|
|
532
|
+
]
|
|
533
|
+
}
|
|
534
|
+
) : /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ e(
|
|
535
|
+
Y,
|
|
536
|
+
{
|
|
537
|
+
members: g,
|
|
538
|
+
currentUserId: l,
|
|
539
|
+
canManage: r,
|
|
540
|
+
onRoleChange: D,
|
|
541
|
+
onRemove: F,
|
|
542
|
+
isLoading: m
|
|
543
|
+
}
|
|
544
|
+
) })
|
|
262
545
|
] })
|
|
546
|
+
] }) });
|
|
547
|
+
}
|
|
548
|
+
function re() {
|
|
549
|
+
return /* @__PURE__ */ t("div", { className: "space-y-3", role: "status", "aria-label": "Loading invitations", children: [
|
|
550
|
+
[1, 2].map((n) => /* @__PURE__ */ e(
|
|
551
|
+
"div",
|
|
552
|
+
{
|
|
553
|
+
className: "h-16 sm:h-20 rounded-lg bg-muted animate-pulse"
|
|
554
|
+
},
|
|
555
|
+
n
|
|
556
|
+
)),
|
|
557
|
+
/* @__PURE__ */ e("span", { className: "sr-only", children: "Loading invitations..." })
|
|
263
558
|
] });
|
|
264
559
|
}
|
|
265
|
-
function
|
|
266
|
-
|
|
267
|
-
|
|
560
|
+
function ie({
|
|
561
|
+
entityName: n,
|
|
562
|
+
onConfirm: a,
|
|
563
|
+
onCancel: l
|
|
268
564
|
}) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
565
|
+
return /* @__PURE__ */ e(
|
|
566
|
+
"div",
|
|
567
|
+
{
|
|
568
|
+
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",
|
|
569
|
+
role: "dialog",
|
|
570
|
+
"aria-modal": "true",
|
|
571
|
+
"aria-label": "Decline invitation",
|
|
572
|
+
onClick: (r) => {
|
|
573
|
+
r.target === r.currentTarget && l();
|
|
574
|
+
},
|
|
575
|
+
onKeyDown: (r) => {
|
|
576
|
+
r.key === "Escape" && l();
|
|
577
|
+
},
|
|
578
|
+
children: /* @__PURE__ */ t("div", { className: "w-full max-w-sm rounded-lg bg-background p-4 sm:p-6 shadow-lg", children: [
|
|
579
|
+
/* @__PURE__ */ e("h3", { className: "text-lg font-semibold mb-2", children: "Decline Invitation" }),
|
|
580
|
+
/* @__PURE__ */ t("p", { className: "text-sm text-muted-foreground mb-4", children: [
|
|
581
|
+
"Are you sure you want to decline the invitation to join",
|
|
582
|
+
" ",
|
|
583
|
+
/* @__PURE__ */ e("strong", { children: n }),
|
|
584
|
+
"? You will need a new invitation to join later."
|
|
585
|
+
] }),
|
|
586
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", children: [
|
|
587
|
+
/* @__PURE__ */ e(
|
|
588
|
+
"button",
|
|
589
|
+
{
|
|
590
|
+
type: "button",
|
|
591
|
+
onClick: l,
|
|
592
|
+
className: "px-4 py-2 rounded-lg border hover:bg-muted transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 w-full sm:w-auto",
|
|
593
|
+
children: "Keep"
|
|
594
|
+
}
|
|
595
|
+
),
|
|
596
|
+
/* @__PURE__ */ e(
|
|
597
|
+
"button",
|
|
598
|
+
{
|
|
599
|
+
type: "button",
|
|
600
|
+
onClick: a,
|
|
601
|
+
className: "px-4 py-2 rounded-lg bg-destructive text-destructive-foreground font-medium hover:bg-destructive/90 transition-colors focus:outline-none focus:ring-2 focus:ring-destructive focus:ring-offset-2 w-full sm:w-auto",
|
|
602
|
+
children: "Decline"
|
|
603
|
+
}
|
|
604
|
+
)
|
|
605
|
+
] })
|
|
606
|
+
] })
|
|
274
607
|
}
|
|
275
|
-
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
function ue({
|
|
611
|
+
client: n,
|
|
612
|
+
onInvitationAccepted: a
|
|
613
|
+
}) {
|
|
614
|
+
const {
|
|
615
|
+
data: l = [],
|
|
616
|
+
isLoading: r,
|
|
617
|
+
isError: i,
|
|
618
|
+
error: o,
|
|
619
|
+
refetch: g
|
|
620
|
+
} = V(n), m = X(n), v = Z(n), [u, y] = k(null), x = async (c) => {
|
|
276
621
|
try {
|
|
277
|
-
await
|
|
278
|
-
} catch (
|
|
279
|
-
console.error("Failed to
|
|
622
|
+
await m.mutateAsync(c), a?.();
|
|
623
|
+
} catch (w) {
|
|
624
|
+
console.error("Failed to accept invitation:", w);
|
|
280
625
|
}
|
|
281
|
-
},
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
626
|
+
}, N = (c) => {
|
|
627
|
+
const s = l.find((f) => f.token === c)?.entity?.displayName || "this organization";
|
|
628
|
+
y({ token: c, entityName: s });
|
|
629
|
+
}, p = async () => {
|
|
630
|
+
if (u) {
|
|
631
|
+
try {
|
|
632
|
+
await v.mutateAsync(u.token);
|
|
633
|
+
} catch (c) {
|
|
634
|
+
console.error("Failed to decline invitation:", c);
|
|
635
|
+
}
|
|
636
|
+
y(null);
|
|
637
|
+
}
|
|
638
|
+
}, b = l.filter(
|
|
639
|
+
(c) => c.status === "pending"
|
|
640
|
+
).length;
|
|
641
|
+
return /* @__PURE__ */ e(I, { spacing: "lg", maxWidth: "4xl", children: /* @__PURE__ */ t("div", { role: "main", "aria-label": "Invitations", children: [
|
|
642
|
+
u && /* @__PURE__ */ e(
|
|
643
|
+
ie,
|
|
644
|
+
{
|
|
645
|
+
entityName: u.entityName,
|
|
646
|
+
onConfirm: p,
|
|
647
|
+
onCancel: () => y(null)
|
|
648
|
+
}
|
|
649
|
+
),
|
|
650
|
+
/* @__PURE__ */ t("div", { className: "mb-4 sm:mb-6", children: [
|
|
651
|
+
/* @__PURE__ */ e("h1", { className: "text-xl sm:text-2xl font-bold text-foreground", children: "Invitations" }),
|
|
652
|
+
/* @__PURE__ */ e("p", { className: "text-sm sm:text-base text-muted-foreground", children: b > 0 ? `You have ${b} pending invitation${b > 1 ? "s" : ""}` : "No pending invitations" })
|
|
286
653
|
] }),
|
|
287
|
-
/* @__PURE__ */
|
|
288
|
-
|
|
654
|
+
i && /* @__PURE__ */ t(
|
|
655
|
+
"div",
|
|
289
656
|
{
|
|
290
|
-
|
|
657
|
+
className: "rounded-lg border border-destructive/50 bg-destructive/10 p-4 sm:p-6 text-center mb-4 sm:mb-6",
|
|
658
|
+
role: "alert",
|
|
659
|
+
"aria-live": "polite",
|
|
660
|
+
children: [
|
|
661
|
+
/* @__PURE__ */ e("p", { className: "text-destructive font-medium mb-2", children: "Failed to load invitations" }),
|
|
662
|
+
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-4", children: o?.message || "An unexpected error occurred" }),
|
|
663
|
+
/* @__PURE__ */ e(
|
|
664
|
+
"button",
|
|
665
|
+
{
|
|
666
|
+
type: "button",
|
|
667
|
+
onClick: () => g(),
|
|
668
|
+
"aria-label": "Retry loading invitations",
|
|
669
|
+
className: "px-4 py-2 rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",
|
|
670
|
+
children: "Retry"
|
|
671
|
+
}
|
|
672
|
+
)
|
|
673
|
+
]
|
|
674
|
+
}
|
|
675
|
+
),
|
|
676
|
+
r && /* @__PURE__ */ e(re, {}),
|
|
677
|
+
!r && !i && /* @__PURE__ */ e(R, { children: l.length === 0 ? /* @__PURE__ */ t(
|
|
678
|
+
"div",
|
|
679
|
+
{
|
|
680
|
+
className: "text-center py-6 sm:py-8 text-muted-foreground border border-dashed rounded-lg",
|
|
681
|
+
role: "status",
|
|
682
|
+
children: [
|
|
683
|
+
/* @__PURE__ */ e("p", { className: "text-base sm:text-lg font-medium mb-1", children: "No invitations" }),
|
|
684
|
+
/* @__PURE__ */ e("p", { className: "text-sm", children: "You don't have any pending invitations" })
|
|
685
|
+
]
|
|
686
|
+
}
|
|
687
|
+
) : /* @__PURE__ */ e("section", { "aria-label": "Invitation list", children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ e(
|
|
688
|
+
S,
|
|
689
|
+
{
|
|
690
|
+
invitations: l,
|
|
291
691
|
mode: "user",
|
|
292
|
-
onAccept:
|
|
293
|
-
onDecline:
|
|
294
|
-
isLoading:
|
|
692
|
+
onAccept: x,
|
|
693
|
+
onDecline: N,
|
|
694
|
+
isLoading: r,
|
|
295
695
|
emptyMessage: "You don't have any pending invitations"
|
|
296
696
|
}
|
|
297
|
-
)
|
|
298
|
-
] });
|
|
697
|
+
) }) }) })
|
|
698
|
+
] }) });
|
|
299
699
|
}
|
|
300
700
|
export {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
701
|
+
de as EntityListPage,
|
|
702
|
+
ue as InvitationsPage,
|
|
703
|
+
me as MembersManagementPage
|
|
304
704
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(r,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("@sudobility/components"),require("@sudobility/entity-components"),require("@sudobility/entity_client")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@sudobility/components","@sudobility/entity-components","@sudobility/entity_client"],e):(r=typeof globalThis<"u"?globalThis:r||self,e(r.EntityPages={},r.jsxRuntime,r.React,r.SudobilityComponents,r.SudobilityEntityComponents,r.SudobilityEntityClient))})(this,(function(r,e,v,x,b,s){"use strict";function M(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const i in t)if(i!=="default"){const n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(a,i,n.get?n:{enumerable:!0,get:()=>t[i]})}}return a.default=t,Object.freeze(a)}const N=M(v);function I({title:t,titleId:a,...i},n){return N.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:n,"aria-labelledby":a},i),t?N.createElement("title",{id:a},t):null,N.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"}))}const k=N.forwardRef(I);function E({client:t,onSelectEntity:a}){const[i,n]=v.useState(!1),[c,g]=v.useState({displayName:"",description:""}),[y,m]=v.useState(null),{data:u=[],isLoading:o}=s.useEntities(t),d=s.useCreateEntity(t),w=u.filter(l=>l.entityType==="personal"),S=u.filter(l=>l.entityType==="organization"),C=async l=>{if(l.preventDefault(),m(null),!c.displayName.trim()){m("Display name is required");return}try{await d.mutateAsync({displayName:c.displayName.trim(),description:c.description.trim()||void 0}),n(!1),g({displayName:"",description:""})}catch(p){m(p.message||"Failed to create organization")}};return e.jsxs(x.Section,{spacing:"lg",maxWidth:"4xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Workspaces"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage your personal and organization workspaces"})]}),e.jsxs("button",{type:"button",onClick:()=>n(!0),className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors",children:[e.jsx(k,{className:"h-4 w-4"}),e.jsx("span",{children:"New Organization"})]})]}),i&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"w-full max-w-md rounded-lg bg-background p-6 shadow-lg",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Create Organization"}),e.jsxs("form",{onSubmit:C,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Display Name"}),e.jsx("input",{type:"text",value:c.displayName,onChange:l=>g(p=>({...p,displayName:l.target.value})),placeholder:"My Organization",className:"w-full px-3 py-2 rounded-lg border bg-background focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Description (optional)"}),e.jsx("textarea",{value:c.description,onChange:l=>g(p=>({...p,description:l.target.value})),placeholder:"What is this organization for?",rows:3,className:"w-full px-3 py-2 rounded-lg border bg-background focus:outline-none focus:ring-2 focus:ring-primary resize-y"})]}),y&&e.jsx("p",{className:"text-sm text-destructive",children:y}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{n(!1),g({displayName:"",description:""}),m(null)},className:"px-4 py-2 rounded-lg border hover:bg-muted transition-colors",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:d.isPending,className:"px-4 py-2 rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors disabled:opacity-50",children:d.isPending?"Creating...":"Create"})]})]})]})}),w.length>0&&e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-lg font-semibold mb-3",children:"Personal Workspace"}),e.jsx(b.EntityList,{entities:w,onSelect:a,isLoading:o})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3",children:"Organizations"}),S.length===0&&!o?e.jsxs("div",{className:"text-center py-8 text-muted-foreground border border-dashed rounded-lg",children:[e.jsx("p",{children:"No organizations yet"}),e.jsx("button",{type:"button",onClick:()=>n(!0),className:"mt-2 text-primary hover:underline",children:"Create your first organization"})]}):e.jsx(b.EntityList,{entities:S,onSelect:a,isLoading:o})]})]})}function L({client:t,entity:a,currentUserId:i}){const n=a.userRole==="owner",{data:c=[],isLoading:g}=s.useEntityMembers(t,a.entitySlug),y=s.useUpdateMemberRole(t),m=s.useRemoveMember(t),{data:u=[],isLoading:o}=s.useEntityInvitations(t,n?a.entitySlug:null),d=s.useCreateInvitation(t),w=s.useCancelInvitation(t),S=async(h,f)=>{try{await y.mutateAsync({entitySlug:a.entitySlug,memberId:h,role:f})}catch(j){console.error("Failed to update role:",j)}},C=async h=>{if(confirm("Are you sure you want to remove this member?"))try{await m.mutateAsync({entitySlug:a.entitySlug,memberId:h})}catch(f){console.error("Failed to remove member:",f)}},l=async h=>{await d.mutateAsync({entitySlug:a.entitySlug,request:h})},p=async h=>{try{await w.mutateAsync({entitySlug:a.entitySlug,invitationId:h})}catch(f){console.error("Failed to cancel invitation:",f)}};return a.entityType==="personal"?e.jsx(x.Section,{spacing:"lg",maxWidth:"4xl",children:e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx("p",{children:"Personal workspaces cannot have additional members."}),e.jsx("p",{className:"mt-2",children:"Create an organization to collaborate with others."})]})}):e.jsxs(x.Section,{spacing:"lg",maxWidth:"4xl",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Members"}),e.jsxs("p",{className:"text-muted-foreground",children:["Manage members and invitations for ",a.displayName]})]}),n&&e.jsxs("div",{className:"rounded-lg border p-4 mb-8",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Invite Members"}),e.jsx(b.InvitationForm,{onSubmit:l,isSubmitting:d.isPending})]}),n&&e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-lg font-semibold mb-3",children:"Pending Invitations"}),e.jsx(b.InvitationList,{invitations:u,mode:"admin",onCancel:p,isLoading:o,emptyMessage:"No pending invitations"})]}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-lg font-semibold mb-3",children:["Current Members (",c.length,")"]}),e.jsx(b.MemberList,{members:c,currentUserId:i,canManage:n,onRoleChange:S,onRemove:C,isLoading:g})]})]})}function P({client:t,onInvitationAccepted:a}){const{data:i=[],isLoading:n}=s.useMyInvitations(t),c=s.useAcceptInvitation(t),g=s.useDeclineInvitation(t),y=async o=>{try{await c.mutateAsync(o),a?.()}catch(d){console.error("Failed to accept invitation:",d)}},m=async o=>{try{await g.mutateAsync(o)}catch(d){console.error("Failed to decline invitation:",d)}},u=i.filter(o=>o.status==="pending").length;return e.jsxs(x.Section,{spacing:"lg",maxWidth:"4xl",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Invitations"}),e.jsx("p",{className:"text-muted-foreground",children:u>0?`You have ${u} pending invitation${u>1?"s":""}`:"No pending invitations"})]}),e.jsx(b.InvitationList,{invitations:i,mode:"user",onAccept:y,onDecline:m,isLoading:n,emptyMessage:"You don't have any pending invitations"})]})}r.EntityListPage=E,r.InvitationsPage=P,r.MembersManagementPage=L,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(l,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("@sudobility/components"),require("@sudobility/entity-components"),require("@sudobility/entity_client")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@sudobility/components","@sudobility/entity-components","@sudobility/entity_client"],e):(l=typeof globalThis<"u"?globalThis:l||self,e(l.EntityPages={},l.jsxRuntime,l.React,l.SudobilityComponents,l.SudobilityEntityComponents,l.SudobilityEntityClient))})(this,(function(l,e,N,E,w,m){"use strict";function j(r){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const s in r)if(s!=="default"){const t=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(a,s,t.get?t:{enumerable:!0,get:()=>r[s]})}}return a.default=r,Object.freeze(a)}const I=j(N);function D({title:r,titleId:a,...s},t){return I.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:t,"aria-labelledby":a},s),r?I.createElement("title",{id:a},r):null,I.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"}))}const P=I.forwardRef(D);function A(){return e.jsxs("div",{className:"space-y-3",role:"status","aria-label":"Loading workspaces",children:[[1,2,3].map(r=>e.jsx("div",{className:"h-16 sm:h-20 rounded-lg bg-muted animate-pulse"},r)),e.jsx("span",{className:"sr-only",children:"Loading workspaces..."})]})}function F({client:r,onSelectEntity:a}){const[s,t]=N.useState(!1),[o,n]=N.useState({displayName:"",description:""}),[f,u]=N.useState(null),{data:x=[],isLoading:g,isError:v,error:k,refetch:S}=m.useEntities(r),p=m.useCreateEntity(r),h=x.filter(i=>i.entityType==="personal"),c=x.filter(i=>i.entityType==="organization"),C=async i=>{if(i.preventDefault(),u(null),!o.displayName.trim()){u("Display name is required");return}try{await p.mutateAsync({displayName:o.displayName.trim(),description:o.description.trim()||void 0}),t(!1),n({displayName:"",description:""})}catch(b){u(b.message||"Failed to create organization")}};return e.jsx(E.Section,{spacing:"lg",maxWidth:"4xl",children:e.jsxs("div",{role:"main","aria-label":"Workspaces",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-6 sm:mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-foreground",children:"Workspaces"}),e.jsx("p",{className:"text-sm sm:text-base text-muted-foreground",children:"Manage your personal and organization workspaces"})]}),e.jsxs("button",{type:"button",onClick:()=>t(!0),"aria-label":"Create new organization",className:"flex items-center justify-center gap-2 px-4 py-2 rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 w-full sm:w-auto",children:[e.jsx(P,{className:"h-4 w-4","aria-hidden":"true"}),e.jsx("span",{children:"New Organization"})]})]}),s&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",role:"dialog","aria-modal":"true","aria-label":"Create organization",onClick:i=>{i.target===i.currentTarget&&(t(!1),n({displayName:"",description:""}),u(null))},onKeyDown:i=>{i.key==="Escape"&&(t(!1),n({displayName:"",description:""}),u(null))},children:e.jsxs("div",{className:"w-full max-w-md rounded-lg bg-background p-4 sm:p-6 shadow-lg",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Create Organization"}),e.jsxs("form",{onSubmit:C,className:"space-y-4","aria-label":"Create organization form",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"create-org-name",className:"block text-sm font-medium mb-1",children:"Display Name"}),e.jsx("input",{id:"create-org-name",type:"text",value:o.displayName,onChange:i=>n(b=>({...b,displayName:i.target.value})),placeholder:"My Organization","aria-required":"true","aria-invalid":f?"true":void 0,className:"w-full px-3 py-2 rounded-lg border bg-background focus:outline-none focus:ring-2 focus:ring-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"create-org-description",className:"block text-sm font-medium mb-1",children:"Description (optional)"}),e.jsx("textarea",{id:"create-org-description",value:o.description,onChange:i=>n(b=>({...b,description:i.target.value})),placeholder:"What is this organization for?",rows:3,className:"w-full px-3 py-2 rounded-lg border bg-background focus:outline-none focus:ring-2 focus:ring-primary resize-y"})]}),f&&e.jsx("p",{className:"text-sm text-destructive",role:"alert","aria-live":"polite",children:f}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx("button",{type:"button",onClick:()=>{t(!1),n({displayName:"",description:""}),u(null)},className:"px-4 py-2 rounded-lg border hover:bg-muted transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 w-full sm:w-auto",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:p.isPending,"aria-busy":p.isPending,className:"px-4 py-2 rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 w-full sm:w-auto",children:p.isPending?"Creating...":"Create"})]})]})]})}),v&&e.jsxs("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 sm:p-6 text-center mb-6 sm:mb-8",role:"alert","aria-live":"polite",children:[e.jsx("p",{className:"text-destructive font-medium mb-2",children:"Failed to load workspaces"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:k?.message||"An unexpected error occurred"}),e.jsx("button",{type:"button",onClick:()=>S(),"aria-label":"Retry loading workspaces",className:"px-4 py-2 rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",children:"Retry"})]}),g&&e.jsx(A,{}),!g&&!v&&e.jsxs(e.Fragment,{children:[h.length>0&&e.jsxs("section",{className:"mb-6 sm:mb-8","aria-label":"Personal workspace",children:[e.jsx("h2",{className:"text-base sm:text-lg font-semibold mb-3",children:"Personal Workspace"}),e.jsx(w.EntityList,{entities:h,onSelect:a,isLoading:g})]}),e.jsxs("section",{"aria-label":"Organizations",children:[e.jsx("h2",{className:"text-base sm:text-lg font-semibold mb-3",children:"Organizations"}),c.length===0?e.jsxs("div",{className:"text-center py-6 sm:py-8 text-muted-foreground border border-dashed rounded-lg",role:"status",children:[e.jsx("p",{children:"No organizations yet"}),e.jsx("button",{type:"button",onClick:()=>t(!0),className:"mt-2 text-primary hover:underline focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 rounded","aria-label":"Create your first organization",children:"Create your first organization"})]}):e.jsx(w.EntityList,{entities:c,onSelect:a,isLoading:g})]}),x.length===0&&e.jsxs("div",{className:"text-center py-8 sm:py-12 text-muted-foreground",role:"status",children:[e.jsx("p",{className:"text-base sm:text-lg font-medium mb-2",children:"No workspaces found"}),e.jsx("p",{className:"text-sm",children:"Create an organization to get started."})]})]})]})})}function z(){return e.jsxs("div",{className:"space-y-3",role:"status","aria-label":"Loading members",children:[[1,2,3].map(r=>e.jsx("div",{className:"h-14 sm:h-16 rounded-lg bg-muted animate-pulse"},r)),e.jsx("span",{className:"sr-only",children:"Loading members..."})]})}function O({title:r,message:a,confirmLabel:s,onConfirm:t,onCancel:o}){return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",role:"dialog","aria-modal":"true","aria-label":r,onClick:n=>{n.target===n.currentTarget&&o()},onKeyDown:n=>{n.key==="Escape"&&o()},children:e.jsxs("div",{className:"w-full max-w-sm rounded-lg bg-background p-4 sm:p-6 shadow-lg",children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:r}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:a}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx("button",{type:"button",onClick:o,className:"px-4 py-2 rounded-lg border hover:bg-muted transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 w-full sm:w-auto",children:"Cancel"}),e.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 rounded-lg bg-destructive text-destructive-foreground font-medium hover:bg-destructive/90 transition-colors focus:outline-none focus:ring-2 focus:ring-destructive focus:ring-offset-2 w-full sm:w-auto",children:s})]})]})})}function T({client:r,entity:a,currentUserId:s}){const t=a.userRole==="owner",[o,n]=N.useState(null),{data:f=[],isLoading:u,isError:x,error:g,refetch:v}=m.useEntityMembers(r,a.entitySlug),k=m.useUpdateMemberRole(r),S=m.useRemoveMember(r),{data:p=[],isLoading:h,isError:c,error:C,refetch:i}=m.useEntityInvitations(r,t?a.entitySlug:null),b=m.useCreateInvitation(r),Y=m.useCancelInvitation(r),$=async(d,y)=>{try{await k.mutateAsync({entitySlug:a.entitySlug,memberId:d,role:y})}catch(M){console.error("Failed to update role:",M)}},U=d=>{const y=f.find(L=>L.id===d),M=y?.user?.displayName||y?.user?.email||"this member";n({type:"removeMember",id:d,displayLabel:M})},B=async d=>{try{await S.mutateAsync({entitySlug:a.entitySlug,memberId:d})}catch(y){console.error("Failed to remove member:",y)}},G=async d=>{await b.mutateAsync({entitySlug:a.entitySlug,request:d})},H=d=>{const M=p.find(L=>L.id===d)?.email||"this invitation";n({type:"cancelInvitation",id:d,displayLabel:M})},J=async d=>{try{await Y.mutateAsync({entitySlug:a.entitySlug,invitationId:d})}catch(y){console.error("Failed to cancel invitation:",y)}},Q=async()=>{o&&(o.type==="removeMember"?await B(o.id):o.type==="cancelInvitation"&&await J(o.id),n(null))};return a.entityType==="personal"?e.jsx(E.Section,{spacing:"lg",maxWidth:"4xl",children:e.jsxs("div",{className:"text-center py-8 sm:py-12 text-muted-foreground",role:"status","aria-label":"Personal workspace notice",children:[e.jsx("p",{children:"Personal workspaces cannot have additional members."}),e.jsx("p",{className:"mt-2",children:"Create an organization to collaborate with others."})]})}):e.jsx(E.Section,{spacing:"lg",maxWidth:"4xl",children:e.jsxs("div",{role:"main","aria-label":"Members management",children:[o&&e.jsx(O,{title:o.type==="removeMember"?"Remove Member":"Cancel Invitation",message:o.type==="removeMember"?`Are you sure you want to remove ${o.displayLabel}? They will lose access to this organization.`:`Are you sure you want to cancel the invitation to ${o.displayLabel}?`,confirmLabel:o.type==="removeMember"?"Remove":"Cancel Invitation",onConfirm:Q,onCancel:()=>n(null)}),e.jsxs("div",{className:"mb-6 sm:mb-8",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-foreground",children:"Members"}),e.jsxs("p",{className:"text-sm sm:text-base text-muted-foreground",children:["Manage members and invitations for ",a.displayName]})]}),t&&e.jsxs("section",{className:"rounded-lg border p-3 sm:p-4 mb-6 sm:mb-8","aria-label":"Invite members",children:[e.jsx("h2",{className:"text-base sm:text-lg font-semibold mb-3 sm:mb-4",children:"Invite Members"}),e.jsx(w.InvitationForm,{onSubmit:G,isSubmitting:b.isPending})]}),t&&e.jsxs("section",{className:"mb-6 sm:mb-8","aria-label":"Pending invitations",children:[e.jsx("h2",{className:"text-base sm:text-lg font-semibold mb-3",children:"Pending Invitations"}),c?e.jsxs("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-center",role:"alert","aria-live":"polite",children:[e.jsx("p",{className:"text-destructive font-medium mb-2",children:"Failed to load invitations"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:C?.message||"An unexpected error occurred"}),e.jsx("button",{type:"button",onClick:()=>i(),"aria-label":"Retry loading invitations",className:"px-3 py-1.5 text-sm rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",children:"Retry"})]}):h?e.jsx(z,{}):p.length===0?e.jsx("div",{className:"text-center py-4 sm:py-6 text-muted-foreground border border-dashed rounded-lg",role:"status",children:e.jsx("p",{children:"No pending invitations"})}):e.jsx("div",{className:"overflow-x-auto",children:e.jsx(w.InvitationList,{invitations:p,mode:"admin",onCancel:H,isLoading:h,emptyMessage:"No pending invitations"})})]}),e.jsxs("section",{"aria-label":"Current members",children:[e.jsxs("h2",{className:"text-base sm:text-lg font-semibold mb-3",children:["Current Members (",f.length,")"]}),x?e.jsxs("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 text-center",role:"alert","aria-live":"polite",children:[e.jsx("p",{className:"text-destructive font-medium mb-2",children:"Failed to load members"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:g?.message||"An unexpected error occurred"}),e.jsx("button",{type:"button",onClick:()=>v(),"aria-label":"Retry loading members",className:"px-3 py-1.5 text-sm rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",children:"Retry"})]}):u?e.jsx(z,{}):f.length===0?e.jsxs("div",{className:"text-center py-4 sm:py-6 text-muted-foreground border border-dashed rounded-lg",role:"status",children:[e.jsx("p",{children:"No members yet"}),t&&e.jsx("p",{className:"text-sm mt-1",children:"Use the invite form above to add members."})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsx(w.MemberList,{members:f,currentUserId:s,canManage:t,onRoleChange:$,onRemove:U,isLoading:u})})]})]})})}function W(){return e.jsxs("div",{className:"space-y-3",role:"status","aria-label":"Loading invitations",children:[[1,2].map(r=>e.jsx("div",{className:"h-16 sm:h-20 rounded-lg bg-muted animate-pulse"},r)),e.jsx("span",{className:"sr-only",children:"Loading invitations..."})]})}function q({entityName:r,onConfirm:a,onCancel:s}){return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",role:"dialog","aria-modal":"true","aria-label":"Decline invitation",onClick:t=>{t.target===t.currentTarget&&s()},onKeyDown:t=>{t.key==="Escape"&&s()},children:e.jsxs("div",{className:"w-full max-w-sm rounded-lg bg-background p-4 sm:p-6 shadow-lg",children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Decline Invitation"}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["Are you sure you want to decline the invitation to join"," ",e.jsx("strong",{children:r}),"? You will need a new invitation to join later."]}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx("button",{type:"button",onClick:s,className:"px-4 py-2 rounded-lg border hover:bg-muted transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 w-full sm:w-auto",children:"Keep"}),e.jsx("button",{type:"button",onClick:a,className:"px-4 py-2 rounded-lg bg-destructive text-destructive-foreground font-medium hover:bg-destructive/90 transition-colors focus:outline-none focus:ring-2 focus:ring-destructive focus:ring-offset-2 w-full sm:w-auto",children:"Decline"})]})]})})}function K({client:r,onInvitationAccepted:a}){const{data:s=[],isLoading:t,isError:o,error:n,refetch:f}=m.useMyInvitations(r),u=m.useAcceptInvitation(r),x=m.useDeclineInvitation(r),[g,v]=N.useState(null),k=async c=>{try{await u.mutateAsync(c),a?.()}catch(C){console.error("Failed to accept invitation:",C)}},S=c=>{const i=s.find(b=>b.token===c)?.entity?.displayName||"this organization";v({token:c,entityName:i})},p=async()=>{if(g){try{await x.mutateAsync(g.token)}catch(c){console.error("Failed to decline invitation:",c)}v(null)}},h=s.filter(c=>c.status==="pending").length;return e.jsx(E.Section,{spacing:"lg",maxWidth:"4xl",children:e.jsxs("div",{role:"main","aria-label":"Invitations",children:[g&&e.jsx(q,{entityName:g.entityName,onConfirm:p,onCancel:()=>v(null)}),e.jsxs("div",{className:"mb-4 sm:mb-6",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-foreground",children:"Invitations"}),e.jsx("p",{className:"text-sm sm:text-base text-muted-foreground",children:h>0?`You have ${h} pending invitation${h>1?"s":""}`:"No pending invitations"})]}),o&&e.jsxs("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4 sm:p-6 text-center mb-4 sm:mb-6",role:"alert","aria-live":"polite",children:[e.jsx("p",{className:"text-destructive font-medium mb-2",children:"Failed to load invitations"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:n?.message||"An unexpected error occurred"}),e.jsx("button",{type:"button",onClick:()=>f(),"aria-label":"Retry loading invitations",className:"px-4 py-2 rounded-lg bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2",children:"Retry"})]}),t&&e.jsx(W,{}),!t&&!o&&e.jsx(e.Fragment,{children:s.length===0?e.jsxs("div",{className:"text-center py-6 sm:py-8 text-muted-foreground border border-dashed rounded-lg",role:"status",children:[e.jsx("p",{className:"text-base sm:text-lg font-medium mb-1",children:"No invitations"}),e.jsx("p",{className:"text-sm",children:"You don't have any pending invitations"})]}):e.jsx("section",{"aria-label":"Invitation list",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsx(w.InvitationList,{invitations:s,mode:"user",onAccept:k,onDecline:S,isLoading:t,emptyMessage:"You don't have any pending invitations"})})})})]})})}l.EntityListPage=F,l.InvitationsPage=K,l.MembersManagementPage=T,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sudobility/entity_pages",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.53",
|
|
4
4
|
"description": "Page containers for entity/organization management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.umd.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
44
44
|
"@tanstack/react-query": "^5.0.0",
|
|
45
45
|
"@sudobility/components": "^5.0.15",
|
|
46
|
-
"@sudobility/entity_client": "^0.0.
|
|
46
|
+
"@sudobility/entity_client": "^0.0.24",
|
|
47
47
|
"@sudobility/entity-components": "^1.0.11",
|
|
48
48
|
"@heroicons/react": "^2.2.0",
|
|
49
49
|
"@sudobility/types": "^1.9.54"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@heroicons/react": "^2.2.0",
|
|
54
54
|
"@sudobility/components": "^5.0.15",
|
|
55
55
|
"@sudobility/entity-components": "^1.0.11",
|
|
56
|
-
"@sudobility/entity_client": "^0.0.
|
|
56
|
+
"@sudobility/entity_client": "^0.0.24",
|
|
57
57
|
"@sudobility/types": "^1.9.54",
|
|
58
58
|
"@tanstack/react-query": "^5.0.0",
|
|
59
59
|
"@testing-library/dom": "^10.4.0",
|