@firecms/user_management 3.0.0-3.0.0-canary.8.0 → 3.0.0-3.0.0-canary.44.0

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.
Files changed (43) hide show
  1. package/LICENSE +113 -21
  2. package/dist/UserManagementProvider.d.ts +4 -3
  3. package/dist/components/roles/RoleChip.d.ts +1 -1
  4. package/dist/components/roles/RolesDetailsForm.d.ts +1 -2
  5. package/dist/components/roles/RolesTable.d.ts +1 -1
  6. package/dist/components/roles/default_roles.d.ts +1 -1
  7. package/dist/components/users/UserDetailsForm.d.ts +2 -2
  8. package/dist/components/users/UsersTable.d.ts +2 -2
  9. package/dist/hooks/index.d.ts +1 -1
  10. package/dist/hooks/{useBuildFirestoreUserManagement.d.ts → useFirestoreUserManagement.d.ts} +7 -3
  11. package/dist/hooks/useUserManagement.d.ts +3 -2
  12. package/dist/index.es.js +559 -472
  13. package/dist/index.es.js.map +1 -1
  14. package/dist/index.umd.js +1 -1
  15. package/dist/index.umd.js.map +1 -1
  16. package/dist/types/index.d.ts +1 -2
  17. package/dist/types/persisted_user.d.ts +5 -0
  18. package/dist/types/user_management.d.ts +14 -10
  19. package/dist/useUserManagementPlugin.d.ts +6 -1
  20. package/dist/utils/permissions.d.ts +3 -4
  21. package/package.json +12 -15
  22. package/src/UserManagementProvider.tsx +4 -3
  23. package/src/components/roles/RoleChip.tsx +1 -1
  24. package/src/components/roles/RolesDetailsForm.tsx +1 -2
  25. package/src/components/roles/RolesTable.tsx +1 -2
  26. package/src/components/roles/RolesView.tsx +1 -2
  27. package/src/components/roles/default_roles.tsx +1 -1
  28. package/src/components/users/UserDetailsForm.tsx +14 -13
  29. package/src/components/users/UsersTable.tsx +6 -6
  30. package/src/components/users/UsersView.tsx +3 -3
  31. package/src/hooks/index.ts +1 -1
  32. package/src/hooks/{useBuildFirestoreUserManagement.tsx → useFirestoreUserManagement.tsx} +87 -54
  33. package/src/hooks/useUserManagement.tsx +3 -3
  34. package/src/types/index.ts +1 -2
  35. package/src/types/persisted_user.ts +6 -0
  36. package/src/types/user_management.tsx +17 -11
  37. package/src/useUserManagementPlugin.tsx +89 -3
  38. package/src/utils/permissions.ts +7 -5
  39. package/dist/types/firecms_user.d.ts +0 -7
  40. package/dist/types/roles.d.ts +0 -31
  41. package/src/types/firecms_user.ts +0 -8
  42. package/src/types/roles.ts +0 -41
  43. package/tailwind.config.js +0 -68
package/dist/index.es.js CHANGED
@@ -1,22 +1,25 @@
1
- import A, { useRef as Se, useEffect as Z, useCallback as E, useContext as Ie, useState as F } from "react";
2
- import { getFirestore as ee, onSnapshot as le, collection as se, setDoc as ae, doc as G, deleteDoc as ce } from "firebase/firestore";
3
- import { jsx as e, jsxs as s, Fragment as H } from "react/jsx-runtime";
4
- import { getColorSchemeForSeed as ke, Chip as Ee, Dialog as de, DialogContent as ue, Typography as _, TextField as K, Paper as Pe, Table as ie, TableHeader as re, TableCell as a, TableBody as oe, TableRow as M, Tooltip as L, Checkbox as P, Select as ne, SelectItem as T, DialogActions as me, Button as q, LoadingButton as he, DoneIcon as fe, IconButton as ge, DeleteIcon as pe, CenteredView as Ce, Container as ve, AddIcon as we, MultiSelect as Ae, MultiSelectItem as Fe } from "@firecms/ui";
5
- import * as V from "yup";
6
- import { toSnakeCase as Te, FieldCaption as B, DeleteConfirmationDialog as ye, useNavigationController as Be, useSnackbarController as be, useAuthController as Le, useCustomizationController as Ve, defaultDateFormat as _e } from "@firecms/core";
7
- import { useCreateFormex as Ne, getIn as j, Formex as xe } from "@firecms/formex";
1
+ import F, { useEffect as ce, useCallback as k, useContext as Ie, useState as P } from "react";
2
+ import { getFirestore as Y, onSnapshot as ue, collection as ee, setDoc as me, doc as H, addDoc as Fe, deleteDoc as he } from "firebase/firestore";
3
+ import { jsx as e, jsxs as s, Fragment as K } from "react/jsx-runtime";
4
+ import { getColorSchemeForSeed as Pe, Chip as Ae, Dialog as fe, DialogContent as ge, Typography as A, TextField as Q, Paper as pe, Table as re, TableHeader as ie, TableCell as d, TableBody as oe, TableRow as W, Tooltip as V, Checkbox as I, Select as ne, SelectItem as L, DialogActions as Ce, Button as O, LoadingButton as ve, DoneIcon as we, IconButton as ye, DeleteIcon as be, CenteredView as Ne, Container as Ue, AddIcon as le, MultiSelect as Te, MultiSelectItem as Le } from "@firecms/ui";
5
+ import * as M from "yup";
6
+ import { toSnakeCase as Be, FieldCaption as B, DeleteConfirmationDialog as xe, useNavigationController as _e, useSnackbarController as se, useAuthController as ae, useCustomizationController as Ve, defaultDateFormat as Me } from "@firecms/core";
7
+ import { useCreateFormex as Re, getIn as J, Formex as De } from "@firecms/formex";
8
8
  import { format as Oe } from "date-fns";
9
9
  import * as $e from "date-fns/locale";
