@firecms/user_management 3.0.0-canary.40 → 3.0.0-canary.41

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