@firecms/user_management 3.0.0-beta.4.pre.2 → 3.0.0-canary.11

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