@skylabs-digital/react-identity-access 1.2.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 +814 -721
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/TenantProvider.d.ts +1 -2
- package/dist/providers/TenantProvider.d.ts.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,44 +12,44 @@ 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
|
|
20
|
-
let
|
|
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
|
+
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
|
-
const
|
|
27
|
-
|
|
28
|
-
} catch (
|
|
29
|
-
console.warn("Failed to inject auth headers:",
|
|
26
|
+
const h = await this.sessionManager.getAuthHeaders();
|
|
27
|
+
M = { ...M, ...h };
|
|
28
|
+
} catch (h) {
|
|
29
|
+
console.warn("Failed to inject auth headers:", h);
|
|
30
30
|
}
|
|
31
|
-
const P = new AbortController(),
|
|
31
|
+
const P = new AbortController(), g = setTimeout(() => P.abort(), T);
|
|
32
32
|
try {
|
|
33
|
-
const
|
|
33
|
+
const h = await fetch(m, {
|
|
34
34
|
method: e,
|
|
35
|
-
headers:
|
|
35
|
+
headers: M,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
37
|
signal: P.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(g), h.status === 401 && !(n != null && n.skipRetry) && !o && this.sessionManager)
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r,
|
|
41
|
+
const p = this.sessionManager.getTokens();
|
|
42
|
+
if (p != null && p.refreshToken)
|
|
43
|
+
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, n, !0);
|
|
44
44
|
} catch {
|
|
45
|
-
throw new Error(`HTTP ${
|
|
45
|
+
throw new Error(`HTTP ${h.status}: ${h.statusText}`);
|
|
46
46
|
}
|
|
47
|
-
if (!
|
|
48
|
-
throw new Error(`HTTP ${
|
|
49
|
-
const x =
|
|
50
|
-
return !x || !x.includes("application/json") ? {} : await
|
|
51
|
-
} catch (
|
|
52
|
-
throw clearTimeout(
|
|
47
|
+
if (!h.ok)
|
|
48
|
+
throw new Error(`HTTP ${h.status}: ${h.statusText}`);
|
|
49
|
+
const x = h.headers.get("content-type");
|
|
50
|
+
return !x || !x.includes("application/json") ? {} : await h.json();
|
|
51
|
+
} catch (h) {
|
|
52
|
+
throw clearTimeout(g), h instanceof Error && h.name === "AbortError" ? new Error(`Request timeout after ${T}ms`) : h;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -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,9 +170,9 @@ const ge = ee(null), Se = () => /* @__PURE__ */ n(
|
|
|
170
170
|
]
|
|
171
171
|
}
|
|
172
172
|
);
|
|
173
|
-
function
|
|
174
|
-
const [t, r] =
|
|
175
|
-
const
|
|
173
|
+
function Ze({ config: i, children: e }) {
|
|
174
|
+
const [t, r] = b(null), [n, o] = b(!0), [m, T] = b(null), M = z(() => {
|
|
175
|
+
const g = () => {
|
|
176
176
|
P();
|
|
177
177
|
};
|
|
178
178
|
return {
|
|
@@ -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:
|
|
185
|
-
retryApp:
|
|
183
|
+
isAppLoading: n,
|
|
184
|
+
appError: m,
|
|
185
|
+
retryApp: g
|
|
186
186
|
};
|
|
187
|
-
}, [i, t,
|
|
187
|
+
}, [i, t, n, m]), P = Z(async () => {
|
|
188
188
|
try {
|
|
189
|
-
|
|
190
|
-
const
|
|
189
|
+
o(!0), T(null);
|
|
190
|
+
const g = new G(i.baseUrl), x = await new be(g, {}).getPublicAppInfo(i.appId);
|
|
191
191
|
r(x);
|
|
192
|
-
} catch (
|
|
193
|
-
const
|
|
194
|
-
|
|
192
|
+
} catch (g) {
|
|
193
|
+
const h = g instanceof Error ? g : new Error("Failed to load app information");
|
|
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
|
|
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), Te = () => /* @__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
|
-
),
|
|
573
|
+
), Te = ({ error: i, retry: e }) => /* @__PURE__ */ c(
|
|
574
574
|
"div",
|
|
575
575
|
{
|
|
576
576
|
style: {
|
|
@@ -584,9 +584,9 @@ const pe = ee(null), Te = () => /* @__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,75 +604,73 @@ const pe = ee(null), Te = () => /* @__PURE__ */ n(
|
|
|
604
604
|
]
|
|
605
605
|
}
|
|
606
606
|
);
|
|
607
|
-
function
|
|
608
|
-
const { baseUrl: t, appInfo: r, appId:
|
|
609
|
-
const
|
|
610
|
-
if (l === "fixed")
|
|
611
|
-
return i.fixedTenantSlug || null;
|
|
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";
|
|
612
610
|
if (typeof window > "u") return null;
|
|
613
|
-
if (
|
|
614
|
-
const
|
|
615
|
-
if (
|
|
616
|
-
const
|
|
617
|
-
return localStorage.setItem(w,
|
|
611
|
+
if (d === "subdomain") {
|
|
612
|
+
const a = window.location.hostname.split(".");
|
|
613
|
+
if (a.length >= 3) {
|
|
614
|
+
const l = a[0];
|
|
615
|
+
return localStorage.setItem(w, l), l;
|
|
618
616
|
}
|
|
619
617
|
return localStorage.getItem(w);
|
|
620
|
-
} else if (
|
|
621
|
-
const
|
|
622
|
-
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);
|
|
623
621
|
}
|
|
624
622
|
return null;
|
|
625
|
-
}, [i.tenantMode, i.
|
|
626
|
-
async (
|
|
623
|
+
}, [i.tenantMode, i.selectorParam]), y = z(() => L(), [L]), S = (r == null ? void 0 : r.settingsSchema) || null, k = Z(
|
|
624
|
+
async (d) => {
|
|
627
625
|
try {
|
|
628
|
-
|
|
629
|
-
const w = new G(t),
|
|
630
|
-
|
|
626
|
+
M(!0), g(null);
|
|
627
|
+
const w = new G(t), a = await new de(w, n).getPublicTenantInfo(d);
|
|
628
|
+
m(a);
|
|
631
629
|
} catch (w) {
|
|
632
|
-
const
|
|
633
|
-
|
|
630
|
+
const u = w instanceof Error ? w : new Error("Failed to load tenant information");
|
|
631
|
+
g(u), m(null);
|
|
634
632
|
} finally {
|
|
635
|
-
|
|
633
|
+
M(!1);
|
|
636
634
|
}
|
|
637
635
|
},
|
|
638
|
-
[t,
|
|
639
|
-
), R =
|
|
640
|
-
if (
|
|
636
|
+
[t, n]
|
|
637
|
+
), R = Z(async () => {
|
|
638
|
+
if (o != null && o.id)
|
|
641
639
|
try {
|
|
642
|
-
A(!0),
|
|
643
|
-
const
|
|
644
|
-
x(
|
|
645
|
-
} catch (
|
|
646
|
-
const w =
|
|
647
|
-
|
|
640
|
+
A(!0), f(null);
|
|
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
|
+
f(w), x(null);
|
|
648
646
|
} finally {
|
|
649
647
|
A(!1);
|
|
650
648
|
}
|
|
651
|
-
}, [t,
|
|
649
|
+
}, [t, o]), D = Z(() => {
|
|
652
650
|
R();
|
|
653
|
-
}, [R]), E =
|
|
654
|
-
(
|
|
655
|
-
if (!
|
|
651
|
+
}, [R]), E = Z(
|
|
652
|
+
(d) => {
|
|
653
|
+
if (!S)
|
|
656
654
|
return { isValid: !0, errors: [] };
|
|
657
655
|
const w = [];
|
|
658
656
|
try {
|
|
659
|
-
return
|
|
657
|
+
return S.properties && Object.entries(S.properties).forEach(([u, a]) => {
|
|
660
658
|
var W;
|
|
661
|
-
const
|
|
662
|
-
if ((W =
|
|
663
|
-
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`);
|
|
664
662
|
return;
|
|
665
663
|
}
|
|
666
|
-
if (
|
|
667
|
-
if (
|
|
668
|
-
const I =
|
|
669
|
-
I === "string" && N !== "string" ? w.push(`Field '${
|
|
664
|
+
if (l != null) {
|
|
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`);
|
|
670
668
|
}
|
|
671
|
-
|
|
672
|
-
`Field '${
|
|
673
|
-
),
|
|
674
|
-
`Field '${
|
|
675
|
-
),
|
|
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(", ")}`);
|
|
676
674
|
}
|
|
677
675
|
}), {
|
|
678
676
|
isValid: w.length === 0,
|
|
@@ -685,108 +683,105 @@ function Ze({ config: i, children: e }) {
|
|
|
685
683
|
};
|
|
686
684
|
}
|
|
687
685
|
},
|
|
688
|
-
[
|
|
686
|
+
[S]
|
|
689
687
|
);
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
a != null && a.id ? R() : (x(null), y(null), A(!1));
|
|
697
|
-
}, [a == null ? void 0 : a.id, R]);
|
|
698
|
-
const D = O(() => ({
|
|
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(() => ({
|
|
699
694
|
// Tenant info
|
|
700
|
-
tenant:
|
|
701
|
-
tenantSlug:
|
|
702
|
-
isTenantLoading:
|
|
695
|
+
tenant: o,
|
|
696
|
+
tenantSlug: y,
|
|
697
|
+
isTenantLoading: T,
|
|
703
698
|
tenantError: P,
|
|
704
699
|
retryTenant: () => {
|
|
705
|
-
|
|
700
|
+
y && k(y);
|
|
706
701
|
},
|
|
707
702
|
// Settings
|
|
708
|
-
settings:
|
|
709
|
-
settingsSchema:
|
|
710
|
-
isSettingsLoading:
|
|
703
|
+
settings: h,
|
|
704
|
+
settingsSchema: S,
|
|
705
|
+
isSettingsLoading: p,
|
|
711
706
|
settingsError: F,
|
|
712
707
|
// Actions
|
|
713
|
-
refreshSettings:
|
|
708
|
+
refreshSettings: D,
|
|
714
709
|
// Validation
|
|
715
710
|
validateSettings: E
|
|
716
711
|
}), [
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
712
|
+
o,
|
|
713
|
+
y,
|
|
714
|
+
T,
|
|
720
715
|
P,
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
716
|
+
h,
|
|
717
|
+
S,
|
|
718
|
+
p,
|
|
724
719
|
F,
|
|
725
|
-
|
|
720
|
+
D,
|
|
726
721
|
E
|
|
727
722
|
]);
|
|
728
|
-
if (
|
|
729
|
-
return /* @__PURE__ */
|
|
730
|
-
if (P
|
|
731
|
-
const
|
|
732
|
-
return /* @__PURE__ */
|
|
723
|
+
if (T)
|
|
724
|
+
return /* @__PURE__ */ s(H, { children: i.loadingFallback || /* @__PURE__ */ s(ke, {}) });
|
|
725
|
+
if (P) {
|
|
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 });
|
|
733
728
|
}
|
|
734
|
-
return /* @__PURE__ */
|
|
729
|
+
return /* @__PURE__ */ s(fe.Provider, { value: B, children: e });
|
|
735
730
|
}
|
|
736
|
-
function
|
|
737
|
-
const i = te(
|
|
731
|
+
function le() {
|
|
732
|
+
const i = te(fe);
|
|
738
733
|
if (!i)
|
|
739
734
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
740
735
|
return i;
|
|
741
736
|
}
|
|
742
|
-
const
|
|
743
|
-
function
|
|
737
|
+
const rt = le;
|
|
738
|
+
function st() {
|
|
744
739
|
const {
|
|
745
740
|
settings: i,
|
|
746
741
|
settingsSchema: e,
|
|
747
742
|
isSettingsLoading: t,
|
|
748
743
|
settingsError: r,
|
|
749
|
-
validateSettings:
|
|
750
|
-
} =
|
|
744
|
+
validateSettings: n
|
|
745
|
+
} = le();
|
|
751
746
|
return {
|
|
752
747
|
settings: i,
|
|
753
748
|
settingsSchema: e,
|
|
754
749
|
isLoading: t,
|
|
755
750
|
error: r,
|
|
756
|
-
validateSettings:
|
|
751
|
+
validateSettings: n
|
|
757
752
|
};
|
|
758
753
|
}
|
|
759
|
-
function
|
|
760
|
-
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();
|
|
761
756
|
return {
|
|
762
757
|
tenant: i,
|
|
763
758
|
tenantSlug: e,
|
|
764
759
|
isLoading: t,
|
|
765
760
|
error: r,
|
|
766
|
-
retry:
|
|
761
|
+
retry: n
|
|
767
762
|
};
|
|
768
763
|
}
|
|
769
|
-
const
|
|
770
|
-
function
|
|
771
|
-
const { appId: t, baseUrl: r } = re(),
|
|
772
|
-
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 = {
|
|
773
768
|
get: () => {
|
|
774
769
|
try {
|
|
775
|
-
const
|
|
776
|
-
return
|
|
770
|
+
const u = localStorage.getItem(d);
|
|
771
|
+
return u ? JSON.parse(u) : null;
|
|
777
772
|
} catch {
|
|
778
773
|
return null;
|
|
779
774
|
}
|
|
780
775
|
},
|
|
781
|
-
set: (
|
|
776
|
+
set: (u) => {
|
|
782
777
|
try {
|
|
783
|
-
localStorage.setItem(
|
|
778
|
+
localStorage.setItem(d, JSON.stringify(u));
|
|
784
779
|
} catch {
|
|
785
780
|
}
|
|
786
781
|
},
|
|
787
782
|
clear: () => {
|
|
788
783
|
try {
|
|
789
|
-
localStorage.removeItem(
|
|
784
|
+
localStorage.removeItem(d);
|
|
790
785
|
} catch {
|
|
791
786
|
}
|
|
792
787
|
}
|
|
@@ -796,162 +791,162 @@ function rt({ config: i = {}, children: e }) {
|
|
|
796
791
|
tokenStorage: w,
|
|
797
792
|
baseUrl: r
|
|
798
793
|
});
|
|
799
|
-
}, [
|
|
800
|
-
const
|
|
801
|
-
return
|
|
802
|
-
}, [r,
|
|
803
|
-
|
|
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(() => {
|
|
804
799
|
console.log("AuthProvider - userPermissions changed:", E);
|
|
805
800
|
}, [E]);
|
|
806
|
-
const
|
|
807
|
-
const
|
|
801
|
+
const B = z(() => {
|
|
802
|
+
const d = async () => {
|
|
808
803
|
try {
|
|
809
|
-
|
|
810
|
-
const
|
|
811
|
-
if (!(
|
|
804
|
+
p(!0), F(null);
|
|
805
|
+
const v = f.getUser();
|
|
806
|
+
if (!(v != null && v.id))
|
|
812
807
|
throw new Error("No user ID available in session");
|
|
813
|
-
const $ = await
|
|
814
|
-
|
|
815
|
-
} catch (
|
|
816
|
-
const $ =
|
|
808
|
+
const $ = await S.getUserById(v.id);
|
|
809
|
+
h($), f.setUser($);
|
|
810
|
+
} catch (v) {
|
|
811
|
+
const $ = v instanceof Error ? v : new Error("Failed to load user data");
|
|
817
812
|
F($), console.error("Failed to load user data:", $);
|
|
818
813
|
} finally {
|
|
819
|
-
|
|
814
|
+
p(!1);
|
|
820
815
|
}
|
|
821
816
|
}, w = async () => {
|
|
822
|
-
await
|
|
823
|
-
},
|
|
824
|
-
const V = await
|
|
825
|
-
email:
|
|
817
|
+
await d();
|
|
818
|
+
}, u = async (v, $, J) => {
|
|
819
|
+
const V = await y.login({
|
|
820
|
+
email: v,
|
|
826
821
|
password: $,
|
|
827
|
-
tenantId:
|
|
822
|
+
tenantId: J
|
|
828
823
|
});
|
|
829
|
-
if (
|
|
824
|
+
if (f.setTokens({
|
|
830
825
|
accessToken: V.accessToken,
|
|
831
826
|
refreshToken: V.refreshToken,
|
|
832
827
|
expiresIn: V.expiresIn
|
|
833
828
|
}), V.user) {
|
|
834
|
-
|
|
829
|
+
f.setUser(V.user), h(V.user);
|
|
835
830
|
try {
|
|
836
|
-
await
|
|
837
|
-
} catch (
|
|
838
|
-
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);
|
|
839
834
|
}
|
|
840
835
|
}
|
|
841
836
|
return V;
|
|
842
|
-
},
|
|
843
|
-
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,
|
|
844
839
|
name: $,
|
|
845
|
-
password:
|
|
840
|
+
password: J,
|
|
846
841
|
tenantName: V,
|
|
847
842
|
appId: t
|
|
848
|
-
}), W = async (
|
|
849
|
-
const
|
|
850
|
-
await
|
|
851
|
-
}, I = async (
|
|
852
|
-
await
|
|
853
|
-
}, N = async (
|
|
854
|
-
await
|
|
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: $ });
|
|
855
850
|
}, _ = async () => {
|
|
856
|
-
const
|
|
857
|
-
if (!(
|
|
851
|
+
const v = f.getTokens();
|
|
852
|
+
if (!(v != null && v.refreshToken))
|
|
858
853
|
throw new Error("No refresh token available");
|
|
859
|
-
const $ = await
|
|
860
|
-
refreshToken:
|
|
854
|
+
const $ = await y.refreshToken({
|
|
855
|
+
refreshToken: v.refreshToken
|
|
861
856
|
});
|
|
862
|
-
|
|
857
|
+
f.setTokens({
|
|
863
858
|
accessToken: $.accessToken,
|
|
864
|
-
refreshToken: $.refreshToken ||
|
|
859
|
+
refreshToken: $.refreshToken || v.refreshToken,
|
|
865
860
|
expiresIn: $.expiresIn
|
|
866
861
|
});
|
|
867
|
-
},
|
|
868
|
-
|
|
869
|
-
},
|
|
870
|
-
|
|
871
|
-
},
|
|
872
|
-
|
|
873
|
-
},
|
|
862
|
+
}, C = () => {
|
|
863
|
+
f.clearSession(), h(null), F(null);
|
|
864
|
+
}, U = (v) => {
|
|
865
|
+
f.setTokens(v);
|
|
866
|
+
}, Q = () => f.hasValidSession(), q = () => {
|
|
867
|
+
f.clearSession(), h(null), F(null);
|
|
868
|
+
}, O = async () => {
|
|
874
869
|
if (t)
|
|
875
870
|
try {
|
|
876
871
|
P(!0);
|
|
877
|
-
const { roles:
|
|
878
|
-
|
|
879
|
-
} catch (
|
|
880
|
-
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);
|
|
881
876
|
} finally {
|
|
882
877
|
P(!1);
|
|
883
878
|
}
|
|
884
879
|
}, j = async () => {
|
|
885
|
-
await
|
|
886
|
-
},
|
|
880
|
+
await O();
|
|
881
|
+
}, ie = (v) => {
|
|
887
882
|
if (!E || E.length === 0)
|
|
888
883
|
return !1;
|
|
889
|
-
if (typeof
|
|
890
|
-
return E.includes(
|
|
891
|
-
const $ = `${
|
|
884
|
+
if (typeof v == "string")
|
|
885
|
+
return E.includes(v);
|
|
886
|
+
const $ = `${v.resource}.${v.action}`;
|
|
892
887
|
return E.includes($);
|
|
893
888
|
};
|
|
894
889
|
return {
|
|
895
|
-
sessionManager:
|
|
896
|
-
authenticatedHttpService:
|
|
897
|
-
login:
|
|
898
|
-
signup:
|
|
899
|
-
signupTenantAdmin:
|
|
890
|
+
sessionManager: f,
|
|
891
|
+
authenticatedHttpService: L,
|
|
892
|
+
login: u,
|
|
893
|
+
signup: a,
|
|
894
|
+
signupTenantAdmin: l,
|
|
900
895
|
changePassword: W,
|
|
901
896
|
requestPasswordReset: I,
|
|
902
897
|
confirmPasswordReset: N,
|
|
903
898
|
refreshToken: _,
|
|
904
|
-
logout:
|
|
905
|
-
setTokens:
|
|
906
|
-
hasValidSession:
|
|
907
|
-
clearSession:
|
|
908
|
-
currentUser:
|
|
899
|
+
logout: C,
|
|
900
|
+
setTokens: U,
|
|
901
|
+
hasValidSession: Q,
|
|
902
|
+
clearSession: q,
|
|
903
|
+
currentUser: g,
|
|
909
904
|
isUserLoading: x,
|
|
910
905
|
userError: A,
|
|
911
906
|
refreshUser: w,
|
|
912
|
-
userRole:
|
|
907
|
+
userRole: D,
|
|
913
908
|
userPermissions: E,
|
|
914
|
-
availableRoles:
|
|
915
|
-
rolesLoading:
|
|
916
|
-
hasPermission:
|
|
917
|
-
hasAnyPermission: (
|
|
918
|
-
hasAllPermissions: (
|
|
909
|
+
availableRoles: m,
|
|
910
|
+
rolesLoading: M,
|
|
911
|
+
hasPermission: ie,
|
|
912
|
+
hasAnyPermission: (v) => v.some(($) => ie($)),
|
|
913
|
+
hasAllPermissions: (v) => v.every(($) => ie($)),
|
|
919
914
|
getUserPermissionStrings: () => E || [],
|
|
920
915
|
refreshRoles: j
|
|
921
916
|
};
|
|
922
917
|
}, [
|
|
918
|
+
f,
|
|
919
|
+
L,
|
|
923
920
|
y,
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
b,
|
|
927
|
-
T,
|
|
921
|
+
S,
|
|
922
|
+
k,
|
|
928
923
|
t,
|
|
929
|
-
|
|
930
|
-
|
|
924
|
+
m,
|
|
925
|
+
g,
|
|
931
926
|
x,
|
|
932
927
|
A,
|
|
933
|
-
|
|
928
|
+
D,
|
|
934
929
|
E
|
|
935
930
|
]);
|
|
936
|
-
return
|
|
931
|
+
return Y(() => {
|
|
937
932
|
!i.initialRoles && t && (async () => {
|
|
938
933
|
try {
|
|
939
934
|
P(!0);
|
|
940
|
-
const w = new G(r),
|
|
941
|
-
|
|
935
|
+
const w = new G(r), u = new ce(w), { roles: a } = await u.getRolesByApp(t);
|
|
936
|
+
T(a);
|
|
942
937
|
} catch (w) {
|
|
943
938
|
console.error("Failed to fetch roles:", w);
|
|
944
939
|
} finally {
|
|
945
940
|
P(!1);
|
|
946
941
|
}
|
|
947
942
|
})();
|
|
948
|
-
}, [t, r, i.initialRoles]),
|
|
949
|
-
const
|
|
950
|
-
|
|
951
|
-
}, [
|
|
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 });
|
|
952
947
|
}
|
|
953
948
|
function se() {
|
|
954
|
-
const i = te(
|
|
949
|
+
const i = te(ye);
|
|
955
950
|
if (!i)
|
|
956
951
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
957
952
|
return i;
|
|
@@ -977,12 +972,12 @@ class Me {
|
|
|
977
972
|
throw new Error("SessionManager is required for private endpoints");
|
|
978
973
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
979
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);
|
|
980
|
-
const
|
|
975
|
+
const n = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
|
|
981
976
|
headers: t
|
|
982
977
|
});
|
|
983
978
|
return {
|
|
984
|
-
featureFlags:
|
|
985
|
-
meta:
|
|
979
|
+
featureFlags: o.data,
|
|
980
|
+
meta: o.meta
|
|
986
981
|
};
|
|
987
982
|
}
|
|
988
983
|
async getFeatureFlagById(e) {
|
|
@@ -1019,8 +1014,8 @@ class Me {
|
|
|
1019
1014
|
throw new Error("Tenant ID and App ID are required");
|
|
1020
1015
|
const r = new URLSearchParams();
|
|
1021
1016
|
r.append("tenantId", e), r.append("appId", t);
|
|
1022
|
-
const
|
|
1023
|
-
return (await this.httpService.get(
|
|
1017
|
+
const n = `/tenant-feature-flags${r.toString() ? `?${r.toString()}` : ""}`;
|
|
1018
|
+
return (await this.httpService.get(n, {
|
|
1024
1019
|
headers: { "X-Tenant-ID": e }
|
|
1025
1020
|
})).data;
|
|
1026
1021
|
}
|
|
@@ -1028,61 +1023,61 @@ class Me {
|
|
|
1028
1023
|
async getTenantFeatureFlag(e, t, r) {
|
|
1029
1024
|
if (!e || !t || !r)
|
|
1030
1025
|
throw new Error("Flag Key, Tenant ID and App ID are required");
|
|
1031
|
-
const
|
|
1032
|
-
|
|
1033
|
-
const
|
|
1034
|
-
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, {
|
|
1035
1030
|
headers: { "X-Tenant-ID": t }
|
|
1036
1031
|
})).data;
|
|
1037
1032
|
}
|
|
1038
1033
|
}
|
|
1039
|
-
const
|
|
1040
|
-
function
|
|
1041
|
-
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(() => {
|
|
1042
1037
|
const A = new G(t);
|
|
1043
1038
|
return new Me(A);
|
|
1044
1039
|
}, [t]), x = async () => {
|
|
1045
|
-
if (!(
|
|
1046
|
-
|
|
1040
|
+
if (!(n != null && n.id)) {
|
|
1041
|
+
m([]);
|
|
1047
1042
|
return;
|
|
1048
1043
|
}
|
|
1049
|
-
|
|
1044
|
+
M(!0), g(null);
|
|
1050
1045
|
try {
|
|
1051
|
-
const A = await
|
|
1052
|
-
|
|
1046
|
+
const A = await h.getTenantFeatureFlags(n.id, r);
|
|
1047
|
+
m(A);
|
|
1053
1048
|
} catch (A) {
|
|
1054
1049
|
const F = A instanceof Error ? A.message : "Failed to fetch feature flags";
|
|
1055
|
-
|
|
1050
|
+
g(F), i.onError && i.onError(A instanceof Error ? A : new Error(F));
|
|
1056
1051
|
} finally {
|
|
1057
|
-
|
|
1052
|
+
M(!1);
|
|
1058
1053
|
}
|
|
1059
1054
|
};
|
|
1060
|
-
|
|
1055
|
+
Y(() => {
|
|
1061
1056
|
x();
|
|
1062
1057
|
const A = i.refreshInterval || 5 * 60 * 1e3, F = setInterval(x, A);
|
|
1063
1058
|
return () => clearInterval(F);
|
|
1064
|
-
}, [
|
|
1065
|
-
const
|
|
1066
|
-
featureFlags:
|
|
1067
|
-
loading:
|
|
1059
|
+
}, [n == null ? void 0 : n.id, i.refreshInterval]);
|
|
1060
|
+
const p = z(() => ({
|
|
1061
|
+
featureFlags: o,
|
|
1062
|
+
loading: T,
|
|
1068
1063
|
error: P,
|
|
1069
|
-
isEnabled: (
|
|
1070
|
-
const
|
|
1071
|
-
return (
|
|
1064
|
+
isEnabled: (y) => {
|
|
1065
|
+
const S = o.find((k) => k.key === y);
|
|
1066
|
+
return (S == null ? void 0 : S.value) === !0;
|
|
1072
1067
|
},
|
|
1073
|
-
getFlag: (
|
|
1074
|
-
getFlagState: (
|
|
1075
|
-
const
|
|
1076
|
-
return
|
|
1068
|
+
getFlag: (y) => o.find((S) => S.key === y),
|
|
1069
|
+
getFlagState: (y) => {
|
|
1070
|
+
const S = o.find((k) => k.key === y);
|
|
1071
|
+
return S ? S.value ? "enabled" : "disabled" : "not_found";
|
|
1077
1072
|
},
|
|
1078
1073
|
refresh: async () => {
|
|
1079
1074
|
await x();
|
|
1080
1075
|
}
|
|
1081
|
-
}), [
|
|
1082
|
-
return /* @__PURE__ */
|
|
1076
|
+
}), [o, T, P]);
|
|
1077
|
+
return /* @__PURE__ */ s(we.Provider, { value: p, children: e });
|
|
1083
1078
|
}
|
|
1084
1079
|
function Ee() {
|
|
1085
|
-
const i = te(
|
|
1080
|
+
const i = te(we);
|
|
1086
1081
|
if (!i)
|
|
1087
1082
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1088
1083
|
return i;
|
|
@@ -1153,64 +1148,64 @@ class Re {
|
|
|
1153
1148
|
)).data;
|
|
1154
1149
|
}
|
|
1155
1150
|
}
|
|
1156
|
-
const
|
|
1157
|
-
function
|
|
1158
|
-
const { baseUrl: t } = re(), { tenant: r } =
|
|
1159
|
-
const
|
|
1160
|
-
return new Re(
|
|
1161
|
-
}, [t]),
|
|
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
|
+
const p = new G(t);
|
|
1155
|
+
return new Re(p);
|
|
1156
|
+
}, [t]), h = async () => {
|
|
1162
1157
|
if (!(r != null && r.id)) {
|
|
1163
|
-
|
|
1158
|
+
o(null);
|
|
1164
1159
|
return;
|
|
1165
1160
|
}
|
|
1166
|
-
|
|
1161
|
+
T(!0), P(null);
|
|
1167
1162
|
try {
|
|
1168
|
-
const
|
|
1169
|
-
|
|
1170
|
-
} catch (
|
|
1171
|
-
const A =
|
|
1172
|
-
P(A), i.onError && i.onError(
|
|
1163
|
+
const p = await g.getTenantSubscriptionFeatures(r.id);
|
|
1164
|
+
o(p);
|
|
1165
|
+
} catch (p) {
|
|
1166
|
+
const A = p instanceof Error ? p.message : "Failed to fetch subscription";
|
|
1167
|
+
P(A), i.onError && i.onError(p instanceof Error ? p : new Error(A));
|
|
1173
1168
|
} finally {
|
|
1174
|
-
|
|
1169
|
+
T(!1);
|
|
1175
1170
|
}
|
|
1176
1171
|
};
|
|
1177
|
-
|
|
1178
|
-
if (
|
|
1179
|
-
const
|
|
1172
|
+
Y(() => {
|
|
1173
|
+
if (h(), !i.refreshInterval) return;
|
|
1174
|
+
const p = i.refreshInterval || 10 * 60 * 1e3, A = setInterval(h, p);
|
|
1180
1175
|
return () => clearInterval(A);
|
|
1181
1176
|
}, [r == null ? void 0 : r.id, i.refreshInterval]);
|
|
1182
|
-
const x =
|
|
1183
|
-
const
|
|
1177
|
+
const x = z(() => {
|
|
1178
|
+
const p = (n == null ? void 0 : n.features) || [];
|
|
1184
1179
|
return {
|
|
1185
|
-
subscription:
|
|
1186
|
-
features:
|
|
1187
|
-
loading:
|
|
1188
|
-
error:
|
|
1189
|
-
isFeatureEnabled: (
|
|
1190
|
-
const
|
|
1191
|
-
return
|
|
1180
|
+
subscription: n,
|
|
1181
|
+
features: p,
|
|
1182
|
+
loading: m,
|
|
1183
|
+
error: M,
|
|
1184
|
+
isFeatureEnabled: (S) => {
|
|
1185
|
+
const k = p.find((R) => R.key === S);
|
|
1186
|
+
return k ? k.type === "BOOLEAN" || k.type === "boolean" ? k.value === !0 : !!k.value : !1;
|
|
1192
1187
|
},
|
|
1193
|
-
getFeature: (
|
|
1194
|
-
getFeatureValue: (
|
|
1195
|
-
const R =
|
|
1196
|
-
return R ? R.value :
|
|
1188
|
+
getFeature: (S) => p.find((k) => k.key === S),
|
|
1189
|
+
getFeatureValue: (S, k) => {
|
|
1190
|
+
const R = p.find((D) => D.key === S);
|
|
1191
|
+
return R ? R.value : k;
|
|
1197
1192
|
},
|
|
1198
|
-
hasAllowedPlan: (
|
|
1193
|
+
hasAllowedPlan: (S) => !n || !n.isActive ? !1 : S.includes(n.planId),
|
|
1199
1194
|
refresh: async () => {
|
|
1200
|
-
await
|
|
1195
|
+
await h();
|
|
1201
1196
|
}
|
|
1202
1197
|
};
|
|
1203
|
-
}, [
|
|
1204
|
-
return /* @__PURE__ */
|
|
1198
|
+
}, [n, m, M]);
|
|
1199
|
+
return /* @__PURE__ */ s(me.Provider, { value: x, children: e });
|
|
1205
1200
|
}
|
|
1206
1201
|
function Fe() {
|
|
1207
|
-
const i = te(
|
|
1202
|
+
const i = te(me);
|
|
1208
1203
|
if (i === void 0)
|
|
1209
1204
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1210
1205
|
return i;
|
|
1211
1206
|
}
|
|
1212
|
-
var
|
|
1213
|
-
const
|
|
1207
|
+
var X = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(X || {});
|
|
1208
|
+
const ue = () => /* @__PURE__ */ c(
|
|
1214
1209
|
"div",
|
|
1215
1210
|
{
|
|
1216
1211
|
style: {
|
|
@@ -1226,10 +1221,10 @@ const de = () => /* @__PURE__ */ u(
|
|
|
1226
1221
|
margin: "20px 0"
|
|
1227
1222
|
},
|
|
1228
1223
|
children: [
|
|
1229
|
-
/* @__PURE__ */
|
|
1230
|
-
/* @__PURE__ */
|
|
1231
|
-
/* @__PURE__ */
|
|
1232
|
-
/* @__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(
|
|
1233
1228
|
"button",
|
|
1234
1229
|
{
|
|
1235
1230
|
style: {
|
|
@@ -1247,11 +1242,11 @@ const de = () => /* @__PURE__ */ u(
|
|
|
1247
1242
|
)
|
|
1248
1243
|
]
|
|
1249
1244
|
}
|
|
1250
|
-
),
|
|
1245
|
+
), he = ({
|
|
1251
1246
|
userType: i,
|
|
1252
1247
|
minUserType: e,
|
|
1253
1248
|
missingPermissions: t
|
|
1254
|
-
}) => /* @__PURE__ */
|
|
1249
|
+
}) => /* @__PURE__ */ c(
|
|
1255
1250
|
"div",
|
|
1256
1251
|
{
|
|
1257
1252
|
style: {
|
|
@@ -1267,57 +1262,57 @@ const de = () => /* @__PURE__ */ u(
|
|
|
1267
1262
|
margin: "20px 0"
|
|
1268
1263
|
},
|
|
1269
1264
|
children: [
|
|
1270
|
-
/* @__PURE__ */
|
|
1271
|
-
/* @__PURE__ */
|
|
1272
|
-
e && i ? /* @__PURE__ */
|
|
1273
|
-
/* @__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: [
|
|
1274
1269
|
"This content requires ",
|
|
1275
|
-
/* @__PURE__ */
|
|
1270
|
+
/* @__PURE__ */ s("strong", { children: e }),
|
|
1276
1271
|
" access level or higher."
|
|
1277
1272
|
] }),
|
|
1278
|
-
/* @__PURE__ */
|
|
1273
|
+
/* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1279
1274
|
"Your current access level: ",
|
|
1280
|
-
/* @__PURE__ */
|
|
1275
|
+
/* @__PURE__ */ s("strong", { children: i })
|
|
1281
1276
|
] })
|
|
1282
|
-
] }) : /* @__PURE__ */
|
|
1283
|
-
/* @__PURE__ */
|
|
1284
|
-
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: [
|
|
1285
1280
|
"Required permissions: ",
|
|
1286
|
-
/* @__PURE__ */
|
|
1281
|
+
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
1287
1282
|
] })
|
|
1288
1283
|
] })
|
|
1289
1284
|
]
|
|
1290
1285
|
}
|
|
1291
1286
|
), Ie = (i, e) => {
|
|
1292
1287
|
const t = {
|
|
1293
|
-
[
|
|
1294
|
-
[
|
|
1295
|
-
[
|
|
1288
|
+
[X.USER]: 1,
|
|
1289
|
+
[X.TENANT_ADMIN]: 2,
|
|
1290
|
+
[X.SUPERUSER]: 3
|
|
1296
1291
|
};
|
|
1297
1292
|
return t[i] >= t[e];
|
|
1298
1293
|
};
|
|
1299
|
-
function
|
|
1294
|
+
function at({
|
|
1300
1295
|
children: i,
|
|
1301
1296
|
fallback: e,
|
|
1302
1297
|
minUserType: t,
|
|
1303
1298
|
requiredPermissions: r,
|
|
1304
|
-
requireAllPermissions:
|
|
1299
|
+
requireAllPermissions: n = !1
|
|
1305
1300
|
}) {
|
|
1306
|
-
const { hasValidSession:
|
|
1307
|
-
if (!
|
|
1308
|
-
return /* @__PURE__ */
|
|
1309
|
-
const
|
|
1310
|
-
if (!
|
|
1311
|
-
return /* @__PURE__ */
|
|
1312
|
-
if (t && !Ie(
|
|
1313
|
-
return /* @__PURE__ */
|
|
1314
|
-
if (r && r.length > 0 && !(
|
|
1315
|
-
const x = r.filter((
|
|
1316
|
-
return /* @__PURE__ */
|
|
1317
|
-
}
|
|
1318
|
-
return /* @__PURE__ */
|
|
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
|
+
if (!g)
|
|
1306
|
+
return /* @__PURE__ */ s(H, { children: e || /* @__PURE__ */ s(ue, {}) });
|
|
1307
|
+
if (t && !Ie(g.userType, t))
|
|
1308
|
+
return /* @__PURE__ */ s(he, { userType: g.userType, minUserType: t });
|
|
1309
|
+
if (r && r.length > 0 && !(n ? P(r) : M(r))) {
|
|
1310
|
+
const x = r.filter((p) => !T(p)).map((p) => typeof p == "string" ? p : p.name);
|
|
1311
|
+
return /* @__PURE__ */ s(he, { missingPermissions: x });
|
|
1312
|
+
}
|
|
1313
|
+
return /* @__PURE__ */ s(H, { children: i });
|
|
1319
1314
|
}
|
|
1320
|
-
const He = ({ redirectPath: i }) => /* @__PURE__ */
|
|
1315
|
+
const He = ({ redirectPath: i }) => /* @__PURE__ */ s(
|
|
1321
1316
|
"div",
|
|
1322
1317
|
{
|
|
1323
1318
|
style: {
|
|
@@ -1330,7 +1325,7 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1330
1325
|
backgroundColor: "#f9fafb",
|
|
1331
1326
|
textAlign: "center"
|
|
1332
1327
|
},
|
|
1333
|
-
children: /* @__PURE__ */
|
|
1328
|
+
children: /* @__PURE__ */ c(
|
|
1334
1329
|
"div",
|
|
1335
1330
|
{
|
|
1336
1331
|
style: {
|
|
@@ -1341,10 +1336,10 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1341
1336
|
maxWidth: "400px"
|
|
1342
1337
|
},
|
|
1343
1338
|
children: [
|
|
1344
|
-
/* @__PURE__ */
|
|
1345
|
-
/* @__PURE__ */
|
|
1346
|
-
/* @__PURE__ */
|
|
1347
|
-
/* @__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: [
|
|
1348
1343
|
"Redirecting to ",
|
|
1349
1344
|
i,
|
|
1350
1345
|
"..."
|
|
@@ -1353,11 +1348,11 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1353
1348
|
}
|
|
1354
1349
|
)
|
|
1355
1350
|
}
|
|
1356
|
-
),
|
|
1351
|
+
), ge = ({
|
|
1357
1352
|
userType: i,
|
|
1358
1353
|
minUserType: e,
|
|
1359
1354
|
missingPermissions: t
|
|
1360
|
-
}) => /* @__PURE__ */
|
|
1355
|
+
}) => /* @__PURE__ */ s(
|
|
1361
1356
|
"div",
|
|
1362
1357
|
{
|
|
1363
1358
|
style: {
|
|
@@ -1370,7 +1365,7 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1370
1365
|
backgroundColor: "#f9fafb",
|
|
1371
1366
|
textAlign: "center"
|
|
1372
1367
|
},
|
|
1373
|
-
children: /* @__PURE__ */
|
|
1368
|
+
children: /* @__PURE__ */ c(
|
|
1374
1369
|
"div",
|
|
1375
1370
|
{
|
|
1376
1371
|
style: {
|
|
@@ -1381,63 +1376,159 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1381
1376
|
maxWidth: "400px"
|
|
1382
1377
|
},
|
|
1383
1378
|
children: [
|
|
1384
|
-
/* @__PURE__ */
|
|
1385
|
-
/* @__PURE__ */
|
|
1386
|
-
e && i ? /* @__PURE__ */
|
|
1387
|
-
/* @__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: [
|
|
1388
1383
|
"This page requires ",
|
|
1389
|
-
/* @__PURE__ */
|
|
1384
|
+
/* @__PURE__ */ s("strong", { children: e }),
|
|
1390
1385
|
" access level or higher."
|
|
1391
1386
|
] }),
|
|
1392
|
-
/* @__PURE__ */
|
|
1387
|
+
/* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1393
1388
|
"Your current access level: ",
|
|
1394
|
-
/* @__PURE__ */
|
|
1389
|
+
/* @__PURE__ */ s("strong", { children: i })
|
|
1395
1390
|
] })
|
|
1396
|
-
] }) : /* @__PURE__ */
|
|
1397
|
-
/* @__PURE__ */
|
|
1398
|
-
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: [
|
|
1399
1394
|
"Required permissions: ",
|
|
1400
|
-
/* @__PURE__ */
|
|
1395
|
+
/* @__PURE__ */ s("strong", { children: t.join(", ") })
|
|
1401
1396
|
] })
|
|
1402
1397
|
] })
|
|
1403
1398
|
]
|
|
1404
1399
|
}
|
|
1405
1400
|
)
|
|
1406
1401
|
}
|
|
1407
|
-
),
|
|
1402
|
+
), Ce = (i, e) => {
|
|
1408
1403
|
const t = {
|
|
1409
|
-
[
|
|
1410
|
-
[
|
|
1411
|
-
[
|
|
1404
|
+
[X.USER]: 1,
|
|
1405
|
+
[X.TENANT_ADMIN]: 2,
|
|
1406
|
+
[X.SUPERUSER]: 3
|
|
1412
1407
|
};
|
|
1413
1408
|
return t[i] >= t[e];
|
|
1414
1409
|
};
|
|
1415
|
-
function
|
|
1410
|
+
function lt({
|
|
1416
1411
|
children: i,
|
|
1417
1412
|
redirectTo: e = "/login",
|
|
1418
1413
|
minUserType: t,
|
|
1419
1414
|
requiredPermissions: r,
|
|
1420
|
-
requireAllPermissions:
|
|
1421
|
-
fallback:
|
|
1415
|
+
requireAllPermissions: n = !1,
|
|
1416
|
+
fallback: o
|
|
1422
1417
|
}) {
|
|
1423
|
-
const { hasValidSession:
|
|
1424
|
-
if (!
|
|
1425
|
-
return
|
|
1426
|
-
/* @__PURE__ */
|
|
1427
|
-
/* @__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 })
|
|
1428
1423
|
] });
|
|
1429
|
-
const x =
|
|
1424
|
+
const x = T.getUser();
|
|
1430
1425
|
if (!x)
|
|
1431
|
-
return /* @__PURE__ */
|
|
1432
|
-
if (t &&
|
|
1433
|
-
return /* @__PURE__ */
|
|
1434
|
-
if (r && r.length > 0 && !(
|
|
1435
|
-
const A = r.filter((F) => !
|
|
1436
|
-
return /* @__PURE__ */
|
|
1437
|
-
}
|
|
1438
|
-
return /* @__PURE__ */
|
|
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
|
+
const A = r.filter((F) => !M(F)).map((F) => typeof F == "string" ? F : F.name);
|
|
1431
|
+
return /* @__PURE__ */ s(ge, { missingPermissions: A });
|
|
1432
|
+
}
|
|
1433
|
+
return /* @__PURE__ */ s(H, { children: i });
|
|
1439
1434
|
}
|
|
1440
|
-
const
|
|
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
|
+
)
|
|
1518
|
+
}
|
|
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 });
|
|
1530
|
+
}
|
|
1531
|
+
const De = () => /* @__PURE__ */ c(
|
|
1441
1532
|
"div",
|
|
1442
1533
|
{
|
|
1443
1534
|
style: {
|
|
@@ -1449,19 +1540,19 @@ const Ce = () => /* @__PURE__ */ u(
|
|
|
1449
1540
|
color: "#dc2626"
|
|
1450
1541
|
},
|
|
1451
1542
|
children: [
|
|
1452
|
-
/* @__PURE__ */
|
|
1453
|
-
/* @__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." })
|
|
1454
1545
|
]
|
|
1455
1546
|
}
|
|
1456
1547
|
);
|
|
1457
|
-
function
|
|
1548
|
+
function ut({
|
|
1458
1549
|
children: i,
|
|
1459
|
-
fallback: e = /* @__PURE__ */
|
|
1550
|
+
fallback: e = /* @__PURE__ */ s(De, {}),
|
|
1460
1551
|
allowedPlans: t,
|
|
1461
1552
|
requiredFeature: r
|
|
1462
1553
|
}) {
|
|
1463
|
-
const { subscription:
|
|
1464
|
-
return
|
|
1554
|
+
const { subscription: n, hasAllowedPlan: o, isFeatureEnabled: m, loading: T } = Fe();
|
|
1555
|
+
return T ? /* @__PURE__ */ s(
|
|
1465
1556
|
"div",
|
|
1466
1557
|
{
|
|
1467
1558
|
style: {
|
|
@@ -1471,9 +1562,9 @@ function at({
|
|
|
1471
1562
|
},
|
|
1472
1563
|
children: "Loading subscription..."
|
|
1473
1564
|
}
|
|
1474
|
-
) :
|
|
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 });
|
|
1475
1566
|
}
|
|
1476
|
-
const
|
|
1567
|
+
const Be = ({ flagName: i }) => /* @__PURE__ */ c(
|
|
1477
1568
|
"div",
|
|
1478
1569
|
{
|
|
1479
1570
|
style: {
|
|
@@ -1490,9 +1581,9 @@ const Le = ({ flagName: i }) => /* @__PURE__ */ u(
|
|
|
1490
1581
|
color: "#6c757d"
|
|
1491
1582
|
},
|
|
1492
1583
|
children: [
|
|
1493
|
-
/* @__PURE__ */
|
|
1494
|
-
/* @__PURE__ */
|
|
1495
|
-
/* @__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: [
|
|
1496
1587
|
'Feature flag "',
|
|
1497
1588
|
i,
|
|
1498
1589
|
'" is disabled'
|
|
@@ -1500,9 +1591,9 @@ const Le = ({ flagName: i }) => /* @__PURE__ */ u(
|
|
|
1500
1591
|
]
|
|
1501
1592
|
}
|
|
1502
1593
|
);
|
|
1503
|
-
function
|
|
1504
|
-
const { isEnabled: r, loading:
|
|
1505
|
-
return
|
|
1594
|
+
function ht({ name: i, children: e, fallback: t }) {
|
|
1595
|
+
const { isEnabled: r, loading: n } = Ee();
|
|
1596
|
+
return n ? /* @__PURE__ */ s(
|
|
1506
1597
|
"div",
|
|
1507
1598
|
{
|
|
1508
1599
|
style: {
|
|
@@ -1515,9 +1606,9 @@ function lt({ name: i, children: e, fallback: t }) {
|
|
|
1515
1606
|
},
|
|
1516
1607
|
children: "Loading feature flags..."
|
|
1517
1608
|
}
|
|
1518
|
-
) : (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 }) }));
|
|
1519
1610
|
}
|
|
1520
|
-
const
|
|
1611
|
+
const qe = () => /* @__PURE__ */ c(
|
|
1521
1612
|
"svg",
|
|
1522
1613
|
{
|
|
1523
1614
|
width: "16",
|
|
@@ -1530,11 +1621,11 @@ const De = () => /* @__PURE__ */ u(
|
|
|
1530
1621
|
strokeLinejoin: "round",
|
|
1531
1622
|
style: { flexShrink: 0 },
|
|
1532
1623
|
children: [
|
|
1533
|
-
/* @__PURE__ */
|
|
1534
|
-
/* @__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" })
|
|
1535
1626
|
]
|
|
1536
1627
|
}
|
|
1537
|
-
),
|
|
1628
|
+
), Ue = () => /* @__PURE__ */ c(
|
|
1538
1629
|
"svg",
|
|
1539
1630
|
{
|
|
1540
1631
|
width: "16",
|
|
@@ -1547,14 +1638,14 @@ const De = () => /* @__PURE__ */ u(
|
|
|
1547
1638
|
strokeLinejoin: "round",
|
|
1548
1639
|
style: { flexShrink: 0 },
|
|
1549
1640
|
children: [
|
|
1550
|
-
/* @__PURE__ */
|
|
1551
|
-
/* @__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" })
|
|
1552
1643
|
]
|
|
1553
1644
|
}
|
|
1554
|
-
),
|
|
1555
|
-
showPassword: /* @__PURE__ */
|
|
1556
|
-
hidePassword: /* @__PURE__ */
|
|
1557
|
-
},
|
|
1645
|
+
), Ne = {
|
|
1646
|
+
showPassword: /* @__PURE__ */ s(qe, {}),
|
|
1647
|
+
hidePassword: /* @__PURE__ */ s(Ue, {})
|
|
1648
|
+
}, ze = {
|
|
1558
1649
|
title: "Sign In",
|
|
1559
1650
|
emailLabel: "Email",
|
|
1560
1651
|
emailPlaceholder: "Enter your email",
|
|
@@ -1566,7 +1657,7 @@ const De = () => /* @__PURE__ */ u(
|
|
|
1566
1657
|
signupText: "Don't have an account?",
|
|
1567
1658
|
errorMessage: "Invalid email or password",
|
|
1568
1659
|
loadingText: "Signing in..."
|
|
1569
|
-
},
|
|
1660
|
+
}, Oe = {
|
|
1570
1661
|
container: {
|
|
1571
1662
|
maxWidth: "400px",
|
|
1572
1663
|
width: "100%",
|
|
@@ -1673,71 +1764,71 @@ const De = () => /* @__PURE__ */ u(
|
|
|
1673
1764
|
fontSize: "0.875rem"
|
|
1674
1765
|
}
|
|
1675
1766
|
};
|
|
1676
|
-
function
|
|
1767
|
+
function gt({
|
|
1677
1768
|
copy: i = {},
|
|
1678
1769
|
styles: e = {},
|
|
1679
1770
|
icons: t = {},
|
|
1680
1771
|
onSuccess: r,
|
|
1681
|
-
onError:
|
|
1682
|
-
onForgotPassword:
|
|
1683
|
-
onSignupClick:
|
|
1684
|
-
showForgotPassword:
|
|
1685
|
-
showSignupLink:
|
|
1772
|
+
onError: n,
|
|
1773
|
+
onForgotPassword: o,
|
|
1774
|
+
onSignupClick: m,
|
|
1775
|
+
showForgotPassword: T = !0,
|
|
1776
|
+
showSignupLink: M = !0,
|
|
1686
1777
|
className: P
|
|
1687
1778
|
}) {
|
|
1688
|
-
const [
|
|
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 = () => {
|
|
1689
1780
|
const I = {};
|
|
1690
|
-
return
|
|
1691
|
-
},
|
|
1692
|
-
if (I.preventDefault(), !!
|
|
1781
|
+
return g.trim() || (I.email = !0), x.trim() || (I.password = !0), R(I), Object.keys(I).length === 0;
|
|
1782
|
+
}, a = async (I) => {
|
|
1783
|
+
if (I.preventDefault(), !!u()) {
|
|
1693
1784
|
if (!(E != null && E.id)) {
|
|
1694
|
-
|
|
1785
|
+
S("Tenant not found");
|
|
1695
1786
|
return;
|
|
1696
1787
|
}
|
|
1697
|
-
|
|
1788
|
+
L(!0), S("");
|
|
1698
1789
|
try {
|
|
1699
|
-
const N = await
|
|
1790
|
+
const N = await D(g, x, E.id);
|
|
1700
1791
|
r == null || r(N);
|
|
1701
1792
|
} catch (N) {
|
|
1702
|
-
const _ = N.message ||
|
|
1703
|
-
|
|
1793
|
+
const _ = N.message || B.errorMessage;
|
|
1794
|
+
S(_), n == null || n(_);
|
|
1704
1795
|
} finally {
|
|
1705
|
-
|
|
1796
|
+
L(!1);
|
|
1706
1797
|
}
|
|
1707
1798
|
}
|
|
1708
|
-
},
|
|
1709
|
-
...
|
|
1710
|
-
...
|
|
1799
|
+
}, l = (I) => ({
|
|
1800
|
+
...d.input,
|
|
1801
|
+
...k[I] ? d.inputError : {}
|
|
1711
1802
|
}), W = () => ({
|
|
1712
|
-
...
|
|
1713
|
-
...
|
|
1714
|
-
...!
|
|
1803
|
+
...d.button,
|
|
1804
|
+
...f ? d.buttonLoading : {},
|
|
1805
|
+
...!g || !x || f ? d.buttonDisabled : {}
|
|
1715
1806
|
});
|
|
1716
|
-
return /* @__PURE__ */
|
|
1717
|
-
/* @__PURE__ */
|
|
1718
|
-
/* @__PURE__ */
|
|
1719
|
-
/* @__PURE__ */
|
|
1720
|
-
/* @__PURE__ */
|
|
1721
|
-
/* @__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(
|
|
1722
1813
|
"input",
|
|
1723
1814
|
{
|
|
1724
1815
|
id: "email",
|
|
1725
1816
|
name: "email",
|
|
1726
1817
|
type: "email",
|
|
1727
|
-
value:
|
|
1818
|
+
value: g,
|
|
1728
1819
|
onChange: (I) => {
|
|
1729
|
-
|
|
1820
|
+
h(I.target.value), k.email && R((N) => ({ ...N, email: !1 }));
|
|
1730
1821
|
},
|
|
1731
|
-
placeholder:
|
|
1732
|
-
style:
|
|
1733
|
-
disabled:
|
|
1822
|
+
placeholder: B.emailPlaceholder,
|
|
1823
|
+
style: l("email"),
|
|
1824
|
+
disabled: f
|
|
1734
1825
|
}
|
|
1735
1826
|
)
|
|
1736
1827
|
] }),
|
|
1737
|
-
/* @__PURE__ */
|
|
1738
|
-
/* @__PURE__ */
|
|
1739
|
-
/* @__PURE__ */
|
|
1740
|
-
/* @__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(
|
|
1741
1832
|
"input",
|
|
1742
1833
|
{
|
|
1743
1834
|
id: "password",
|
|
@@ -1745,47 +1836,47 @@ function ct({
|
|
|
1745
1836
|
type: A ? "text" : "password",
|
|
1746
1837
|
value: x,
|
|
1747
1838
|
onChange: (I) => {
|
|
1748
|
-
|
|
1839
|
+
p(I.target.value), k.password && R((N) => ({ ...N, password: !1 }));
|
|
1749
1840
|
},
|
|
1750
|
-
placeholder:
|
|
1841
|
+
placeholder: B.passwordPlaceholder,
|
|
1751
1842
|
style: {
|
|
1752
|
-
...
|
|
1843
|
+
...l("password"),
|
|
1753
1844
|
paddingRight: "2.5rem"
|
|
1754
1845
|
// Make room for the icon
|
|
1755
1846
|
},
|
|
1756
|
-
disabled:
|
|
1847
|
+
disabled: f
|
|
1757
1848
|
}
|
|
1758
1849
|
),
|
|
1759
|
-
/* @__PURE__ */
|
|
1850
|
+
/* @__PURE__ */ s(
|
|
1760
1851
|
"button",
|
|
1761
1852
|
{
|
|
1762
1853
|
type: "button",
|
|
1763
1854
|
onClick: () => F(!A),
|
|
1764
|
-
style:
|
|
1765
|
-
disabled:
|
|
1855
|
+
style: d.passwordToggle,
|
|
1856
|
+
disabled: f,
|
|
1766
1857
|
"aria-label": A ? "Hide password" : "Show password",
|
|
1767
1858
|
children: A ? w.hidePassword : w.showPassword
|
|
1768
1859
|
}
|
|
1769
1860
|
)
|
|
1770
1861
|
] })
|
|
1771
1862
|
] }),
|
|
1772
|
-
/* @__PURE__ */
|
|
1773
|
-
|
|
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 })
|
|
1774
1865
|
] }),
|
|
1775
|
-
(
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
/* @__PURE__ */
|
|
1780
|
-
|
|
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,
|
|
1781
1872
|
" "
|
|
1782
1873
|
] }),
|
|
1783
|
-
/* @__PURE__ */
|
|
1874
|
+
/* @__PURE__ */ s("a", { onClick: m, style: d.link, children: B.signupLink })
|
|
1784
1875
|
] })
|
|
1785
1876
|
] })
|
|
1786
1877
|
] });
|
|
1787
1878
|
}
|
|
1788
|
-
const
|
|
1879
|
+
const je = {
|
|
1789
1880
|
title: "Create Account",
|
|
1790
1881
|
nameLabel: "Full Name",
|
|
1791
1882
|
namePlaceholder: "Enter your full name",
|
|
@@ -1805,7 +1896,7 @@ const Oe = {
|
|
|
1805
1896
|
passwordMismatchError: "Passwords do not match",
|
|
1806
1897
|
isAdminLabel: "Create new organization",
|
|
1807
1898
|
isAdminDescription: "Check this if you want to create a new organization"
|
|
1808
|
-
},
|
|
1899
|
+
}, Ve = {
|
|
1809
1900
|
container: {
|
|
1810
1901
|
maxWidth: "400px",
|
|
1811
1902
|
width: "100%",
|
|
@@ -1904,154 +1995,154 @@ const Oe = {
|
|
|
1904
1995
|
fontSize: "0.875rem"
|
|
1905
1996
|
}
|
|
1906
1997
|
};
|
|
1907
|
-
function
|
|
1998
|
+
function pt({
|
|
1908
1999
|
copy: i = {},
|
|
1909
2000
|
styles: e = {},
|
|
1910
2001
|
signupType: t = "user",
|
|
1911
2002
|
onSuccess: r,
|
|
1912
|
-
onError:
|
|
1913
|
-
onLoginClick:
|
|
1914
|
-
showLoginLink:
|
|
1915
|
-
className:
|
|
2003
|
+
onError: n,
|
|
2004
|
+
onLoginClick: o,
|
|
2005
|
+
showLoginLink: m = !0,
|
|
2006
|
+
className: T
|
|
1916
2007
|
}) {
|
|
1917
|
-
const [
|
|
1918
|
-
const
|
|
1919
|
-
return
|
|
1920
|
-
}, W = async (
|
|
1921
|
-
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()) {
|
|
1922
2013
|
if (x !== A) {
|
|
1923
|
-
R(
|
|
2014
|
+
R(u.passwordMismatchError), E({ confirmPassword: !0 });
|
|
1924
2015
|
return;
|
|
1925
2016
|
}
|
|
1926
2017
|
if (t === "user" && !(w != null && w.id)) {
|
|
1927
2018
|
R("Tenant not found");
|
|
1928
2019
|
return;
|
|
1929
2020
|
}
|
|
1930
|
-
|
|
2021
|
+
S(!0), R("");
|
|
1931
2022
|
try {
|
|
1932
|
-
let
|
|
1933
|
-
t === "tenant" ?
|
|
1934
|
-
} catch (
|
|
1935
|
-
const
|
|
1936
|
-
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);
|
|
1937
2028
|
} finally {
|
|
1938
|
-
|
|
2029
|
+
S(!1);
|
|
1939
2030
|
}
|
|
1940
2031
|
}
|
|
1941
|
-
}, I = (
|
|
1942
|
-
...
|
|
1943
|
-
...
|
|
2032
|
+
}, I = (C) => ({
|
|
2033
|
+
...a.input,
|
|
2034
|
+
...D[C] ? a.inputError : {}
|
|
1944
2035
|
}), N = () => ({
|
|
1945
|
-
...
|
|
1946
|
-
...
|
|
1947
|
-
...!
|
|
1948
|
-
}), _ =
|
|
1949
|
-
return /* @__PURE__ */
|
|
1950
|
-
/* @__PURE__ */
|
|
1951
|
-
/* @__PURE__ */
|
|
1952
|
-
/* @__PURE__ */
|
|
1953
|
-
/* @__PURE__ */
|
|
1954
|
-
/* @__PURE__ */
|
|
2036
|
+
...a.button,
|
|
2037
|
+
...y ? a.buttonLoading : {},
|
|
2038
|
+
...!M || !g || !x || !A || y || t === "tenant" && !f ? a.buttonDisabled : {}
|
|
2039
|
+
}), _ = M && g && x && A && (t === "user" || f);
|
|
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(
|
|
1955
2046
|
"input",
|
|
1956
2047
|
{
|
|
1957
2048
|
id: "name",
|
|
1958
2049
|
name: "name",
|
|
1959
2050
|
type: "text",
|
|
1960
|
-
value:
|
|
1961
|
-
onChange: (
|
|
1962
|
-
P(
|
|
2051
|
+
value: M,
|
|
2052
|
+
onChange: (C) => {
|
|
2053
|
+
P(C.target.value), D.name && E((U) => ({ ...U, name: !1 }));
|
|
1963
2054
|
},
|
|
1964
|
-
placeholder:
|
|
2055
|
+
placeholder: u.namePlaceholder,
|
|
1965
2056
|
style: I("name"),
|
|
1966
|
-
disabled:
|
|
2057
|
+
disabled: y
|
|
1967
2058
|
}
|
|
1968
2059
|
)
|
|
1969
2060
|
] }),
|
|
1970
|
-
/* @__PURE__ */
|
|
1971
|
-
/* @__PURE__ */
|
|
1972
|
-
/* @__PURE__ */
|
|
2061
|
+
/* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
|
|
2062
|
+
/* @__PURE__ */ s("label", { style: a.label, children: u.emailLabel }),
|
|
2063
|
+
/* @__PURE__ */ s(
|
|
1973
2064
|
"input",
|
|
1974
2065
|
{
|
|
1975
2066
|
id: "email",
|
|
1976
2067
|
name: "email",
|
|
1977
2068
|
type: "email",
|
|
1978
|
-
value:
|
|
1979
|
-
onChange: (
|
|
1980
|
-
|
|
2069
|
+
value: g,
|
|
2070
|
+
onChange: (C) => {
|
|
2071
|
+
h(C.target.value), D.email && E((U) => ({ ...U, email: !1 }));
|
|
1981
2072
|
},
|
|
1982
|
-
placeholder:
|
|
2073
|
+
placeholder: u.emailPlaceholder,
|
|
1983
2074
|
style: I("email"),
|
|
1984
|
-
disabled:
|
|
2075
|
+
disabled: y
|
|
1985
2076
|
}
|
|
1986
2077
|
)
|
|
1987
2078
|
] }),
|
|
1988
|
-
/* @__PURE__ */
|
|
1989
|
-
/* @__PURE__ */
|
|
1990
|
-
/* @__PURE__ */
|
|
2079
|
+
/* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
|
|
2080
|
+
/* @__PURE__ */ s("label", { style: a.label, children: u.passwordLabel }),
|
|
2081
|
+
/* @__PURE__ */ s(
|
|
1991
2082
|
"input",
|
|
1992
2083
|
{
|
|
1993
2084
|
id: "password",
|
|
1994
2085
|
name: "password",
|
|
1995
2086
|
type: "password",
|
|
1996
2087
|
value: x,
|
|
1997
|
-
onChange: (
|
|
1998
|
-
|
|
2088
|
+
onChange: (C) => {
|
|
2089
|
+
p(C.target.value), D.password && E((U) => ({ ...U, password: !1 }));
|
|
1999
2090
|
},
|
|
2000
|
-
placeholder:
|
|
2091
|
+
placeholder: u.passwordPlaceholder,
|
|
2001
2092
|
style: I("password"),
|
|
2002
|
-
disabled:
|
|
2093
|
+
disabled: y
|
|
2003
2094
|
}
|
|
2004
2095
|
)
|
|
2005
2096
|
] }),
|
|
2006
|
-
/* @__PURE__ */
|
|
2007
|
-
/* @__PURE__ */
|
|
2008
|
-
/* @__PURE__ */
|
|
2097
|
+
/* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
|
|
2098
|
+
/* @__PURE__ */ s("label", { style: a.label, children: u.confirmPasswordLabel }),
|
|
2099
|
+
/* @__PURE__ */ s(
|
|
2009
2100
|
"input",
|
|
2010
2101
|
{
|
|
2011
2102
|
id: "confirmPassword",
|
|
2012
2103
|
name: "confirmPassword",
|
|
2013
2104
|
type: "password",
|
|
2014
2105
|
value: A,
|
|
2015
|
-
onChange: (
|
|
2016
|
-
F(
|
|
2106
|
+
onChange: (C) => {
|
|
2107
|
+
F(C.target.value), D.confirmPassword && E((U) => ({ ...U, confirmPassword: !1 })), k === u.passwordMismatchError && R("");
|
|
2017
2108
|
},
|
|
2018
|
-
placeholder:
|
|
2109
|
+
placeholder: u.confirmPasswordPlaceholder,
|
|
2019
2110
|
style: I("confirmPassword"),
|
|
2020
|
-
disabled:
|
|
2111
|
+
disabled: y
|
|
2021
2112
|
}
|
|
2022
2113
|
)
|
|
2023
2114
|
] }),
|
|
2024
|
-
t === "tenant" && /* @__PURE__ */
|
|
2025
|
-
/* @__PURE__ */
|
|
2026
|
-
/* @__PURE__ */
|
|
2115
|
+
t === "tenant" && /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
|
|
2116
|
+
/* @__PURE__ */ s("label", { style: a.label, children: u.tenantNameLabel }),
|
|
2117
|
+
/* @__PURE__ */ s(
|
|
2027
2118
|
"input",
|
|
2028
2119
|
{
|
|
2029
2120
|
id: "tenantName",
|
|
2030
2121
|
name: "tenantName",
|
|
2031
2122
|
type: "text",
|
|
2032
|
-
value:
|
|
2033
|
-
onChange: (
|
|
2034
|
-
C
|
|
2123
|
+
value: f,
|
|
2124
|
+
onChange: (C) => {
|
|
2125
|
+
L(C.target.value), D.tenantName && E((U) => ({ ...U, tenantName: !1 }));
|
|
2035
2126
|
},
|
|
2036
|
-
placeholder:
|
|
2127
|
+
placeholder: u.tenantNamePlaceholder,
|
|
2037
2128
|
style: I("tenantName"),
|
|
2038
|
-
disabled:
|
|
2129
|
+
disabled: y
|
|
2039
2130
|
}
|
|
2040
2131
|
)
|
|
2041
2132
|
] }),
|
|
2042
|
-
/* @__PURE__ */
|
|
2043
|
-
|
|
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 })
|
|
2044
2135
|
] }),
|
|
2045
|
-
|
|
2046
|
-
/* @__PURE__ */
|
|
2047
|
-
|
|
2136
|
+
m && /* @__PURE__ */ c("div", { style: a.linkContainer, children: [
|
|
2137
|
+
/* @__PURE__ */ c("span", { style: a.divider, children: [
|
|
2138
|
+
u.loginText,
|
|
2048
2139
|
" "
|
|
2049
2140
|
] }),
|
|
2050
|
-
/* @__PURE__ */
|
|
2141
|
+
/* @__PURE__ */ s("a", { onClick: o, style: a.link, children: u.loginLink })
|
|
2051
2142
|
] })
|
|
2052
2143
|
] });
|
|
2053
2144
|
}
|
|
2054
|
-
const
|
|
2145
|
+
const We = {
|
|
2055
2146
|
title: "Reset Password",
|
|
2056
2147
|
subtitle: "Enter your email address and we'll send you a link to reset your password.",
|
|
2057
2148
|
emailLabel: "Email",
|
|
@@ -2073,7 +2164,7 @@ const je = {
|
|
|
2073
2164
|
resetLoadingText: "Resetting...",
|
|
2074
2165
|
resetSuccessMessage: "Password reset successfully!",
|
|
2075
2166
|
passwordMismatchError: "Passwords do not match"
|
|
2076
|
-
},
|
|
2167
|
+
}, Ge = {
|
|
2077
2168
|
container: {
|
|
2078
2169
|
maxWidth: "400px",
|
|
2079
2170
|
margin: "0 auto",
|
|
@@ -2165,186 +2256,186 @@ const je = {
|
|
|
2165
2256
|
cursor: "pointer"
|
|
2166
2257
|
}
|
|
2167
2258
|
};
|
|
2168
|
-
function
|
|
2259
|
+
function ft({
|
|
2169
2260
|
copy: i = {},
|
|
2170
2261
|
styles: e = {},
|
|
2171
2262
|
mode: t = "request",
|
|
2172
2263
|
token: r = "",
|
|
2173
|
-
onSuccess:
|
|
2174
|
-
onError:
|
|
2175
|
-
onBackToLogin:
|
|
2176
|
-
onModeChange:
|
|
2177
|
-
className:
|
|
2264
|
+
onSuccess: n,
|
|
2265
|
+
onError: o,
|
|
2266
|
+
onBackToLogin: m,
|
|
2267
|
+
onModeChange: T,
|
|
2268
|
+
className: M
|
|
2178
2269
|
}) {
|
|
2179
|
-
const [P,
|
|
2180
|
-
const
|
|
2181
|
-
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;
|
|
2182
2273
|
}, I = () => {
|
|
2183
|
-
const
|
|
2184
|
-
return
|
|
2185
|
-
}, N = async (
|
|
2186
|
-
if (
|
|
2187
|
-
if (!(
|
|
2188
|
-
|
|
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)) {
|
|
2279
|
+
k("Tenant not found");
|
|
2189
2280
|
return;
|
|
2190
2281
|
}
|
|
2191
|
-
|
|
2282
|
+
y(!0), k(""), D("");
|
|
2192
2283
|
try {
|
|
2193
|
-
await
|
|
2194
|
-
} catch (
|
|
2195
|
-
const j =
|
|
2196
|
-
|
|
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);
|
|
2197
2288
|
} finally {
|
|
2198
|
-
|
|
2289
|
+
y(!1);
|
|
2199
2290
|
}
|
|
2200
2291
|
}
|
|
2201
|
-
}, _ = async (
|
|
2202
|
-
if (
|
|
2203
|
-
if (
|
|
2204
|
-
|
|
2292
|
+
}, _ = async (q) => {
|
|
2293
|
+
if (q.preventDefault(), !!I()) {
|
|
2294
|
+
if (p !== F) {
|
|
2295
|
+
k(a.passwordMismatchError), B({ confirmPassword: !0 });
|
|
2205
2296
|
return;
|
|
2206
2297
|
}
|
|
2207
|
-
|
|
2298
|
+
y(!0), k(""), D("");
|
|
2208
2299
|
try {
|
|
2209
|
-
await w(
|
|
2210
|
-
} catch (
|
|
2211
|
-
const j =
|
|
2212
|
-
|
|
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);
|
|
2213
2304
|
} finally {
|
|
2214
|
-
|
|
2305
|
+
y(!1);
|
|
2215
2306
|
}
|
|
2216
2307
|
}
|
|
2217
|
-
},
|
|
2218
|
-
...
|
|
2219
|
-
...E[
|
|
2220
|
-
}),
|
|
2221
|
-
...
|
|
2222
|
-
...
|
|
2308
|
+
}, C = (q) => ({
|
|
2309
|
+
...l.input,
|
|
2310
|
+
...E[q] ? l.inputError : {}
|
|
2311
|
+
}), U = () => ({
|
|
2312
|
+
...l.button,
|
|
2313
|
+
...L ? l.buttonLoading : {}
|
|
2223
2314
|
});
|
|
2224
2315
|
if (t === "reset") {
|
|
2225
|
-
const
|
|
2226
|
-
return /* @__PURE__ */
|
|
2227
|
-
/* @__PURE__ */
|
|
2228
|
-
/* @__PURE__ */
|
|
2229
|
-
/* @__PURE__ */
|
|
2230
|
-
/* @__PURE__ */
|
|
2231
|
-
/* @__PURE__ */
|
|
2232
|
-
/* @__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(
|
|
2233
2324
|
"input",
|
|
2234
2325
|
{
|
|
2235
2326
|
type: "text",
|
|
2236
|
-
value:
|
|
2237
|
-
onChange: (
|
|
2238
|
-
x(
|
|
2327
|
+
value: h,
|
|
2328
|
+
onChange: (O) => {
|
|
2329
|
+
x(O.target.value), E.token && B((j) => ({ ...j, token: !1 }));
|
|
2239
2330
|
},
|
|
2240
|
-
placeholder:
|
|
2241
|
-
style:
|
|
2242
|
-
disabled:
|
|
2331
|
+
placeholder: a.tokenPlaceholder,
|
|
2332
|
+
style: C("token"),
|
|
2333
|
+
disabled: L
|
|
2243
2334
|
}
|
|
2244
2335
|
)
|
|
2245
2336
|
] }),
|
|
2246
|
-
/* @__PURE__ */
|
|
2247
|
-
/* @__PURE__ */
|
|
2248
|
-
/* @__PURE__ */
|
|
2337
|
+
/* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
|
|
2338
|
+
/* @__PURE__ */ s("label", { style: l.label, children: a.newPasswordLabel }),
|
|
2339
|
+
/* @__PURE__ */ s(
|
|
2249
2340
|
"input",
|
|
2250
2341
|
{
|
|
2251
2342
|
type: "password",
|
|
2252
|
-
value:
|
|
2253
|
-
onChange: (
|
|
2254
|
-
A(
|
|
2343
|
+
value: p,
|
|
2344
|
+
onChange: (O) => {
|
|
2345
|
+
A(O.target.value), E.newPassword && B((j) => ({ ...j, newPassword: !1 }));
|
|
2255
2346
|
},
|
|
2256
|
-
placeholder:
|
|
2257
|
-
style:
|
|
2258
|
-
disabled:
|
|
2347
|
+
placeholder: a.newPasswordPlaceholder,
|
|
2348
|
+
style: C("newPassword"),
|
|
2349
|
+
disabled: L
|
|
2259
2350
|
}
|
|
2260
2351
|
)
|
|
2261
2352
|
] }),
|
|
2262
|
-
/* @__PURE__ */
|
|
2263
|
-
/* @__PURE__ */
|
|
2264
|
-
/* @__PURE__ */
|
|
2353
|
+
/* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
|
|
2354
|
+
/* @__PURE__ */ s("label", { style: l.label, children: a.confirmPasswordLabel }),
|
|
2355
|
+
/* @__PURE__ */ s(
|
|
2265
2356
|
"input",
|
|
2266
2357
|
{
|
|
2267
2358
|
type: "password",
|
|
2268
2359
|
value: F,
|
|
2269
|
-
onChange: (
|
|
2270
|
-
|
|
2360
|
+
onChange: (O) => {
|
|
2361
|
+
f(O.target.value), E.confirmPassword && B((j) => ({ ...j, confirmPassword: !1 })), S === a.passwordMismatchError && k("");
|
|
2271
2362
|
},
|
|
2272
|
-
placeholder:
|
|
2273
|
-
style:
|
|
2274
|
-
disabled:
|
|
2363
|
+
placeholder: a.confirmPasswordPlaceholder,
|
|
2364
|
+
style: C("confirmPassword"),
|
|
2365
|
+
disabled: L
|
|
2275
2366
|
}
|
|
2276
2367
|
)
|
|
2277
2368
|
] }),
|
|
2278
|
-
/* @__PURE__ */
|
|
2369
|
+
/* @__PURE__ */ s(
|
|
2279
2370
|
"button",
|
|
2280
2371
|
{
|
|
2281
2372
|
type: "submit",
|
|
2282
|
-
disabled: !
|
|
2373
|
+
disabled: !q || L,
|
|
2283
2374
|
style: {
|
|
2284
|
-
...
|
|
2285
|
-
...!
|
|
2375
|
+
...U(),
|
|
2376
|
+
...!q || L ? l.buttonDisabled : {}
|
|
2286
2377
|
},
|
|
2287
|
-
children:
|
|
2378
|
+
children: L ? a.resetLoadingText : a.resetSubmitButton
|
|
2288
2379
|
}
|
|
2289
2380
|
),
|
|
2290
|
-
|
|
2291
|
-
R && /* @__PURE__ */
|
|
2381
|
+
S && /* @__PURE__ */ s("div", { style: l.errorText, children: S }),
|
|
2382
|
+
R && /* @__PURE__ */ s("div", { style: l.successText, children: R })
|
|
2292
2383
|
] }),
|
|
2293
|
-
/* @__PURE__ */
|
|
2294
|
-
/* @__PURE__ */
|
|
2295
|
-
|
|
2296
|
-
/* @__PURE__ */
|
|
2297
|
-
/* @__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" })
|
|
2298
2389
|
] })
|
|
2299
2390
|
] })
|
|
2300
2391
|
] });
|
|
2301
2392
|
}
|
|
2302
|
-
const
|
|
2303
|
-
return /* @__PURE__ */
|
|
2304
|
-
/* @__PURE__ */
|
|
2305
|
-
/* @__PURE__ */
|
|
2306
|
-
/* @__PURE__ */
|
|
2307
|
-
/* @__PURE__ */
|
|
2308
|
-
/* @__PURE__ */
|
|
2309
|
-
/* @__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(
|
|
2310
2401
|
"input",
|
|
2311
2402
|
{
|
|
2312
2403
|
type: "email",
|
|
2313
2404
|
value: P,
|
|
2314
|
-
onChange: (
|
|
2315
|
-
|
|
2405
|
+
onChange: (q) => {
|
|
2406
|
+
g(q.target.value), E.email && B((O) => ({ ...O, email: !1 }));
|
|
2316
2407
|
},
|
|
2317
|
-
placeholder:
|
|
2318
|
-
style:
|
|
2319
|
-
disabled:
|
|
2408
|
+
placeholder: a.emailPlaceholder,
|
|
2409
|
+
style: C("email"),
|
|
2410
|
+
disabled: L
|
|
2320
2411
|
}
|
|
2321
2412
|
)
|
|
2322
2413
|
] }),
|
|
2323
|
-
/* @__PURE__ */
|
|
2414
|
+
/* @__PURE__ */ s(
|
|
2324
2415
|
"button",
|
|
2325
2416
|
{
|
|
2326
2417
|
type: "submit",
|
|
2327
|
-
disabled: !
|
|
2418
|
+
disabled: !Q || L,
|
|
2328
2419
|
style: {
|
|
2329
|
-
...
|
|
2330
|
-
...!
|
|
2420
|
+
...U(),
|
|
2421
|
+
...!Q || L ? l.buttonDisabled : {}
|
|
2331
2422
|
},
|
|
2332
|
-
children:
|
|
2423
|
+
children: L ? a.loadingText : a.submitButton
|
|
2333
2424
|
}
|
|
2334
2425
|
),
|
|
2335
|
-
|
|
2336
|
-
R && /* @__PURE__ */
|
|
2426
|
+
S && /* @__PURE__ */ s("div", { style: l.errorText, children: S }),
|
|
2427
|
+
R && /* @__PURE__ */ s("div", { style: l.successText, children: R })
|
|
2337
2428
|
] }),
|
|
2338
|
-
/* @__PURE__ */
|
|
2339
|
-
/* @__PURE__ */
|
|
2340
|
-
|
|
2341
|
-
/* @__PURE__ */
|
|
2342
|
-
/* @__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" })
|
|
2343
2434
|
] })
|
|
2344
2435
|
] })
|
|
2345
2436
|
] });
|
|
2346
2437
|
}
|
|
2347
|
-
class
|
|
2438
|
+
class yt {
|
|
2348
2439
|
constructor(e, t) {
|
|
2349
2440
|
this.httpService = e, this.sessionManager = t;
|
|
2350
2441
|
}
|
|
@@ -2365,12 +2456,12 @@ class ht {
|
|
|
2365
2456
|
throw new Error("SessionManager is required for private endpoints");
|
|
2366
2457
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
2367
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);
|
|
2368
|
-
const
|
|
2459
|
+
const n = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
|
|
2369
2460
|
headers: t
|
|
2370
2461
|
});
|
|
2371
2462
|
return {
|
|
2372
|
-
permissions:
|
|
2373
|
-
meta:
|
|
2463
|
+
permissions: o.data,
|
|
2464
|
+
meta: o.meta
|
|
2374
2465
|
};
|
|
2375
2466
|
}
|
|
2376
2467
|
async getPermissionById(e) {
|
|
@@ -2405,14 +2496,14 @@ class ht {
|
|
|
2405
2496
|
async getAppPermissions(e, t) {
|
|
2406
2497
|
const r = new URLSearchParams();
|
|
2407
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);
|
|
2408
|
-
const
|
|
2499
|
+
const n = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n);
|
|
2409
2500
|
return {
|
|
2410
|
-
permissions:
|
|
2411
|
-
meta:
|
|
2501
|
+
permissions: o.data,
|
|
2502
|
+
meta: o.meta
|
|
2412
2503
|
};
|
|
2413
2504
|
}
|
|
2414
2505
|
}
|
|
2415
|
-
class
|
|
2506
|
+
class wt {
|
|
2416
2507
|
constructor(e, t) {
|
|
2417
2508
|
this.httpService = e, this.sessionManager = t;
|
|
2418
2509
|
}
|
|
@@ -2429,12 +2520,12 @@ class gt {
|
|
|
2429
2520
|
async getSubscriptionPlans(e) {
|
|
2430
2521
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
2431
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);
|
|
2432
|
-
const
|
|
2523
|
+
const n = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
|
|
2433
2524
|
headers: t
|
|
2434
2525
|
});
|
|
2435
2526
|
return {
|
|
2436
|
-
plans:
|
|
2437
|
-
meta:
|
|
2527
|
+
plans: o.data,
|
|
2528
|
+
meta: o.meta
|
|
2438
2529
|
};
|
|
2439
2530
|
}
|
|
2440
2531
|
async getSubscriptionPlanById(e) {
|
|
@@ -2463,7 +2554,7 @@ class gt {
|
|
|
2463
2554
|
});
|
|
2464
2555
|
}
|
|
2465
2556
|
}
|
|
2466
|
-
class
|
|
2557
|
+
class mt {
|
|
2467
2558
|
constructor(e) {
|
|
2468
2559
|
this.httpService = e;
|
|
2469
2560
|
}
|
|
@@ -2472,7 +2563,7 @@ class pt {
|
|
|
2472
2563
|
return await this.httpService.get("/health");
|
|
2473
2564
|
}
|
|
2474
2565
|
}
|
|
2475
|
-
class
|
|
2566
|
+
class bt {
|
|
2476
2567
|
// Date string to Date object
|
|
2477
2568
|
static toDate(e) {
|
|
2478
2569
|
return new Date(e);
|
|
@@ -2589,46 +2680,48 @@ class ft {
|
|
|
2589
2680
|
// Transform query parameters for API calls
|
|
2590
2681
|
static transformQueryParams(e) {
|
|
2591
2682
|
const t = new URLSearchParams();
|
|
2592
|
-
return Object.entries(e).forEach(([r,
|
|
2593
|
-
|
|
2683
|
+
return Object.entries(e).forEach(([r, n]) => {
|
|
2684
|
+
n != null && n !== "" && t.append(r, String(n));
|
|
2594
2685
|
}), t;
|
|
2595
2686
|
}
|
|
2596
2687
|
}
|
|
2597
2688
|
export {
|
|
2598
|
-
|
|
2689
|
+
bt as ApiMappers,
|
|
2599
2690
|
be as AppApiService,
|
|
2600
|
-
|
|
2691
|
+
Ze as AppProvider,
|
|
2601
2692
|
Ae as AuthApiService,
|
|
2602
|
-
|
|
2603
|
-
|
|
2693
|
+
nt as AuthProvider,
|
|
2694
|
+
ht as FeatureFlag,
|
|
2604
2695
|
Me as FeatureFlagApiService,
|
|
2605
|
-
|
|
2606
|
-
|
|
2696
|
+
it as FeatureFlagProvider,
|
|
2697
|
+
mt as HealthApiService,
|
|
2607
2698
|
G as HttpService,
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
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,
|
|
2614
2706
|
xe as SessionManager,
|
|
2615
|
-
|
|
2707
|
+
pt as SignupForm,
|
|
2616
2708
|
Re as SubscriptionApiService,
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2709
|
+
ut as SubscriptionGuard,
|
|
2710
|
+
wt as SubscriptionPlanApiService,
|
|
2711
|
+
ot as SubscriptionProvider,
|
|
2712
|
+
de as TenantApiService,
|
|
2713
|
+
tt as TenantProvider,
|
|
2714
|
+
ct as TenantRoute,
|
|
2622
2715
|
Pe as UserApiService,
|
|
2623
|
-
|
|
2624
|
-
|
|
2716
|
+
X as UserType,
|
|
2717
|
+
et as useApi,
|
|
2625
2718
|
re as useApp,
|
|
2626
2719
|
se as useAuth,
|
|
2627
2720
|
Ee as useFeatureFlags,
|
|
2628
|
-
|
|
2721
|
+
st as useSettings,
|
|
2629
2722
|
Fe as useSubscription,
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2723
|
+
le as useTenant,
|
|
2724
|
+
K as useTenantInfo,
|
|
2725
|
+
rt as useTenantSettings
|
|
2633
2726
|
};
|
|
2634
2727
|
//# sourceMappingURL=index.es.js.map
|