10
- const hn = ["Admin"], Me = {
10
+ const fn = ["Admin"], qe = {
11
11
  read: !1,
12
12
  edit: !1,
13
13
  create: !1,
14
14
  delete: !1
15
15
  };
16
- function qe({ collection: t, user: i }) {
17
- const n = i?.roles;
16
+ function Ye({
17
+ collection: t,
18
+ user: r
19
+ }) {
20
+ const n = r?.roles;
18
21
  if (n) {
19
- if (t.ownerId === i?.uid)
22
+ if (t.ownerId === r?.uid)
20
23
  return {
21
24
  read: !0,
22
25
  create: !0,
@@ -24,277 +27,299 @@ function qe({ collection: t, user: i }) {
24
27
  delete: !0
25
28
  };
26
29
  {
27
- const d = {
30
+ const l = {
28
31
  read: !1,
29
32
  create: !1,
30
33
  edit: !1,
31
34
  delete: !1
32
35
  };
33
- return n.map((r) => Ye(r, t.id)).reduce(te, d);
36
+ return n.map((i) => We(i, t.id)).reduce(te, l);
34
37
  }
35
38
  } else
36
- return Me;
39
+ return qe;
37
40
  }
38
- function Ye(t, i) {
41
+ function We(t, r) {
39
42
  const n = {
40
43
  read: t.isAdmin || t.defaultPermissions?.read,
41
44
  create: t.isAdmin || t.defaultPermissions?.create,
42
45
  edit: t.isAdmin || t.defaultPermissions?.edit,
43
46
  delete: t.isAdmin || t.defaultPermissions?.delete
44
47
  };
45
- return t.collectionPermissions && t.collectionPermissions[i] ? te(t.collectionPermissions[i], n) : t.defaultPermissions ? te(t.defaultPermissions, n) : n;
48
+ return t.collectionPermissions && t.collectionPermissions[r] ? te(t.collectionPermissions[r], n) : t.defaultPermissions ? te(t.defaultPermissions, n) : n;
46
49
  }
47
- const te = (t, i) => ({
48
- read: t.read || i.read,
49
- create: t.create || i.create,
50
- edit: t.edit || i.edit,
51
- delete: t.delete || i.delete
50
+ const te = (t, r) => ({
51
+ read: t.read || r.read,
52
+ create: t.create || r.create,
53
+ edit: t.edit || r.edit,
54
+ delete: t.delete || r.delete
52
55
  });
53
- function fn(t, i) {
54
- return t ? i.roles ? i.roles.map((n) => t.find((d) => d.id === n.id)).filter(Boolean) : [] : void 0;
56
+ function gn(t, r) {
57
+ return t ? r.roles ? r.roles.map((n) => t.find((l) => l.id === n.id)).filter(Boolean) : [] : void 0;
55
58
  }
56
- const We = (t, i) => {
57
- const n = t.map((r) => r.id), d = i.map((r) => r.id);
58
- return n.length === i.length && n.every((r) => d.includes(r));
59
+ const je = (t, r) => {
60
+ const n = t.map((i) => i.id), l = r.map((i) => i.id);
61
+ return n.length === r.length && n.every((i) => l.includes(i));
59
62
  };
60
- function gn(t, i) {
61
- if (!i)
63
+ function pn(t, r) {
64
+ if (!r)
62
65
  return;
63
- const n = je(i), d = new Date(n.exp * 1e3);
66
+ const n = ze(r), l = new Date(n.exp * 1e3);
64
67
  localStorage.setItem(`auth_token::${t}`, JSON.stringify({
65
- token: i,
66
- expiry: d
68
+ token: r,
69
+ expiry: l
67
70
  }));
68
71
  }
69
- function pn(t) {
70
- const i = localStorage.getItem(`auth_token::${t}`);
71
- if (i) {
72
- const n = JSON.parse(i);
72
+ function Cn(t) {
73
+ const r = localStorage.getItem(`auth_token::${t}`);
74
+ if (r) {
75
+ const n = JSON.parse(r);
73
76
  if (n.expiry = new Date(n.expiry), n.expiry > /* @__PURE__ */ new Date())
74
77
  return n.token;
75
78
  }
76
79
  }
77
- function Cn() {
80
+ function vn() {
78
81
  for (let t = 0; t < localStorage.length; t++) {
79
- const i = localStorage.key(t);
80
- i?.startsWith("auth_token::") && localStorage.removeItem(i);
82
+ const r = localStorage.key(t);
83
+ r?.startsWith("auth_token::") && localStorage.removeItem(r);
81
84
  }
82
85
  }
83
- function je(t) {
86
+ function ze(t) {
84
87
  if (!t)
85
88
  throw new Error("No JWT token");
86
- const n = t.split(".")[1].replace(/-/g, "+").replace(/_/g, "/"), d = decodeURIComponent(window.atob(n).split("").map(function(r) {
87
- return "%" + ("00" + r.charCodeAt(0).toString(16)).slice(-2);
89
+ const n = t.split(".")[1].replace(/-/g, "+").replace(/_/g, "/"), l = decodeURIComponent(window.atob(n).split("").map(function(i) {
90
+ return "%" + ("00" + i.charCodeAt(0).toString(16)).slice(-2);
88
91
  }).join(""));
89
- return JSON.parse(d);
92
+ return JSON.parse(l);
90
93
  }
91
- function vn(t, i = 10) {
94
+ function wn(t, r = 10) {
92
95
  if (!/^#([0-9A-Fa-f]{3}){1,2}$/.test(t))
93
96
  throw new Error("Invalid color format");
94
97
  let n = t.substring(1).split("");
95
98
  n.length === 3 && (n = [n[0], n[0], n[1], n[1], n[2], n[2]]);
96
- let d = parseInt(n[0] + n[1], 16), r = parseInt(n[2] + n[3], 16), m = parseInt(n[4] + n[5], 16);
97
- return d = Math.floor(d * (1 - i / 100)), r = Math.floor(r * (1 - i / 100)), m = Math.floor(m * (1 - i / 100)), "#" + (d < 16 ? "0" : "") + d.toString(16) + (r < 16 ? "0" : "") + r.toString(16) + (m < 16 ? "0" : "") + m.toString(16);
99
+ let l = parseInt(n[0] + n[1], 16), i = parseInt(n[2] + n[3], 16), m = parseInt(n[4] + n[5], 16);
100
+ return l = Math.floor(l * (1 - r / 100)), i = Math.floor(i * (1 - r / 100)), m = Math.floor(m * (1 - r / 100)), "#" + (l < 16 ? "0" : "") + l.toString(16) + (i < 16 ? "0" : "") + i.toString(16) + (m < 16 ? "0" : "") + m.toString(16);
98
101
  }
99
- function wn(t, i = 10) {
102
+ function yn(t, r = 10) {
100
103
  if (!/^#([0-9A-Fa-f]{3}){1,2}$/.test(t))
101
104
  throw new Error("Invalid color format");
102
105
  let n = t.substring(1).split("");
103
106
  n.length === 3 && (n = [n[0], n[0], n[1], n[1], n[2], n[2]]);
104
- const d = parseInt(n[0] + n[1], 16), r = parseInt(n[2] + n[3], 16), m = parseInt(n[4] + n[5], 16), f = i / 100;
105
- return `rgba(${d}, ${r}, ${m}, ${f})`;
107
+ const l = parseInt(n[0] + n[1], 16), i = parseInt(n[2] + n[3], 16), m = parseInt(n[4] + n[5], 16), f = r / 100;
108
+ return `rgba(${l}, ${i}, ${m}, ${f})`;
106
109
  }
107
- function yn({
110
+ function bn({
108
111
  firebaseApp: t,
109
- usersPath: i = "__FIRECMS/config/users",
112
+ usersPath: r = "__FIRECMS/config/users",
110
113
  rolesPath: n = "__FIRECMS/config/roles",
111
- usersLimit: d,
112
- canEditRoles: r = !0,
113
- authController: m,
114
- allowDefaultRolesCreation: f,
115
- includeCollectionConfigPermissions: p
114
+ usersLimit: l,
115
+ canEditRoles: i = !0,
116
+ allowDefaultRolesCreation: m,
117
+ includeCollectionConfigPermissions: f
116
118
  }) {
117
- const N = Se(), [v, c] = A.useState(!0), [I, w] = A.useState(!0), [l, g] = A.useState([]), [R, y] = A.useState([]), O = R.map((C) => ({
118
- ...C,
119
- roles: l.filter((b) => C.roles?.includes(b.id))
120
- })), [z, u] = A.useState(), [h, x] = A.useState(), U = v || I, k = O.find((C) => C.email?.toLowerCase() === m.user?.email?.toLowerCase());
121
- Z(() => {
122
- t && (N.current = ee(t));
123
- }, [t]), Z(() => {
119
+ const [v, R] = F.useState(!0), [w, c] = F.useState(!0), [S, U] = F.useState([]), [a, C] = F.useState([]), y = a.map((g) => ({
120
+ ...g,
121
+ roles: S.filter((p) => g.roles?.includes(p.id))
122
+ })), [b, _] = F.useState(), [z, u] = F.useState(), h = v || w;
123
+ ce(() => {
124
124
  if (!t || !n)
125
125
  return;
126
- const C = ee(t);
127
- return le(
128
- se(C, n),
126
+ const g = Y(t);
127
+ return ue(
128
+ ee(g, n),
129
129
  {
130
- next: (b) => {
131
- u(void 0);
130
+ next: (p) => {
131
+ _(void 0);
132
132
  try {
133
- const D = Je(b.docs);
134
- g(D);
135
- } catch (D) {
136
- u(D);
133
+ const N = Ge(p.docs);
134
+ U(N);
135
+ } catch (N) {
136
+ console.error("Error loading roles", N), _(N);
137
137
  }
138
- c(!1);
138
+ R(!1);
139
139
  },
140
- error: (b) => {
141
- u(b), c(!1);
140
+ error: (p) => {
141
+ console.error("Error loading roles", p), _(p), R(!1);
142
142
  }
143
143
  }
144
144
  );
145
- }, [t, n]), Z(() => {
146
- if (!t || !i)
145
+ }, [t, n]), ce(() => {
146
+ if (!t || !r)
147
147
  return;
148
- const C = ee(t);
149
- return le(
150
- se(C, i),
148
+ const g = Y(t);
149
+ return ue(
150
+ ee(g, r),
151
151
  {
152
- next: (b) => {
153
- x(void 0);
152
+ next: (p) => {
153
+ u(void 0);
154
154
  try {
155
- const D = ze(b.docs);
156
- y(D);
157
- } catch (D) {
158
- x(D);
155
+ const N = Je(p.docs);
156
+ C(N);
157
+ } catch (N) {
158
+ console.error("Error loading users", N), u(N);
159
159
  }
160
- w(!1);
160
+ c(!1);
161
161
  },
162
- error: (b) => {
163
- x(b), w(!1);
162
+ error: (p) => {
163
+ console.error("Error loading users", p), u(p), c(!1);
164
164
  }
165
165
  }
166
166
  );
167
- }, [t, i]);
168
- const o = E(async (C) => {
169
- const b = N.current;
170
- if (!b || !i)
171
- throw Error("useFirestoreConfigurationPersistence Firestore not initialised");
172
- console.debug("Persisting user", C);
173
- const D = C.roles.map((Ue) => Ue.id), {
174
- uid: W,
175
- ...X
176
- } = C;
177
- return ae(G(b, i, W), { ...X, roles: D }, { merge: !0 }).then(() => C);
178
- }, [i]), S = E((C) => {
179
- const b = N.current;
180
- if (!b || !n)
181
- throw Error("useFirestoreConfigurationPersistence Firestore not initialised");
182
- console.debug("Persisting role", C);
167
+ }, [t, r]);
168
+ const x = k(async (g) => {
169
+ if (!t)
170
+ throw Error("useFirestoreUserManagement Firebase not initialised");
171
+ const p = Y(t);
172
+ if (!p || !r)
173
+ throw Error("useFirestoreUserManagement Firestore not initialised");
174
+ console.debug("Persisting user", g);
175
+ const N = g.roles?.map((ke) => ke.id), {
176
+ uid: q,
177
+ ...Z
178
+ } = g, de = {
179
+ ...Z,
180
+ roles: N
181
+ };
182
+ return q ? me(H(p, r, q), de, { merge: !0 }).then(() => g) : Fe(ee(p, r), de).then(() => g);
183
+ }, [r, t]), D = k((g) => {
184
+ if (!t)
185
+ throw Error("useFirestoreUserManagement Firebase not initialised");
186
+ const p = Y(t);
187
+ if (!p || !n)
188
+ throw Error("useFirestoreUserManagement Firestore not initialised");
189
+ console.debug("Persisting role", g);
183
190
  const {
184
- id: D,
185
- ...W
186
- } = C, X = G(b, n, D);
187
- return ae(X, W, { merge: !0 });
188
- }, [n]), $ = E(async (C) => {
189
- const b = N.current;
190
- if (!b || !i)
191
- throw Error("useFirestoreConfigurationPersistence Firestore not initialised");
192
- console.debug("Deleting", C);
193
- const { uid: D } = C;
194
- return ce(G(b, i, D));
195
- }, [i]), J = E((C) => {
196
- const b = N.current;
197
- if (!b || !n)
198
- throw Error("useFirestoreConfigurationPersistence Firestore not initialised");
199
- console.debug("Deleting", C);
200
- const { id: D } = C, W = G(b, n, D);
201
- return ce(W);
202
- }, [n]), De = E(({
203
- collection: C
204
- }) => qe({
205
- collection: C,
206
- user: k ?? null
207
- }), [k?.uid]);
191
+ id: N,
192
+ ...q
193
+ } = g, Z = H(p, n, N);
194
+ return me(Z, q, { merge: !0 });
195
+ }, [n, t]), T = k(async (g) => {
196
+ if (!t)
197
+ throw Error("useFirestoreUserManagement Firebase not initialised");
198
+ const p = Y(t);
199
+ if (!p || !r)
200
+ throw Error("useFirestoreUserManagement Firestore not initialised");
201
+ console.debug("Deleting", g);
202
+ const { uid: N } = g;
203
+ return he(H(p, r, N));
204
+ }, [r, t]), o = k((g) => {
205
+ if (!t)
206
+ throw Error("useFirestoreUserManagement Firebase not initialised");
207
+ const p = Y(t);
208
+ if (!p || !n)
209
+ throw Error("useFirestoreUserManagement Firestore not initialised");
210
+ console.debug("Deleting", g);
211
+ const { id: N } = g, q = H(p, n, N);
212
+ return he(q);
213
+ }, [n, t]), E = k(({
214
+ collection: g,
215
+ user: p
216
+ }) => Ye({
217
+ collection: g,
218
+ user: p
219
+ }), []), $ = k((g) => {
220
+ if (!y)
221
+ throw Error("Users not loaded");
222
+ return y.find((N) => N.email?.toLowerCase() === g?.email?.toLowerCase())?.roles;
223
+ }, [y]), G = k(({ user: g }) => {
224
+ if (console.debug("Authenticating user", g), h)
225
+ return console.warn("User management is still loading"), !1;
226
+ if (y.length === 0 || y.find((N) => N.email?.toLowerCase() === g?.email?.toLowerCase()))
227
+ return !0;
228
+ throw Error("Could not find a user with the provided email in the user management system.");
229
+ }, [h, y]);
208
230
  return {
209
- loading: U,
210
- loggedInUser: k,
211
- roles: l,
212
- users: O,
213
- saveUser: o,
214
- saveRole: S,
215
- deleteUser: $,
216
- deleteRole: J,
217
- usersLimit: d,
218
- canEditRoles: r === void 0 ? !0 : r,
219
- allowDefaultRolesCreation: f === void 0 ? !0 : f,
220
- includeCollectionConfigPermissions: !!p,
221
- collectionPermissions: De
231
+ loading: h,
232
+ roles: S,
233
+ users: y,
234
+ saveUser: x,
235
+ saveRole: D,
236
+ rolesError: b,
237
+ deleteUser: T,
238
+ deleteRole: o,
239
+ usersLimit: l,
240
+ usersError: z,
241
+ canEditRoles: i === void 0 ? !0 : i,
242
+ allowDefaultRolesCreation: m === void 0 ? !0 : m,
243
+ includeCollectionConfigPermissions: !!f,
244
+ collectionPermissions: E,
245
+ defineRolesFor: $,
246
+ authenticator: G
222
247
  };
223
248
  }
224
- const ze = (t) => t.map((i) => {
225
- const n = i.data();
249
+ const Je = (t) => t.map((r) => {
250
+ const n = r.data();
226
251
  return {
227
- uid: i.id,
252
+ uid: r.id,
228
253
  ...n,
229
254
  created_on: n?.created_on?.toDate(),
230
255
  updated_on: n?.updated_on?.toDate()
231
256
  };
232
- }), Je = (t) => t.map((i) => ({
233
- id: i.id,
234
- ...i.data()
235
- })), Re = A.createContext({});
236
- function Ge({
257
+ }), Ge = (t) => t.map((r) => ({
258
+ id: r.id,
259
+ ...r.data()
260
+ })), Ee = F.createContext({});
261
+ function He({
237
262
  children: t,
238
- userManagement: i
263
+ userManagement: r
239
264
  }) {
240
- return /* @__PURE__ */ e(Re.Provider, { value: i, children: t });
265
+ return /* @__PURE__ */ e(Ee.Provider, { value: r, children: t });
241
266
  }
242
- const Y = () => Ie(Re);
243
- function Q({ role: t }) {
244
- let i;
245
- return t.isAdmin ? i = "blueDarker" : t.id === "editor" ? i = "yellowLight" : t.id === "viewer" ? i = "grayLight" : i = ke(t.id), /* @__PURE__ */ e(
246
- Ee,
267
+ const j = () => Ie(Ee);
268
+ function X({ role: t }) {
269
+ let r;
270
+ return t.isAdmin ? r = "blueDarker" : t.id === "editor" ? r = "yellowLight" : t.id === "viewer" ? r = "grayLight" : r = Pe(t.id), /* @__PURE__ */ e(
271
+ Ae,
247
272
  {
248
- colorScheme: i,
273
+ colorScheme: r,
249
274
  children: t.name
250
275
  },
251
276
  t.id
252
277
  );
253
278
  }
254
- const He = V.object().shape({
255
- id: V.string().required("Required"),
256
- name: V.string().required("Required")
279
+ const Ke = M.object().shape({
280
+ id: M.string().required("Required"),
281
+ name: M.string().required("Required")
257
282
  });
258
- function Ke({
283
+ function Qe({
259
284
  open: t,
260
- role: i,
285
+ role: r,
261
286
  editable: n,
262
- handleClose: d,
263
- collections: r
287
+ handleClose: l,
288
+ collections: i
264
289
  }) {
265
- const { saveRole: m } = Y(), f = !i, [p, N] = F(), v = E((o) => (N(void 0), m(o)), [m]), c = Ne({
266
- initialValues: i ?? {
290
+ const { saveRole: m } = j(), f = !r, [v, R] = P(), w = k((o) => (R(void 0), m(o)), [m]), c = Re({
291
+ initialValues: r ?? {
267
292
  name: ""
268
293
  },
269
- onSubmit: (o, S) => v(o).then(() => {
270
- S.resetForm({
294
+ onSubmit: (o, E) => w(o).then(() => {
295
+ E.resetForm({
271
296
  values: o
272
- }), d();
273
- }).catch(($) => N($)),
274
- validation: (o) => He.validate(o, { abortEarly: !1 }).then(() => ({})).catch((S) => {
297
+ }), l();
298
+ }).catch(($) => R($)),
299
+ validation: (o) => Ke.validate(o, { abortEarly: !1 }).then(() => ({})).catch((E) => {
275
300
  const $ = {};
276
- return S.inner.forEach((J) => {
277
- $[J.path] = J.message;
301
+ return E.inner.forEach((G) => {
302
+ $[G.path] = G.message;
278
303
  }), $;
279
304
  })
280
305
  }), {
281
- isSubmitting: I,
282
- touched: w,
283
- values: l,
284
- errors: g,
285
- handleChange: R,
286
- setFieldValue: y,
287
- dirty: O,
306
+ isSubmitting: S,
307
+ touched: U,
308
+ values: a,
309
+ errors: C,
310
+ handleChange: y,
311
+ setFieldValue: b,
312
+ dirty: _,
288
313
  setFieldTouched: z
289
- } = c, u = l.isAdmin ?? !1, h = l.defaultPermissions?.create ?? !1, x = l.defaultPermissions?.read ?? !1, U = l.defaultPermissions?.edit ?? !1, k = l.defaultPermissions?.delete ?? !1;
290
- return A.useEffect(() => {
291
- !j(w, "id") && l.name && y("id", Te(l.name));
292
- }, [w, l.name]), /* @__PURE__ */ e(
293
- de,
314
+ } = c, u = a.isAdmin ?? !1, h = a.defaultPermissions?.create ?? !1, x = a.defaultPermissions?.read ?? !1, D = a.defaultPermissions?.edit ?? !1, T = a.defaultPermissions?.delete ?? !1;
315
+ return F.useEffect(() => {
316
+ !J(U, "id") && a.name && b("id", Be(a.name));
317
+ }, [U, a.name]), /* @__PURE__ */ e(
318
+ fe,
294
319
  {
295
320
  open: t,
296
321
  maxWidth: "4xl",
297
- children: /* @__PURE__ */ e(xe, { value: c, children: /* @__PURE__ */ s(
322
+ children: /* @__PURE__ */ e(De, { value: c, children: /* @__PURE__ */ s(
298
323
  "form",
299
324
  {
300
325
  noValidate: !0,
@@ -307,13 +332,13 @@ function Ke({
307
332
  height: "100%"
308
333
  },
309
334
  children: [
310
- /* @__PURE__ */ s(ue, { className: "flex-grow", children: [
335
+ /* @__PURE__ */ s(ge, { className: "flex-grow", children: [
311
336
  /* @__PURE__ */ e(
312
337
  "div",
313
338
  {
314
339
  className: "flex flex-row pt-12 pb-8",
315
340
  children: /* @__PURE__ */ e(
316
- _,
341
+ A,
317
342
  {
318
343
  variant: "h4",
319
344
  className: "flex-grow",
@@ -325,69 +350,69 @@ function Ke({
325
350
  /* @__PURE__ */ s("div", { className: "grid grid-cols-12 gap-8", children: [
326
351
  /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-8", children: [
327
352
  /* @__PURE__ */ e(
328
- K,
353
+ Q,
329
354
  {
330
355
  name: "name",
331
356
  required: !0,
332
- error: w.name && !!g.name,
333
- value: l.name,
357
+ error: U.name && !!C.name,
358
+ value: a.name,
334
359
  disabled: u || !n,
335
- onChange: R,
360
+ onChange: y,
336
361
  "aria-describedby": "name-helper-text",
337
362
  label: "Name"
338
363
  }
339
364
  ),
340
- /* @__PURE__ */ e(B, { children: w.name && g.name ? g.name : "Name of this role" })
365
+ /* @__PURE__ */ e(B, { children: U.name && C.name ? C.name : "Name of this role" })
341
366
  ] }),
342
367
  /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
343
368
  /* @__PURE__ */ e(
344
- K,
369
+ Q,
345
370
  {
346
371
  name: "id",
347
372
  required: !0,
348
- error: w.id && !!g.id,
349
- value: l.id,
373
+ error: U.id && !!C.id,
374
+ value: a.id,
350
375
  disabled: !f || !n,
351
376
  onChange: (o) => {
352
- R(o), z("id", !0);
377
+ y(o), z("id", !0);
353
378
  },
354
379
  "aria-describedby": "id-helper-text",
355
380
  label: "ID"
356
381
  }
357
382
  ),
358
- /* @__PURE__ */ e(B, { children: w.id && g.id ? g.id : "ID of this role" })
383
+ /* @__PURE__ */ e(B, { children: U.id && C.id ? C.id : "ID of this role" })
359
384
  ] }),
360
385
  /* @__PURE__ */ s("div", { className: "col-span-12", children: [
361
386
  /* @__PURE__ */ e(
362
- Pe,
387
+ pe,
363
388
  {
364
389
  className: "bg-inherit",
365
- children: /* @__PURE__ */ s(ie, { children: [
366
- /* @__PURE__ */ s(re, { children: [
367
- /* @__PURE__ */ e(a, {}),
390
+ children: /* @__PURE__ */ s(re, { children: [
391
+ /* @__PURE__ */ s(ie, { children: [
392
+ /* @__PURE__ */ e(d, {}),
368
393
  /* @__PURE__ */ e(
369
- a,
394
+ d,
370
395
  {
371
396
  align: "center",
372
397
  children: "Create entities"
373
398
  }
374
399
  ),
375
400
  /* @__PURE__ */ e(
376
- a,
401
+ d,
377
402
  {
378
403
  align: "center",
379
404
  children: "Read entities"
380
405
  }
381
406
  ),
382
407
  /* @__PURE__ */ e(
383
- a,
408
+ d,
384
409
  {
385
410
  align: "center",
386
411
  children: "Update entities"
387
412
  }
388
413
  ),
389
414
  /* @__PURE__ */ e(
390
- a,
415
+ d,
391
416
  {
392
417
  align: "center",
393
418
  children: "Delete entities"
@@ -395,28 +420,28 @@ function Ke({
395
420
  )
396
421
  ] }),
397
422
  /* @__PURE__ */ s(oe, { children: [
398
- /* @__PURE__ */ s(M, { children: [
423
+ /* @__PURE__ */ s(W, { children: [
399
424
  /* @__PURE__ */ e(
400
- a,
425
+ d,
401
426
  {
402
427
  scope: "row",
403
428
  children: /* @__PURE__ */ e("strong", { children: "All collections" })
404
429
  }
405
430
  ),
406
431
  /* @__PURE__ */ e(
407
- a,
432
+ d,
408
433
  {
409
434
  align: "center",
410
435
  children: /* @__PURE__ */ e(
411
- L,
436
+ V,
412
437
  {
413
438
  title: "Create entities in collections",
414
439
  children: /* @__PURE__ */ e(
415
- P,
440
+ I,
416
441
  {
417
442
  disabled: u || !n,
418
443
  checked: (u || h) ?? !1,
419
- onCheckedChange: (o) => y("defaultPermissions.create", o)
444
+ onCheckedChange: (o) => b("defaultPermissions.create", o)
420
445
  }
421
446
  )
422
447
  }
@@ -424,19 +449,19 @@ function Ke({
424
449
  }
425
450
  ),
426
451
  /* @__PURE__ */ e(
427
- a,
452
+ d,
428
453
  {
429
454
  align: "center",
430
455
  children: /* @__PURE__ */ e(
431
- L,
456
+ V,
432
457
  {
433
458
  title: "Access all data in every collection",
434
459
  children: /* @__PURE__ */ e(
435
- P,
460
+ I,
436
461
  {
437
462
  disabled: u || !n,
438
463
  checked: (u || x) ?? !1,
439
- onCheckedChange: (o) => y("defaultPermissions.read", o)
464
+ onCheckedChange: (o) => b("defaultPermissions.read", o)
440
465
  }
441
466
  )
442
467
  }
@@ -444,19 +469,19 @@ function Ke({
444
469
  }
445
470
  ),
446
471
  /* @__PURE__ */ e(
447
- a,
472
+ d,
448
473
  {
449
474
  align: "center",
450
475
  children: /* @__PURE__ */ e(
451
- L,
476
+ V,
452
477
  {
453
478
  title: "Update data in any collection",
454
479
  children: /* @__PURE__ */ e(
455
- P,
480
+ I,
456
481
  {
457
482
  disabled: u || !n,
458
- checked: (u || U) ?? !1,
459
- onCheckedChange: (o) => y("defaultPermissions.edit", o)
483
+ checked: (u || D) ?? !1,
484
+ onCheckedChange: (o) => b("defaultPermissions.edit", o)
460
485
  }
461
486
  )
462
487
  }
@@ -464,19 +489,19 @@ function Ke({
464
489
  }
465
490
  ),
466
491
  /* @__PURE__ */ e(
467
- a,
492
+ d,
468
493
  {
469
494
  align: "center",
470
495
  children: /* @__PURE__ */ e(
471
- L,
496
+ V,
472
497
  {
473
498
  title: "Delete data in any collection",
474
499
  children: /* @__PURE__ */ e(
475
- P,
500
+ I,
476
501
  {
477
502
  disabled: u || !n,
478
- checked: (u || k) ?? !1,
479
- onCheckedChange: (o) => y("defaultPermissions.delete", o)
503
+ checked: (u || T) ?? !1,
504
+ onCheckedChange: (o) => b("defaultPermissions.delete", o)
480
505
  }
481
506
  )
482
507
  }
@@ -484,66 +509,66 @@ function Ke({
484
509
  }
485
510
  )
486
511
  ] }),
487
- r && r.map((o) => /* @__PURE__ */ s(M, { children: [
512
+ i && i.map((o) => /* @__PURE__ */ s(W, { children: [
488
513
  /* @__PURE__ */ e(
489
- a,
514
+ d,
490
515
  {
491
516
  scope: "row",
492
517
  children: o.name
493
518
  }
494
519
  ),
495
520
  /* @__PURE__ */ e(
496
- a,
521
+ d,
497
522
  {
498
523
  align: "center",
499
524
  children: /* @__PURE__ */ e(
500
- P,
525
+ I,
501
526
  {
502
527
  disabled: u || h || !n,
503
- checked: (u || h || j(l, `collectionPermissions.${o.path}.create`)) ?? !1,
504
- onCheckedChange: (S) => y(`collectionPermissions.${o.path}.create`, S)
528
+ checked: (u || h || J(a, `collectionPermissions.${o.path}.create`)) ?? !1,
529
+ onCheckedChange: (E) => b(`collectionPermissions.${o.path}.create`, E)
505
530
  }
506
531
  )
507
532
  }
508
533
  ),
509
534
  /* @__PURE__ */ e(
510
- a,
535
+ d,
511
536
  {
512
537
  align: "center",
513
538
  children: /* @__PURE__ */ e(
514
- P,
539
+ I,
515
540
  {
516
541
  disabled: u || x || !n,
517
- checked: (u || x || j(l, `collectionPermissions.${o.path}.read`)) ?? !1,
518
- onCheckedChange: (S) => y(`collectionPermissions.${o.path}.read`, S)
542
+ checked: (u || x || J(a, `collectionPermissions.${o.path}.read`)) ?? !1,
543
+ onCheckedChange: (E) => b(`collectionPermissions.${o.path}.read`, E)
519
544
  }
520
545
  )
521
546
  }
522
547
  ),
523
548
  /* @__PURE__ */ e(
524
- a,
549
+ d,
525
550
  {
526
551
  align: "center",
527
552
  children: /* @__PURE__ */ e(
528
- P,
553
+ I,
529
554
  {
530
- disabled: u || U || !n,
531
- checked: (u || U || j(l, `collectionPermissions.${o.path}.edit`)) ?? !1,
532
- onCheckedChange: (S) => y(`collectionPermissions.${o.path}.edit`, S)
555
+ disabled: u || D || !n,
556
+ checked: (u || D || J(a, `collectionPermissions.${o.path}.edit`)) ?? !1,
557
+ onCheckedChange: (E) => b(`collectionPermissions.${o.path}.edit`, E)
533
558
  }
534
559
  )
535
560
  }
536
561
  ),
537
562
  /* @__PURE__ */ e(
538
- a,
563
+ d,
539
564
  {
540
565
  align: "center",
541
566
  children: /* @__PURE__ */ e(
542
- P,
567
+ I,
543
568
  {
544
- disabled: u || k || !n,
545
- checked: (u || k || j(l, `collectionPermissions.${o.path}.delete`)) ?? !1,
546
- onCheckedChange: (S) => y(`collectionPermissions.${o.path}.delete`, S)
569
+ disabled: u || T || !n,
570
+ checked: (u || T || J(a, `collectionPermissions.${o.path}.delete`)) ?? !1,
571
+ onCheckedChange: (E) => b(`collectionPermissions.${o.path}.delete`, E)
547
572
  }
548
573
  )
549
574
  }
@@ -559,25 +584,25 @@ function Ke({
559
584
  /* @__PURE__ */ s(
560
585
  ne,
561
586
  {
562
- error: w.config && !!g.config,
587
+ error: U.config && !!C.config,
563
588
  id: "createCollections",
564
589
  name: "createCollections",
565
590
  label: "Create collections",
566
591
  position: "item-aligned",
567
592
  disabled: u || !n,
568
- onChange: (o) => y("config.createCollections", o.target.value === "true"),
569
- value: u || l.config?.createCollections ? "true" : "false",
593
+ onChange: (o) => b("config.createCollections", o.target.value === "true"),
594
+ value: u || a.config?.createCollections ? "true" : "false",
570
595
  renderValue: (o) => o === "true" ? "Yes" : "No",
571
596
  children: [
572
597
  /* @__PURE__ */ e(
573
- T,
598
+ L,
574
599
  {
575
600
  value: "true",
576
601
  children: " Yes "
577
602
  }
578
603
  ),
579
604
  /* @__PURE__ */ e(
580
- T,
605
+ L,
581
606
  {
582
607
  value: "false",
583
608
  children: " No "
@@ -586,38 +611,38 @@ function Ke({
586
611
  ]
587
612
  }
588
613
  ),
589
- /* @__PURE__ */ e(B, { children: w.config && g.config ? g.config : "Can the user create collections" })
614
+ /* @__PURE__ */ e(B, { children: U.config && C.config ? C.config : "Can the user create collections" })
590
615
  ] }),
591
616
  /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
592
617
  /* @__PURE__ */ s(
593
618
  ne,
594
619
  {
595
- error: w.config && !!g.config,
620
+ error: U.config && !!C.config,
596
621
  id: "editCollections",
597
622
  name: "editCollections",
598
623
  label: "Edit collections",
599
624
  disabled: u || !n,
600
625
  position: "item-aligned",
601
- onChange: (o) => y("config.editCollections", o.target.value === "own" ? "own" : o.target.value === "true"),
602
- value: u ? "true" : l.config?.editCollections === "own" ? "own" : l.config?.editCollections ? "true" : "false",
626
+ onChange: (o) => b("config.editCollections", o.target.value === "own" ? "own" : o.target.value === "true"),
627
+ value: u ? "true" : a.config?.editCollections === "own" ? "own" : a.config?.editCollections ? "true" : "false",
603
628
  renderValue: (o) => o === "own" ? "Own" : o === "true" ? "Yes" : "No",
604
629
  children: [
605
630
  /* @__PURE__ */ e(
606
- T,
631
+ L,
607
632
  {
608
633
  value: "true",
609
634
  children: " Yes "
610
635
  }
611
636
  ),
612
637
  /* @__PURE__ */ e(
613
- T,
638
+ L,
614
639
  {
615
640
  value: "false",
616
641
  children: " No "
617
642
  }
618
643
  ),
619
644
  /* @__PURE__ */ e(
620
- T,
645
+ L,
621
646
  {
622
647
  value: "own",
623
648
  children: " Only his/her own "
@@ -626,38 +651,38 @@ function Ke({
626
651
  ]
627
652
  }
628
653
  ),
629
- /* @__PURE__ */ e(B, { children: w.config && g.config ? g.config : "Can the user edit collections" })
654
+ /* @__PURE__ */ e(B, { children: U.config && C.config ? C.config : "Can the user edit collections" })
630
655
  ] }),
631
656
  /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
632
657
  /* @__PURE__ */ s(
633
658
  ne,
634
659
  {
635
- error: w.config && !!g.config,
660
+ error: U.config && !!C.config,
636
661
  id: "deleteCollections",
637
662
  name: "deleteCollections",
638
663
  label: "Delete collections",
639
664
  disabled: u || !n,
640
665
  position: "item-aligned",
641
- onChange: (o) => y("config.deleteCollections", o.target.value === "own" ? "own" : o.target.value === "true"),
642
- value: u ? "true" : l.config?.deleteCollections === "own" ? "own" : l.config?.deleteCollections ? "true" : "false",
666
+ onChange: (o) => b("config.deleteCollections", o.target.value === "own" ? "own" : o.target.value === "true"),
667
+ value: u ? "true" : a.config?.deleteCollections === "own" ? "own" : a.config?.deleteCollections ? "true" : "false",
643
668
  renderValue: (o) => o === "own" ? "Own" : o === "true" ? "Yes" : "No",
644
669
  children: [
645
670
  /* @__PURE__ */ e(
646
- T,
671
+ L,
647
672
  {
648
673
  value: "true",
649
674
  children: " Yes "
650
675
  }
651
676
  ),
652
677
  /* @__PURE__ */ e(
653
- T,
678
+ L,
654
679
  {
655
680
  value: "false",
656
681
  children: " No "
657
682
  }
658
683
  ),
659
684
  /* @__PURE__ */ e(
660
- T,
685
+ L,
661
686
  {
662
687
  value: "own",
663
688
  children: " Only his/her own "
@@ -666,31 +691,31 @@ function Ke({
666
691
  ]
667
692
  }
668
693
  ),
669
- /* @__PURE__ */ e(B, { children: w.config && g.config ? g.config : "Can the user delete collections" })
694
+ /* @__PURE__ */ e(B, { children: U.config && C.config ? C.config : "Can the user delete collections" })
670
695
  ] })
671
696
  ] })
672
697
  ] }),
673
- /* @__PURE__ */ s(me, { position: "sticky", children: [
674
- p && /* @__PURE__ */ e(_, { className: "text-red-500", children: "There was an error saving this role" }),
698
+ /* @__PURE__ */ s(Ce, { position: "sticky", children: [
699
+ v && /* @__PURE__ */ e(A, { className: "text-red-500", children: "There was an error saving this role" }),
675
700
  /* @__PURE__ */ e(
676
- q,
701
+ O,
677
702
  {
678
703
  variant: "text",
679
704
  onClick: () => {
680
- d();
705
+ l();
681
706
  },
682
707
  children: "Cancel"
683
708
  }
684
709
  ),
685
710
  /* @__PURE__ */ e(
686
- he,
711
+ ve,
687
712
  {
688
713
  variant: "filled",
689
714
  color: "primary",
690
715
  type: "submit",
691
- disabled: !O,
692
- loading: I,
693
- startIcon: /* @__PURE__ */ e(fe, {}),
716
+ disabled: !_,
717
+ loading: S,
718
+ startIcon: /* @__PURE__ */ e(we, {}),
694
719
  children: f ? "Create role" : "Update"
695
720
  }
696
721
  )
@@ -701,7 +726,7 @@ function Ke({
701
726
  }
702
727
  );
703
728
  }
704
- const Qe = [
729
+ const Se = [
705
730
  {
706
731
  id: "admin",
707
732
  name: "Admin",
@@ -737,67 +762,67 @@ const Qe = [
737
762
  ];
738
763
  function Xe({
739
764
  onRoleClicked: t,
740
- editable: i
765
+ editable: r
741
766
  }) {
742
767
  const {
743
768
  roles: n,
744
- saveRole: d,
745
- deleteRole: r,
769
+ saveRole: l,
770
+ deleteRole: i,
746
771
  allowDefaultRolesCreation: m
747
- } = Y(), [f, p] = F(void 0), [N, v] = F(!1);
772
+ } = j(), [f, v] = P(void 0), [R, w] = P(!1);
748
773
  return /* @__PURE__ */ s(
749
774
  "div",
750
775
  {
751
776
  className: "w-full overflow-auto",
752
777
  children: [
753
- /* @__PURE__ */ s(ie, { children: [
754
- /* @__PURE__ */ s(re, { children: [
755
- /* @__PURE__ */ e(a, { header: !0, className: "w-16" }),
756
- /* @__PURE__ */ e(a, { header: !0, children: "Role" }),
757
- /* @__PURE__ */ e(a, { header: !0, className: "items-center", children: "Is Admin" }),
758
- /* @__PURE__ */ e(a, { header: !0, children: "Default permissions" })
778
+ /* @__PURE__ */ s(re, { children: [
779
+ /* @__PURE__ */ s(ie, { children: [
780
+ /* @__PURE__ */ e(d, { header: !0, className: "w-16" }),
781
+ /* @__PURE__ */ e(d, { header: !0, children: "Role" }),
782
+ /* @__PURE__ */ e(d, { header: !0, className: "items-center", children: "Is Admin" }),
783
+ /* @__PURE__ */ e(d, { header: !0, children: "Default permissions" })
759
784
  ] }),
760
785
  /* @__PURE__ */ s(oe, { children: [
761
786
  n && n.map((c) => {
762
- const I = c.isAdmin || c.defaultPermissions?.create, w = c.isAdmin || c.defaultPermissions?.read, l = c.isAdmin || c.defaultPermissions?.edit, g = c.isAdmin || c.defaultPermissions?.delete;
787
+ const S = c.isAdmin || c.defaultPermissions?.create, U = c.isAdmin || c.defaultPermissions?.read, a = c.isAdmin || c.defaultPermissions?.edit, C = c.isAdmin || c.defaultPermissions?.delete;
763
788
  return /* @__PURE__ */ s(
764
- M,
789
+ W,
765
790
  {
766
791
  onClick: () => {
767
792
  t(c);
768
793
  },
769
794
  children: [
770
- /* @__PURE__ */ e(a, { style: { width: "64px" }, children: !c.isAdmin && /* @__PURE__ */ e(L, { title: "Delete this role", children: /* @__PURE__ */ e(
771
- ge,
795
+ /* @__PURE__ */ e(d, { style: { width: "64px" }, children: !c.isAdmin && /* @__PURE__ */ e(V, { title: "Delete this role", children: /* @__PURE__ */ e(
796
+ ye,
772
797
  {
773
798
  size: "small",
774
- disabled: !i,
775
- onClick: (R) => (R.stopPropagation(), p(c)),
776
- children: /* @__PURE__ */ e(pe, {})
799
+ disabled: !r,
800
+ onClick: (y) => (y.stopPropagation(), v(c)),
801
+ children: /* @__PURE__ */ e(be, {})
777
802
  }
778
803
  ) }) }),
779
- /* @__PURE__ */ e(a, { children: /* @__PURE__ */ e(Q, { role: c }) }),
780
- /* @__PURE__ */ e(a, { className: "items-center", children: /* @__PURE__ */ e(P, { checked: c.isAdmin ?? !1 }) }),
781
- /* @__PURE__ */ e(a, { children: /* @__PURE__ */ s("ul", { children: [
782
- I && /* @__PURE__ */ e("li", { children: "Create" }),
783
- w && /* @__PURE__ */ e("li", { children: "Read" }),
784
- l && /* @__PURE__ */ e("li", { children: "Update" }),
785
- g && /* @__PURE__ */ e("li", { children: "Delete" })
804
+ /* @__PURE__ */ e(d, { children: /* @__PURE__ */ e(X, { role: c }) }),
805
+ /* @__PURE__ */ e(d, { className: "items-center", children: /* @__PURE__ */ e(I, { checked: c.isAdmin ?? !1 }) }),
806
+ /* @__PURE__ */ e(d, { children: /* @__PURE__ */ s("ul", { children: [
807
+ S && /* @__PURE__ */ e("li", { children: "Create" }),
808
+ U && /* @__PURE__ */ e("li", { children: "Read" }),
809
+ a && /* @__PURE__ */ e("li", { children: "Update" }),
810
+ C && /* @__PURE__ */ e("li", { children: "Delete" })
786
811
  ] }) })
787
812
  ]
788
813
  },
789
814
  c.name
790
815
  );
791
816
  }),
792
- (!n || n.length === 0) && /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e(a, { colspan: 4, children: /* @__PURE__ */ s(Ce, { className: "flex flex-col gap-4 my-8 items-center", children: [
793
- /* @__PURE__ */ e(_, { variant: "label", children: "You don't have any roles yet." }),
817
+ (!n || n.length === 0) && /* @__PURE__ */ e(W, { children: /* @__PURE__ */ e(d, { colspan: 4, children: /* @__PURE__ */ s(Ne, { className: "flex flex-col gap-4 my-8 items-center", children: [
818
+ /* @__PURE__ */ e(A, { variant: "label", children: "You don't have any roles yet." }),
794
819
  m && /* @__PURE__ */ e(
795
- q,
820
+ O,
796
821
  {
797
822
  variant: "outlined",
798
823
  onClick: () => {
799
- Qe.forEach((c) => {
800
- d(c);
824
+ Se.forEach((c) => {
825
+ l(c);
801
826
  });
802
827
  },
803
828
  children: "Create default roles"
@@ -807,38 +832,38 @@ function Xe({
807
832
  ] })
808
833
  ] }),
809
834
  /* @__PURE__ */ e(
810
- ye,
835
+ xe,
811
836
  {
812
837
  open: !!f,
813
- loading: N,
838
+ loading: R,
814
839
  onAccept: () => {
815
- f && (v(!0), r(f).then(() => {
816
- p(void 0);
840
+ f && (w(!0), i(f).then(() => {
841
+ v(void 0);
817
842
  }).finally(() => {
818
- v(!1);
843
+ w(!1);
819
844
  }));
820
845
  },
821
846
  onCancel: () => {
822
- p(void 0);
847
+ v(void 0);
823
848
  },
824
- title: /* @__PURE__ */ e(H, { children: "Delete?" }),
825
- body: /* @__PURE__ */ e(H, { children: "Are you sure you want to delete this role?" })
849
+ title: /* @__PURE__ */ e(K, { children: "Delete?" }),
850
+ body: /* @__PURE__ */ e(K, { children: "Are you sure you want to delete this role?" })
826
851
  }
827
852
  )
828
853
  ]
829
854
  }
830
855
  );
831
856
  }
832
- const Ze = A.memo(
833
- function({ children: i }) {
834
- const { collections: n } = Be(), [d, r] = F(!1), [m, f] = F(), { canEditRoles: p } = Y(), N = E((c) => {
835
- r(!0), f(c);
857
+ const Ze = F.memo(
858
+ function({ children: r }) {
859
+ const { collections: n } = _e(), [l, i] = P(!1), [m, f] = P(), { canEditRoles: v } = j(), R = k((c) => {
860
+ i(!0), f(c);
836
861
  }, []);
837
- return /* @__PURE__ */ s(ve, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
838
- i,
862
+ return /* @__PURE__ */ s(Ue, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
863
+ r,
839
864
  /* @__PURE__ */ s("div", { className: "flex items-center mt-12", children: [
840
865
  /* @__PURE__ */ e(
841
- _,
866
+ A,
842
867
  {
843
868
  gutterBottom: !0,
844
869
  variant: "h4",
@@ -847,99 +872,100 @@ const Ze = A.memo(
847
872
  children: "Roles"
848
873
  }
849
874
  ),
850
- /* @__PURE__ */ e(L, { title: p ? void 0 : "Update plans to customise roles", children: /* @__PURE__ */ e(
851
- q,
875
+ /* @__PURE__ */ e(V, { title: v ? void 0 : "Update plans to customise roles", children: /* @__PURE__ */ e(
876
+ O,
852
877
  {
853
878
  size: "large",
854
- disabled: !p,
855
- startIcon: /* @__PURE__ */ e(we, {}),
856
- onClick: () => r(!0),
879
+ disabled: !v,
880
+ startIcon: /* @__PURE__ */ e(le, {}),
881
+ onClick: () => i(!0),
857
882
  children: "Add role"
858
883
  }
859
884
  ) })
860
885
  ] }),
861
- /* @__PURE__ */ e(Xe, { onRoleClicked: N, editable: !!p }),
886
+ /* @__PURE__ */ e(Xe, { onRoleClicked: R, editable: !!v }),
862
887
  /* @__PURE__ */ e(
863
- Ke,
888
+ Qe,
864
889
  {
865
- open: d,
890
+ open: l,
866
891
  role: m,
867
- editable: p,
892
+ editable: v,
868
893
  collections: n,
869
894
  handleClose: () => {
870
- f(void 0), r(!1);
895
+ f(void 0), i(!1);
871
896
  }
872
897
  },
873
898
  m?.id ?? "new"
874
899
  )
875
900
  ] });
876
901
  }
877
- ), en = V.object().shape({
878
- displayName: V.string().required("Required"),
879
- email: V.string().email().required("Required"),
880
- roles: V.array().min(1)
902
+ ), en = M.object().shape({
903
+ displayName: M.string().required("Required"),
904
+ email: M.string().email().required("Required"),
905
+ roles: M.array().min(1)
881
906
  });
882
- function nn(t, i, n, d, r) {
883
- const m = n.filter((v) => v.roles.map((c) => c.id).includes("admin")), f = t.roles.map((v) => v.id).includes("admin");
884
- if ((!r || !We(r.roles, i.roles)) && !f)
907
+ function nn(t, r, n, l, i) {
908
+ const m = n.filter((w) => w.roles?.map((c) => c.id).includes("admin")), f = t.roles?.map((w) => w.id).includes("admin");
909
+ if ((!i || !je(i.roles ?? [], r.roles ?? [])) && !f)
885
910
  throw new Error("Only admins can change roles");
886
- if (r && r.roles.map((v) => v.id).includes("admin") && !i.roles.map((v) => v.id).includes("admin") && m.length === 1)
911
+ if (i && i.roles?.map((w) => w.id).includes("admin") && !r.roles?.map((w) => w.id).includes("admin") && m.length === 1)
887
912
  throw new Error("There must be at least one admin");
888
913
  return !0;
889
914
  }
890
915
  function tn({
891
916
  open: t,
892
- user: i,
917
+ user: r,
893
918
  handleClose: n
894
919
  }) {
895
- const d = be(), {
896
- loggedInUser: r,
920
+ const l = se(), {
921
+ user: i
922
+ } = ae(), {
897
923
  saveUser: m,
898
924
  users: f,
899
- roles: p
900
- } = Y(), N = !i, v = E((h) => {
901
- if (!r)
925
+ roles: v
926
+ } = j(), R = !r, w = k((h) => {
927
+ if (!i)
902
928
  throw new Error("Logged user not found");
903
929
  try {
904
- return nn(r, h, f, p, i), m(h);
930
+ return nn(i, h, f, v, r), m(h);
905
931
  } catch (x) {
906
932
  return Promise.reject(x);
907
933
  }
908
- }, [p, m, i, f, r]), c = Ne({
909
- initialValues: i ?? {
934
+ }, [v, m, r, f, i]), c = Re({
935
+ initialValues: r ?? {
910
936
  displayName: "",
911
937
  email: "",
912
- roles: p.filter((h) => h.id === "editor")
938
+ roles: v.filter((h) => h.id === "editor")
913
939
  },
914
- validation: (h) => en.validate(h, { abortEarly: !1 }).then(() => ({})).catch((x) => x.inner.reduce((U, k) => (U[k.path] = k.message, U), {})),
915
- onSubmit: (h, x) => v(h).then(() => {
940
+ validation: (h) => en.validate(h, { abortEarly: !1 }).then(() => ({})).catch((x) => x.inner.reduce((D, T) => (D[T.path] = T.message, D), {})),
941
+ onSubmit: (h, x) => w(h).then(() => {
916
942
  n(), x.resetForm({
917
943
  values: h
918
944
  });
919
- }).catch((U) => {
920
- d.open({
945
+ }).catch((D) => {
946
+ l.open({
921
947
  type: "error",
922
- message: U.message
948
+ message: D.message
923
949
  });
924
950
  })
925
951
  }), {
926
- isSubmitting: I,
927
- touched: w,
928
- handleChange: l,
929
- values: g,
930
- errors: R,
931
- setFieldValue: y,
932
- dirty: O,
952
+ isSubmitting: S,
953
+ touched: U,
954
+ handleChange: a,
955
+ values: C,
956
+ errors: y,
957
+ setFieldValue: b,
958
+ dirty: _,
933
959
  handleSubmit: z,
934
960
  submitCount: u
935
961
  } = c;
936
962
  return /* @__PURE__ */ e(
937
- de,
963
+ fe,
938
964
  {
939
965
  open: t,
940
966
  onOpenChange: (h) => h ? void 0 : n(),
941
967
  maxWidth: "4xl",
942
- children: /* @__PURE__ */ e(xe, { value: c, children: /* @__PURE__ */ s(
968
+ children: /* @__PURE__ */ e(De, { value: c, children: /* @__PURE__ */ s(
943
969
  "form",
944
970
  {
945
971
  onSubmit: z,
@@ -952,13 +978,13 @@ function tn({
952
978
  height: "100%"
953
979
  },
954
980
  children: [
955
- /* @__PURE__ */ s(ue, { className: "h-full flex-grow", children: [
981
+ /* @__PURE__ */ s(ge, { className: "h-full flex-grow", children: [
956
982
  /* @__PURE__ */ e(
957
983
  "div",
958
984
  {
959
985
  className: "flex flex-row pt-4 pb-4",
960
986
  children: /* @__PURE__ */ e(
961
- _,
987
+ A,
962
988
  {
963
989
  variant: "h4",
964
990
  className: "flex-grow",
@@ -970,49 +996,49 @@ function tn({
970
996
  /* @__PURE__ */ s("div", { className: "grid grid-cols-12 gap-8", children: [
971
997
  /* @__PURE__ */ s("div", { className: "col-span-12", children: [
972
998
  /* @__PURE__ */ e(
973
- K,
999
+ Q,
974
1000
  {
975
1001
  name: "displayName",
976
1002
  required: !0,
977
- error: u > 0 && !!R.displayName,
978
- value: g.displayName ?? "",
979
- onChange: l,
1003
+ error: u > 0 && !!y.displayName,
1004
+ value: C.displayName ?? "",
1005
+ onChange: a,
980
1006
  "aria-describedby": "name-helper-text",
981
1007
  label: "Name"
982
1008
  }
983
1009
  ),
984
- /* @__PURE__ */ e(B, { children: u > 0 && R.displayName ? R.displayName : "Name of this user" })
1010
+ /* @__PURE__ */ e(B, { children: u > 0 && y.displayName ? y.displayName : "Name of this user" })
985
1011
  ] }),
986
1012
  /* @__PURE__ */ s("div", { className: "col-span-12", children: [
987
1013
  /* @__PURE__ */ e(
988
- K,
1014
+ Q,
989
1015
  {
990
1016
  required: !0,
991
- error: u > 0 && !!R.email,
1017
+ error: u > 0 && !!y.email,
992
1018
  name: "email",
993
- value: g.email ?? "",
994
- onChange: l,
1019
+ value: C.email ?? "",
1020
+ onChange: a,
995
1021
  "aria-describedby": "email-helper-text",
996
1022
  label: "Email"
997
1023
  }
998
1024
  ),
999
- /* @__PURE__ */ e(B, { children: u > 0 && R.email ? R.email : "Email of this user" })
1025
+ /* @__PURE__ */ e(B, { children: u > 0 && y.email ? y.email : "Email of this user" })
1000
1026
  ] }),
1001
1027
  /* @__PURE__ */ e("div", { className: "col-span-12", children: /* @__PURE__ */ e(
1002
- Ae,
1028
+ Te,
1003
1029
  {
1004
1030
  label: "Roles",
1005
- value: g.roles.map((h) => h.id) ?? [],
1006
- onMultiValueChange: (h) => y("roles", h.map((x) => p.find((U) => U.id === x))),
1031
+ value: C.roles?.map((h) => h.id) ?? [],
1032
+ onMultiValueChange: (h) => b("roles", h.map((x) => v.find((D) => D.id === x))),
1007
1033
  renderValue: (h) => {
1008
- const x = p.find((U) => U.id === h);
1009
- return x ? /* @__PURE__ */ e("div", { className: "flex flex-wrap space-x-2 space-y-2", children: /* @__PURE__ */ e(Q, { role: x }, x?.id) }) : null;
1034
+ const x = v.find((D) => D.id === h);
1035
+ return x ? /* @__PURE__ */ e("div", { className: "flex flex-wrap space-x-2 space-y-2", children: /* @__PURE__ */ e(X, { role: x }, x?.id) }) : null;
1010
1036
  },
1011
- children: p.map((h) => /* @__PURE__ */ e(
1012
- Fe,
1037
+ children: v.map((h) => /* @__PURE__ */ e(
1038
+ Le,
1013
1039
  {
1014
1040
  value: h.id,
1015
- children: /* @__PURE__ */ e(Q, { role: h }, h?.id)
1041
+ children: /* @__PURE__ */ e(X, { role: h }, h?.id)
1016
1042
  },
1017
1043
  h.id
1018
1044
  ))
@@ -1020,9 +1046,9 @@ function tn({
1020
1046
  ) })
1021
1047
  ] })
1022
1048
  ] }),
1023
- /* @__PURE__ */ s(me, { children: [
1049
+ /* @__PURE__ */ s(Ce, { children: [
1024
1050
  /* @__PURE__ */ e(
1025
- q,
1051
+ O,
1026
1052
  {
1027
1053
  variant: "text",
1028
1054
  onClick: () => {
@@ -1032,15 +1058,15 @@ function tn({
1032
1058
  }
1033
1059
  ),
1034
1060
  /* @__PURE__ */ e(
1035
- he,
1061
+ ve,
1036
1062
  {
1037
1063
  variant: "filled",
1038
1064
  color: "primary",
1039
1065
  type: "submit",
1040
- disabled: !O,
1041
- loading: I,
1042
- startIcon: /* @__PURE__ */ e(fe, {}),
1043
- children: N ? "Create user" : "Update"
1066
+ disabled: !_,
1067
+ loading: S,
1068
+ startIcon: /* @__PURE__ */ e(we, {}),
1069
+ children: R ? "Create user" : "Update"
1044
1070
  }
1045
1071
  )
1046
1072
  ] })
@@ -1052,66 +1078,66 @@ function tn({
1052
1078
  }
1053
1079
  function rn({ onUserClicked: t }) {
1054
1080
  const {
1055
- users: i,
1081
+ users: r,
1056
1082
  saveUser: n,
1057
- deleteUser: d
1058
- } = Y(), r = Le(), m = be(), f = Ve(), p = f?.locale ? $e[f?.locale] : void 0, N = f?.dateTimeFormat ?? _e, [v, c] = F(void 0), [I, w] = F(!1);
1083
+ deleteUser: l
1084
+ } = j(), i = ae(), m = se(), f = Ve(), v = f?.locale ? $e[f?.locale] : void 0, R = f?.dateTimeFormat ?? Me, [w, c] = P(void 0), [S, U] = P(!1);
1059
1085
  return /* @__PURE__ */ s("div", { className: "overflow-auto", children: [
1060
- /* @__PURE__ */ s(ie, { children: [
1061
- /* @__PURE__ */ s(re, { children: [
1062
- /* @__PURE__ */ e(a, { className: "truncate w-16" }),
1063
- /* @__PURE__ */ e(a, { children: "ID" }),
1064
- /* @__PURE__ */ e(a, { children: "Email" }),
1065
- /* @__PURE__ */ e(a, { children: "Name" }),
1066
- /* @__PURE__ */ e(a, { children: "Roles" }),
1067
- /* @__PURE__ */ e(a, { children: "Created on" })
1086
+ /* @__PURE__ */ s(re, { children: [
1087
+ /* @__PURE__ */ s(ie, { children: [
1088
+ /* @__PURE__ */ e(d, { className: "truncate w-16" }),
1089
+ /* @__PURE__ */ e(d, { children: "ID" }),
1090
+ /* @__PURE__ */ e(d, { children: "Email" }),
1091
+ /* @__PURE__ */ e(d, { children: "Name" }),
1092
+ /* @__PURE__ */ e(d, { children: "Roles" }),
1093
+ /* @__PURE__ */ e(d, { children: "Created on" })
1068
1094
  ] }),
1069
1095
  /* @__PURE__ */ s(oe, { children: [
1070
- i && i.map((l) => {
1071
- const g = l.roles, R = l.created_on ? Oe(l.created_on, N, { locale: p }) : "";
1096
+ r && r.map((a) => {
1097
+ const C = a.roles, y = a.created_on ? Oe(a.created_on, R, { locale: v }) : "";
1072
1098
  return /* @__PURE__ */ s(
1073
- M,
1099
+ W,
1074
1100
  {
1075
1101
  onClick: () => {
1076
- t(l);
1102
+ t(a);
1077
1103
  },
1078
1104
  children: [
1079
- /* @__PURE__ */ e(a, { className: "w-10", children: /* @__PURE__ */ e(L, { title: "Delete this user", children: /* @__PURE__ */ e(
1080
- ge,
1105
+ /* @__PURE__ */ e(d, { className: "w-10", children: /* @__PURE__ */ e(V, { title: "Delete this user", children: /* @__PURE__ */ e(
1106
+ ye,
1081
1107
  {
1082
1108
  size: "small",
1083
- onClick: (y) => (y.stopPropagation(), c(l)),
1084
- children: /* @__PURE__ */ e(pe, {})
1109
+ onClick: (b) => (b.stopPropagation(), c(a)),
1110
+ children: /* @__PURE__ */ e(be, {})
1085
1111
  }
1086
1112
  ) }) }),
1087
- /* @__PURE__ */ e(a, { children: l.uid }),
1088
- /* @__PURE__ */ e(a, { children: l.email }),
1089
- /* @__PURE__ */ e(a, { className: "font-medium align-left", children: l.displayName }),
1090
- /* @__PURE__ */ e(a, { className: "align-left", children: g ? /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-2", children: g.map(
1091
- (y) => /* @__PURE__ */ e(Q, { role: y }, y?.id)
1113
+ /* @__PURE__ */ e(d, { children: a.uid }),
1114
+ /* @__PURE__ */ e(d, { children: a.email }),
1115
+ /* @__PURE__ */ e(d, { className: "font-medium align-left", children: a.displayName }),
1116
+ /* @__PURE__ */ e(d, { className: "align-left", children: C ? /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-2", children: C.map(
1117
+ (b) => /* @__PURE__ */ e(X, { role: b }, b?.id)
1092
1118
  ) }) : null }),
1093
- /* @__PURE__ */ e(a, { children: R })
1119
+ /* @__PURE__ */ e(d, { children: y })
1094
1120
  ]
1095
1121
  },
1096
- "row_" + l.uid
1122
+ "row_" + a.uid
1097
1123
  );
1098
1124
  }),
1099
- (!i || i.length === 0) && /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e(a, { colspan: 6, children: /* @__PURE__ */ s(Ce, { className: "flex flex-col gap-4 my-8 items-center", children: [
1100
- /* @__PURE__ */ e(_, { variant: "label", children: "There are no users yet" }),
1125
+ (!r || r.length === 0) && /* @__PURE__ */ e(W, { children: /* @__PURE__ */ e(d, { colspan: 6, children: /* @__PURE__ */ s(Ne, { className: "flex flex-col gap-4 my-8 items-center", children: [
1126
+ /* @__PURE__ */ e(A, { variant: "label", children: "There are no users yet" }),
1101
1127
  /* @__PURE__ */ e(
1102
- q,
1128
+ O,
1103
1129
  {
1104
1130
  variant: "outlined",
1105
1131
  onClick: () => {
1106
- if (!r.user?.uid)
1132
+ if (!i.user?.uid)
1107
1133
  throw Error("UsersTable, authController misconfiguration");
1108
1134
  n({
1109
- uid: r.user?.uid,
1110
- email: r.user?.email,
1111
- displayName: r.user?.displayName,
1112
- photoURL: r.user?.photoURL,
1113
- providerId: r.user?.providerId,
1114
- isAnonymous: r.user?.isAnonymous,
1135
+ uid: i.user?.uid,
1136
+ email: i.user?.email,
1137
+ displayName: i.user?.displayName,
1138
+ photoURL: i.user?.photoURL,
1139
+ providerId: i.user?.providerId,
1140
+ isAnonymous: i.user?.isAnonymous,
1115
1141
  roles: [{ id: "admin", name: "Admin" }],
1116
1142
  created_on: /* @__PURE__ */ new Date()
1117
1143
  }).then(() => {
@@ -1119,10 +1145,10 @@ function rn({ onUserClicked: t }) {
1119
1145
  type: "success",
1120
1146
  message: "User added successfully"
1121
1147
  });
1122
- }).catch((l) => {
1148
+ }).catch((a) => {
1123
1149
  m.open({
1124
1150
  type: "error",
1125
- message: "Error adding user: " + l.message
1151
+ message: "Error adding user: " + a.message
1126
1152
  });
1127
1153
  });
1128
1154
  },
@@ -1133,46 +1159,46 @@ function rn({ onUserClicked: t }) {
1133
1159
  ] })
1134
1160
  ] }),
1135
1161
  /* @__PURE__ */ e(
1136
- ye,
1162
+ xe,
1137
1163
  {
1138
- open: !!v,
1139
- loading: I,
1164
+ open: !!w,
1165
+ loading: S,
1140
1166
  onAccept: () => {
1141
- v && (w(!0), d(v).then(() => {
1167
+ w && (U(!0), l(w).then(() => {
1142
1168
  c(void 0);
1143
- }).catch((l) => {
1169
+ }).catch((a) => {
1144
1170
  m.open({
1145
1171
  type: "error",
1146
- message: "Error deleting user: " + l.message
1172
+ message: "Error deleting user: " + a.message
1147
1173
  });
1148
1174
  }).finally(() => {
1149
- w(!1);
1175
+ U(!1);
1150
1176
  }));
1151
1177
  },
1152
1178
  onCancel: () => {
1153
1179
  c(void 0);
1154
1180
  },
1155
- title: /* @__PURE__ */ e(H, { children: "Delete?" }),
1156
- body: /* @__PURE__ */ e(H, { children: "Are you sure you want to delete this user?" })
1181
+ title: /* @__PURE__ */ e(K, { children: "Delete?" }),
1182
+ body: /* @__PURE__ */ e(K, { children: "Are you sure you want to delete this user?" })
1157
1183
  }
1158
1184
  )
1159
1185
  ] });
1160
1186
  }
1161
- const on = function({ children: i }) {
1162
- const [n, d] = F(), [r, m] = F(), { users: f, usersLimit: p } = Y(), N = p !== void 0 && f && f.length >= p, v = E((I) => {
1163
- m(I), d(!0);
1164
- }, []), c = E(() => {
1165
- d(!1), m(void 0);
1187
+ const on = function({ children: r }) {
1188
+ const [n, l] = P(), [i, m] = P(), { users: f, usersLimit: v } = j(), R = v !== void 0 && f && f.length >= v, w = k((S) => {
1189
+ m(S), l(!0);
1190
+ }, []), c = k(() => {
1191
+ l(!1), m(void 0);
1166
1192
  }, []);
1167
- return /* @__PURE__ */ s(ve, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
1168
- i,
1193
+ return /* @__PURE__ */ s(Ue, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
1194
+ r,
1169
1195
  /* @__PURE__ */ s(
1170
1196
  "div",
1171
1197
  {
1172
1198
  className: "flex items-center mt-12",
1173
1199
  children: [
1174
1200
  /* @__PURE__ */ e(
1175
- _,
1201
+ A,
1176
1202
  {
1177
1203
  gutterBottom: !0,
1178
1204
  variant: "h4",
@@ -1182,43 +1208,103 @@ const on = function({ children: i }) {
1182
1208
  }
1183
1209
  ),
1184
1210
  /* @__PURE__ */ e(
1185
- q,
1211
+ O,
1186
1212
  {
1187
1213
  size: "large",
1188
- disabled: N,
1189
- startIcon: /* @__PURE__ */ e(we, {}),
1190
- onClick: () => d(!0),
1214
+ disabled: R,
1215
+ startIcon: /* @__PURE__ */ e(le, {}),
1216
+ onClick: () => l(!0),
1191
1217
  children: "Add user"
1192
1218
  }
1193
1219
  )
1194
1220
  ]
1195
1221
  }
1196
1222
  ),
1197
- /* @__PURE__ */ e(rn, { onUserClicked: v }),
1223
+ /* @__PURE__ */ e(rn, { onUserClicked: w }),
1198
1224
  /* @__PURE__ */ e(
1199
1225
  tn,
1200
1226
  {
1201
1227
  open: n ?? !1,
1202
- user: r,
1228
+ user: i,
1203
1229
  handleClose: c
1204
1230
  },
1205
- r?.uid ?? "new"
1231
+ i?.uid ?? "new"
1206
1232
  )
1207
1233
  ] });
1208
1234
  };
1209
- function bn({ userManagement: t }) {
1235
+ function Nn({ userManagement: t }) {
1236
+ const r = t.users.length === 0, n = t.roles.length === 0;
1210
1237
  return {
1211
- name: "User management plugin",
1238
+ key: "user_management",
1212
1239
  loading: t.loading,
1240
+ homePage: {
1241
+ additionalChildrenStart: r || n ? /* @__PURE__ */ e(
1242
+ ln,
1243
+ {
1244
+ noUsers: r,
1245
+ noRoles: n,
1246
+ userManagement: t
1247
+ }
1248
+ ) : void 0
1249
+ },
1213
1250
  provider: {
1214
- Component: Ge,
1251
+ Component: He,
1215
1252
  props: {
1216
1253
  userManagement: t
1217
1254
  }
1218
1255
  }
1219
1256
  };
1220
1257
  }
1221
- const Nn = [
1258
+ function ln({
1259
+ noUsers: t,
1260
+ noRoles: r,
1261
+ userManagement: n
1262
+ }) {
1263
+ const l = ae(), i = se();
1264
+ return /* @__PURE__ */ s(
1265
+ pe,
1266
+ {
1267
+ className: "my-4 flex flex-col px-4 py-6 bg-white dark:bg-slate-800 gap-2",
1268
+ children: [
1269
+ /* @__PURE__ */ e(A, { variant: "subtitle2", className: "uppercase", children: "Create your users and roles" }),
1270
+ /* @__PURE__ */ e(A, { children: "You have no users or roles defined. You can create default roles and add the current user as admin." }),
1271
+ /* @__PURE__ */ s(O, { onClick: () => {
1272
+ if (!l.user?.uid)
1273
+ throw Error("UsersTable, authController misconfiguration");
1274
+ t && n.saveUser({
1275
+ uid: l.user?.uid,
1276
+ email: l.user?.email,
1277
+ displayName: l.user?.displayName,
1278
+ photoURL: l.user?.photoURL,
1279
+ providerId: l.user?.providerId,
1280
+ isAnonymous: l.user?.isAnonymous,
1281
+ roles: [{
1282
+ id: "admin",
1283
+ name: "Admin"
1284
+ }],
1285
+ created_on: /* @__PURE__ */ new Date()
1286
+ }).then(() => {
1287
+ i.open({
1288
+ type: "success",
1289
+ message: "User added successfully"
1290
+ });
1291
+ }).catch((f) => {
1292
+ i.open({
1293
+ type: "error",
1294
+ message: "Error adding user: " + f.message
1295
+ });
1296
+ }), r && Se.forEach((f) => {
1297
+ n.saveRole(f);
1298
+ });
1299
+ }, children: [
1300
+ /* @__PURE__ */ e(le, {}),
1301
+ t && r ? "Create default roles and add current user as admin" : t ? "Add current user as admin" : r ? "Create default roles" : void 0
1302
+ ] })
1303
+ ]
1304
+ }
1305
+ );
1306
+ }
1307
+ const Un = [
1222
1308
  {
1223
1309
  path: "users",
1224
1310
  name: "CMS Users",
@@ -1235,29 +1321,30 @@ const Nn = [
1235
1321
  }
1236
1322
  ];
1237
1323
  export {
1238
- hn as RESERVED_GROUPS,
1239
- Q as RoleChip,
1240
- He as RoleYupSchema,
1241
- Ke as RolesDetailsForm,
1324
+ ln as IntroWidget,
1325
+ fn as RESERVED_GROUPS,
1326
+ X as RoleChip,
1327
+ Ke as RoleYupSchema,
1328
+ Qe as RolesDetailsForm,
1242
1329
  Xe as RolesTable,
1243
1330
  Ze as RolesView,
1244
1331
  tn as UserDetailsForm,
1245
- Re as UserManagementContext,
1246
- Ge as UserManagementProvider,
1332
+ Ee as UserManagementContext,
1333
+ He as UserManagementProvider,
1247
1334
  en as UserYupSchema,
1248
1335
  rn as UsersTable,
1249
1336
  on as UsersView,
1250
- We as areRolesEqual,
1251
- gn as cacheDelegatedLoginToken,
1252
- Cn as clearDelegatedLoginTokensCache,
1253
- vn as darkenColor,
1254
- pn as getDelegatedLoginTokenFromCache,
1255
- fn as getUserRoles,
1256
- wn as hexToRgbaWithOpacity,
1257
- qe as resolveUserRolePermissions,
1258
- yn as useBuildFirestoreUserManagement,
1259
- Y as useUserManagement,
1260
- bn as useUserManagementPlugin,
1261
- Nn as userManagementAdminViews
1337
+ je as areRolesEqual,
1338
+ pn as cacheDelegatedLoginToken,
1339
+ vn as clearDelegatedLoginTokensCache,
1340
+ wn as darkenColor,
1341
+ Cn as getDelegatedLoginTokenFromCache,
1342
+ gn as getUserRoles,
1343
+ yn as hexToRgbaWithOpacity,
1344
+ Ye as resolveUserRolePermissions,
1345
+ bn as useFirestoreUserManagement,
1346
+ j as useUserManagement,
1347
+ Nn as useUserManagementPlugin,
1348
+ Un as userManagementAdminViews
1262
1349
  };
1263
1350
  //# sourceMappingURL=index.es.js.map