@firecms/user_management 3.0.0-canary.8 → 3.0.0-canary.80

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