@skylabs-digital/react-identity-access 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/LandingRoute.d.ts +8 -0
- package/dist/components/LandingRoute.d.ts.map +1 -0
- package/dist/components/TenantRoute.d.ts +8 -0
- package/dist/components/TenantRoute.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +697 -599
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as ee, useState as
|
|
3
|
-
import { useLocation as
|
|
1
|
+
import { jsx as s, Fragment as H, jsxs as c } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as ee, useState as b, useMemo as z, useCallback as Z, useEffect as Y, useContext as te } from "react";
|
|
3
|
+
import { useLocation as ae, Navigate as ne } from "react-router";
|
|
4
4
|
class G {
|
|
5
5
|
// SessionManager instance
|
|
6
6
|
constructor(e, t = 1e4) {
|
|
@@ -12,16 +12,16 @@ class G {
|
|
|
12
12
|
getBaseUrl() {
|
|
13
13
|
return this.baseUrl;
|
|
14
14
|
}
|
|
15
|
-
async request(e, t, r,
|
|
16
|
-
return this.executeRequest(e, t, r,
|
|
15
|
+
async request(e, t, r, n) {
|
|
16
|
+
return this.executeRequest(e, t, r, n, !1);
|
|
17
17
|
}
|
|
18
|
-
async executeRequest(e, t, r,
|
|
19
|
-
const
|
|
18
|
+
async executeRequest(e, t, r, n, o = !1) {
|
|
19
|
+
const m = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, T = (n == null ? void 0 : n.timeout) || this.timeout;
|
|
20
20
|
let M = {
|
|
21
21
|
"Content-Type": "application/json",
|
|
22
|
-
...
|
|
22
|
+
...n == null ? void 0 : n.headers
|
|
23
23
|
};
|
|
24
|
-
if (!(
|
|
24
|
+
if (!(n != null && n.skipAuth) && this.sessionManager)
|
|
25
25
|
try {
|
|
26
26
|
const h = await this.sessionManager.getAuthHeaders();
|
|
27
27
|
M = { ...M, ...h };
|
|
@@ -30,17 +30,17 @@ class G {
|
|
|
30
30
|
}
|
|
31
31
|
const P = new AbortController(), g = setTimeout(() => P.abort(), T);
|
|
32
32
|
try {
|
|
33
|
-
const h = await fetch(
|
|
33
|
+
const h = await fetch(m, {
|
|
34
34
|
method: e,
|
|
35
35
|
headers: M,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
37
|
signal: P.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(g), h.status === 401 && !(
|
|
39
|
+
if (clearTimeout(g), h.status === 401 && !(n != null && n.skipRetry) && !o && this.sessionManager)
|
|
40
40
|
try {
|
|
41
41
|
const p = this.sessionManager.getTokens();
|
|
42
42
|
if (p != null && p.refreshToken)
|
|
43
|
-
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r,
|
|
43
|
+
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, n, !0);
|
|
44
44
|
} catch {
|
|
45
45
|
throw new Error(`HTTP ${h.status}: ${h.statusText}`);
|
|
46
46
|
}
|
|
@@ -78,12 +78,12 @@ class be {
|
|
|
78
78
|
async getApps(e) {
|
|
79
79
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
80
80
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
81
|
-
const
|
|
81
|
+
const n = `/apps/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
|
|
82
82
|
headers: t
|
|
83
83
|
});
|
|
84
84
|
return {
|
|
85
|
-
apps:
|
|
86
|
-
meta:
|
|
85
|
+
apps: o.data,
|
|
86
|
+
meta: o.meta
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
async getAppById(e) {
|
|
@@ -110,11 +110,11 @@ class be {
|
|
|
110
110
|
)).data;
|
|
111
111
|
}
|
|
112
112
|
async updateSettingsSchema(e, t, r) {
|
|
113
|
-
const
|
|
113
|
+
const n = await this.sessionManager.getAuthHeaders();
|
|
114
114
|
return (await this.httpService.put(
|
|
115
115
|
`/apps/${e}/settings-schema`,
|
|
116
116
|
{ schema: t, defaultSettings: r },
|
|
117
|
-
{ headers:
|
|
117
|
+
{ headers: n }
|
|
118
118
|
)).data;
|
|
119
119
|
}
|
|
120
120
|
async exportConfig(e) {
|
|
@@ -124,7 +124,7 @@ class be {
|
|
|
124
124
|
})).data;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
const
|
|
127
|
+
const pe = ee(null), Se = () => /* @__PURE__ */ s(
|
|
128
128
|
"div",
|
|
129
129
|
{
|
|
130
130
|
style: {
|
|
@@ -134,9 +134,9 @@ const ge = ee(null), Se = () => /* @__PURE__ */ n(
|
|
|
134
134
|
height: "100vh",
|
|
135
135
|
fontFamily: "system-ui, sans-serif"
|
|
136
136
|
},
|
|
137
|
-
children: /* @__PURE__ */
|
|
137
|
+
children: /* @__PURE__ */ s("div", { children: "Loading application..." })
|
|
138
138
|
}
|
|
139
|
-
), ve = ({ error: i, retry: e }) => /* @__PURE__ */
|
|
139
|
+
), ve = ({ error: i, retry: e }) => /* @__PURE__ */ c(
|
|
140
140
|
"div",
|
|
141
141
|
{
|
|
142
142
|
style: {
|
|
@@ -150,9 +150,9 @@ const ge = ee(null), Se = () => /* @__PURE__ */ n(
|
|
|
150
150
|
padding: "20px"
|
|
151
151
|
},
|
|
152
152
|
children: [
|
|
153
|
-
/* @__PURE__ */
|
|
154
|
-
/* @__PURE__ */
|
|
155
|
-
/* @__PURE__ */
|
|
153
|
+
/* @__PURE__ */ s("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Application Error" }),
|
|
154
|
+
/* @__PURE__ */ s("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load application" }),
|
|
155
|
+
/* @__PURE__ */ s(
|
|
156
156
|
"button",
|
|
157
157
|
{
|
|
158
158
|
onClick: e,
|
|
@@ -170,8 +170,8 @@ const ge = ee(null), Se = () => /* @__PURE__ */ n(
|
|
|
170
170
|
]
|
|
171
171
|
}
|
|
172
172
|
);
|
|
173
|
-
function
|
|
174
|
-
const [t, r] =
|
|
173
|
+
function Ze({ config: i, children: e }) {
|
|
174
|
+
const [t, r] = b(null), [n, o] = b(!0), [m, T] = b(null), M = z(() => {
|
|
175
175
|
const g = () => {
|
|
176
176
|
P();
|
|
177
177
|
};
|
|
@@ -180,39 +180,39 @@ function Je({ config: i, children: e }) {
|
|
|
180
180
|
baseUrl: i.baseUrl,
|
|
181
181
|
// App info
|
|
182
182
|
appInfo: t,
|
|
183
|
-
isAppLoading:
|
|
184
|
-
appError:
|
|
183
|
+
isAppLoading: n,
|
|
184
|
+
appError: m,
|
|
185
185
|
retryApp: g
|
|
186
186
|
};
|
|
187
|
-
}, [i, t,
|
|
187
|
+
}, [i, t, n, m]), P = Z(async () => {
|
|
188
188
|
try {
|
|
189
|
-
|
|
189
|
+
o(!0), T(null);
|
|
190
190
|
const g = new G(i.baseUrl), x = await new be(g, {}).getPublicAppInfo(i.appId);
|
|
191
191
|
r(x);
|
|
192
192
|
} catch (g) {
|
|
193
193
|
const h = g instanceof Error ? g : new Error("Failed to load app information");
|
|
194
194
|
T(h), r(null);
|
|
195
195
|
} finally {
|
|
196
|
-
|
|
196
|
+
o(!1);
|
|
197
197
|
}
|
|
198
198
|
}, [i.baseUrl, i.appId]);
|
|
199
|
-
if (
|
|
199
|
+
if (Y(() => {
|
|
200
200
|
P();
|
|
201
|
-
}, [P]),
|
|
202
|
-
return /* @__PURE__ */
|
|
203
|
-
if (
|
|
204
|
-
const g = typeof i.errorFallback == "function" ? i.errorFallback(
|
|
205
|
-
return /* @__PURE__ */
|
|
201
|
+
}, [P]), n)
|
|
202
|
+
return /* @__PURE__ */ s(H, { children: i.loadingFallback || /* @__PURE__ */ s(Se, {}) });
|
|
203
|
+
if (m) {
|
|
204
|
+
const g = typeof i.errorFallback == "function" ? i.errorFallback(m, () => P()) : i.errorFallback || /* @__PURE__ */ s(ve, { error: m, retry: () => P() });
|
|
205
|
+
return /* @__PURE__ */ s(H, { children: g });
|
|
206
206
|
}
|
|
207
|
-
return /* @__PURE__ */
|
|
207
|
+
return /* @__PURE__ */ s(pe.Provider, { value: M, children: e });
|
|
208
208
|
}
|
|
209
209
|
function re() {
|
|
210
|
-
const i = te(
|
|
210
|
+
const i = te(pe);
|
|
211
211
|
if (!i)
|
|
212
212
|
throw new Error("useApp must be used within an AppProvider");
|
|
213
213
|
return i;
|
|
214
214
|
}
|
|
215
|
-
const
|
|
215
|
+
const et = re;
|
|
216
216
|
class xe {
|
|
217
217
|
constructor(e = {}) {
|
|
218
218
|
this.refreshPromise = null, this.refreshQueue = [], this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || {
|
|
@@ -281,10 +281,10 @@ class xe {
|
|
|
281
281
|
try {
|
|
282
282
|
await this.refreshPromise;
|
|
283
283
|
const t = this.getTokens(), r = t != null && t.accessToken ? { Authorization: `Bearer ${t.accessToken}` } : {};
|
|
284
|
-
return this.refreshQueue.forEach(({ resolve:
|
|
284
|
+
return this.refreshQueue.forEach(({ resolve: n }) => n(r)), this.refreshQueue = [], r;
|
|
285
285
|
} catch (t) {
|
|
286
286
|
const r = t instanceof Error ? t : new Error("Token refresh failed");
|
|
287
|
-
return this.refreshQueue.forEach(({ reject:
|
|
287
|
+
return this.refreshQueue.forEach(({ reject: n }) => n(r)), this.refreshQueue = [], this.clearSession(), this.onRefreshFailed && this.onRefreshFailed(), {};
|
|
288
288
|
} finally {
|
|
289
289
|
this.refreshPromise = null;
|
|
290
290
|
}
|
|
@@ -303,11 +303,11 @@ class xe {
|
|
|
303
303
|
});
|
|
304
304
|
if (!r.ok)
|
|
305
305
|
throw new Error(`Token refresh failed: ${r.status} ${r.statusText}`);
|
|
306
|
-
const
|
|
306
|
+
const n = await r.json();
|
|
307
307
|
this.setTokens({
|
|
308
|
-
accessToken:
|
|
309
|
-
refreshToken:
|
|
310
|
-
expiresIn:
|
|
308
|
+
accessToken: n.accessToken,
|
|
309
|
+
refreshToken: n.refreshToken || e,
|
|
310
|
+
expiresIn: n.expiresIn
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
313
|
setUser(e) {
|
|
@@ -364,7 +364,7 @@ class Ae {
|
|
|
364
364
|
});
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
|
-
class
|
|
367
|
+
class ce {
|
|
368
368
|
constructor(e, t) {
|
|
369
369
|
this.httpService = e, this.sessionManager = t;
|
|
370
370
|
}
|
|
@@ -404,10 +404,10 @@ class le {
|
|
|
404
404
|
async getRolesByApp(e, t) {
|
|
405
405
|
const r = new URLSearchParams();
|
|
406
406
|
t != null && t.page && r.append("page", t.page.toString()), t != null && t.limit && r.append("limit", t.limit.toString()), t != null && t.sortBy && r.append("sortBy", t.sortBy), t != null && t.sortOrder && r.append("sortOrder", t.sortOrder);
|
|
407
|
-
const
|
|
407
|
+
const n = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n);
|
|
408
408
|
return {
|
|
409
|
-
roles:
|
|
410
|
-
meta:
|
|
409
|
+
roles: o.data,
|
|
410
|
+
meta: o.meta
|
|
411
411
|
};
|
|
412
412
|
}
|
|
413
413
|
async assignRole(e, t) {
|
|
@@ -429,14 +429,14 @@ class le {
|
|
|
429
429
|
async getUserRoles(e, t) {
|
|
430
430
|
if (!this.sessionManager)
|
|
431
431
|
throw new Error("SessionManager is required for private endpoints");
|
|
432
|
-
const r = await this.sessionManager.getAuthHeaders(),
|
|
433
|
-
t != null && t.page &&
|
|
434
|
-
const
|
|
432
|
+
const r = await this.sessionManager.getAuthHeaders(), n = new URLSearchParams();
|
|
433
|
+
t != null && t.page && n.append("page", t.page.toString()), t != null && t.limit && n.append("limit", t.limit.toString()), t != null && t.sortBy && n.append("sortBy", t.sortBy), t != null && t.sortOrder && n.append("sortOrder", t.sortOrder);
|
|
434
|
+
const o = `/roles/user/${e}${n.toString() ? `?${n.toString()}` : ""}`, m = await this.httpService.get(o, {
|
|
435
435
|
headers: r
|
|
436
436
|
});
|
|
437
437
|
return {
|
|
438
|
-
roles:
|
|
439
|
-
meta:
|
|
438
|
+
roles: m.data,
|
|
439
|
+
meta: m.meta
|
|
440
440
|
};
|
|
441
441
|
}
|
|
442
442
|
}
|
|
@@ -453,12 +453,12 @@ class Pe {
|
|
|
453
453
|
async getUsers(e) {
|
|
454
454
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
455
455
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
456
|
-
const
|
|
456
|
+
const n = `/users/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
|
|
457
457
|
headers: t
|
|
458
458
|
});
|
|
459
459
|
return {
|
|
460
|
-
users:
|
|
461
|
-
meta:
|
|
460
|
+
users: o.data,
|
|
461
|
+
meta: o.meta
|
|
462
462
|
};
|
|
463
463
|
}
|
|
464
464
|
async getUserById(e) {
|
|
@@ -480,7 +480,7 @@ class Pe {
|
|
|
480
480
|
});
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
|
-
class
|
|
483
|
+
class de {
|
|
484
484
|
constructor(e, t, r) {
|
|
485
485
|
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
486
486
|
}
|
|
@@ -497,12 +497,12 @@ class ce {
|
|
|
497
497
|
throw new Error("SessionManager is required for private endpoints");
|
|
498
498
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
499
499
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
500
|
-
const
|
|
500
|
+
const n = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
|
|
501
501
|
headers: t
|
|
502
502
|
});
|
|
503
503
|
return {
|
|
504
|
-
tenants:
|
|
505
|
-
meta:
|
|
504
|
+
tenants: o.data,
|
|
505
|
+
meta: o.meta
|
|
506
506
|
};
|
|
507
507
|
}
|
|
508
508
|
async getTenantById(e) {
|
|
@@ -558,7 +558,7 @@ class ce {
|
|
|
558
558
|
)).data;
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
|
-
const
|
|
561
|
+
const fe = ee(null), ke = () => /* @__PURE__ */ s(
|
|
562
562
|
"div",
|
|
563
563
|
{
|
|
564
564
|
style: {
|
|
@@ -568,9 +568,9 @@ const pe = ee(null), ke = () => /* @__PURE__ */ n(
|
|
|
568
568
|
height: "100vh",
|
|
569
569
|
fontFamily: "system-ui, sans-serif"
|
|
570
570
|
},
|
|
571
|
-
children: /* @__PURE__ */
|
|
571
|
+
children: /* @__PURE__ */ s("div", { children: "Loading tenant..." })
|
|
572
572
|
}
|
|
573
|
-
), Te = ({ error: i, retry: e }) => /* @__PURE__ */
|
|
573
|
+
), Te = ({ error: i, retry: e }) => /* @__PURE__ */ c(
|
|
574
574
|
"div",
|
|
575
575
|
{
|
|
576
576
|
style: {
|
|
@@ -584,9 +584,9 @@ const pe = ee(null), ke = () => /* @__PURE__ */ n(
|
|
|
584
584
|
padding: "20px"
|
|
585
585
|
},
|
|
586
586
|
children: [
|
|
587
|
-
/* @__PURE__ */
|
|
588
|
-
/* @__PURE__ */
|
|
589
|
-
/* @__PURE__ */
|
|
587
|
+
/* @__PURE__ */ s("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Tenant Error" }),
|
|
588
|
+
/* @__PURE__ */ s("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load tenant" }),
|
|
589
|
+
/* @__PURE__ */ s(
|
|
590
590
|
"button",
|
|
591
591
|
{
|
|
592
592
|
onClick: e,
|
|
@@ -604,73 +604,73 @@ const pe = ee(null), ke = () => /* @__PURE__ */ n(
|
|
|
604
604
|
]
|
|
605
605
|
}
|
|
606
606
|
);
|
|
607
|
-
function
|
|
608
|
-
const { baseUrl: t, appInfo: r, appId:
|
|
609
|
-
const
|
|
607
|
+
function tt({ config: i, children: e }) {
|
|
608
|
+
const { baseUrl: t, appInfo: r, appId: n } = re(), [o, m] = b(i.initialTenant || null), [T, M] = b(!i.initialTenant), [P, g] = b(null), [h, x] = b(null), [p, A] = b(!1), [F, f] = b(null), L = Z(() => {
|
|
609
|
+
const d = i.tenantMode || "selector", w = "tenant";
|
|
610
610
|
if (typeof window > "u") return null;
|
|
611
|
-
if (
|
|
612
|
-
const
|
|
613
|
-
if (
|
|
614
|
-
const l =
|
|
611
|
+
if (d === "subdomain") {
|
|
612
|
+
const a = window.location.hostname.split(".");
|
|
613
|
+
if (a.length >= 3) {
|
|
614
|
+
const l = a[0];
|
|
615
615
|
return localStorage.setItem(w, l), l;
|
|
616
616
|
}
|
|
617
617
|
return localStorage.getItem(w);
|
|
618
|
-
} else if (
|
|
619
|
-
const
|
|
620
|
-
return
|
|
618
|
+
} else if (d === "selector") {
|
|
619
|
+
const a = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
|
|
620
|
+
return a ? (localStorage.setItem(w, a), a) : localStorage.getItem(w);
|
|
621
621
|
}
|
|
622
622
|
return null;
|
|
623
|
-
}, [i.tenantMode, i.selectorParam]), y =
|
|
624
|
-
async (
|
|
623
|
+
}, [i.tenantMode, i.selectorParam]), y = z(() => L(), [L]), S = (r == null ? void 0 : r.settingsSchema) || null, k = Z(
|
|
624
|
+
async (d) => {
|
|
625
625
|
try {
|
|
626
626
|
M(!0), g(null);
|
|
627
|
-
const w = new G(t),
|
|
628
|
-
|
|
627
|
+
const w = new G(t), a = await new de(w, n).getPublicTenantInfo(d);
|
|
628
|
+
m(a);
|
|
629
629
|
} catch (w) {
|
|
630
|
-
const
|
|
631
|
-
g(
|
|
630
|
+
const u = w instanceof Error ? w : new Error("Failed to load tenant information");
|
|
631
|
+
g(u), m(null);
|
|
632
632
|
} finally {
|
|
633
633
|
M(!1);
|
|
634
634
|
}
|
|
635
635
|
},
|
|
636
|
-
[t,
|
|
637
|
-
), R =
|
|
638
|
-
if (
|
|
636
|
+
[t, n]
|
|
637
|
+
), R = Z(async () => {
|
|
638
|
+
if (o != null && o.id)
|
|
639
639
|
try {
|
|
640
640
|
A(!0), f(null);
|
|
641
|
-
const
|
|
642
|
-
x(
|
|
643
|
-
} catch (
|
|
644
|
-
const w =
|
|
641
|
+
const d = new G(t), u = await new de(d, o.appId).getTenantSettings(o.id);
|
|
642
|
+
x(u);
|
|
643
|
+
} catch (d) {
|
|
644
|
+
const w = d instanceof Error ? d : new Error("Failed to load tenant settings");
|
|
645
645
|
f(w), x(null);
|
|
646
646
|
} finally {
|
|
647
647
|
A(!1);
|
|
648
648
|
}
|
|
649
|
-
}, [t,
|
|
649
|
+
}, [t, o]), D = Z(() => {
|
|
650
650
|
R();
|
|
651
|
-
}, [R]), E =
|
|
652
|
-
(
|
|
653
|
-
if (!
|
|
651
|
+
}, [R]), E = Z(
|
|
652
|
+
(d) => {
|
|
653
|
+
if (!S)
|
|
654
654
|
return { isValid: !0, errors: [] };
|
|
655
655
|
const w = [];
|
|
656
656
|
try {
|
|
657
|
-
return
|
|
657
|
+
return S.properties && Object.entries(S.properties).forEach(([u, a]) => {
|
|
658
658
|
var W;
|
|
659
|
-
const l =
|
|
660
|
-
if ((W =
|
|
661
|
-
w.push(`Field '${
|
|
659
|
+
const l = d[u];
|
|
660
|
+
if ((W = S.required) != null && W.includes(u) && l == null) {
|
|
661
|
+
w.push(`Field '${u}' is required`);
|
|
662
662
|
return;
|
|
663
663
|
}
|
|
664
664
|
if (l != null) {
|
|
665
|
-
if (
|
|
666
|
-
const I =
|
|
667
|
-
I === "string" && N !== "string" ? w.push(`Field '${
|
|
665
|
+
if (a.type) {
|
|
666
|
+
const I = a.type, N = typeof l;
|
|
667
|
+
I === "string" && N !== "string" ? w.push(`Field '${u}' must be a string`) : (I === "number" || I === "integer") && N !== "number" ? w.push(`Field '${u}' must be a number`) : I === "boolean" && N !== "boolean" ? w.push(`Field '${u}' must be a boolean`) : I === "array" && !Array.isArray(l) && w.push(`Field '${u}' must be an array`);
|
|
668
668
|
}
|
|
669
|
-
|
|
670
|
-
`Field '${
|
|
671
|
-
),
|
|
672
|
-
`Field '${
|
|
673
|
-
),
|
|
669
|
+
a.minLength !== void 0 && typeof l == "string" && l.length < a.minLength && w.push(
|
|
670
|
+
`Field '${u}' must be at least ${a.minLength} characters long`
|
|
671
|
+
), a.maxLength !== void 0 && typeof l == "string" && l.length > a.maxLength && w.push(
|
|
672
|
+
`Field '${u}' must be no more than ${a.maxLength} characters long`
|
|
673
|
+
), a.minimum !== void 0 && typeof l == "number" && l < a.minimum && w.push(`Field '${u}' must be at least ${a.minimum}`), a.maximum !== void 0 && typeof l == "number" && l > a.maximum && w.push(`Field '${u}' must be no more than ${a.maximum}`), a.pattern && typeof l == "string" && (new RegExp(a.pattern).test(l) || w.push(`Field '${u}' does not match the required pattern`)), a.enum && !a.enum.includes(l) && w.push(`Field '${u}' must be one of: ${a.enum.join(", ")}`);
|
|
674
674
|
}
|
|
675
675
|
}), {
|
|
676
676
|
isValid: w.length === 0,
|
|
@@ -683,16 +683,16 @@ function Ze({ config: i, children: e }) {
|
|
|
683
683
|
};
|
|
684
684
|
}
|
|
685
685
|
},
|
|
686
|
-
[
|
|
686
|
+
[S]
|
|
687
687
|
);
|
|
688
|
-
|
|
689
|
-
!i.initialTenant && y ? k(y) : !i.initialTenant && !y && (
|
|
690
|
-
}, [i.initialTenant, y, k]),
|
|
691
|
-
|
|
692
|
-
}, [
|
|
693
|
-
const
|
|
688
|
+
Y(() => {
|
|
689
|
+
!i.initialTenant && y ? k(y) : !i.initialTenant && !y && (m(null), g(null), M(!1));
|
|
690
|
+
}, [i.initialTenant, y, k]), Y(() => {
|
|
691
|
+
o != null && o.id ? R() : (x(null), f(null), A(!1));
|
|
692
|
+
}, [o == null ? void 0 : o.id, R]);
|
|
693
|
+
const B = z(() => ({
|
|
694
694
|
// Tenant info
|
|
695
|
-
tenant:
|
|
695
|
+
tenant: o,
|
|
696
696
|
tenantSlug: y,
|
|
697
697
|
isTenantLoading: T,
|
|
698
698
|
tenantError: P,
|
|
@@ -701,87 +701,87 @@ function Ze({ config: i, children: e }) {
|
|
|
701
701
|
},
|
|
702
702
|
// Settings
|
|
703
703
|
settings: h,
|
|
704
|
-
settingsSchema:
|
|
704
|
+
settingsSchema: S,
|
|
705
705
|
isSettingsLoading: p,
|
|
706
706
|
settingsError: F,
|
|
707
707
|
// Actions
|
|
708
|
-
refreshSettings:
|
|
708
|
+
refreshSettings: D,
|
|
709
709
|
// Validation
|
|
710
710
|
validateSettings: E
|
|
711
711
|
}), [
|
|
712
|
-
|
|
712
|
+
o,
|
|
713
713
|
y,
|
|
714
714
|
T,
|
|
715
715
|
P,
|
|
716
716
|
h,
|
|
717
|
-
|
|
717
|
+
S,
|
|
718
718
|
p,
|
|
719
719
|
F,
|
|
720
|
-
|
|
720
|
+
D,
|
|
721
721
|
E
|
|
722
722
|
]);
|
|
723
723
|
if (T)
|
|
724
|
-
return /* @__PURE__ */
|
|
724
|
+
return /* @__PURE__ */ s(H, { children: i.loadingFallback || /* @__PURE__ */ s(ke, {}) });
|
|
725
725
|
if (P) {
|
|
726
|
-
const
|
|
727
|
-
return /* @__PURE__ */
|
|
726
|
+
const d = typeof i.errorFallback == "function" ? i.errorFallback(P, () => k(y || "")) : i.errorFallback || /* @__PURE__ */ s(Te, { error: P, retry: () => k(y || "") });
|
|
727
|
+
return /* @__PURE__ */ s(H, { children: d });
|
|
728
728
|
}
|
|
729
|
-
return /* @__PURE__ */
|
|
729
|
+
return /* @__PURE__ */ s(fe.Provider, { value: B, children: e });
|
|
730
730
|
}
|
|
731
|
-
function
|
|
732
|
-
const i = te(
|
|
731
|
+
function le() {
|
|
732
|
+
const i = te(fe);
|
|
733
733
|
if (!i)
|
|
734
734
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
735
735
|
return i;
|
|
736
736
|
}
|
|
737
|
-
const
|
|
738
|
-
function
|
|
737
|
+
const rt = le;
|
|
738
|
+
function st() {
|
|
739
739
|
const {
|
|
740
740
|
settings: i,
|
|
741
741
|
settingsSchema: e,
|
|
742
742
|
isSettingsLoading: t,
|
|
743
743
|
settingsError: r,
|
|
744
|
-
validateSettings:
|
|
745
|
-
} =
|
|
744
|
+
validateSettings: n
|
|
745
|
+
} = le();
|
|
746
746
|
return {
|
|
747
747
|
settings: i,
|
|
748
748
|
settingsSchema: e,
|
|
749
749
|
isLoading: t,
|
|
750
750
|
error: r,
|
|
751
|
-
validateSettings:
|
|
751
|
+
validateSettings: n
|
|
752
752
|
};
|
|
753
753
|
}
|
|
754
|
-
function
|
|
755
|
-
const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant:
|
|
754
|
+
function K() {
|
|
755
|
+
const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: n } = le();
|
|
756
756
|
return {
|
|
757
757
|
tenant: i,
|
|
758
758
|
tenantSlug: e,
|
|
759
759
|
isLoading: t,
|
|
760
760
|
error: r,
|
|
761
|
-
retry:
|
|
761
|
+
retry: n
|
|
762
762
|
};
|
|
763
763
|
}
|
|
764
|
-
const
|
|
765
|
-
function
|
|
766
|
-
const { appId: t, baseUrl: r } = re(),
|
|
767
|
-
const
|
|
764
|
+
const ye = ee(null);
|
|
765
|
+
function nt({ config: i = {}, children: e }) {
|
|
766
|
+
const { appId: t, baseUrl: r } = re(), n = K(), o = (n == null ? void 0 : n.tenantSlug) || null, [m, T] = b(i.initialRoles || []), [M, P] = b(!i.initialRoles), [g, h] = b(null), [x, p] = b(!1), [A, F] = b(null), f = z(() => {
|
|
767
|
+
const d = o ? `auth_tokens_${o}` : "auth_tokens", w = {
|
|
768
768
|
get: () => {
|
|
769
769
|
try {
|
|
770
|
-
const
|
|
771
|
-
return
|
|
770
|
+
const u = localStorage.getItem(d);
|
|
771
|
+
return u ? JSON.parse(u) : null;
|
|
772
772
|
} catch {
|
|
773
773
|
return null;
|
|
774
774
|
}
|
|
775
775
|
},
|
|
776
|
-
set: (
|
|
776
|
+
set: (u) => {
|
|
777
777
|
try {
|
|
778
|
-
localStorage.setItem(
|
|
778
|
+
localStorage.setItem(d, JSON.stringify(u));
|
|
779
779
|
} catch {
|
|
780
780
|
}
|
|
781
781
|
},
|
|
782
782
|
clear: () => {
|
|
783
783
|
try {
|
|
784
|
-
localStorage.removeItem(
|
|
784
|
+
localStorage.removeItem(d);
|
|
785
785
|
} catch {
|
|
786
786
|
}
|
|
787
787
|
}
|
|
@@ -791,35 +791,35 @@ function rt({ config: i = {}, children: e }) {
|
|
|
791
791
|
tokenStorage: w,
|
|
792
792
|
baseUrl: r
|
|
793
793
|
});
|
|
794
|
-
}, [
|
|
795
|
-
const
|
|
796
|
-
return
|
|
797
|
-
}, [r, f]), y =
|
|
798
|
-
|
|
794
|
+
}, [o, r, i.onRefreshFailed]), L = z(() => {
|
|
795
|
+
const d = new G(r);
|
|
796
|
+
return d.setSessionManager(f), d;
|
|
797
|
+
}, [r, f]), y = z(() => new Ae(new G(r)), [r]), S = z(() => new Pe(L, f), [L, f]), k = z(() => new ce(new G(r)), [r]), R = z(() => g || f.getUser(), [g, f]), D = z(() => R != null && R.roleId && m.find((d) => d.id === R.roleId) || null, [R, m]), E = z(() => (D == null ? void 0 : D.permissions) || [], [D]);
|
|
798
|
+
Y(() => {
|
|
799
799
|
console.log("AuthProvider - userPermissions changed:", E);
|
|
800
800
|
}, [E]);
|
|
801
|
-
const
|
|
802
|
-
const
|
|
801
|
+
const B = z(() => {
|
|
802
|
+
const d = async () => {
|
|
803
803
|
try {
|
|
804
804
|
p(!0), F(null);
|
|
805
|
-
const
|
|
806
|
-
if (!(
|
|
805
|
+
const v = f.getUser();
|
|
806
|
+
if (!(v != null && v.id))
|
|
807
807
|
throw new Error("No user ID available in session");
|
|
808
|
-
const $ = await
|
|
808
|
+
const $ = await S.getUserById(v.id);
|
|
809
809
|
h($), f.setUser($);
|
|
810
|
-
} catch (
|
|
811
|
-
const $ =
|
|
810
|
+
} catch (v) {
|
|
811
|
+
const $ = v instanceof Error ? v : new Error("Failed to load user data");
|
|
812
812
|
F($), console.error("Failed to load user data:", $);
|
|
813
813
|
} finally {
|
|
814
814
|
p(!1);
|
|
815
815
|
}
|
|
816
816
|
}, w = async () => {
|
|
817
|
-
await
|
|
818
|
-
},
|
|
817
|
+
await d();
|
|
818
|
+
}, u = async (v, $, J) => {
|
|
819
819
|
const V = await y.login({
|
|
820
|
-
email:
|
|
820
|
+
email: v,
|
|
821
821
|
password: $,
|
|
822
|
-
tenantId:
|
|
822
|
+
tenantId: J
|
|
823
823
|
});
|
|
824
824
|
if (f.setTokens({
|
|
825
825
|
accessToken: V.accessToken,
|
|
@@ -828,125 +828,125 @@ function rt({ config: i = {}, children: e }) {
|
|
|
828
828
|
}), V.user) {
|
|
829
829
|
f.setUser(V.user), h(V.user);
|
|
830
830
|
try {
|
|
831
|
-
await
|
|
832
|
-
} catch (
|
|
833
|
-
console.warn("Failed to load complete user data after login:",
|
|
831
|
+
await d();
|
|
832
|
+
} catch (oe) {
|
|
833
|
+
console.warn("Failed to load complete user data after login:", oe);
|
|
834
834
|
}
|
|
835
835
|
}
|
|
836
836
|
return V;
|
|
837
|
-
},
|
|
838
|
-
email:
|
|
837
|
+
}, a = async (v, $, J, V) => await y.signup({ email: v, name: $, password: J, tenantId: V }), l = async (v, $, J, V) => await y.signupTenantAdmin({
|
|
838
|
+
email: v,
|
|
839
839
|
name: $,
|
|
840
|
-
password:
|
|
840
|
+
password: J,
|
|
841
841
|
tenantName: V,
|
|
842
842
|
appId: t
|
|
843
|
-
}), W = async (
|
|
844
|
-
const
|
|
845
|
-
await y.changePassword({ currentPassword:
|
|
846
|
-
}, I = async (
|
|
847
|
-
await y.requestPasswordReset({ email:
|
|
848
|
-
}, N = async (
|
|
849
|
-
await y.confirmPasswordReset({ token:
|
|
843
|
+
}), W = async (v, $) => {
|
|
844
|
+
const J = await f.getAuthHeaders();
|
|
845
|
+
await y.changePassword({ currentPassword: v, newPassword: $ }, J);
|
|
846
|
+
}, I = async (v, $) => {
|
|
847
|
+
await y.requestPasswordReset({ email: v, tenantId: $ });
|
|
848
|
+
}, N = async (v, $) => {
|
|
849
|
+
await y.confirmPasswordReset({ token: v, newPassword: $ });
|
|
850
850
|
}, _ = async () => {
|
|
851
|
-
const
|
|
852
|
-
if (!(
|
|
851
|
+
const v = f.getTokens();
|
|
852
|
+
if (!(v != null && v.refreshToken))
|
|
853
853
|
throw new Error("No refresh token available");
|
|
854
854
|
const $ = await y.refreshToken({
|
|
855
|
-
refreshToken:
|
|
855
|
+
refreshToken: v.refreshToken
|
|
856
856
|
});
|
|
857
857
|
f.setTokens({
|
|
858
858
|
accessToken: $.accessToken,
|
|
859
|
-
refreshToken: $.refreshToken ||
|
|
859
|
+
refreshToken: $.refreshToken || v.refreshToken,
|
|
860
860
|
expiresIn: $.expiresIn
|
|
861
861
|
});
|
|
862
|
-
},
|
|
862
|
+
}, C = () => {
|
|
863
863
|
f.clearSession(), h(null), F(null);
|
|
864
|
-
},
|
|
865
|
-
f.setTokens(
|
|
866
|
-
},
|
|
864
|
+
}, U = (v) => {
|
|
865
|
+
f.setTokens(v);
|
|
866
|
+
}, Q = () => f.hasValidSession(), q = () => {
|
|
867
867
|
f.clearSession(), h(null), F(null);
|
|
868
|
-
},
|
|
868
|
+
}, O = async () => {
|
|
869
869
|
if (t)
|
|
870
870
|
try {
|
|
871
871
|
P(!0);
|
|
872
|
-
const { roles:
|
|
873
|
-
T(
|
|
874
|
-
} catch (
|
|
875
|
-
console.error("Failed to fetch roles:",
|
|
872
|
+
const { roles: v } = await k.getRolesByApp(t);
|
|
873
|
+
T(v);
|
|
874
|
+
} catch (v) {
|
|
875
|
+
console.error("Failed to fetch roles:", v);
|
|
876
876
|
} finally {
|
|
877
877
|
P(!1);
|
|
878
878
|
}
|
|
879
879
|
}, j = async () => {
|
|
880
|
-
await
|
|
881
|
-
},
|
|
880
|
+
await O();
|
|
881
|
+
}, ie = (v) => {
|
|
882
882
|
if (!E || E.length === 0)
|
|
883
883
|
return !1;
|
|
884
|
-
if (typeof
|
|
885
|
-
return E.includes(
|
|
886
|
-
const $ = `${
|
|
884
|
+
if (typeof v == "string")
|
|
885
|
+
return E.includes(v);
|
|
886
|
+
const $ = `${v.resource}.${v.action}`;
|
|
887
887
|
return E.includes($);
|
|
888
888
|
};
|
|
889
889
|
return {
|
|
890
890
|
sessionManager: f,
|
|
891
|
-
authenticatedHttpService:
|
|
892
|
-
login:
|
|
893
|
-
signup:
|
|
891
|
+
authenticatedHttpService: L,
|
|
892
|
+
login: u,
|
|
893
|
+
signup: a,
|
|
894
894
|
signupTenantAdmin: l,
|
|
895
895
|
changePassword: W,
|
|
896
896
|
requestPasswordReset: I,
|
|
897
897
|
confirmPasswordReset: N,
|
|
898
898
|
refreshToken: _,
|
|
899
|
-
logout:
|
|
900
|
-
setTokens:
|
|
901
|
-
hasValidSession:
|
|
902
|
-
clearSession:
|
|
899
|
+
logout: C,
|
|
900
|
+
setTokens: U,
|
|
901
|
+
hasValidSession: Q,
|
|
902
|
+
clearSession: q,
|
|
903
903
|
currentUser: g,
|
|
904
904
|
isUserLoading: x,
|
|
905
905
|
userError: A,
|
|
906
906
|
refreshUser: w,
|
|
907
|
-
userRole:
|
|
907
|
+
userRole: D,
|
|
908
908
|
userPermissions: E,
|
|
909
|
-
availableRoles:
|
|
909
|
+
availableRoles: m,
|
|
910
910
|
rolesLoading: M,
|
|
911
|
-
hasPermission:
|
|
912
|
-
hasAnyPermission: (
|
|
913
|
-
hasAllPermissions: (
|
|
911
|
+
hasPermission: ie,
|
|
912
|
+
hasAnyPermission: (v) => v.some(($) => ie($)),
|
|
913
|
+
hasAllPermissions: (v) => v.every(($) => ie($)),
|
|
914
914
|
getUserPermissionStrings: () => E || [],
|
|
915
915
|
refreshRoles: j
|
|
916
916
|
};
|
|
917
917
|
}, [
|
|
918
918
|
f,
|
|
919
|
-
|
|
919
|
+
L,
|
|
920
920
|
y,
|
|
921
|
-
|
|
921
|
+
S,
|
|
922
922
|
k,
|
|
923
923
|
t,
|
|
924
|
-
|
|
924
|
+
m,
|
|
925
925
|
g,
|
|
926
926
|
x,
|
|
927
927
|
A,
|
|
928
|
-
|
|
928
|
+
D,
|
|
929
929
|
E
|
|
930
930
|
]);
|
|
931
|
-
return
|
|
931
|
+
return Y(() => {
|
|
932
932
|
!i.initialRoles && t && (async () => {
|
|
933
933
|
try {
|
|
934
934
|
P(!0);
|
|
935
|
-
const w = new G(r),
|
|
936
|
-
T(
|
|
935
|
+
const w = new G(r), u = new ce(w), { roles: a } = await u.getRolesByApp(t);
|
|
936
|
+
T(a);
|
|
937
937
|
} catch (w) {
|
|
938
938
|
console.error("Failed to fetch roles:", w);
|
|
939
939
|
} finally {
|
|
940
940
|
P(!1);
|
|
941
941
|
}
|
|
942
942
|
})();
|
|
943
|
-
}, [t, r, i.initialRoles]),
|
|
944
|
-
const
|
|
945
|
-
|
|
946
|
-
}, [f]), /* @__PURE__ */
|
|
943
|
+
}, [t, r, i.initialRoles]), Y(() => {
|
|
944
|
+
const d = f.getUser();
|
|
945
|
+
d && f.hasValidSession() && h(d);
|
|
946
|
+
}, [f]), /* @__PURE__ */ s(ye.Provider, { value: B, children: e });
|
|
947
947
|
}
|
|
948
948
|
function se() {
|
|
949
|
-
const i = te(
|
|
949
|
+
const i = te(ye);
|
|
950
950
|
if (!i)
|
|
951
951
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
952
952
|
return i;
|
|
@@ -972,12 +972,12 @@ class Me {
|
|
|
972
972
|
throw new Error("SessionManager is required for private endpoints");
|
|
973
973
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
974
974
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
975
|
-
const
|
|
975
|
+
const n = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
|
|
976
976
|
headers: t
|
|
977
977
|
});
|
|
978
978
|
return {
|
|
979
|
-
featureFlags:
|
|
980
|
-
meta:
|
|
979
|
+
featureFlags: o.data,
|
|
980
|
+
meta: o.meta
|
|
981
981
|
};
|
|
982
982
|
}
|
|
983
983
|
async getFeatureFlagById(e) {
|
|
@@ -1014,8 +1014,8 @@ class Me {
|
|
|
1014
1014
|
throw new Error("Tenant ID and App ID are required");
|
|
1015
1015
|
const r = new URLSearchParams();
|
|
1016
1016
|
r.append("tenantId", e), r.append("appId", t);
|
|
1017
|
-
const
|
|
1018
|
-
return (await this.httpService.get(
|
|
1017
|
+
const n = `/tenant-feature-flags${r.toString() ? `?${r.toString()}` : ""}`;
|
|
1018
|
+
return (await this.httpService.get(n, {
|
|
1019
1019
|
headers: { "X-Tenant-ID": e }
|
|
1020
1020
|
})).data;
|
|
1021
1021
|
}
|
|
@@ -1023,28 +1023,28 @@ class Me {
|
|
|
1023
1023
|
async getTenantFeatureFlag(e, t, r) {
|
|
1024
1024
|
if (!e || !t || !r)
|
|
1025
1025
|
throw new Error("Flag Key, Tenant ID and App ID are required");
|
|
1026
|
-
const
|
|
1027
|
-
|
|
1028
|
-
const
|
|
1029
|
-
return (await this.httpService.get(
|
|
1026
|
+
const n = new URLSearchParams();
|
|
1027
|
+
n.append("tenantId", t), n.append("appId", r);
|
|
1028
|
+
const o = `/tenant-feature-flags/${e}${n.toString() ? `?${n.toString()}` : ""}`;
|
|
1029
|
+
return (await this.httpService.get(o, {
|
|
1030
1030
|
headers: { "X-Tenant-ID": t }
|
|
1031
1031
|
})).data;
|
|
1032
1032
|
}
|
|
1033
1033
|
}
|
|
1034
|
-
const
|
|
1035
|
-
function
|
|
1036
|
-
const { baseUrl: t, appId: r } = re(), { tenant:
|
|
1034
|
+
const we = ee(null);
|
|
1035
|
+
function it({ config: i = {}, children: e }) {
|
|
1036
|
+
const { baseUrl: t, appId: r } = re(), { tenant: n } = K(), [o, m] = b([]), [T, M] = b(!1), [P, g] = b(null), h = z(() => {
|
|
1037
1037
|
const A = new G(t);
|
|
1038
1038
|
return new Me(A);
|
|
1039
1039
|
}, [t]), x = async () => {
|
|
1040
|
-
if (!(
|
|
1041
|
-
|
|
1040
|
+
if (!(n != null && n.id)) {
|
|
1041
|
+
m([]);
|
|
1042
1042
|
return;
|
|
1043
1043
|
}
|
|
1044
1044
|
M(!0), g(null);
|
|
1045
1045
|
try {
|
|
1046
|
-
const A = await h.getTenantFeatureFlags(
|
|
1047
|
-
|
|
1046
|
+
const A = await h.getTenantFeatureFlags(n.id, r);
|
|
1047
|
+
m(A);
|
|
1048
1048
|
} catch (A) {
|
|
1049
1049
|
const F = A instanceof Error ? A.message : "Failed to fetch feature flags";
|
|
1050
1050
|
g(F), i.onError && i.onError(A instanceof Error ? A : new Error(F));
|
|
@@ -1052,32 +1052,32 @@ function st({ config: i = {}, children: e }) {
|
|
|
1052
1052
|
M(!1);
|
|
1053
1053
|
}
|
|
1054
1054
|
};
|
|
1055
|
-
|
|
1055
|
+
Y(() => {
|
|
1056
1056
|
x();
|
|
1057
1057
|
const A = i.refreshInterval || 5 * 60 * 1e3, F = setInterval(x, A);
|
|
1058
1058
|
return () => clearInterval(F);
|
|
1059
|
-
}, [
|
|
1060
|
-
const p =
|
|
1061
|
-
featureFlags:
|
|
1059
|
+
}, [n == null ? void 0 : n.id, i.refreshInterval]);
|
|
1060
|
+
const p = z(() => ({
|
|
1061
|
+
featureFlags: o,
|
|
1062
1062
|
loading: T,
|
|
1063
1063
|
error: P,
|
|
1064
1064
|
isEnabled: (y) => {
|
|
1065
|
-
const
|
|
1066
|
-
return (
|
|
1065
|
+
const S = o.find((k) => k.key === y);
|
|
1066
|
+
return (S == null ? void 0 : S.value) === !0;
|
|
1067
1067
|
},
|
|
1068
|
-
getFlag: (y) =>
|
|
1068
|
+
getFlag: (y) => o.find((S) => S.key === y),
|
|
1069
1069
|
getFlagState: (y) => {
|
|
1070
|
-
const
|
|
1071
|
-
return
|
|
1070
|
+
const S = o.find((k) => k.key === y);
|
|
1071
|
+
return S ? S.value ? "enabled" : "disabled" : "not_found";
|
|
1072
1072
|
},
|
|
1073
1073
|
refresh: async () => {
|
|
1074
1074
|
await x();
|
|
1075
1075
|
}
|
|
1076
|
-
}), [
|
|
1077
|
-
return /* @__PURE__ */
|
|
1076
|
+
}), [o, T, P]);
|
|
1077
|
+
return /* @__PURE__ */ s(we.Provider, { value: p, children: e });
|
|
1078
1078
|
}
|
|
1079
1079
|
function Ee() {
|
|
1080
|
-
const i = te(
|
|
1080
|
+
const i = te(we);
|
|
1081
1081
|
if (!i)
|
|
1082
1082
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1083
1083
|
return i;
|
|
@@ -1148,20 +1148,20 @@ class Re {
|
|
|
1148
1148
|
)).data;
|
|
1149
1149
|
}
|
|
1150
1150
|
}
|
|
1151
|
-
const
|
|
1152
|
-
function
|
|
1153
|
-
const { baseUrl: t } = re(), { tenant: r } =
|
|
1151
|
+
const me = ee(void 0);
|
|
1152
|
+
function ot({ config: i = {}, children: e }) {
|
|
1153
|
+
const { baseUrl: t } = re(), { tenant: r } = K(), [n, o] = b(null), [m, T] = b(!1), [M, P] = b(null), g = z(() => {
|
|
1154
1154
|
const p = new G(t);
|
|
1155
1155
|
return new Re(p);
|
|
1156
1156
|
}, [t]), h = async () => {
|
|
1157
1157
|
if (!(r != null && r.id)) {
|
|
1158
|
-
|
|
1158
|
+
o(null);
|
|
1159
1159
|
return;
|
|
1160
1160
|
}
|
|
1161
1161
|
T(!0), P(null);
|
|
1162
1162
|
try {
|
|
1163
1163
|
const p = await g.getTenantSubscriptionFeatures(r.id);
|
|
1164
|
-
|
|
1164
|
+
o(p);
|
|
1165
1165
|
} catch (p) {
|
|
1166
1166
|
const A = p instanceof Error ? p.message : "Failed to fetch subscription";
|
|
1167
1167
|
P(A), i.onError && i.onError(p instanceof Error ? p : new Error(A));
|
|
@@ -1169,43 +1169,43 @@ function nt({ config: i = {}, children: e }) {
|
|
|
1169
1169
|
T(!1);
|
|
1170
1170
|
}
|
|
1171
1171
|
};
|
|
1172
|
-
|
|
1172
|
+
Y(() => {
|
|
1173
1173
|
if (h(), !i.refreshInterval) return;
|
|
1174
1174
|
const p = i.refreshInterval || 10 * 60 * 1e3, A = setInterval(h, p);
|
|
1175
1175
|
return () => clearInterval(A);
|
|
1176
1176
|
}, [r == null ? void 0 : r.id, i.refreshInterval]);
|
|
1177
|
-
const x =
|
|
1178
|
-
const p = (
|
|
1177
|
+
const x = z(() => {
|
|
1178
|
+
const p = (n == null ? void 0 : n.features) || [];
|
|
1179
1179
|
return {
|
|
1180
|
-
subscription:
|
|
1180
|
+
subscription: n,
|
|
1181
1181
|
features: p,
|
|
1182
|
-
loading:
|
|
1182
|
+
loading: m,
|
|
1183
1183
|
error: M,
|
|
1184
|
-
isFeatureEnabled: (
|
|
1185
|
-
const k = p.find((R) => R.key ===
|
|
1184
|
+
isFeatureEnabled: (S) => {
|
|
1185
|
+
const k = p.find((R) => R.key === S);
|
|
1186
1186
|
return k ? k.type === "BOOLEAN" || k.type === "boolean" ? k.value === !0 : !!k.value : !1;
|
|
1187
1187
|
},
|
|
1188
|
-
getFeature: (
|
|
1189
|
-
getFeatureValue: (
|
|
1190
|
-
const R = p.find((
|
|
1188
|
+
getFeature: (S) => p.find((k) => k.key === S),
|
|
1189
|
+
getFeatureValue: (S, k) => {
|
|
1190
|
+
const R = p.find((D) => D.key === S);
|
|
1191
1191
|
return R ? R.value : k;
|
|
1192
1192
|
},
|
|
1193
|
-
hasAllowedPlan: (
|
|
1193
|
+
hasAllowedPlan: (S) => !n || !n.isActive ? !1 : S.includes(n.planId),
|
|
1194
1194
|
refresh: async () => {
|
|
1195
1195
|
await h();
|
|
1196
1196
|
}
|
|
1197
1197
|
};
|
|
1198
|
-
}, [
|
|
1199
|
-
return /* @__PURE__ */
|
|
1198
|
+
}, [n, m, M]);
|
|
1199
|
+
return /* @__PURE__ */ s(me.Provider, { value: x, children: e });
|
|
1200
1200
|
}
|
|
1201
1201
|
function Fe() {
|
|
1202
|
-
const i = te(
|
|
1202
|
+
const i = te(me);
|
|
1203
1203
|
if (i === void 0)
|
|
1204
1204
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1205
1205
|
return i;
|
|
1206
1206
|
}
|
|
1207
|
-
var
|
|
1208
|
-
const
|
|
1207
|
+
var X = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(X || {});
|
|
1208
|
+
const ue = () => /* @__PURE__ */ c(
|
|
1209
1209
|
"div",
|
|
1210
1210
|
{
|
|
1211
1211
|
style: {
|
|
@@ -1221,10 +1221,10 @@ const de = () => /* @__PURE__ */ u(
|
|
|
1221
1221
|
margin: "20px 0"
|
|
1222
1222
|
},
|
|
1223
1223
|
children: [
|
|
1224
|
-
/* @__PURE__ */
|
|
1225
|
-
/* @__PURE__ */
|
|
1226
|
-
/* @__PURE__ */
|
|
1227
|
-
/* @__PURE__ */
|
|
1224
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "🔒" }),
|
|
1225
|
+
/* @__PURE__ */ s("h3", { style: { color: "#495057", marginBottom: "10px" }, children: "Access Required" }),
|
|
1226
|
+
/* @__PURE__ */ s("p", { style: { color: "#6c757d", fontSize: "14px", marginBottom: "15px" }, children: "You need to be signed in to view this content." }),
|
|
1227
|
+
/* @__PURE__ */ s(
|
|
1228
1228
|
"button",
|
|
1229
1229
|
{
|
|
1230
1230
|
style: {
|
|
@@ -1242,11 +1242,11 @@ const de = () => /* @__PURE__ */ u(
|
|
|
1242
1242
|
)
|
|
1243
1243
|
]
|
|
1244
1244
|
}
|
|
1245
|
-
),
|
|
1245
|
+
), he = ({
|
|
1246
1246
|
userType: i,
|
|
1247
1247
|
minUserType: e,
|
|
1248
1248
|
missingPermissions: t
|
|
1249
|
-
}) => /* @__PURE__ */
|
|
1249
|
+
}) => /* @__PURE__ */ c(
|
|
1250
1250
|
"div",
|
|
1251
1251
|
{
|
|
1252
1252
|
style: {
|
|
@@ -1262,57 +1262,57 @@ const de = () => /* @__PURE__ */ u(
|
|
|
1262
1262
|
margin: "20px 0"
|
|
1263
1263
|
},
|
|
1264
1264
|
children: [
|
|
1265
|
-
/* @__PURE__ */
|
|
1266
|
-
/* @__PURE__ */
|
|
1267
|
-
e && i ? /* @__PURE__ */
|
|
1268
|
-
/* @__PURE__ */
|
|
1265
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1266
|
+
/* @__PURE__ */ s("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1267
|
+
e && i ? /* @__PURE__ */ c(H, { children: [
|
|
1268
|
+
/* @__PURE__ */ c("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1269
1269
|
"This content requires ",
|
|
1270
|
-
/* @__PURE__ */
|
|
1270
|
+
/* @__PURE__ */ s("strong", { children: e }),
|
|
1271
1271
|
" access level or higher."
|
|
1272
1272
|
] }),
|
|
1273
|
-
/* @__PURE__ */
|
|
1273
|
+
/* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1274
1274
|
"Your current access level: ",
|
|
1275
|
-
/* @__PURE__ */
|
|
1275
|
+
/* @__PURE__ */ s("strong", { children: i })
|
|
1276
1276
|
] })
|
|
1277
|
-
] }) : /* @__PURE__ */
|
|
1278
|
-
/* @__PURE__ */
|
|
1279
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1277
|
+
] }) : /* @__PURE__ */ c(H, { children: [
|
|
1278
|
+
/* @__PURE__ */ s("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1279
|
+
t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1280
1280
|
"Required permissions: ",
|
|
1281
|
-
/* @__PURE__ */
|
|
1281
|
+
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
1282
1282
|
] })
|
|
1283
1283
|
] })
|
|
1284
1284
|
]
|
|
1285
1285
|
}
|
|
1286
1286
|
), Ie = (i, e) => {
|
|
1287
1287
|
const t = {
|
|
1288
|
-
[
|
|
1289
|
-
[
|
|
1290
|
-
[
|
|
1288
|
+
[X.USER]: 1,
|
|
1289
|
+
[X.TENANT_ADMIN]: 2,
|
|
1290
|
+
[X.SUPERUSER]: 3
|
|
1291
1291
|
};
|
|
1292
1292
|
return t[i] >= t[e];
|
|
1293
1293
|
};
|
|
1294
|
-
function
|
|
1294
|
+
function at({
|
|
1295
1295
|
children: i,
|
|
1296
1296
|
fallback: e,
|
|
1297
1297
|
minUserType: t,
|
|
1298
1298
|
requiredPermissions: r,
|
|
1299
|
-
requireAllPermissions:
|
|
1299
|
+
requireAllPermissions: n = !1
|
|
1300
1300
|
}) {
|
|
1301
|
-
const { hasValidSession:
|
|
1302
|
-
if (!
|
|
1303
|
-
return /* @__PURE__ */
|
|
1304
|
-
const g =
|
|
1301
|
+
const { hasValidSession: o, sessionManager: m, hasPermission: T, hasAnyPermission: M, hasAllPermissions: P } = se();
|
|
1302
|
+
if (!o())
|
|
1303
|
+
return /* @__PURE__ */ s(H, { children: e || /* @__PURE__ */ s(ue, {}) });
|
|
1304
|
+
const g = m.getUser();
|
|
1305
1305
|
if (!g)
|
|
1306
|
-
return /* @__PURE__ */
|
|
1306
|
+
return /* @__PURE__ */ s(H, { children: e || /* @__PURE__ */ s(ue, {}) });
|
|
1307
1307
|
if (t && !Ie(g.userType, t))
|
|
1308
|
-
return /* @__PURE__ */
|
|
1309
|
-
if (r && r.length > 0 && !(
|
|
1308
|
+
return /* @__PURE__ */ s(he, { userType: g.userType, minUserType: t });
|
|
1309
|
+
if (r && r.length > 0 && !(n ? P(r) : M(r))) {
|
|
1310
1310
|
const x = r.filter((p) => !T(p)).map((p) => typeof p == "string" ? p : p.name);
|
|
1311
|
-
return /* @__PURE__ */
|
|
1311
|
+
return /* @__PURE__ */ s(he, { missingPermissions: x });
|
|
1312
1312
|
}
|
|
1313
|
-
return /* @__PURE__ */
|
|
1313
|
+
return /* @__PURE__ */ s(H, { children: i });
|
|
1314
1314
|
}
|
|
1315
|
-
const He = ({ redirectPath: i }) => /* @__PURE__ */
|
|
1315
|
+
const He = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
1316
1316
|
"div",
|
|
1317
1317
|
{
|
|
1318
1318
|
style: {
|
|
@@ -1325,7 +1325,7 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1325
1325
|
backgroundColor: "#f9fafb",
|
|
1326
1326
|
textAlign: "center"
|
|
1327
1327
|
},
|
|
1328
|
-
children: /* @__PURE__ */
|
|
1328
|
+
children: /* @__PURE__ */ c(
|
|
1329
1329
|
"div",
|
|
1330
1330
|
{
|
|
1331
1331
|
style: {
|
|
@@ -1336,10 +1336,10 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1336
1336
|
maxWidth: "400px"
|
|
1337
1337
|
},
|
|
1338
1338
|
children: [
|
|
1339
|
-
/* @__PURE__ */
|
|
1340
|
-
/* @__PURE__ */
|
|
1341
|
-
/* @__PURE__ */
|
|
1342
|
-
/* @__PURE__ */
|
|
1339
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1340
|
+
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1341
|
+
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1342
|
+
/* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1343
1343
|
"Redirecting to ",
|
|
1344
1344
|
i,
|
|
1345
1345
|
"..."
|
|
@@ -1348,11 +1348,11 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1348
1348
|
}
|
|
1349
1349
|
)
|
|
1350
1350
|
}
|
|
1351
|
-
),
|
|
1351
|
+
), ge = ({
|
|
1352
1352
|
userType: i,
|
|
1353
1353
|
minUserType: e,
|
|
1354
1354
|
missingPermissions: t
|
|
1355
|
-
}) => /* @__PURE__ */
|
|
1355
|
+
}) => /* @__PURE__ */ s(
|
|
1356
1356
|
"div",
|
|
1357
1357
|
{
|
|
1358
1358
|
style: {
|
|
@@ -1365,7 +1365,7 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1365
1365
|
backgroundColor: "#f9fafb",
|
|
1366
1366
|
textAlign: "center"
|
|
1367
1367
|
},
|
|
1368
|
-
children: /* @__PURE__ */
|
|
1368
|
+
children: /* @__PURE__ */ c(
|
|
1369
1369
|
"div",
|
|
1370
1370
|
{
|
|
1371
1371
|
style: {
|
|
@@ -1376,63 +1376,159 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1376
1376
|
maxWidth: "400px"
|
|
1377
1377
|
},
|
|
1378
1378
|
children: [
|
|
1379
|
-
/* @__PURE__ */
|
|
1380
|
-
/* @__PURE__ */
|
|
1381
|
-
e && i ? /* @__PURE__ */
|
|
1382
|
-
/* @__PURE__ */
|
|
1379
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1380
|
+
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1381
|
+
e && i ? /* @__PURE__ */ c(H, { children: [
|
|
1382
|
+
/* @__PURE__ */ c("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1383
1383
|
"This page requires ",
|
|
1384
|
-
/* @__PURE__ */
|
|
1384
|
+
/* @__PURE__ */ s("strong", { children: e }),
|
|
1385
1385
|
" access level or higher."
|
|
1386
1386
|
] }),
|
|
1387
|
-
/* @__PURE__ */
|
|
1387
|
+
/* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1388
1388
|
"Your current access level: ",
|
|
1389
|
-
/* @__PURE__ */
|
|
1389
|
+
/* @__PURE__ */ s("strong", { children: i })
|
|
1390
1390
|
] })
|
|
1391
|
-
] }) : /* @__PURE__ */
|
|
1392
|
-
/* @__PURE__ */
|
|
1393
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1391
|
+
] }) : /* @__PURE__ */ c(H, { children: [
|
|
1392
|
+
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1393
|
+
t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1394
1394
|
"Required permissions: ",
|
|
1395
|
-
/* @__PURE__ */
|
|
1395
|
+
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
1396
1396
|
] })
|
|
1397
1397
|
] })
|
|
1398
1398
|
]
|
|
1399
1399
|
}
|
|
1400
1400
|
)
|
|
1401
1401
|
}
|
|
1402
|
-
),
|
|
1402
|
+
), Ce = (i, e) => {
|
|
1403
1403
|
const t = {
|
|
1404
|
-
[
|
|
1405
|
-
[
|
|
1406
|
-
[
|
|
1404
|
+
[X.USER]: 1,
|
|
1405
|
+
[X.TENANT_ADMIN]: 2,
|
|
1406
|
+
[X.SUPERUSER]: 3
|
|
1407
1407
|
};
|
|
1408
1408
|
return t[i] >= t[e];
|
|
1409
1409
|
};
|
|
1410
|
-
function
|
|
1410
|
+
function lt({
|
|
1411
1411
|
children: i,
|
|
1412
1412
|
redirectTo: e = "/login",
|
|
1413
1413
|
minUserType: t,
|
|
1414
1414
|
requiredPermissions: r,
|
|
1415
|
-
requireAllPermissions:
|
|
1416
|
-
fallback:
|
|
1415
|
+
requireAllPermissions: n = !1,
|
|
1416
|
+
fallback: o
|
|
1417
1417
|
}) {
|
|
1418
|
-
const { hasValidSession:
|
|
1419
|
-
if (!
|
|
1420
|
-
return
|
|
1421
|
-
/* @__PURE__ */
|
|
1422
|
-
/* @__PURE__ */
|
|
1418
|
+
const { hasValidSession: m, sessionManager: T, hasPermission: M, hasAnyPermission: P, hasAllPermissions: g } = se(), h = ae();
|
|
1419
|
+
if (!m())
|
|
1420
|
+
return o ? /* @__PURE__ */ s(H, { children: o }) : /* @__PURE__ */ c(H, { children: [
|
|
1421
|
+
/* @__PURE__ */ s(He, { redirectPath: e }),
|
|
1422
|
+
/* @__PURE__ */ s(ne, { to: e, state: { from: h.pathname }, replace: !0 })
|
|
1423
1423
|
] });
|
|
1424
1424
|
const x = T.getUser();
|
|
1425
1425
|
if (!x)
|
|
1426
|
-
return /* @__PURE__ */
|
|
1427
|
-
if (t &&
|
|
1428
|
-
return /* @__PURE__ */
|
|
1429
|
-
if (r && r.length > 0 && !(
|
|
1426
|
+
return /* @__PURE__ */ s(ne, { to: e, state: { from: h.pathname }, replace: !0 });
|
|
1427
|
+
if (t && !Ce(x.userType, t))
|
|
1428
|
+
return /* @__PURE__ */ s(ge, { userType: x.userType, minUserType: t });
|
|
1429
|
+
if (r && r.length > 0 && !(n ? g(r) : P(r))) {
|
|
1430
1430
|
const A = r.filter((F) => !M(F)).map((F) => typeof F == "string" ? F : F.name);
|
|
1431
|
-
return /* @__PURE__ */
|
|
1431
|
+
return /* @__PURE__ */ s(ge, { missingPermissions: A });
|
|
1432
|
+
}
|
|
1433
|
+
return /* @__PURE__ */ s(H, { children: i });
|
|
1434
|
+
}
|
|
1435
|
+
const $e = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
1436
|
+
"div",
|
|
1437
|
+
{
|
|
1438
|
+
style: {
|
|
1439
|
+
display: "flex",
|
|
1440
|
+
flexDirection: "column",
|
|
1441
|
+
justifyContent: "center",
|
|
1442
|
+
alignItems: "center",
|
|
1443
|
+
minHeight: "100vh",
|
|
1444
|
+
padding: "2rem",
|
|
1445
|
+
backgroundColor: "#f9fafb",
|
|
1446
|
+
textAlign: "center"
|
|
1447
|
+
},
|
|
1448
|
+
children: /* @__PURE__ */ c(
|
|
1449
|
+
"div",
|
|
1450
|
+
{
|
|
1451
|
+
style: {
|
|
1452
|
+
backgroundColor: "#ffffff",
|
|
1453
|
+
padding: "2rem",
|
|
1454
|
+
borderRadius: "8px",
|
|
1455
|
+
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)",
|
|
1456
|
+
maxWidth: "400px"
|
|
1457
|
+
},
|
|
1458
|
+
children: [
|
|
1459
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
1460
|
+
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
1461
|
+
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
1462
|
+
/* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1463
|
+
"Redirecting to ",
|
|
1464
|
+
i,
|
|
1465
|
+
"..."
|
|
1466
|
+
] })
|
|
1467
|
+
]
|
|
1468
|
+
}
|
|
1469
|
+
)
|
|
1470
|
+
}
|
|
1471
|
+
);
|
|
1472
|
+
function ct({
|
|
1473
|
+
children: i,
|
|
1474
|
+
redirectTo: e = "/",
|
|
1475
|
+
fallback: t
|
|
1476
|
+
}) {
|
|
1477
|
+
const { tenant: r, isLoading: n, error: o } = K(), m = ae();
|
|
1478
|
+
return n || o ? null : r ? /* @__PURE__ */ s(H, { children: i }) : t ? /* @__PURE__ */ s(H, { children: t }) : /* @__PURE__ */ c(H, { children: [
|
|
1479
|
+
/* @__PURE__ */ s($e, { redirectPath: e }),
|
|
1480
|
+
/* @__PURE__ */ s(ne, { to: e, state: { from: m.pathname }, replace: !0 })
|
|
1481
|
+
] });
|
|
1482
|
+
}
|
|
1483
|
+
const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
1484
|
+
"div",
|
|
1485
|
+
{
|
|
1486
|
+
style: {
|
|
1487
|
+
display: "flex",
|
|
1488
|
+
flexDirection: "column",
|
|
1489
|
+
justifyContent: "center",
|
|
1490
|
+
alignItems: "center",
|
|
1491
|
+
minHeight: "100vh",
|
|
1492
|
+
padding: "2rem",
|
|
1493
|
+
backgroundColor: "#f9fafb",
|
|
1494
|
+
textAlign: "center"
|
|
1495
|
+
},
|
|
1496
|
+
children: /* @__PURE__ */ c(
|
|
1497
|
+
"div",
|
|
1498
|
+
{
|
|
1499
|
+
style: {
|
|
1500
|
+
backgroundColor: "#ffffff",
|
|
1501
|
+
padding: "2rem",
|
|
1502
|
+
borderRadius: "8px",
|
|
1503
|
+
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)",
|
|
1504
|
+
maxWidth: "400px"
|
|
1505
|
+
},
|
|
1506
|
+
children: [
|
|
1507
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
1508
|
+
/* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
1509
|
+
/* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
1510
|
+
/* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1511
|
+
"Redirecting to ",
|
|
1512
|
+
i,
|
|
1513
|
+
"..."
|
|
1514
|
+
] })
|
|
1515
|
+
]
|
|
1516
|
+
}
|
|
1517
|
+
)
|
|
1432
1518
|
}
|
|
1433
|
-
|
|
1519
|
+
);
|
|
1520
|
+
function dt({
|
|
1521
|
+
children: i,
|
|
1522
|
+
redirectTo: e = "/dashboard",
|
|
1523
|
+
fallback: t
|
|
1524
|
+
}) {
|
|
1525
|
+
const { tenant: r, isLoading: n, error: o } = K(), m = ae();
|
|
1526
|
+
return n || o ? null : r ? t ? /* @__PURE__ */ s(H, { children: t }) : /* @__PURE__ */ c(H, { children: [
|
|
1527
|
+
/* @__PURE__ */ s(Le, { redirectPath: e }),
|
|
1528
|
+
/* @__PURE__ */ s(ne, { to: e, state: { from: m.pathname }, replace: !0 })
|
|
1529
|
+
] }) : /* @__PURE__ */ s(H, { children: i });
|
|
1434
1530
|
}
|
|
1435
|
-
const
|
|
1531
|
+
const De = () => /* @__PURE__ */ c(
|
|
1436
1532
|
"div",
|
|
1437
1533
|
{
|
|
1438
1534
|
style: {
|
|
@@ -1444,19 +1540,19 @@ const Ce = () => /* @__PURE__ */ u(
|
|
|
1444
1540
|
color: "#dc2626"
|
|
1445
1541
|
},
|
|
1446
1542
|
children: [
|
|
1447
|
-
/* @__PURE__ */
|
|
1448
|
-
/* @__PURE__ */
|
|
1543
|
+
/* @__PURE__ */ s("h3", { style: { margin: "0 0 1rem 0" }, children: "🔒 Subscription Required" }),
|
|
1544
|
+
/* @__PURE__ */ s("p", { style: { margin: 0 }, children: "This feature requires a higher subscription plan. Please upgrade your plan to access this content." })
|
|
1449
1545
|
]
|
|
1450
1546
|
}
|
|
1451
1547
|
);
|
|
1452
|
-
function
|
|
1548
|
+
function ut({
|
|
1453
1549
|
children: i,
|
|
1454
|
-
fallback: e = /* @__PURE__ */
|
|
1550
|
+
fallback: e = /* @__PURE__ */ s(De, {}),
|
|
1455
1551
|
allowedPlans: t,
|
|
1456
1552
|
requiredFeature: r
|
|
1457
1553
|
}) {
|
|
1458
|
-
const { subscription:
|
|
1459
|
-
return T ? /* @__PURE__ */
|
|
1554
|
+
const { subscription: n, hasAllowedPlan: o, isFeatureEnabled: m, loading: T } = Fe();
|
|
1555
|
+
return T ? /* @__PURE__ */ s(
|
|
1460
1556
|
"div",
|
|
1461
1557
|
{
|
|
1462
1558
|
style: {
|
|
@@ -1466,9 +1562,9 @@ function at({
|
|
|
1466
1562
|
},
|
|
1467
1563
|
children: "Loading subscription..."
|
|
1468
1564
|
}
|
|
1469
|
-
) :
|
|
1565
|
+
) : n ? n.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ s(H, { children: e }) : r && !m(r) ? /* @__PURE__ */ s(H, { children: e }) : /* @__PURE__ */ s(H, { children: i }) : /* @__PURE__ */ s(H, { children: e }) : /* @__PURE__ */ s(H, { children: e });
|
|
1470
1566
|
}
|
|
1471
|
-
const
|
|
1567
|
+
const Be = ({ flagName: i }) => /* @__PURE__ */ c(
|
|
1472
1568
|
"div",
|
|
1473
1569
|
{
|
|
1474
1570
|
style: {
|
|
@@ -1485,9 +1581,9 @@ const Le = ({ flagName: i }) => /* @__PURE__ */ u(
|
|
|
1485
1581
|
color: "#6c757d"
|
|
1486
1582
|
},
|
|
1487
1583
|
children: [
|
|
1488
|
-
/* @__PURE__ */
|
|
1489
|
-
/* @__PURE__ */
|
|
1490
|
-
/* @__PURE__ */
|
|
1584
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
1585
|
+
/* @__PURE__ */ s("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
1586
|
+
/* @__PURE__ */ c("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
1491
1587
|
'Feature flag "',
|
|
1492
1588
|
i,
|
|
1493
1589
|
'" is disabled'
|
|
@@ -1495,9 +1591,9 @@ const Le = ({ flagName: i }) => /* @__PURE__ */ u(
|
|
|
1495
1591
|
]
|
|
1496
1592
|
}
|
|
1497
1593
|
);
|
|
1498
|
-
function
|
|
1499
|
-
const { isEnabled: r, loading:
|
|
1500
|
-
return
|
|
1594
|
+
function ht({ name: i, children: e, fallback: t }) {
|
|
1595
|
+
const { isEnabled: r, loading: n } = Ee();
|
|
1596
|
+
return n ? /* @__PURE__ */ s(
|
|
1501
1597
|
"div",
|
|
1502
1598
|
{
|
|
1503
1599
|
style: {
|
|
@@ -1510,9 +1606,9 @@ function lt({ name: i, children: e, fallback: t }) {
|
|
|
1510
1606
|
},
|
|
1511
1607
|
children: "Loading feature flags..."
|
|
1512
1608
|
}
|
|
1513
|
-
) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */
|
|
1609
|
+
) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ s(H, { children: e }) : /* @__PURE__ */ s(H, { children: t || /* @__PURE__ */ s(Be, { flagName: i }) }));
|
|
1514
1610
|
}
|
|
1515
|
-
const
|
|
1611
|
+
const qe = () => /* @__PURE__ */ c(
|
|
1516
1612
|
"svg",
|
|
1517
1613
|
{
|
|
1518
1614
|
width: "16",
|
|
@@ -1525,11 +1621,11 @@ const De = () => /* @__PURE__ */ u(
|
|
|
1525
1621
|
strokeLinejoin: "round",
|
|
1526
1622
|
style: { flexShrink: 0 },
|
|
1527
1623
|
children: [
|
|
1528
|
-
/* @__PURE__ */
|
|
1529
|
-
/* @__PURE__ */
|
|
1624
|
+
/* @__PURE__ */ s("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
|
|
1625
|
+
/* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
|
|
1530
1626
|
]
|
|
1531
1627
|
}
|
|
1532
|
-
),
|
|
1628
|
+
), Ue = () => /* @__PURE__ */ c(
|
|
1533
1629
|
"svg",
|
|
1534
1630
|
{
|
|
1535
1631
|
width: "16",
|
|
@@ -1542,14 +1638,14 @@ const De = () => /* @__PURE__ */ u(
|
|
|
1542
1638
|
strokeLinejoin: "round",
|
|
1543
1639
|
style: { flexShrink: 0 },
|
|
1544
1640
|
children: [
|
|
1545
|
-
/* @__PURE__ */
|
|
1546
|
-
/* @__PURE__ */
|
|
1641
|
+
/* @__PURE__ */ s("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
|
|
1642
|
+
/* @__PURE__ */ s("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1547
1643
|
]
|
|
1548
1644
|
}
|
|
1549
|
-
),
|
|
1550
|
-
showPassword: /* @__PURE__ */
|
|
1551
|
-
hidePassword: /* @__PURE__ */
|
|
1552
|
-
},
|
|
1645
|
+
), Ne = {
|
|
1646
|
+
showPassword: /* @__PURE__ */ s(qe, {}),
|
|
1647
|
+
hidePassword: /* @__PURE__ */ s(Ue, {})
|
|
1648
|
+
}, ze = {
|
|
1553
1649
|
title: "Sign In",
|
|
1554
1650
|
emailLabel: "Email",
|
|
1555
1651
|
emailPlaceholder: "Enter your email",
|
|
@@ -1561,7 +1657,7 @@ const De = () => /* @__PURE__ */ u(
|
|
|
1561
1657
|
signupText: "Don't have an account?",
|
|
1562
1658
|
errorMessage: "Invalid email or password",
|
|
1563
1659
|
loadingText: "Signing in..."
|
|
1564
|
-
},
|
|
1660
|
+
}, Oe = {
|
|
1565
1661
|
container: {
|
|
1566
1662
|
maxWidth: "400px",
|
|
1567
1663
|
width: "100%",
|
|
@@ -1668,52 +1764,52 @@ const De = () => /* @__PURE__ */ u(
|
|
|
1668
1764
|
fontSize: "0.875rem"
|
|
1669
1765
|
}
|
|
1670
1766
|
};
|
|
1671
|
-
function
|
|
1767
|
+
function gt({
|
|
1672
1768
|
copy: i = {},
|
|
1673
1769
|
styles: e = {},
|
|
1674
1770
|
icons: t = {},
|
|
1675
1771
|
onSuccess: r,
|
|
1676
|
-
onError:
|
|
1677
|
-
onForgotPassword:
|
|
1678
|
-
onSignupClick:
|
|
1772
|
+
onError: n,
|
|
1773
|
+
onForgotPassword: o,
|
|
1774
|
+
onSignupClick: m,
|
|
1679
1775
|
showForgotPassword: T = !0,
|
|
1680
1776
|
showSignupLink: M = !0,
|
|
1681
1777
|
className: P
|
|
1682
1778
|
}) {
|
|
1683
|
-
const [g, h] =
|
|
1779
|
+
const [g, h] = b(""), [x, p] = b(""), [A, F] = b(!1), [f, L] = b(!1), [y, S] = b(""), [k, R] = b({}), { login: D } = se(), { tenant: E } = K(), B = { ...ze, ...i }, d = { ...Oe, ...e }, w = { ...Ne, ...t }, u = () => {
|
|
1684
1780
|
const I = {};
|
|
1685
1781
|
return g.trim() || (I.email = !0), x.trim() || (I.password = !0), R(I), Object.keys(I).length === 0;
|
|
1686
|
-
},
|
|
1687
|
-
if (I.preventDefault(), !!
|
|
1782
|
+
}, a = async (I) => {
|
|
1783
|
+
if (I.preventDefault(), !!u()) {
|
|
1688
1784
|
if (!(E != null && E.id)) {
|
|
1689
|
-
|
|
1785
|
+
S("Tenant not found");
|
|
1690
1786
|
return;
|
|
1691
1787
|
}
|
|
1692
|
-
|
|
1788
|
+
L(!0), S("");
|
|
1693
1789
|
try {
|
|
1694
|
-
const N = await
|
|
1790
|
+
const N = await D(g, x, E.id);
|
|
1695
1791
|
r == null || r(N);
|
|
1696
1792
|
} catch (N) {
|
|
1697
|
-
const _ = N.message ||
|
|
1698
|
-
|
|
1793
|
+
const _ = N.message || B.errorMessage;
|
|
1794
|
+
S(_), n == null || n(_);
|
|
1699
1795
|
} finally {
|
|
1700
|
-
|
|
1796
|
+
L(!1);
|
|
1701
1797
|
}
|
|
1702
1798
|
}
|
|
1703
1799
|
}, l = (I) => ({
|
|
1704
|
-
...
|
|
1705
|
-
...k[I] ?
|
|
1800
|
+
...d.input,
|
|
1801
|
+
...k[I] ? d.inputError : {}
|
|
1706
1802
|
}), W = () => ({
|
|
1707
|
-
...
|
|
1708
|
-
...f ?
|
|
1709
|
-
...!g || !x || f ?
|
|
1803
|
+
...d.button,
|
|
1804
|
+
...f ? d.buttonLoading : {},
|
|
1805
|
+
...!g || !x || f ? d.buttonDisabled : {}
|
|
1710
1806
|
});
|
|
1711
|
-
return /* @__PURE__ */
|
|
1712
|
-
/* @__PURE__ */
|
|
1713
|
-
/* @__PURE__ */
|
|
1714
|
-
/* @__PURE__ */
|
|
1715
|
-
/* @__PURE__ */
|
|
1716
|
-
/* @__PURE__ */
|
|
1807
|
+
return /* @__PURE__ */ c("div", { className: P, style: d.container, children: [
|
|
1808
|
+
/* @__PURE__ */ s("h2", { style: d.title, children: B.title }),
|
|
1809
|
+
/* @__PURE__ */ c("form", { onSubmit: a, style: d.form, children: [
|
|
1810
|
+
/* @__PURE__ */ c("div", { style: d.fieldGroup, children: [
|
|
1811
|
+
/* @__PURE__ */ s("label", { style: d.label, children: B.emailLabel }),
|
|
1812
|
+
/* @__PURE__ */ s(
|
|
1717
1813
|
"input",
|
|
1718
1814
|
{
|
|
1719
1815
|
id: "email",
|
|
@@ -1723,16 +1819,16 @@ function ct({
|
|
|
1723
1819
|
onChange: (I) => {
|
|
1724
1820
|
h(I.target.value), k.email && R((N) => ({ ...N, email: !1 }));
|
|
1725
1821
|
},
|
|
1726
|
-
placeholder:
|
|
1822
|
+
placeholder: B.emailPlaceholder,
|
|
1727
1823
|
style: l("email"),
|
|
1728
1824
|
disabled: f
|
|
1729
1825
|
}
|
|
1730
1826
|
)
|
|
1731
1827
|
] }),
|
|
1732
|
-
/* @__PURE__ */
|
|
1733
|
-
/* @__PURE__ */
|
|
1734
|
-
/* @__PURE__ */
|
|
1735
|
-
/* @__PURE__ */
|
|
1828
|
+
/* @__PURE__ */ c("div", { style: d.fieldGroup, children: [
|
|
1829
|
+
/* @__PURE__ */ s("label", { style: d.label, children: B.passwordLabel }),
|
|
1830
|
+
/* @__PURE__ */ c("div", { style: d.inputContainer, children: [
|
|
1831
|
+
/* @__PURE__ */ s(
|
|
1736
1832
|
"input",
|
|
1737
1833
|
{
|
|
1738
1834
|
id: "password",
|
|
@@ -1742,7 +1838,7 @@ function ct({
|
|
|
1742
1838
|
onChange: (I) => {
|
|
1743
1839
|
p(I.target.value), k.password && R((N) => ({ ...N, password: !1 }));
|
|
1744
1840
|
},
|
|
1745
|
-
placeholder:
|
|
1841
|
+
placeholder: B.passwordPlaceholder,
|
|
1746
1842
|
style: {
|
|
1747
1843
|
...l("password"),
|
|
1748
1844
|
paddingRight: "2.5rem"
|
|
@@ -1751,12 +1847,12 @@ function ct({
|
|
|
1751
1847
|
disabled: f
|
|
1752
1848
|
}
|
|
1753
1849
|
),
|
|
1754
|
-
/* @__PURE__ */
|
|
1850
|
+
/* @__PURE__ */ s(
|
|
1755
1851
|
"button",
|
|
1756
1852
|
{
|
|
1757
1853
|
type: "button",
|
|
1758
1854
|
onClick: () => F(!A),
|
|
1759
|
-
style:
|
|
1855
|
+
style: d.passwordToggle,
|
|
1760
1856
|
disabled: f,
|
|
1761
1857
|
"aria-label": A ? "Hide password" : "Show password",
|
|
1762
1858
|
children: A ? w.hidePassword : w.showPassword
|
|
@@ -1764,23 +1860,23 @@ function ct({
|
|
|
1764
1860
|
)
|
|
1765
1861
|
] })
|
|
1766
1862
|
] }),
|
|
1767
|
-
/* @__PURE__ */
|
|
1768
|
-
y && /* @__PURE__ */
|
|
1863
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !g || !x || f, style: W(), children: f ? B.loadingText : B.submitButton }),
|
|
1864
|
+
y && /* @__PURE__ */ s("div", { style: d.errorText, children: y })
|
|
1769
1865
|
] }),
|
|
1770
|
-
(T || M) && /* @__PURE__ */
|
|
1771
|
-
T && /* @__PURE__ */
|
|
1772
|
-
T && M && /* @__PURE__ */
|
|
1773
|
-
M && /* @__PURE__ */
|
|
1774
|
-
/* @__PURE__ */
|
|
1775
|
-
|
|
1866
|
+
(T || M) && /* @__PURE__ */ c("div", { style: d.linkContainer, children: [
|
|
1867
|
+
T && /* @__PURE__ */ s("a", { onClick: o, style: d.link, children: B.forgotPasswordLink }),
|
|
1868
|
+
T && M && /* @__PURE__ */ s("div", { style: d.divider, children: "•" }),
|
|
1869
|
+
M && /* @__PURE__ */ c("div", { children: [
|
|
1870
|
+
/* @__PURE__ */ c("span", { style: d.divider, children: [
|
|
1871
|
+
B.signupText,
|
|
1776
1872
|
" "
|
|
1777
1873
|
] }),
|
|
1778
|
-
/* @__PURE__ */
|
|
1874
|
+
/* @__PURE__ */ s("a", { onClick: m, style: d.link, children: B.signupLink })
|
|
1779
1875
|
] })
|
|
1780
1876
|
] })
|
|
1781
1877
|
] });
|
|
1782
1878
|
}
|
|
1783
|
-
const
|
|
1879
|
+
const je = {
|
|
1784
1880
|
title: "Create Account",
|
|
1785
1881
|
nameLabel: "Full Name",
|
|
1786
1882
|
namePlaceholder: "Enter your full name",
|
|
@@ -1800,7 +1896,7 @@ const Oe = {
|
|
|
1800
1896
|
passwordMismatchError: "Passwords do not match",
|
|
1801
1897
|
isAdminLabel: "Create new organization",
|
|
1802
1898
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
1803
|
-
},
|
|
1899
|
+
}, Ve = {
|
|
1804
1900
|
container: {
|
|
1805
1901
|
maxWidth: "400px",
|
|
1806
1902
|
width: "100%",
|
|
@@ -1899,154 +1995,154 @@ const Oe = {
|
|
|
1899
1995
|
fontSize: "0.875rem"
|
|
1900
1996
|
}
|
|
1901
1997
|
};
|
|
1902
|
-
function
|
|
1998
|
+
function pt({
|
|
1903
1999
|
copy: i = {},
|
|
1904
2000
|
styles: e = {},
|
|
1905
2001
|
signupType: t = "user",
|
|
1906
2002
|
onSuccess: r,
|
|
1907
|
-
onError:
|
|
1908
|
-
onLoginClick:
|
|
1909
|
-
showLoginLink:
|
|
2003
|
+
onError: n,
|
|
2004
|
+
onLoginClick: o,
|
|
2005
|
+
showLoginLink: m = !0,
|
|
1910
2006
|
className: T
|
|
1911
2007
|
}) {
|
|
1912
|
-
const [M, P] =
|
|
1913
|
-
const
|
|
1914
|
-
return M.trim() || (
|
|
1915
|
-
}, W = async (
|
|
1916
|
-
if (
|
|
2008
|
+
const [M, P] = b(""), [g, h] = b(""), [x, p] = b(""), [A, F] = b(""), [f, L] = b(""), [y, S] = b(!1), [k, R] = b(""), [D, E] = b({}), { signup: B, signupTenantAdmin: d } = se(), { tenant: w } = K(), u = { ...je, ...i }, a = { ...Ve, ...e }, l = () => {
|
|
2009
|
+
const C = {};
|
|
2010
|
+
return M.trim() || (C.name = !0), g.trim() || (C.email = !0), x.trim() || (C.password = !0), A.trim() || (C.confirmPassword = !0), t === "tenant" && !f.trim() && (C.tenantName = !0), E(C), Object.keys(C).length === 0;
|
|
2011
|
+
}, W = async (C) => {
|
|
2012
|
+
if (C.preventDefault(), !!l()) {
|
|
1917
2013
|
if (x !== A) {
|
|
1918
|
-
R(
|
|
2014
|
+
R(u.passwordMismatchError), E({ confirmPassword: !0 });
|
|
1919
2015
|
return;
|
|
1920
2016
|
}
|
|
1921
2017
|
if (t === "user" && !(w != null && w.id)) {
|
|
1922
2018
|
R("Tenant not found");
|
|
1923
2019
|
return;
|
|
1924
2020
|
}
|
|
1925
|
-
|
|
2021
|
+
S(!0), R("");
|
|
1926
2022
|
try {
|
|
1927
|
-
let
|
|
1928
|
-
t === "tenant" ?
|
|
1929
|
-
} catch (
|
|
1930
|
-
const
|
|
1931
|
-
R(
|
|
2023
|
+
let U;
|
|
2024
|
+
t === "tenant" ? U = await d(g, M, x, f) : U = await B(g, M, x, w.id), r == null || r(U);
|
|
2025
|
+
} catch (U) {
|
|
2026
|
+
const Q = U.message || u.errorMessage;
|
|
2027
|
+
R(Q), n == null || n(Q);
|
|
1932
2028
|
} finally {
|
|
1933
|
-
|
|
2029
|
+
S(!1);
|
|
1934
2030
|
}
|
|
1935
2031
|
}
|
|
1936
|
-
}, I = (
|
|
1937
|
-
...
|
|
1938
|
-
...
|
|
2032
|
+
}, I = (C) => ({
|
|
2033
|
+
...a.input,
|
|
2034
|
+
...D[C] ? a.inputError : {}
|
|
1939
2035
|
}), N = () => ({
|
|
1940
|
-
...
|
|
1941
|
-
...y ?
|
|
1942
|
-
...!M || !g || !x || !A || y || t === "tenant" && !f ?
|
|
2036
|
+
...a.button,
|
|
2037
|
+
...y ? a.buttonLoading : {},
|
|
2038
|
+
...!M || !g || !x || !A || y || t === "tenant" && !f ? a.buttonDisabled : {}
|
|
1943
2039
|
}), _ = M && g && x && A && (t === "user" || f);
|
|
1944
|
-
return /* @__PURE__ */
|
|
1945
|
-
/* @__PURE__ */
|
|
1946
|
-
/* @__PURE__ */
|
|
1947
|
-
/* @__PURE__ */
|
|
1948
|
-
/* @__PURE__ */
|
|
1949
|
-
/* @__PURE__ */
|
|
2040
|
+
return /* @__PURE__ */ c("div", { className: T, style: a.container, children: [
|
|
2041
|
+
/* @__PURE__ */ s("h2", { style: a.title, children: u.title }),
|
|
2042
|
+
/* @__PURE__ */ c("form", { onSubmit: W, style: a.form, children: [
|
|
2043
|
+
/* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
|
|
2044
|
+
/* @__PURE__ */ s("label", { style: a.label, children: u.nameLabel }),
|
|
2045
|
+
/* @__PURE__ */ s(
|
|
1950
2046
|
"input",
|
|
1951
2047
|
{
|
|
1952
2048
|
id: "name",
|
|
1953
2049
|
name: "name",
|
|
1954
2050
|
type: "text",
|
|
1955
2051
|
value: M,
|
|
1956
|
-
onChange: (
|
|
1957
|
-
P(
|
|
2052
|
+
onChange: (C) => {
|
|
2053
|
+
P(C.target.value), D.name && E((U) => ({ ...U, name: !1 }));
|
|
1958
2054
|
},
|
|
1959
|
-
placeholder:
|
|
2055
|
+
placeholder: u.namePlaceholder,
|
|
1960
2056
|
style: I("name"),
|
|
1961
2057
|
disabled: y
|
|
1962
2058
|
}
|
|
1963
2059
|
)
|
|
1964
2060
|
] }),
|
|
1965
|
-
/* @__PURE__ */
|
|
1966
|
-
/* @__PURE__ */
|
|
1967
|
-
/* @__PURE__ */
|
|
2061
|
+
/* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
|
|
2062
|
+
/* @__PURE__ */ s("label", { style: a.label, children: u.emailLabel }),
|
|
2063
|
+
/* @__PURE__ */ s(
|
|
1968
2064
|
"input",
|
|
1969
2065
|
{
|
|
1970
2066
|
id: "email",
|
|
1971
2067
|
name: "email",
|
|
1972
2068
|
type: "email",
|
|
1973
2069
|
value: g,
|
|
1974
|
-
onChange: (
|
|
1975
|
-
h(
|
|
2070
|
+
onChange: (C) => {
|
|
2071
|
+
h(C.target.value), D.email && E((U) => ({ ...U, email: !1 }));
|
|
1976
2072
|
},
|
|
1977
|
-
placeholder:
|
|
2073
|
+
placeholder: u.emailPlaceholder,
|
|
1978
2074
|
style: I("email"),
|
|
1979
2075
|
disabled: y
|
|
1980
2076
|
}
|
|
1981
2077
|
)
|
|
1982
2078
|
] }),
|
|
1983
|
-
/* @__PURE__ */
|
|
1984
|
-
/* @__PURE__ */
|
|
1985
|
-
/* @__PURE__ */
|
|
2079
|
+
/* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
|
|
2080
|
+
/* @__PURE__ */ s("label", { style: a.label, children: u.passwordLabel }),
|
|
2081
|
+
/* @__PURE__ */ s(
|
|
1986
2082
|
"input",
|
|
1987
2083
|
{
|
|
1988
2084
|
id: "password",
|
|
1989
2085
|
name: "password",
|
|
1990
2086
|
type: "password",
|
|
1991
2087
|
value: x,
|
|
1992
|
-
onChange: (
|
|
1993
|
-
p(
|
|
2088
|
+
onChange: (C) => {
|
|
2089
|
+
p(C.target.value), D.password && E((U) => ({ ...U, password: !1 }));
|
|
1994
2090
|
},
|
|
1995
|
-
placeholder:
|
|
2091
|
+
placeholder: u.passwordPlaceholder,
|
|
1996
2092
|
style: I("password"),
|
|
1997
2093
|
disabled: y
|
|
1998
2094
|
}
|
|
1999
2095
|
)
|
|
2000
2096
|
] }),
|
|
2001
|
-
/* @__PURE__ */
|
|
2002
|
-
/* @__PURE__ */
|
|
2003
|
-
/* @__PURE__ */
|
|
2097
|
+
/* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
|
|
2098
|
+
/* @__PURE__ */ s("label", { style: a.label, children: u.confirmPasswordLabel }),
|
|
2099
|
+
/* @__PURE__ */ s(
|
|
2004
2100
|
"input",
|
|
2005
2101
|
{
|
|
2006
2102
|
id: "confirmPassword",
|
|
2007
2103
|
name: "confirmPassword",
|
|
2008
2104
|
type: "password",
|
|
2009
2105
|
value: A,
|
|
2010
|
-
onChange: (
|
|
2011
|
-
F(
|
|
2106
|
+
onChange: (C) => {
|
|
2107
|
+
F(C.target.value), D.confirmPassword && E((U) => ({ ...U, confirmPassword: !1 })), k === u.passwordMismatchError && R("");
|
|
2012
2108
|
},
|
|
2013
|
-
placeholder:
|
|
2109
|
+
placeholder: u.confirmPasswordPlaceholder,
|
|
2014
2110
|
style: I("confirmPassword"),
|
|
2015
2111
|
disabled: y
|
|
2016
2112
|
}
|
|
2017
2113
|
)
|
|
2018
2114
|
] }),
|
|
2019
|
-
t === "tenant" && /* @__PURE__ */
|
|
2020
|
-
/* @__PURE__ */
|
|
2021
|
-
/* @__PURE__ */
|
|
2115
|
+
t === "tenant" && /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
|
|
2116
|
+
/* @__PURE__ */ s("label", { style: a.label, children: u.tenantNameLabel }),
|
|
2117
|
+
/* @__PURE__ */ s(
|
|
2022
2118
|
"input",
|
|
2023
2119
|
{
|
|
2024
2120
|
id: "tenantName",
|
|
2025
2121
|
name: "tenantName",
|
|
2026
2122
|
type: "text",
|
|
2027
2123
|
value: f,
|
|
2028
|
-
onChange: (
|
|
2029
|
-
C
|
|
2124
|
+
onChange: (C) => {
|
|
2125
|
+
L(C.target.value), D.tenantName && E((U) => ({ ...U, tenantName: !1 }));
|
|
2030
2126
|
},
|
|
2031
|
-
placeholder:
|
|
2127
|
+
placeholder: u.tenantNamePlaceholder,
|
|
2032
2128
|
style: I("tenantName"),
|
|
2033
2129
|
disabled: y
|
|
2034
2130
|
}
|
|
2035
2131
|
)
|
|
2036
2132
|
] }),
|
|
2037
|
-
/* @__PURE__ */
|
|
2038
|
-
k && /* @__PURE__ */
|
|
2133
|
+
/* @__PURE__ */ s("button", { type: "submit", disabled: !_ || y, style: N(), children: y ? u.loadingText : u.submitButton }),
|
|
2134
|
+
k && /* @__PURE__ */ s("div", { style: a.errorText, children: k })
|
|
2039
2135
|
] }),
|
|
2040
|
-
|
|
2041
|
-
/* @__PURE__ */
|
|
2042
|
-
|
|
2136
|
+
m && /* @__PURE__ */ c("div", { style: a.linkContainer, children: [
|
|
2137
|
+
/* @__PURE__ */ c("span", { style: a.divider, children: [
|
|
2138
|
+
u.loginText,
|
|
2043
2139
|
" "
|
|
2044
2140
|
] }),
|
|
2045
|
-
/* @__PURE__ */
|
|
2141
|
+
/* @__PURE__ */ s("a", { onClick: o, style: a.link, children: u.loginLink })
|
|
2046
2142
|
] })
|
|
2047
2143
|
] });
|
|
2048
2144
|
}
|
|
2049
|
-
const
|
|
2145
|
+
const We = {
|
|
2050
2146
|
title: "Reset Password",
|
|
2051
2147
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
2052
2148
|
emailLabel: "Email",
|
|
@@ -2068,7 +2164,7 @@ const je = {
|
|
|
2068
2164
|
resetLoadingText: "Resetting...",
|
|
2069
2165
|
resetSuccessMessage: "Password reset successfully!",
|
|
2070
2166
|
passwordMismatchError: "Passwords do not match"
|
|
2071
|
-
},
|
|
2167
|
+
}, Ge = {
|
|
2072
2168
|
container: {
|
|
2073
2169
|
maxWidth: "400px",
|
|
2074
2170
|
margin: "0 auto",
|
|
@@ -2160,186 +2256,186 @@ const je = {
|
|
|
2160
2256
|
cursor: "pointer"
|
|
2161
2257
|
}
|
|
2162
2258
|
};
|
|
2163
|
-
function
|
|
2259
|
+
function ft({
|
|
2164
2260
|
copy: i = {},
|
|
2165
2261
|
styles: e = {},
|
|
2166
2262
|
mode: t = "request",
|
|
2167
2263
|
token: r = "",
|
|
2168
|
-
onSuccess:
|
|
2169
|
-
onError:
|
|
2170
|
-
onBackToLogin:
|
|
2264
|
+
onSuccess: n,
|
|
2265
|
+
onError: o,
|
|
2266
|
+
onBackToLogin: m,
|
|
2171
2267
|
onModeChange: T,
|
|
2172
2268
|
className: M
|
|
2173
2269
|
}) {
|
|
2174
|
-
const [P, g] =
|
|
2175
|
-
const
|
|
2176
|
-
return P.trim() || (
|
|
2270
|
+
const [P, g] = b(""), [h, x] = b(r), [p, A] = b(""), [F, f] = b(""), [L, y] = b(!1), [S, k] = b(""), [R, D] = b(""), [E, B] = b({}), { requestPasswordReset: d, confirmPasswordReset: w } = se(), { tenant: u } = K(), a = { ...We, ...i }, l = { ...Ge, ...e }, W = () => {
|
|
2271
|
+
const q = {};
|
|
2272
|
+
return P.trim() || (q.email = !0), B(q), Object.keys(q).length === 0;
|
|
2177
2273
|
}, I = () => {
|
|
2178
|
-
const
|
|
2179
|
-
return h.trim() || (
|
|
2180
|
-
}, N = async (
|
|
2181
|
-
if (
|
|
2182
|
-
if (!(
|
|
2274
|
+
const q = {};
|
|
2275
|
+
return h.trim() || (q.token = !0), p.trim() || (q.newPassword = !0), F.trim() || (q.confirmPassword = !0), B(q), Object.keys(q).length === 0;
|
|
2276
|
+
}, N = async (q) => {
|
|
2277
|
+
if (q.preventDefault(), !!W()) {
|
|
2278
|
+
if (!(u != null && u.id)) {
|
|
2183
2279
|
k("Tenant not found");
|
|
2184
2280
|
return;
|
|
2185
2281
|
}
|
|
2186
|
-
y(!0), k(""),
|
|
2282
|
+
y(!0), k(""), D("");
|
|
2187
2283
|
try {
|
|
2188
|
-
await
|
|
2189
|
-
} catch (
|
|
2190
|
-
const j =
|
|
2191
|
-
k(j),
|
|
2284
|
+
await d(P, u.id), D(a.successMessage), n == null || n();
|
|
2285
|
+
} catch (O) {
|
|
2286
|
+
const j = O.message || a.errorMessage;
|
|
2287
|
+
k(j), o == null || o(j);
|
|
2192
2288
|
} finally {
|
|
2193
2289
|
y(!1);
|
|
2194
2290
|
}
|
|
2195
2291
|
}
|
|
2196
|
-
}, _ = async (
|
|
2197
|
-
if (
|
|
2292
|
+
}, _ = async (q) => {
|
|
2293
|
+
if (q.preventDefault(), !!I()) {
|
|
2198
2294
|
if (p !== F) {
|
|
2199
|
-
k(
|
|
2295
|
+
k(a.passwordMismatchError), B({ confirmPassword: !0 });
|
|
2200
2296
|
return;
|
|
2201
2297
|
}
|
|
2202
|
-
y(!0), k(""),
|
|
2298
|
+
y(!0), k(""), D("");
|
|
2203
2299
|
try {
|
|
2204
|
-
await w(h, p),
|
|
2205
|
-
} catch (
|
|
2206
|
-
const j =
|
|
2207
|
-
k(j),
|
|
2300
|
+
await w(h, p), D(a.resetSuccessMessage), n == null || n();
|
|
2301
|
+
} catch (O) {
|
|
2302
|
+
const j = O.message || a.errorMessage;
|
|
2303
|
+
k(j), o == null || o(j);
|
|
2208
2304
|
} finally {
|
|
2209
2305
|
y(!1);
|
|
2210
2306
|
}
|
|
2211
2307
|
}
|
|
2212
|
-
},
|
|
2308
|
+
}, C = (q) => ({
|
|
2213
2309
|
...l.input,
|
|
2214
|
-
...E[
|
|
2215
|
-
}),
|
|
2310
|
+
...E[q] ? l.inputError : {}
|
|
2311
|
+
}), U = () => ({
|
|
2216
2312
|
...l.button,
|
|
2217
|
-
...
|
|
2313
|
+
...L ? l.buttonLoading : {}
|
|
2218
2314
|
});
|
|
2219
2315
|
if (t === "reset") {
|
|
2220
|
-
const
|
|
2221
|
-
return /* @__PURE__ */
|
|
2222
|
-
/* @__PURE__ */
|
|
2223
|
-
/* @__PURE__ */
|
|
2224
|
-
/* @__PURE__ */
|
|
2225
|
-
/* @__PURE__ */
|
|
2226
|
-
/* @__PURE__ */
|
|
2227
|
-
/* @__PURE__ */
|
|
2316
|
+
const q = h && p && F;
|
|
2317
|
+
return /* @__PURE__ */ c("div", { className: M, style: l.container, children: [
|
|
2318
|
+
/* @__PURE__ */ s("h2", { style: l.title, children: a.resetTitle }),
|
|
2319
|
+
/* @__PURE__ */ s("p", { style: l.subtitle, children: a.resetSubtitle }),
|
|
2320
|
+
/* @__PURE__ */ c("form", { onSubmit: _, style: l.form, children: [
|
|
2321
|
+
/* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
|
|
2322
|
+
/* @__PURE__ */ s("label", { style: l.label, children: a.tokenLabel }),
|
|
2323
|
+
/* @__PURE__ */ s(
|
|
2228
2324
|
"input",
|
|
2229
2325
|
{
|
|
2230
2326
|
type: "text",
|
|
2231
2327
|
value: h,
|
|
2232
|
-
onChange: (
|
|
2233
|
-
x(
|
|
2328
|
+
onChange: (O) => {
|
|
2329
|
+
x(O.target.value), E.token && B((j) => ({ ...j, token: !1 }));
|
|
2234
2330
|
},
|
|
2235
|
-
placeholder:
|
|
2236
|
-
style:
|
|
2237
|
-
disabled:
|
|
2331
|
+
placeholder: a.tokenPlaceholder,
|
|
2332
|
+
style: C("token"),
|
|
2333
|
+
disabled: L
|
|
2238
2334
|
}
|
|
2239
2335
|
)
|
|
2240
2336
|
] }),
|
|
2241
|
-
/* @__PURE__ */
|
|
2242
|
-
/* @__PURE__ */
|
|
2243
|
-
/* @__PURE__ */
|
|
2337
|
+
/* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
|
|
2338
|
+
/* @__PURE__ */ s("label", { style: l.label, children: a.newPasswordLabel }),
|
|
2339
|
+
/* @__PURE__ */ s(
|
|
2244
2340
|
"input",
|
|
2245
2341
|
{
|
|
2246
2342
|
type: "password",
|
|
2247
2343
|
value: p,
|
|
2248
|
-
onChange: (
|
|
2249
|
-
A(
|
|
2344
|
+
onChange: (O) => {
|
|
2345
|
+
A(O.target.value), E.newPassword && B((j) => ({ ...j, newPassword: !1 }));
|
|
2250
2346
|
},
|
|
2251
|
-
placeholder:
|
|
2252
|
-
style:
|
|
2253
|
-
disabled:
|
|
2347
|
+
placeholder: a.newPasswordPlaceholder,
|
|
2348
|
+
style: C("newPassword"),
|
|
2349
|
+
disabled: L
|
|
2254
2350
|
}
|
|
2255
2351
|
)
|
|
2256
2352
|
] }),
|
|
2257
|
-
/* @__PURE__ */
|
|
2258
|
-
/* @__PURE__ */
|
|
2259
|
-
/* @__PURE__ */
|
|
2353
|
+
/* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
|
|
2354
|
+
/* @__PURE__ */ s("label", { style: l.label, children: a.confirmPasswordLabel }),
|
|
2355
|
+
/* @__PURE__ */ s(
|
|
2260
2356
|
"input",
|
|
2261
2357
|
{
|
|
2262
2358
|
type: "password",
|
|
2263
2359
|
value: F,
|
|
2264
|
-
onChange: (
|
|
2265
|
-
f(
|
|
2360
|
+
onChange: (O) => {
|
|
2361
|
+
f(O.target.value), E.confirmPassword && B((j) => ({ ...j, confirmPassword: !1 })), S === a.passwordMismatchError && k("");
|
|
2266
2362
|
},
|
|
2267
|
-
placeholder:
|
|
2268
|
-
style:
|
|
2269
|
-
disabled:
|
|
2363
|
+
placeholder: a.confirmPasswordPlaceholder,
|
|
2364
|
+
style: C("confirmPassword"),
|
|
2365
|
+
disabled: L
|
|
2270
2366
|
}
|
|
2271
2367
|
)
|
|
2272
2368
|
] }),
|
|
2273
|
-
/* @__PURE__ */
|
|
2369
|
+
/* @__PURE__ */ s(
|
|
2274
2370
|
"button",
|
|
2275
2371
|
{
|
|
2276
2372
|
type: "submit",
|
|
2277
|
-
disabled: !
|
|
2373
|
+
disabled: !q || L,
|
|
2278
2374
|
style: {
|
|
2279
|
-
...
|
|
2280
|
-
...!
|
|
2375
|
+
...U(),
|
|
2376
|
+
...!q || L ? l.buttonDisabled : {}
|
|
2281
2377
|
},
|
|
2282
|
-
children:
|
|
2378
|
+
children: L ? a.resetLoadingText : a.resetSubmitButton
|
|
2283
2379
|
}
|
|
2284
2380
|
),
|
|
2285
|
-
|
|
2286
|
-
R && /* @__PURE__ */
|
|
2381
|
+
S && /* @__PURE__ */ s("div", { style: l.errorText, children: S }),
|
|
2382
|
+
R && /* @__PURE__ */ s("div", { style: l.successText, children: R })
|
|
2287
2383
|
] }),
|
|
2288
|
-
/* @__PURE__ */
|
|
2289
|
-
/* @__PURE__ */
|
|
2290
|
-
T && /* @__PURE__ */
|
|
2291
|
-
/* @__PURE__ */
|
|
2292
|
-
/* @__PURE__ */
|
|
2384
|
+
/* @__PURE__ */ c("div", { style: l.linkContainer, children: [
|
|
2385
|
+
/* @__PURE__ */ s("a", { onClick: m, style: l.link, children: a.backToLoginLink }),
|
|
2386
|
+
T && /* @__PURE__ */ c(H, { children: [
|
|
2387
|
+
/* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
2388
|
+
/* @__PURE__ */ s("a", { onClick: () => T("request"), style: l.link, children: "Request New Link" })
|
|
2293
2389
|
] })
|
|
2294
2390
|
] })
|
|
2295
2391
|
] });
|
|
2296
2392
|
}
|
|
2297
|
-
const
|
|
2298
|
-
return /* @__PURE__ */
|
|
2299
|
-
/* @__PURE__ */
|
|
2300
|
-
/* @__PURE__ */
|
|
2301
|
-
/* @__PURE__ */
|
|
2302
|
-
/* @__PURE__ */
|
|
2303
|
-
/* @__PURE__ */
|
|
2304
|
-
/* @__PURE__ */
|
|
2393
|
+
const Q = P;
|
|
2394
|
+
return /* @__PURE__ */ c("div", { className: M, style: l.container, children: [
|
|
2395
|
+
/* @__PURE__ */ s("h2", { style: l.title, children: a.title }),
|
|
2396
|
+
/* @__PURE__ */ s("p", { style: l.subtitle, children: a.subtitle }),
|
|
2397
|
+
/* @__PURE__ */ c("form", { onSubmit: N, style: l.form, children: [
|
|
2398
|
+
/* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
|
|
2399
|
+
/* @__PURE__ */ s("label", { style: l.label, children: a.emailLabel }),
|
|
2400
|
+
/* @__PURE__ */ s(
|
|
2305
2401
|
"input",
|
|
2306
2402
|
{
|
|
2307
2403
|
type: "email",
|
|
2308
2404
|
value: P,
|
|
2309
|
-
onChange: (
|
|
2310
|
-
g(
|
|
2405
|
+
onChange: (q) => {
|
|
2406
|
+
g(q.target.value), E.email && B((O) => ({ ...O, email: !1 }));
|
|
2311
2407
|
},
|
|
2312
|
-
placeholder:
|
|
2313
|
-
style:
|
|
2314
|
-
disabled:
|
|
2408
|
+
placeholder: a.emailPlaceholder,
|
|
2409
|
+
style: C("email"),
|
|
2410
|
+
disabled: L
|
|
2315
2411
|
}
|
|
2316
2412
|
)
|
|
2317
2413
|
] }),
|
|
2318
|
-
/* @__PURE__ */
|
|
2414
|
+
/* @__PURE__ */ s(
|
|
2319
2415
|
"button",
|
|
2320
2416
|
{
|
|
2321
2417
|
type: "submit",
|
|
2322
|
-
disabled: !
|
|
2418
|
+
disabled: !Q || L,
|
|
2323
2419
|
style: {
|
|
2324
|
-
...
|
|
2325
|
-
...!
|
|
2420
|
+
...U(),
|
|
2421
|
+
...!Q || L ? l.buttonDisabled : {}
|
|
2326
2422
|
},
|
|
2327
|
-
children:
|
|
2423
|
+
children: L ? a.loadingText : a.submitButton
|
|
2328
2424
|
}
|
|
2329
2425
|
),
|
|
2330
|
-
|
|
2331
|
-
R && /* @__PURE__ */
|
|
2426
|
+
S && /* @__PURE__ */ s("div", { style: l.errorText, children: S }),
|
|
2427
|
+
R && /* @__PURE__ */ s("div", { style: l.successText, children: R })
|
|
2332
2428
|
] }),
|
|
2333
|
-
/* @__PURE__ */
|
|
2334
|
-
/* @__PURE__ */
|
|
2335
|
-
T && /* @__PURE__ */
|
|
2336
|
-
/* @__PURE__ */
|
|
2337
|
-
/* @__PURE__ */
|
|
2429
|
+
/* @__PURE__ */ c("div", { style: l.linkContainer, children: [
|
|
2430
|
+
/* @__PURE__ */ s("a", { onClick: m, style: l.link, children: a.backToLoginLink }),
|
|
2431
|
+
T && /* @__PURE__ */ c(H, { children: [
|
|
2432
|
+
/* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
2433
|
+
/* @__PURE__ */ s("a", { onClick: () => T("reset"), style: l.link, children: "I have a token" })
|
|
2338
2434
|
] })
|
|
2339
2435
|
] })
|
|
2340
2436
|
] });
|
|
2341
2437
|
}
|
|
2342
|
-
class
|
|
2438
|
+
class yt {
|
|
2343
2439
|
constructor(e, t) {
|
|
2344
2440
|
this.httpService = e, this.sessionManager = t;
|
|
2345
2441
|
}
|
|
@@ -2360,12 +2456,12 @@ class ht {
|
|
|
2360
2456
|
throw new Error("SessionManager is required for private endpoints");
|
|
2361
2457
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
2362
2458
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
2363
|
-
const
|
|
2459
|
+
const n = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
|
|
2364
2460
|
headers: t
|
|
2365
2461
|
});
|
|
2366
2462
|
return {
|
|
2367
|
-
permissions:
|
|
2368
|
-
meta:
|
|
2463
|
+
permissions: o.data,
|
|
2464
|
+
meta: o.meta
|
|
2369
2465
|
};
|
|
2370
2466
|
}
|
|
2371
2467
|
async getPermissionById(e) {
|
|
@@ -2400,14 +2496,14 @@ class ht {
|
|
|
2400
2496
|
async getAppPermissions(e, t) {
|
|
2401
2497
|
const r = new URLSearchParams();
|
|
2402
2498
|
t != null && t.page && r.append("page", t.page.toString()), t != null && t.limit && r.append("limit", t.limit.toString()), t != null && t.sortBy && r.append("sortBy", t.sortBy), t != null && t.sortOrder && r.append("sortOrder", t.sortOrder);
|
|
2403
|
-
const
|
|
2499
|
+
const n = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n);
|
|
2404
2500
|
return {
|
|
2405
|
-
permissions:
|
|
2406
|
-
meta:
|
|
2501
|
+
permissions: o.data,
|
|
2502
|
+
meta: o.meta
|
|
2407
2503
|
};
|
|
2408
2504
|
}
|
|
2409
2505
|
}
|
|
2410
|
-
class
|
|
2506
|
+
class wt {
|
|
2411
2507
|
constructor(e, t) {
|
|
2412
2508
|
this.httpService = e, this.sessionManager = t;
|
|
2413
2509
|
}
|
|
@@ -2424,12 +2520,12 @@ class gt {
|
|
|
2424
2520
|
async getSubscriptionPlans(e) {
|
|
2425
2521
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
2426
2522
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder), e != null && e.appId && r.append("appId", e.appId);
|
|
2427
|
-
const
|
|
2523
|
+
const n = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
|
|
2428
2524
|
headers: t
|
|
2429
2525
|
});
|
|
2430
2526
|
return {
|
|
2431
|
-
plans:
|
|
2432
|
-
meta:
|
|
2527
|
+
plans: o.data,
|
|
2528
|
+
meta: o.meta
|
|
2433
2529
|
};
|
|
2434
2530
|
}
|
|
2435
2531
|
async getSubscriptionPlanById(e) {
|
|
@@ -2458,7 +2554,7 @@ class gt {
|
|
|
2458
2554
|
});
|
|
2459
2555
|
}
|
|
2460
2556
|
}
|
|
2461
|
-
class
|
|
2557
|
+
class mt {
|
|
2462
2558
|
constructor(e) {
|
|
2463
2559
|
this.httpService = e;
|
|
2464
2560
|
}
|
|
@@ -2467,7 +2563,7 @@ class pt {
|
|
|
2467
2563
|
return await this.httpService.get("/health");
|
|
2468
2564
|
}
|
|
2469
2565
|
}
|
|
2470
|
-
class
|
|
2566
|
+
class bt {
|
|
2471
2567
|
// Date string to Date object
|
|
2472
2568
|
static toDate(e) {
|
|
2473
2569
|
return new Date(e);
|
|
@@ -2584,46 +2680,48 @@ class ft {
|
|
|
2584
2680
|
// Transform query parameters for API calls
|
|
2585
2681
|
static transformQueryParams(e) {
|
|
2586
2682
|
const t = new URLSearchParams();
|
|
2587
|
-
return Object.entries(e).forEach(([r,
|
|
2588
|
-
|
|
2683
|
+
return Object.entries(e).forEach(([r, n]) => {
|
|
2684
|
+
n != null && n !== "" && t.append(r, String(n));
|
|
2589
2685
|
}), t;
|
|
2590
2686
|
}
|
|
2591
2687
|
}
|
|
2592
2688
|
export {
|
|
2593
|
-
|
|
2689
|
+
bt as ApiMappers,
|
|
2594
2690
|
be as AppApiService,
|
|
2595
|
-
|
|
2691
|
+
Ze as AppProvider,
|
|
2596
2692
|
Ae as AuthApiService,
|
|
2597
|
-
|
|
2598
|
-
|
|
2693
|
+
nt as AuthProvider,
|
|
2694
|
+
ht as FeatureFlag,
|
|
2599
2695
|
Me as FeatureFlagApiService,
|
|
2600
|
-
|
|
2601
|
-
|
|
2696
|
+
it as FeatureFlagProvider,
|
|
2697
|
+
mt as HealthApiService,
|
|
2602
2698
|
G as HttpService,
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2699
|
+
dt as LandingRoute,
|
|
2700
|
+
gt as LoginForm,
|
|
2701
|
+
ft as PasswordRecoveryForm,
|
|
2702
|
+
yt as PermissionApiService,
|
|
2703
|
+
at as Protected,
|
|
2704
|
+
lt as ProtectedRoute,
|
|
2705
|
+
ce as RoleApiService,
|
|
2609
2706
|
xe as SessionManager,
|
|
2610
|
-
|
|
2707
|
+
pt as SignupForm,
|
|
2611
2708
|
Re as SubscriptionApiService,
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2709
|
+
ut as SubscriptionGuard,
|
|
2710
|
+
wt as SubscriptionPlanApiService,
|
|
2711
|
+
ot as SubscriptionProvider,
|
|
2712
|
+
de as TenantApiService,
|
|
2713
|
+
tt as TenantProvider,
|
|
2714
|
+
ct as TenantRoute,
|
|
2617
2715
|
Pe as UserApiService,
|
|
2618
|
-
|
|
2619
|
-
|
|
2716
|
+
X as UserType,
|
|
2717
|
+
et as useApi,
|
|
2620
2718
|
re as useApp,
|
|
2621
2719
|
se as useAuth,
|
|
2622
2720
|
Ee as useFeatureFlags,
|
|
2623
|
-
|
|
2721
|
+
st as useSettings,
|
|
2624
2722
|
Fe as useSubscription,
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2723
|
+
le as useTenant,
|
|
2724
|
+
K as useTenantInfo,
|
|
2725
|
+
rt as useTenantSettings
|
|
2628
2726
|
};
|
|
2629
2727
|
//# sourceMappingURL=index.es.js.map
|