@famgia/omnify-react-sso 2.2.1 → 2.2.3
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/README.md +404 -113
- package/dist/@omnify-base/schemas/Branch.ts +12 -12
- package/dist/@omnify-base/schemas/BranchCache.ts +131 -0
- package/dist/@omnify-base/schemas/OrganizationCache.ts +117 -0
- package/dist/@omnify-base/schemas/Permission.ts +10 -10
- package/dist/@omnify-base/schemas/Role.ts +19 -12
- package/dist/@omnify-base/schemas/RolePermission.ts +6 -6
- package/dist/@omnify-base/schemas/Team.ts +6 -6
- package/dist/@omnify-base/schemas/TeamCache.ts +110 -0
- package/dist/@omnify-base/schemas/TeamPermission.ts +6 -6
- package/dist/@omnify-base/schemas/User.ts +13 -13
- package/dist/@omnify-base/schemas/UserCache.ts +142 -0
- package/dist/index.cjs +1846 -427
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +623 -14
- package/dist/index.d.ts +623 -14
- package/dist/index.js +1790 -400
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.cjs +245 -167
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +67 -28
- package/dist/schemas/index.d.ts +67 -28
- package/dist/schemas/index.js +217 -146
- package/dist/schemas/index.js.map +1 -1
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/{types-BCBSfJJr.d.cts → types-bD5deLxs.d.cts} +102 -1
- package/dist/{types-BCBSfJJr.d.ts → types-bD5deLxs.d.ts} +102 -1
- package/package.json +121 -106
- package/scripts/build-schemas.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -30,16 +30,26 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
BRANCH_HEADERS: () => BRANCH_HEADERS,
|
|
34
|
+
BranchContext: () => BranchContext,
|
|
35
|
+
BranchGate: () => BranchGate,
|
|
36
|
+
BranchProvider: () => BranchProvider,
|
|
37
|
+
I18nProvider: () => I18nProvider,
|
|
38
|
+
OrgBranchSelectorModal: () => OrgBranchSelectorModal,
|
|
33
39
|
OrganizationSwitcher: () => OrganizationSwitcher,
|
|
34
40
|
ProtectedRoute: () => ProtectedRoute,
|
|
35
41
|
SsoCallback: () => SsoCallback,
|
|
36
42
|
SsoContext: () => SsoContext,
|
|
37
43
|
SsoProvider: () => SsoProvider,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
UserForm: () => UserForm,
|
|
45
|
+
UserTable: () => UserTable,
|
|
46
|
+
branchCacheCreateSchema: () => branchCacheCreateSchema,
|
|
47
|
+
branchCacheI18n: () => branchCacheI18n,
|
|
48
|
+
branchCacheSchemas: () => branchCacheSchemas,
|
|
49
|
+
branchCacheUpdateSchema: () => branchCacheUpdateSchema,
|
|
50
|
+
changeLanguage: () => changeLanguage,
|
|
42
51
|
createAuthService: () => createAuthService,
|
|
52
|
+
createBranchHeaderSetter: () => createBranchHeaderSetter,
|
|
43
53
|
createBranchService: () => createBranchService,
|
|
44
54
|
createPermissionService: () => createPermissionService,
|
|
45
55
|
createRoleService: () => createRoleService,
|
|
@@ -47,14 +57,20 @@ __export(src_exports, {
|
|
|
47
57
|
createTeamService: () => createTeamService,
|
|
48
58
|
createTokenService: () => createTokenService,
|
|
49
59
|
createUserRoleService: () => createUserRoleService,
|
|
50
|
-
|
|
60
|
+
createUserService: () => createUserService,
|
|
61
|
+
defaultLocale: () => defaultLocale2,
|
|
62
|
+
defaultTranslations: () => defaultTranslations,
|
|
51
63
|
fallbackLocale: () => fallbackLocale,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
getBranchCacheFieldLabel: () => getBranchCacheFieldLabel,
|
|
65
|
+
getBranchCacheFieldPlaceholder: () => getBranchCacheFieldPlaceholder,
|
|
66
|
+
getBranchCacheLabel: () => getBranchCacheLabel,
|
|
67
|
+
getCurrentLocale: () => getCurrentLocale,
|
|
55
68
|
getEffectivePermissions: () => getEffectivePermissions,
|
|
56
69
|
getMessage: () => getMessage,
|
|
57
70
|
getMessages: () => getMessages,
|
|
71
|
+
getOrganizationCacheFieldLabel: () => getOrganizationCacheFieldLabel,
|
|
72
|
+
getOrganizationCacheFieldPlaceholder: () => getOrganizationCacheFieldPlaceholder,
|
|
73
|
+
getOrganizationCacheLabel: () => getOrganizationCacheLabel,
|
|
58
74
|
getPermissionFieldLabel: () => getPermissionFieldLabel,
|
|
59
75
|
getPermissionFieldPlaceholder: () => getPermissionFieldPlaceholder,
|
|
60
76
|
getPermissionLabel: () => getPermissionLabel,
|
|
@@ -65,15 +81,21 @@ __export(src_exports, {
|
|
|
65
81
|
getRolePermissionFieldPlaceholder: () => getRolePermissionFieldPlaceholder,
|
|
66
82
|
getRolePermissionLabel: () => getRolePermissionLabel,
|
|
67
83
|
getScopeLabel: () => getScopeLabel,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
84
|
+
getTeamCacheFieldLabel: () => getTeamCacheFieldLabel,
|
|
85
|
+
getTeamCacheFieldPlaceholder: () => getTeamCacheFieldPlaceholder,
|
|
86
|
+
getTeamCacheLabel: () => getTeamCacheLabel,
|
|
71
87
|
getTeamPermissionFieldLabel: () => getTeamPermissionFieldLabel,
|
|
72
88
|
getTeamPermissionFieldPlaceholder: () => getTeamPermissionFieldPlaceholder,
|
|
73
89
|
getTeamPermissionLabel: () => getTeamPermissionLabel,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
90
|
+
getUserCacheFieldLabel: () => getUserCacheFieldLabel,
|
|
91
|
+
getUserCacheFieldPlaceholder: () => getUserCacheFieldPlaceholder,
|
|
92
|
+
getUserCacheLabel: () => getUserCacheLabel,
|
|
93
|
+
localeNames: () => localeNames,
|
|
94
|
+
locales: () => locales,
|
|
95
|
+
organizationCacheCreateSchema: () => organizationCacheCreateSchema,
|
|
96
|
+
organizationCacheI18n: () => organizationCacheI18n,
|
|
97
|
+
organizationCacheSchemas: () => organizationCacheSchemas,
|
|
98
|
+
organizationCacheUpdateSchema: () => organizationCacheUpdateSchema,
|
|
77
99
|
permissionCreateSchema: () => permissionCreateSchema,
|
|
78
100
|
permissionI18n: () => permissionI18n,
|
|
79
101
|
permissionSchemas: () => permissionSchemas,
|
|
@@ -86,23 +108,30 @@ __export(src_exports, {
|
|
|
86
108
|
rolePermissionUpdateSchema: () => rolePermissionUpdateSchema,
|
|
87
109
|
roleSchemas: () => roleSchemas,
|
|
88
110
|
roleUpdateSchema: () => roleUpdateSchema,
|
|
111
|
+
setBranchHeaders: () => setBranchHeaders,
|
|
112
|
+
ssoNamespace: () => ssoNamespace,
|
|
89
113
|
ssoQueryKeys: () => ssoQueryKeys,
|
|
90
114
|
supportedLocales: () => supportedLocales,
|
|
91
|
-
|
|
92
|
-
|
|
115
|
+
teamCacheCreateSchema: () => teamCacheCreateSchema,
|
|
116
|
+
teamCacheI18n: () => teamCacheI18n,
|
|
117
|
+
teamCacheSchemas: () => teamCacheSchemas,
|
|
118
|
+
teamCacheUpdateSchema: () => teamCacheUpdateSchema,
|
|
93
119
|
teamPermissionCreateSchema: () => teamPermissionCreateSchema,
|
|
94
120
|
teamPermissionI18n: () => teamPermissionI18n,
|
|
95
121
|
teamPermissionSchemas: () => teamPermissionSchemas,
|
|
96
122
|
teamPermissionUpdateSchema: () => teamPermissionUpdateSchema,
|
|
97
|
-
teamSchemas: () => teamSchemas,
|
|
98
|
-
teamUpdateSchema: () => teamUpdateSchema,
|
|
99
123
|
useAuth: () => useAuth,
|
|
124
|
+
useBranch: () => useBranch,
|
|
125
|
+
useBranchGate: () => useBranchGate,
|
|
126
|
+
useLocale: () => useLocale,
|
|
100
127
|
useOrganization: () => useOrganization,
|
|
101
128
|
useSso: () => useSso,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
129
|
+
useSsoTranslation: () => useSsoTranslation,
|
|
130
|
+
useTranslations: () => useTranslations,
|
|
131
|
+
userCacheCreateSchema: () => userCacheCreateSchema,
|
|
132
|
+
userCacheI18n: () => userCacheI18n,
|
|
133
|
+
userCacheSchemas: () => userCacheSchemas,
|
|
134
|
+
userCacheUpdateSchema: () => userCacheUpdateSchema,
|
|
106
135
|
validationMessages: () => validationMessages
|
|
107
136
|
});
|
|
108
137
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -162,34 +191,34 @@ function getMessages(locale) {
|
|
|
162
191
|
return result;
|
|
163
192
|
}
|
|
164
193
|
|
|
165
|
-
// node_modules/@omnify-base/schemas/
|
|
194
|
+
// node_modules/@omnify-base/schemas/BranchCache.ts
|
|
166
195
|
var import_zod = require("zod");
|
|
167
|
-
var
|
|
196
|
+
var branchCacheI18n = {
|
|
168
197
|
/** Model display name */
|
|
169
|
-
label: { "en": "Branch" },
|
|
198
|
+
label: { "ja": "\u652F\u5E97\u30AD\u30E3\u30C3\u30B7\u30E5", "en": "Branch Cache" },
|
|
170
199
|
/** Field labels and placeholders */
|
|
171
200
|
fields: {
|
|
172
201
|
console_branch_id: {
|
|
173
|
-
label: { "en": "Console Branch ID" }
|
|
202
|
+
label: { "ja": "Console Branch ID", "en": "Console Branch ID" }
|
|
174
203
|
},
|
|
175
204
|
console_org_id: {
|
|
176
|
-
label: { "en": "Console Organization ID" }
|
|
205
|
+
label: { "ja": "Console Organization ID", "en": "Console Organization ID" }
|
|
177
206
|
},
|
|
178
207
|
code: {
|
|
179
|
-
label: { "en": "Branch Code" }
|
|
208
|
+
label: { "ja": "\u652F\u5E97\u30B3\u30FC\u30C9", "en": "Branch Code" }
|
|
180
209
|
},
|
|
181
210
|
name: {
|
|
182
|
-
label: { "en": "Branch Name" }
|
|
211
|
+
label: { "ja": "\u652F\u5E97\u540D", "en": "Branch Name" }
|
|
183
212
|
},
|
|
184
213
|
is_headquarters: {
|
|
185
|
-
label: { "en": "Is Headquarters" }
|
|
214
|
+
label: { "ja": "\u672C\u793E", "en": "Is Headquarters" }
|
|
186
215
|
},
|
|
187
216
|
is_active: {
|
|
188
|
-
label: { "en": "Active" }
|
|
217
|
+
label: { "ja": "\u6709\u52B9", "en": "Active" }
|
|
189
218
|
}
|
|
190
219
|
}
|
|
191
220
|
};
|
|
192
|
-
var
|
|
221
|
+
var baseBranchCacheSchemas = {
|
|
193
222
|
console_branch_id: import_zod.z.string(),
|
|
194
223
|
console_org_id: import_zod.z.string(),
|
|
195
224
|
code: import_zod.z.string().min(1).max(20),
|
|
@@ -197,62 +226,116 @@ var baseBranchSchemas = {
|
|
|
197
226
|
is_headquarters: import_zod.z.boolean(),
|
|
198
227
|
is_active: import_zod.z.boolean()
|
|
199
228
|
};
|
|
200
|
-
var
|
|
201
|
-
console_branch_id:
|
|
202
|
-
console_org_id:
|
|
203
|
-
code:
|
|
204
|
-
name:
|
|
205
|
-
is_headquarters:
|
|
206
|
-
is_active:
|
|
229
|
+
var baseBranchCacheCreateSchema = import_zod.z.object({
|
|
230
|
+
console_branch_id: baseBranchCacheSchemas.console_branch_id,
|
|
231
|
+
console_org_id: baseBranchCacheSchemas.console_org_id,
|
|
232
|
+
code: baseBranchCacheSchemas.code,
|
|
233
|
+
name: baseBranchCacheSchemas.name,
|
|
234
|
+
is_headquarters: baseBranchCacheSchemas.is_headquarters,
|
|
235
|
+
is_active: baseBranchCacheSchemas.is_active
|
|
207
236
|
});
|
|
208
|
-
var
|
|
209
|
-
function
|
|
210
|
-
return
|
|
237
|
+
var baseBranchCacheUpdateSchema = baseBranchCacheCreateSchema.partial();
|
|
238
|
+
function getBranchCacheLabel(locale) {
|
|
239
|
+
return branchCacheI18n.label[locale] ?? branchCacheI18n.label["en"] ?? "BranchCache";
|
|
211
240
|
}
|
|
212
|
-
function
|
|
213
|
-
const fieldI18n =
|
|
241
|
+
function getBranchCacheFieldLabel(field, locale) {
|
|
242
|
+
const fieldI18n = branchCacheI18n.fields[field];
|
|
214
243
|
if (!fieldI18n) return field;
|
|
215
244
|
return fieldI18n.label[locale] ?? fieldI18n.label["en"] ?? field;
|
|
216
245
|
}
|
|
217
|
-
function
|
|
218
|
-
const fieldI18n =
|
|
246
|
+
function getBranchCacheFieldPlaceholder(field, locale) {
|
|
247
|
+
const fieldI18n = branchCacheI18n.fields[field];
|
|
219
248
|
if (!fieldI18n || !("placeholder" in fieldI18n)) return "";
|
|
220
249
|
const placeholder = fieldI18n.placeholder;
|
|
221
250
|
return placeholder[locale] ?? placeholder["en"] ?? "";
|
|
222
251
|
}
|
|
223
252
|
|
|
224
|
-
// src/schemas/
|
|
225
|
-
var
|
|
226
|
-
var
|
|
227
|
-
var
|
|
253
|
+
// src/schemas/BranchCache.ts
|
|
254
|
+
var branchCacheSchemas = { ...baseBranchCacheSchemas };
|
|
255
|
+
var branchCacheCreateSchema = baseBranchCacheCreateSchema;
|
|
256
|
+
var branchCacheUpdateSchema = baseBranchCacheUpdateSchema;
|
|
228
257
|
|
|
229
|
-
// node_modules/@omnify-base/schemas/
|
|
258
|
+
// node_modules/@omnify-base/schemas/OrganizationCache.ts
|
|
230
259
|
var import_zod2 = require("zod");
|
|
260
|
+
var organizationCacheI18n = {
|
|
261
|
+
/** Model display name */
|
|
262
|
+
label: { "ja": "\u7D44\u7E54\u30AD\u30E3\u30C3\u30B7\u30E5", "en": "Organization Cache" },
|
|
263
|
+
/** Field labels and placeholders */
|
|
264
|
+
fields: {
|
|
265
|
+
console_org_id: {
|
|
266
|
+
label: { "ja": "Console Organization ID", "en": "Console Organization ID" }
|
|
267
|
+
},
|
|
268
|
+
name: {
|
|
269
|
+
label: { "ja": "\u7D44\u7E54\u540D", "en": "Organization Name" }
|
|
270
|
+
},
|
|
271
|
+
code: {
|
|
272
|
+
label: { "ja": "\u7D44\u7E54\u30B3\u30FC\u30C9", "en": "Organization Code" }
|
|
273
|
+
},
|
|
274
|
+
is_active: {
|
|
275
|
+
label: { "ja": "\u6709\u52B9", "en": "Active" }
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
var baseOrganizationCacheSchemas = {
|
|
280
|
+
console_org_id: import_zod2.z.string(),
|
|
281
|
+
name: import_zod2.z.string().min(1).max(100),
|
|
282
|
+
code: import_zod2.z.string().min(1).max(20),
|
|
283
|
+
is_active: import_zod2.z.boolean()
|
|
284
|
+
};
|
|
285
|
+
var baseOrganizationCacheCreateSchema = import_zod2.z.object({
|
|
286
|
+
console_org_id: baseOrganizationCacheSchemas.console_org_id,
|
|
287
|
+
name: baseOrganizationCacheSchemas.name,
|
|
288
|
+
code: baseOrganizationCacheSchemas.code,
|
|
289
|
+
is_active: baseOrganizationCacheSchemas.is_active
|
|
290
|
+
});
|
|
291
|
+
var baseOrganizationCacheUpdateSchema = baseOrganizationCacheCreateSchema.partial();
|
|
292
|
+
function getOrganizationCacheLabel(locale) {
|
|
293
|
+
return organizationCacheI18n.label[locale] ?? organizationCacheI18n.label["en"] ?? "OrganizationCache";
|
|
294
|
+
}
|
|
295
|
+
function getOrganizationCacheFieldLabel(field, locale) {
|
|
296
|
+
const fieldI18n = organizationCacheI18n.fields[field];
|
|
297
|
+
if (!fieldI18n) return field;
|
|
298
|
+
return fieldI18n.label[locale] ?? fieldI18n.label["en"] ?? field;
|
|
299
|
+
}
|
|
300
|
+
function getOrganizationCacheFieldPlaceholder(field, locale) {
|
|
301
|
+
const fieldI18n = organizationCacheI18n.fields[field];
|
|
302
|
+
if (!fieldI18n || !("placeholder" in fieldI18n)) return "";
|
|
303
|
+
const placeholder = fieldI18n.placeholder;
|
|
304
|
+
return placeholder[locale] ?? placeholder["en"] ?? "";
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// src/schemas/OrganizationCache.ts
|
|
308
|
+
var organizationCacheSchemas = { ...baseOrganizationCacheSchemas };
|
|
309
|
+
var organizationCacheCreateSchema = baseOrganizationCacheCreateSchema;
|
|
310
|
+
var organizationCacheUpdateSchema = baseOrganizationCacheUpdateSchema;
|
|
311
|
+
|
|
312
|
+
// node_modules/@omnify-base/schemas/Permission.ts
|
|
313
|
+
var import_zod3 = require("zod");
|
|
231
314
|
var permissionI18n = {
|
|
232
315
|
/** Model display name */
|
|
233
|
-
label: { "en": "Permission" },
|
|
316
|
+
label: { "ja": "\u6A29\u9650", "en": "Permission" },
|
|
234
317
|
/** Field labels and placeholders */
|
|
235
318
|
fields: {
|
|
236
319
|
name: {
|
|
237
|
-
label: { "en": "Permission Name" }
|
|
320
|
+
label: { "ja": "\u6A29\u9650\u540D", "en": "Permission Name" }
|
|
238
321
|
},
|
|
239
322
|
slug: {
|
|
240
|
-
label: { "en": "Slug" }
|
|
323
|
+
label: { "ja": "\u30B9\u30E9\u30C3\u30B0", "en": "Slug" }
|
|
241
324
|
},
|
|
242
325
|
group: {
|
|
243
|
-
label: { "en": "Group" }
|
|
326
|
+
label: { "ja": "\u30B0\u30EB\u30FC\u30D7", "en": "Group" }
|
|
244
327
|
},
|
|
245
328
|
roles: {
|
|
246
|
-
label: { "en": "Roles" }
|
|
329
|
+
label: { "ja": "\u30ED\u30FC\u30EB", "en": "Roles" }
|
|
247
330
|
}
|
|
248
331
|
}
|
|
249
332
|
};
|
|
250
333
|
var basePermissionSchemas = {
|
|
251
|
-
name:
|
|
252
|
-
slug:
|
|
253
|
-
group:
|
|
334
|
+
name: import_zod3.z.string().min(1).max(100),
|
|
335
|
+
slug: import_zod3.z.string().min(1).max(100),
|
|
336
|
+
group: import_zod3.z.string().max(50).optional().nullable()
|
|
254
337
|
};
|
|
255
|
-
var basePermissionCreateSchema =
|
|
338
|
+
var basePermissionCreateSchema = import_zod3.z.object({
|
|
256
339
|
name: basePermissionSchemas.name,
|
|
257
340
|
slug: basePermissionSchemas.slug,
|
|
258
341
|
group: basePermissionSchemas.group
|
|
@@ -279,36 +362,41 @@ var permissionCreateSchema = basePermissionCreateSchema;
|
|
|
279
362
|
var permissionUpdateSchema = basePermissionUpdateSchema;
|
|
280
363
|
|
|
281
364
|
// node_modules/@omnify-base/schemas/Role.ts
|
|
282
|
-
var
|
|
365
|
+
var import_zod4 = require("zod");
|
|
283
366
|
var roleI18n = {
|
|
284
367
|
/** Model display name */
|
|
285
|
-
label: { "en": "Role" },
|
|
368
|
+
label: { "ja": "\u30ED\u30FC\u30EB", "en": "Role" },
|
|
286
369
|
/** Field labels and placeholders */
|
|
287
370
|
fields: {
|
|
371
|
+
console_org_id: {
|
|
372
|
+
label: { "ja": "\u7D44\u7E54ID", "en": "Organization ID" }
|
|
373
|
+
},
|
|
288
374
|
name: {
|
|
289
|
-
label: { "en": "Role Name" }
|
|
375
|
+
label: { "ja": "\u30ED\u30FC\u30EB\u540D", "en": "Role Name" }
|
|
290
376
|
},
|
|
291
377
|
slug: {
|
|
292
|
-
label: { "en": "Slug" }
|
|
378
|
+
label: { "ja": "\u30B9\u30E9\u30C3\u30B0", "en": "Slug" }
|
|
293
379
|
},
|
|
294
380
|
description: {
|
|
295
|
-
label: { "en": "Description" }
|
|
381
|
+
label: { "ja": "\u8AAC\u660E", "en": "Description" }
|
|
296
382
|
},
|
|
297
383
|
level: {
|
|
298
|
-
label: { "en": "Level" }
|
|
384
|
+
label: { "ja": "\u30EC\u30D9\u30EB", "en": "Level" }
|
|
299
385
|
},
|
|
300
386
|
permissions: {
|
|
301
|
-
label: { "en": "Permissions" }
|
|
387
|
+
label: { "ja": "\u6A29\u9650", "en": "Permissions" }
|
|
302
388
|
}
|
|
303
389
|
}
|
|
304
390
|
};
|
|
305
391
|
var baseRoleSchemas = {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
392
|
+
console_org_id: import_zod4.z.string().max(36).optional().nullable(),
|
|
393
|
+
name: import_zod4.z.string().min(1).max(100),
|
|
394
|
+
slug: import_zod4.z.string().min(1).max(100),
|
|
395
|
+
description: import_zod4.z.string().optional().nullable(),
|
|
396
|
+
level: import_zod4.z.number().int()
|
|
310
397
|
};
|
|
311
|
-
var baseRoleCreateSchema =
|
|
398
|
+
var baseRoleCreateSchema = import_zod4.z.object({
|
|
399
|
+
console_org_id: baseRoleSchemas.console_org_id,
|
|
312
400
|
name: baseRoleSchemas.name,
|
|
313
401
|
slug: baseRoleSchemas.slug,
|
|
314
402
|
description: baseRoleSchemas.description,
|
|
@@ -336,22 +424,22 @@ var roleCreateSchema = baseRoleCreateSchema;
|
|
|
336
424
|
var roleUpdateSchema = baseRoleUpdateSchema;
|
|
337
425
|
|
|
338
426
|
// node_modules/@omnify-base/schemas/RolePermission.ts
|
|
339
|
-
var
|
|
427
|
+
var import_zod5 = require("zod");
|
|
340
428
|
var rolePermissionI18n = {
|
|
341
429
|
/** Model display name */
|
|
342
|
-
label: { "en": "Role Permission" },
|
|
430
|
+
label: { "ja": "\u30ED\u30FC\u30EB\u6A29\u9650", "en": "Role Permission" },
|
|
343
431
|
/** Field labels and placeholders */
|
|
344
432
|
fields: {
|
|
345
433
|
role: {
|
|
346
|
-
label: { "en": "Role" }
|
|
434
|
+
label: { "ja": "\u30ED\u30FC\u30EB", "en": "Role" }
|
|
347
435
|
},
|
|
348
436
|
permission: {
|
|
349
|
-
label: { "en": "Permission" }
|
|
437
|
+
label: { "ja": "\u6A29\u9650", "en": "Permission" }
|
|
350
438
|
}
|
|
351
439
|
}
|
|
352
440
|
};
|
|
353
441
|
var baseRolePermissionSchemas = {};
|
|
354
|
-
var baseRolePermissionCreateSchema =
|
|
442
|
+
var baseRolePermissionCreateSchema = import_zod5.z.object({});
|
|
355
443
|
var baseRolePermissionUpdateSchema = baseRolePermissionCreateSchema.partial();
|
|
356
444
|
function getRolePermissionLabel(locale) {
|
|
357
445
|
return rolePermissionI18n.label[locale] ?? rolePermissionI18n.label["en"] ?? "RolePermission";
|
|
@@ -373,78 +461,78 @@ var rolePermissionSchemas = { ...baseRolePermissionSchemas };
|
|
|
373
461
|
var rolePermissionCreateSchema = baseRolePermissionCreateSchema;
|
|
374
462
|
var rolePermissionUpdateSchema = baseRolePermissionUpdateSchema;
|
|
375
463
|
|
|
376
|
-
// node_modules/@omnify-base/schemas/
|
|
377
|
-
var
|
|
378
|
-
var
|
|
464
|
+
// node_modules/@omnify-base/schemas/TeamCache.ts
|
|
465
|
+
var import_zod6 = require("zod");
|
|
466
|
+
var teamCacheI18n = {
|
|
379
467
|
/** Model display name */
|
|
380
|
-
label: { "en": "Team" },
|
|
468
|
+
label: { "ja": "\u30C1\u30FC\u30E0\u30AD\u30E3\u30C3\u30B7\u30E5", "en": "Team Cache" },
|
|
381
469
|
/** Field labels and placeholders */
|
|
382
470
|
fields: {
|
|
383
471
|
console_team_id: {
|
|
384
|
-
label: { "en": "Console Team ID" }
|
|
472
|
+
label: { "ja": "Console Team ID", "en": "Console Team ID" }
|
|
385
473
|
},
|
|
386
474
|
console_org_id: {
|
|
387
|
-
label: { "en": "Console Organization ID" }
|
|
475
|
+
label: { "ja": "Console Organization ID", "en": "Console Organization ID" }
|
|
388
476
|
},
|
|
389
477
|
name: {
|
|
390
|
-
label: { "en": "Team Name" }
|
|
478
|
+
label: { "ja": "\u30C1\u30FC\u30E0\u540D", "en": "Team Name" }
|
|
391
479
|
}
|
|
392
480
|
}
|
|
393
481
|
};
|
|
394
|
-
var
|
|
395
|
-
console_team_id:
|
|
396
|
-
console_org_id:
|
|
397
|
-
name:
|
|
482
|
+
var baseTeamCacheSchemas = {
|
|
483
|
+
console_team_id: import_zod6.z.string(),
|
|
484
|
+
console_org_id: import_zod6.z.string(),
|
|
485
|
+
name: import_zod6.z.string().min(1).max(100)
|
|
398
486
|
};
|
|
399
|
-
var
|
|
400
|
-
console_team_id:
|
|
401
|
-
console_org_id:
|
|
402
|
-
name:
|
|
487
|
+
var baseTeamCacheCreateSchema = import_zod6.z.object({
|
|
488
|
+
console_team_id: baseTeamCacheSchemas.console_team_id,
|
|
489
|
+
console_org_id: baseTeamCacheSchemas.console_org_id,
|
|
490
|
+
name: baseTeamCacheSchemas.name
|
|
403
491
|
});
|
|
404
|
-
var
|
|
405
|
-
function
|
|
406
|
-
return
|
|
492
|
+
var baseTeamCacheUpdateSchema = baseTeamCacheCreateSchema.partial();
|
|
493
|
+
function getTeamCacheLabel(locale) {
|
|
494
|
+
return teamCacheI18n.label[locale] ?? teamCacheI18n.label["en"] ?? "TeamCache";
|
|
407
495
|
}
|
|
408
|
-
function
|
|
409
|
-
const fieldI18n =
|
|
496
|
+
function getTeamCacheFieldLabel(field, locale) {
|
|
497
|
+
const fieldI18n = teamCacheI18n.fields[field];
|
|
410
498
|
if (!fieldI18n) return field;
|
|
411
499
|
return fieldI18n.label[locale] ?? fieldI18n.label["en"] ?? field;
|
|
412
500
|
}
|
|
413
|
-
function
|
|
414
|
-
const fieldI18n =
|
|
501
|
+
function getTeamCacheFieldPlaceholder(field, locale) {
|
|
502
|
+
const fieldI18n = teamCacheI18n.fields[field];
|
|
415
503
|
if (!fieldI18n || !("placeholder" in fieldI18n)) return "";
|
|
416
504
|
const placeholder = fieldI18n.placeholder;
|
|
417
505
|
return placeholder[locale] ?? placeholder["en"] ?? "";
|
|
418
506
|
}
|
|
419
507
|
|
|
420
|
-
// src/schemas/
|
|
421
|
-
var
|
|
422
|
-
var
|
|
423
|
-
var
|
|
508
|
+
// src/schemas/TeamCache.ts
|
|
509
|
+
var teamCacheSchemas = { ...baseTeamCacheSchemas };
|
|
510
|
+
var teamCacheCreateSchema = baseTeamCacheCreateSchema;
|
|
511
|
+
var teamCacheUpdateSchema = baseTeamCacheUpdateSchema;
|
|
424
512
|
|
|
425
513
|
// node_modules/@omnify-base/schemas/TeamPermission.ts
|
|
426
|
-
var
|
|
514
|
+
var import_zod7 = require("zod");
|
|
427
515
|
var teamPermissionI18n = {
|
|
428
516
|
/** Model display name */
|
|
429
|
-
label: { "en": "Team Permission" },
|
|
517
|
+
label: { "ja": "\u30C1\u30FC\u30E0\u6A29\u9650", "en": "Team Permission" },
|
|
430
518
|
/** Field labels and placeholders */
|
|
431
519
|
fields: {
|
|
432
520
|
console_org_id: {
|
|
433
|
-
label: { "en": "Console Organization ID" }
|
|
521
|
+
label: { "ja": "Console Organization ID", "en": "Console Organization ID" }
|
|
434
522
|
},
|
|
435
523
|
console_team_id: {
|
|
436
|
-
label: { "en": "Console Team ID" }
|
|
524
|
+
label: { "ja": "Console Team ID", "en": "Console Team ID" }
|
|
437
525
|
},
|
|
438
526
|
permission: {
|
|
439
|
-
label: { "en": "Permission" }
|
|
527
|
+
label: { "ja": "\u6A29\u9650", "en": "Permission" }
|
|
440
528
|
}
|
|
441
529
|
}
|
|
442
530
|
};
|
|
443
531
|
var baseTeamPermissionSchemas = {
|
|
444
|
-
console_org_id:
|
|
445
|
-
console_team_id:
|
|
532
|
+
console_org_id: import_zod7.z.string(),
|
|
533
|
+
console_team_id: import_zod7.z.string()
|
|
446
534
|
};
|
|
447
|
-
var baseTeamPermissionCreateSchema =
|
|
535
|
+
var baseTeamPermissionCreateSchema = import_zod7.z.object({
|
|
448
536
|
console_org_id: baseTeamPermissionSchemas.console_org_id,
|
|
449
537
|
console_team_id: baseTeamPermissionSchemas.console_team_id
|
|
450
538
|
});
|
|
@@ -469,72 +557,77 @@ var teamPermissionSchemas = { ...baseTeamPermissionSchemas };
|
|
|
469
557
|
var teamPermissionCreateSchema = baseTeamPermissionCreateSchema;
|
|
470
558
|
var teamPermissionUpdateSchema = baseTeamPermissionUpdateSchema;
|
|
471
559
|
|
|
472
|
-
// node_modules/@omnify-base/schemas/
|
|
473
|
-
var
|
|
474
|
-
var
|
|
560
|
+
// node_modules/@omnify-base/schemas/UserCache.ts
|
|
561
|
+
var import_zod8 = require("zod");
|
|
562
|
+
var userCacheI18n = {
|
|
475
563
|
/** Model display name */
|
|
476
|
-
label: { "en": "User" },
|
|
564
|
+
label: { "ja": "\u30E6\u30FC\u30B6\u30FC\u30AD\u30E3\u30C3\u30B7\u30E5", "en": "User Cache" },
|
|
477
565
|
/** Field labels and placeholders */
|
|
478
566
|
fields: {
|
|
479
567
|
name: {
|
|
480
|
-
label: { "en": "Name" }
|
|
568
|
+
label: { "ja": "\u540D\u524D", "en": "Name" }
|
|
481
569
|
},
|
|
482
570
|
email: {
|
|
483
|
-
label: { "en": "Email" }
|
|
571
|
+
label: { "ja": "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9", "en": "Email" }
|
|
484
572
|
},
|
|
485
573
|
console_user_id: {
|
|
486
|
-
label: { "en": "Console User ID" }
|
|
574
|
+
label: { "ja": "Console User ID", "en": "Console User ID" }
|
|
575
|
+
},
|
|
576
|
+
console_org_id: {
|
|
577
|
+
label: { "ja": "\u6240\u5C5E\u7D44\u7E54ID", "en": "Organization ID" }
|
|
487
578
|
},
|
|
488
579
|
console_access_token: {
|
|
489
|
-
label: { "en": "Console Access Token" }
|
|
580
|
+
label: { "ja": "Console Access Token", "en": "Console Access Token" }
|
|
490
581
|
},
|
|
491
582
|
console_refresh_token: {
|
|
492
|
-
label: { "en": "Console Refresh Token" }
|
|
583
|
+
label: { "ja": "Console Refresh Token", "en": "Console Refresh Token" }
|
|
493
584
|
},
|
|
494
585
|
console_token_expires_at: {
|
|
495
|
-
label: { "en": "Console Token Expiry" }
|
|
586
|
+
label: { "ja": "Console Token\u6709\u52B9\u671F\u9650", "en": "Console Token Expiry" }
|
|
496
587
|
},
|
|
497
588
|
roles: {
|
|
498
|
-
label: { "en": "Roles" }
|
|
589
|
+
label: { "ja": "\u30ED\u30FC\u30EB", "en": "Roles" }
|
|
499
590
|
}
|
|
500
591
|
}
|
|
501
592
|
};
|
|
502
|
-
var
|
|
503
|
-
name:
|
|
504
|
-
email:
|
|
505
|
-
console_user_id:
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
593
|
+
var baseUserCacheSchemas = {
|
|
594
|
+
name: import_zod8.z.string().min(1),
|
|
595
|
+
email: import_zod8.z.string().min(1),
|
|
596
|
+
console_user_id: import_zod8.z.string().optional().nullable(),
|
|
597
|
+
console_org_id: import_zod8.z.string().optional().nullable(),
|
|
598
|
+
console_access_token: import_zod8.z.string().optional().nullable(),
|
|
599
|
+
console_refresh_token: import_zod8.z.string().optional().nullable(),
|
|
600
|
+
console_token_expires_at: import_zod8.z.string().datetime({ offset: true }).optional().nullable()
|
|
509
601
|
};
|
|
510
|
-
var
|
|
511
|
-
name:
|
|
512
|
-
email:
|
|
513
|
-
console_user_id:
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
602
|
+
var baseUserCacheCreateSchema = import_zod8.z.object({
|
|
603
|
+
name: baseUserCacheSchemas.name,
|
|
604
|
+
email: baseUserCacheSchemas.email,
|
|
605
|
+
console_user_id: baseUserCacheSchemas.console_user_id,
|
|
606
|
+
console_org_id: baseUserCacheSchemas.console_org_id,
|
|
607
|
+
console_access_token: baseUserCacheSchemas.console_access_token,
|
|
608
|
+
console_refresh_token: baseUserCacheSchemas.console_refresh_token,
|
|
609
|
+
console_token_expires_at: baseUserCacheSchemas.console_token_expires_at
|
|
517
610
|
});
|
|
518
|
-
var
|
|
519
|
-
function
|
|
520
|
-
return
|
|
611
|
+
var baseUserCacheUpdateSchema = baseUserCacheCreateSchema.partial();
|
|
612
|
+
function getUserCacheLabel(locale) {
|
|
613
|
+
return userCacheI18n.label[locale] ?? userCacheI18n.label["en"] ?? "UserCache";
|
|
521
614
|
}
|
|
522
|
-
function
|
|
523
|
-
const fieldI18n =
|
|
615
|
+
function getUserCacheFieldLabel(field, locale) {
|
|
616
|
+
const fieldI18n = userCacheI18n.fields[field];
|
|
524
617
|
if (!fieldI18n) return field;
|
|
525
618
|
return fieldI18n.label[locale] ?? fieldI18n.label["en"] ?? field;
|
|
526
619
|
}
|
|
527
|
-
function
|
|
528
|
-
const fieldI18n =
|
|
620
|
+
function getUserCacheFieldPlaceholder(field, locale) {
|
|
621
|
+
const fieldI18n = userCacheI18n.fields[field];
|
|
529
622
|
if (!fieldI18n || !("placeholder" in fieldI18n)) return "";
|
|
530
623
|
const placeholder = fieldI18n.placeholder;
|
|
531
624
|
return placeholder[locale] ?? placeholder["en"] ?? "";
|
|
532
625
|
}
|
|
533
626
|
|
|
534
|
-
// src/schemas/
|
|
535
|
-
var
|
|
536
|
-
var
|
|
537
|
-
var
|
|
627
|
+
// src/schemas/UserCache.ts
|
|
628
|
+
var userCacheSchemas = { ...baseUserCacheSchemas };
|
|
629
|
+
var userCacheCreateSchema = baseUserCacheCreateSchema;
|
|
630
|
+
var userCacheUpdateSchema = baseUserCacheUpdateSchema;
|
|
538
631
|
|
|
539
632
|
// src/context/SsoContext.tsx
|
|
540
633
|
var import_react = require("react");
|
|
@@ -760,20 +853,360 @@ function SsoProvider({ children, config, onAuthChange }) {
|
|
|
760
853
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SsoContext.Provider, { value, children });
|
|
761
854
|
}
|
|
762
855
|
|
|
763
|
-
// src/
|
|
856
|
+
// src/context/BranchContext.tsx
|
|
764
857
|
var import_react3 = require("react");
|
|
858
|
+
var BranchContext = (0, import_react3.createContext)(null);
|
|
859
|
+
function useBranchContext() {
|
|
860
|
+
const context = (0, import_react3.useContext)(BranchContext);
|
|
861
|
+
if (!context) {
|
|
862
|
+
throw new Error("useBranchContext must be used within a BranchProvider");
|
|
863
|
+
}
|
|
864
|
+
return context;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// src/context/BranchProvider.tsx
|
|
868
|
+
var import_react_query = require("@tanstack/react-query");
|
|
869
|
+
var import_react4 = require("react");
|
|
870
|
+
|
|
871
|
+
// src/queryKeys.ts
|
|
872
|
+
var ssoQueryKeys = {
|
|
873
|
+
all: ["sso"],
|
|
874
|
+
// =========================================================================
|
|
875
|
+
// Auth (authService)
|
|
876
|
+
// =========================================================================
|
|
877
|
+
auth: {
|
|
878
|
+
all: () => [...ssoQueryKeys.all, "auth"],
|
|
879
|
+
user: () => [...ssoQueryKeys.auth.all(), "user"],
|
|
880
|
+
globalLogoutUrl: (redirectUri) => [...ssoQueryKeys.auth.all(), "global-logout-url", redirectUri]
|
|
881
|
+
},
|
|
882
|
+
// =========================================================================
|
|
883
|
+
// Tokens (tokenService)
|
|
884
|
+
// =========================================================================
|
|
885
|
+
tokens: {
|
|
886
|
+
all: () => [...ssoQueryKeys.all, "tokens"],
|
|
887
|
+
list: () => [...ssoQueryKeys.tokens.all(), "list"]
|
|
888
|
+
},
|
|
889
|
+
// =========================================================================
|
|
890
|
+
// Roles (roleService)
|
|
891
|
+
// =========================================================================
|
|
892
|
+
roles: {
|
|
893
|
+
all: () => [...ssoQueryKeys.all, "roles"],
|
|
894
|
+
list: () => [...ssoQueryKeys.roles.all(), "list"],
|
|
895
|
+
detail: (id) => [...ssoQueryKeys.roles.all(), "detail", id],
|
|
896
|
+
permissions: (id) => [...ssoQueryKeys.roles.all(), id, "permissions"]
|
|
897
|
+
},
|
|
898
|
+
// =========================================================================
|
|
899
|
+
// Permissions (permissionService)
|
|
900
|
+
// =========================================================================
|
|
901
|
+
permissions: {
|
|
902
|
+
all: () => [...ssoQueryKeys.all, "permissions"],
|
|
903
|
+
list: (params) => [...ssoQueryKeys.permissions.all(), "list", params],
|
|
904
|
+
detail: (id) => [...ssoQueryKeys.permissions.all(), "detail", id],
|
|
905
|
+
matrix: () => [...ssoQueryKeys.permissions.all(), "matrix"]
|
|
906
|
+
},
|
|
907
|
+
// =========================================================================
|
|
908
|
+
// Teams (teamService)
|
|
909
|
+
// =========================================================================
|
|
910
|
+
teams: {
|
|
911
|
+
all: () => [...ssoQueryKeys.all, "teams"],
|
|
912
|
+
list: () => [...ssoQueryKeys.teams.all(), "list"],
|
|
913
|
+
permissions: (teamId) => [...ssoQueryKeys.teams.all(), teamId, "permissions"],
|
|
914
|
+
orphaned: () => [...ssoQueryKeys.teams.all(), "orphaned"]
|
|
915
|
+
},
|
|
916
|
+
// =========================================================================
|
|
917
|
+
// User Roles (userRoleService) - Scoped Role Assignments
|
|
918
|
+
// =========================================================================
|
|
919
|
+
userRoles: {
|
|
920
|
+
all: () => [...ssoQueryKeys.all, "user-roles"],
|
|
921
|
+
list: (userId) => [...ssoQueryKeys.userRoles.all(), userId],
|
|
922
|
+
byBranch: (userId, orgId, branchId) => [...ssoQueryKeys.userRoles.all(), userId, orgId, branchId]
|
|
923
|
+
},
|
|
924
|
+
// =========================================================================
|
|
925
|
+
// Users (userService)
|
|
926
|
+
// =========================================================================
|
|
927
|
+
users: {
|
|
928
|
+
all: () => [...ssoQueryKeys.all, "users"],
|
|
929
|
+
list: (params) => [...ssoQueryKeys.users.all(), "list", params],
|
|
930
|
+
detail: (id) => [...ssoQueryKeys.users.all(), "detail", id]
|
|
931
|
+
},
|
|
932
|
+
// =========================================================================
|
|
933
|
+
// Branches (branchService)
|
|
934
|
+
// =========================================================================
|
|
935
|
+
branches: {
|
|
936
|
+
all: () => [...ssoQueryKeys.all, "branches"],
|
|
937
|
+
list: (orgSlug) => [...ssoQueryKeys.branches.all(), "list", orgSlug],
|
|
938
|
+
detail: (branchId) => [...ssoQueryKeys.branches.all(), "detail", branchId],
|
|
939
|
+
headquarters: (orgSlug) => [...ssoQueryKeys.branches.all(), "headquarters", orgSlug],
|
|
940
|
+
primary: (orgSlug) => [...ssoQueryKeys.branches.all(), "primary", orgSlug]
|
|
941
|
+
},
|
|
942
|
+
// =========================================================================
|
|
943
|
+
// Admin variants (with org context)
|
|
944
|
+
// =========================================================================
|
|
945
|
+
admin: {
|
|
946
|
+
users: {
|
|
947
|
+
all: (orgSlug) => [...ssoQueryKeys.all, "admin", orgSlug, "users"],
|
|
948
|
+
list: (orgSlug, params) => [...ssoQueryKeys.admin.users.all(orgSlug), "list", params],
|
|
949
|
+
detail: (orgSlug, id) => [...ssoQueryKeys.admin.users.all(orgSlug), "detail", id]
|
|
950
|
+
},
|
|
951
|
+
roles: {
|
|
952
|
+
all: (orgSlug) => [...ssoQueryKeys.all, "admin", orgSlug, "roles"],
|
|
953
|
+
list: (orgSlug) => [...ssoQueryKeys.admin.roles.all(orgSlug), "list"],
|
|
954
|
+
detail: (orgSlug, id) => [...ssoQueryKeys.admin.roles.all(orgSlug), "detail", id],
|
|
955
|
+
permissions: (orgSlug, id) => [...ssoQueryKeys.admin.roles.all(orgSlug), id, "permissions"]
|
|
956
|
+
},
|
|
957
|
+
permissions: {
|
|
958
|
+
all: (orgSlug) => [...ssoQueryKeys.all, "admin", orgSlug, "permissions"],
|
|
959
|
+
list: (orgSlug, params) => [...ssoQueryKeys.admin.permissions.all(orgSlug), "list", params],
|
|
960
|
+
detail: (orgSlug, id) => [...ssoQueryKeys.admin.permissions.all(orgSlug), "detail", id],
|
|
961
|
+
matrix: (orgSlug) => [...ssoQueryKeys.admin.permissions.all(orgSlug), "matrix"]
|
|
962
|
+
},
|
|
963
|
+
teams: {
|
|
964
|
+
all: (orgSlug) => [...ssoQueryKeys.all, "admin", orgSlug, "teams"],
|
|
965
|
+
list: (orgSlug) => [...ssoQueryKeys.admin.teams.all(orgSlug), "list"],
|
|
966
|
+
permissions: (orgSlug, teamId) => [...ssoQueryKeys.admin.teams.all(orgSlug), teamId, "permissions"],
|
|
967
|
+
orphaned: (orgSlug) => [...ssoQueryKeys.admin.teams.all(orgSlug), "orphaned"]
|
|
968
|
+
},
|
|
969
|
+
userRoles: {
|
|
970
|
+
all: (orgSlug) => [...ssoQueryKeys.all, "admin", orgSlug, "user-roles"],
|
|
971
|
+
list: (orgSlug, userId) => [...ssoQueryKeys.admin.userRoles.all(orgSlug), userId],
|
|
972
|
+
byBranch: (orgSlug, userId, orgId, branchId) => [...ssoQueryKeys.admin.userRoles.all(orgSlug), userId, orgId, branchId]
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
// src/services/utils.ts
|
|
978
|
+
function getXsrfToken2() {
|
|
979
|
+
if (typeof document === "undefined") return void 0;
|
|
980
|
+
return document.cookie.split("; ").find((row) => row.startsWith("XSRF-TOKEN="))?.split("=")[1];
|
|
981
|
+
}
|
|
982
|
+
function buildHeaders(orgSlug) {
|
|
983
|
+
const headers = {
|
|
984
|
+
"Content-Type": "application/json",
|
|
985
|
+
Accept: "application/json"
|
|
986
|
+
};
|
|
987
|
+
const xsrfToken = getXsrfToken2();
|
|
988
|
+
if (xsrfToken) {
|
|
989
|
+
headers["X-XSRF-TOKEN"] = decodeURIComponent(xsrfToken);
|
|
990
|
+
}
|
|
991
|
+
if (orgSlug) {
|
|
992
|
+
headers["X-Org-Id"] = orgSlug;
|
|
993
|
+
}
|
|
994
|
+
return headers;
|
|
995
|
+
}
|
|
996
|
+
async function csrf(apiUrl) {
|
|
997
|
+
await fetch(`${apiUrl}/sanctum/csrf-cookie`, {
|
|
998
|
+
credentials: "include"
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
async function request(apiUrl, path, options = {}) {
|
|
1002
|
+
const response = await fetch(`${apiUrl}${path}`, {
|
|
1003
|
+
...options,
|
|
1004
|
+
credentials: "include"
|
|
1005
|
+
});
|
|
1006
|
+
if (!response.ok) {
|
|
1007
|
+
const error = await response.json().catch(() => ({}));
|
|
1008
|
+
throw new Error(error.message || `HTTP ${response.status}`);
|
|
1009
|
+
}
|
|
1010
|
+
if (response.status === 204) {
|
|
1011
|
+
return void 0;
|
|
1012
|
+
}
|
|
1013
|
+
return response.json();
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
// src/services/branchService.ts
|
|
1017
|
+
function createBranchService(config) {
|
|
1018
|
+
const { apiUrl } = config;
|
|
1019
|
+
return {
|
|
1020
|
+
/**
|
|
1021
|
+
* Get branches for current user in organization
|
|
1022
|
+
* GET /api/sso/branches
|
|
1023
|
+
*/
|
|
1024
|
+
list: async (orgSlug) => {
|
|
1025
|
+
const params = orgSlug ? `?organization_slug=${orgSlug}` : "";
|
|
1026
|
+
return request(apiUrl, `/api/sso/branches${params}`, {
|
|
1027
|
+
headers: buildHeaders()
|
|
1028
|
+
});
|
|
1029
|
+
},
|
|
1030
|
+
/**
|
|
1031
|
+
* Get a specific branch by ID
|
|
1032
|
+
* GET /api/sso/branches/{id}
|
|
1033
|
+
*/
|
|
1034
|
+
get: async (branchId) => {
|
|
1035
|
+
const response = await request(
|
|
1036
|
+
apiUrl,
|
|
1037
|
+
`/api/sso/branches/${branchId}`,
|
|
1038
|
+
{ headers: buildHeaders() }
|
|
1039
|
+
);
|
|
1040
|
+
return "data" in response ? response.data : response;
|
|
1041
|
+
},
|
|
1042
|
+
/**
|
|
1043
|
+
* Get headquarters branch for organization
|
|
1044
|
+
*/
|
|
1045
|
+
getHeadquarters: async (orgSlug) => {
|
|
1046
|
+
try {
|
|
1047
|
+
const params = orgSlug ? `?organization_slug=${orgSlug}` : "";
|
|
1048
|
+
const data = await request(
|
|
1049
|
+
apiUrl,
|
|
1050
|
+
`/api/sso/branches${params}`,
|
|
1051
|
+
{ headers: buildHeaders() }
|
|
1052
|
+
);
|
|
1053
|
+
return data.branches.find((b) => b.is_headquarters) ?? null;
|
|
1054
|
+
} catch {
|
|
1055
|
+
return null;
|
|
1056
|
+
}
|
|
1057
|
+
},
|
|
1058
|
+
/**
|
|
1059
|
+
* Get primary branch for current user
|
|
1060
|
+
*/
|
|
1061
|
+
getPrimary: async (orgSlug) => {
|
|
1062
|
+
try {
|
|
1063
|
+
const params = orgSlug ? `?organization_slug=${orgSlug}` : "";
|
|
1064
|
+
const data = await request(
|
|
1065
|
+
apiUrl,
|
|
1066
|
+
`/api/sso/branches${params}`,
|
|
1067
|
+
{ headers: buildHeaders() }
|
|
1068
|
+
);
|
|
1069
|
+
if (data.primary_branch_id) {
|
|
1070
|
+
return data.branches.find((b) => b.id === data.primary_branch_id) ?? null;
|
|
1071
|
+
}
|
|
1072
|
+
return null;
|
|
1073
|
+
} catch {
|
|
1074
|
+
return null;
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
// src/context/BranchProvider.tsx
|
|
1081
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1082
|
+
var DEFAULT_STORAGE_KEY = "omnify_selected_branch";
|
|
1083
|
+
function BranchProvider({
|
|
1084
|
+
children,
|
|
1085
|
+
storage = "localStorage",
|
|
1086
|
+
storageKey = DEFAULT_STORAGE_KEY,
|
|
1087
|
+
onBranchChange
|
|
1088
|
+
}) {
|
|
1089
|
+
const { config, currentOrg, isAuthenticated } = useSsoContext();
|
|
1090
|
+
const queryClient = (0, import_react_query.useQueryClient)();
|
|
1091
|
+
const branchService = (0, import_react4.useMemo)(
|
|
1092
|
+
() => createBranchService({ apiUrl: config.apiUrl }),
|
|
1093
|
+
[config.apiUrl]
|
|
1094
|
+
);
|
|
1095
|
+
const getSavedBranchId = (0, import_react4.useCallback)(() => {
|
|
1096
|
+
if (typeof window === "undefined") return null;
|
|
1097
|
+
const storageObj = storage === "localStorage" ? localStorage : sessionStorage;
|
|
1098
|
+
const saved = storageObj.getItem(`${storageKey}_${currentOrg?.slug}`);
|
|
1099
|
+
return saved ? parseInt(saved, 10) : null;
|
|
1100
|
+
}, [storage, storageKey, currentOrg?.slug]);
|
|
1101
|
+
const saveBranchId = (0, import_react4.useCallback)((branchId) => {
|
|
1102
|
+
if (typeof window === "undefined" || !currentOrg?.slug) return;
|
|
1103
|
+
const storageObj = storage === "localStorage" ? localStorage : sessionStorage;
|
|
1104
|
+
if (branchId) {
|
|
1105
|
+
storageObj.setItem(`${storageKey}_${currentOrg.slug}`, String(branchId));
|
|
1106
|
+
} else {
|
|
1107
|
+
storageObj.removeItem(`${storageKey}_${currentOrg.slug}`);
|
|
1108
|
+
}
|
|
1109
|
+
}, [storage, storageKey, currentOrg?.slug]);
|
|
1110
|
+
const [selectedBranchId, setSelectedBranchId] = (0, import_react4.useState)(() => getSavedBranchId());
|
|
1111
|
+
const {
|
|
1112
|
+
data: branchesData,
|
|
1113
|
+
isLoading,
|
|
1114
|
+
error,
|
|
1115
|
+
refetch
|
|
1116
|
+
} = (0, import_react_query.useQuery)({
|
|
1117
|
+
queryKey: ssoQueryKeys.branches.list(currentOrg?.slug),
|
|
1118
|
+
queryFn: () => branchService.list(currentOrg?.slug),
|
|
1119
|
+
enabled: isAuthenticated && !!currentOrg,
|
|
1120
|
+
staleTime: 5 * 60 * 1e3
|
|
1121
|
+
// 5 minutes
|
|
1122
|
+
});
|
|
1123
|
+
const branches = branchesData?.branches ?? [];
|
|
1124
|
+
const allBranchesAccess = branchesData?.all_branches_access ?? false;
|
|
1125
|
+
const primaryBranchId = branchesData?.primary_branch_id ?? null;
|
|
1126
|
+
const hasMultipleBranches = branches.length > 1;
|
|
1127
|
+
const currentBranch = (0, import_react4.useMemo)(() => {
|
|
1128
|
+
if (!branches.length) return null;
|
|
1129
|
+
if (branches.length === 1) {
|
|
1130
|
+
return branches[0];
|
|
1131
|
+
}
|
|
1132
|
+
if (selectedBranchId) {
|
|
1133
|
+
const found = branches.find((b) => b.id === selectedBranchId);
|
|
1134
|
+
if (found) return found;
|
|
1135
|
+
}
|
|
1136
|
+
if (primaryBranchId) {
|
|
1137
|
+
const primary = branches.find((b) => b.id === primaryBranchId);
|
|
1138
|
+
if (primary) return primary;
|
|
1139
|
+
}
|
|
1140
|
+
const hq = branches.find((b) => b.is_headquarters);
|
|
1141
|
+
if (hq) return hq;
|
|
1142
|
+
return branches[0];
|
|
1143
|
+
}, [branches, selectedBranchId, primaryBranchId]);
|
|
1144
|
+
(0, import_react4.useEffect)(() => {
|
|
1145
|
+
if (currentBranch && currentBranch.id !== selectedBranchId) {
|
|
1146
|
+
setSelectedBranchId(currentBranch.id);
|
|
1147
|
+
saveBranchId(currentBranch.id);
|
|
1148
|
+
onBranchChange?.(currentBranch);
|
|
1149
|
+
}
|
|
1150
|
+
}, [currentBranch, selectedBranchId, saveBranchId, onBranchChange]);
|
|
1151
|
+
(0, import_react4.useEffect)(() => {
|
|
1152
|
+
const savedId = getSavedBranchId();
|
|
1153
|
+
setSelectedBranchId(savedId);
|
|
1154
|
+
}, [currentOrg?.slug, getSavedBranchId]);
|
|
1155
|
+
const switchBranch = (0, import_react4.useCallback)((branchId) => {
|
|
1156
|
+
const branch = branches.find((b) => b.id === branchId);
|
|
1157
|
+
if (branch) {
|
|
1158
|
+
setSelectedBranchId(branchId);
|
|
1159
|
+
saveBranchId(branchId);
|
|
1160
|
+
onBranchChange?.(branch);
|
|
1161
|
+
}
|
|
1162
|
+
}, [branches, saveBranchId, onBranchChange]);
|
|
1163
|
+
const refreshBranches = (0, import_react4.useCallback)(async () => {
|
|
1164
|
+
await queryClient.invalidateQueries({
|
|
1165
|
+
queryKey: ssoQueryKeys.branches.list(currentOrg?.slug)
|
|
1166
|
+
});
|
|
1167
|
+
await refetch();
|
|
1168
|
+
}, [queryClient, currentOrg?.slug, refetch]);
|
|
1169
|
+
const contextValue = (0, import_react4.useMemo)(
|
|
1170
|
+
() => ({
|
|
1171
|
+
branches,
|
|
1172
|
+
currentBranch,
|
|
1173
|
+
allBranchesAccess,
|
|
1174
|
+
primaryBranchId,
|
|
1175
|
+
isLoading,
|
|
1176
|
+
error,
|
|
1177
|
+
hasMultipleBranches,
|
|
1178
|
+
switchBranch,
|
|
1179
|
+
refreshBranches
|
|
1180
|
+
}),
|
|
1181
|
+
[
|
|
1182
|
+
branches,
|
|
1183
|
+
currentBranch,
|
|
1184
|
+
allBranchesAccess,
|
|
1185
|
+
primaryBranchId,
|
|
1186
|
+
isLoading,
|
|
1187
|
+
error,
|
|
1188
|
+
hasMultipleBranches,
|
|
1189
|
+
switchBranch,
|
|
1190
|
+
refreshBranches
|
|
1191
|
+
]
|
|
1192
|
+
);
|
|
1193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BranchContext.Provider, { value: contextValue, children });
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
// src/hooks/useAuth.ts
|
|
1197
|
+
var import_react5 = require("react");
|
|
765
1198
|
function useAuth() {
|
|
766
1199
|
const { user, isLoading, isAuthenticated, login, logout, globalLogout, refreshUser } = useSsoContext();
|
|
767
|
-
const handleLogin = (0,
|
|
1200
|
+
const handleLogin = (0, import_react5.useCallback)(
|
|
768
1201
|
(redirectTo) => {
|
|
769
1202
|
login(redirectTo);
|
|
770
1203
|
},
|
|
771
1204
|
[login]
|
|
772
1205
|
);
|
|
773
|
-
const handleLogout = (0,
|
|
1206
|
+
const handleLogout = (0, import_react5.useCallback)(async () => {
|
|
774
1207
|
await logout();
|
|
775
1208
|
}, [logout]);
|
|
776
|
-
const handleGlobalLogout = (0,
|
|
1209
|
+
const handleGlobalLogout = (0, import_react5.useCallback)(
|
|
777
1210
|
(redirectTo) => {
|
|
778
1211
|
globalLogout(redirectTo);
|
|
779
1212
|
},
|
|
@@ -791,7 +1224,7 @@ function useAuth() {
|
|
|
791
1224
|
}
|
|
792
1225
|
|
|
793
1226
|
// src/hooks/useOrganization.ts
|
|
794
|
-
var
|
|
1227
|
+
var import_react6 = require("react");
|
|
795
1228
|
var ROLE_LEVELS = {
|
|
796
1229
|
admin: 100,
|
|
797
1230
|
manager: 50,
|
|
@@ -801,7 +1234,7 @@ function useOrganization() {
|
|
|
801
1234
|
const { organizations, currentOrg, switchOrg } = useSsoContext();
|
|
802
1235
|
const hasMultipleOrgs = organizations.length > 1;
|
|
803
1236
|
const currentRole = currentOrg?.serviceRole ?? null;
|
|
804
|
-
const hasRole = (0,
|
|
1237
|
+
const hasRole = (0, import_react6.useCallback)(
|
|
805
1238
|
(role) => {
|
|
806
1239
|
if (!currentRole) return false;
|
|
807
1240
|
const requiredLevel = ROLE_LEVELS[role] ?? 0;
|
|
@@ -810,13 +1243,13 @@ function useOrganization() {
|
|
|
810
1243
|
},
|
|
811
1244
|
[currentRole]
|
|
812
1245
|
);
|
|
813
|
-
const handleSwitchOrg = (0,
|
|
1246
|
+
const handleSwitchOrg = (0, import_react6.useCallback)(
|
|
814
1247
|
(orgSlug) => {
|
|
815
1248
|
switchOrg(orgSlug);
|
|
816
1249
|
},
|
|
817
1250
|
[switchOrg]
|
|
818
1251
|
);
|
|
819
|
-
return (0,
|
|
1252
|
+
return (0, import_react6.useMemo)(
|
|
820
1253
|
() => ({
|
|
821
1254
|
organizations,
|
|
822
1255
|
currentOrg,
|
|
@@ -830,10 +1263,10 @@ function useOrganization() {
|
|
|
830
1263
|
}
|
|
831
1264
|
|
|
832
1265
|
// src/hooks/useSso.ts
|
|
833
|
-
var
|
|
1266
|
+
var import_react7 = require("react");
|
|
834
1267
|
function useSso() {
|
|
835
1268
|
const context = useSsoContext();
|
|
836
|
-
return (0,
|
|
1269
|
+
return (0, import_react7.useMemo)(
|
|
837
1270
|
() => ({
|
|
838
1271
|
// Auth
|
|
839
1272
|
user: context.user,
|
|
@@ -856,9 +1289,14 @@ function useSso() {
|
|
|
856
1289
|
);
|
|
857
1290
|
}
|
|
858
1291
|
|
|
1292
|
+
// src/hooks/useBranch.ts
|
|
1293
|
+
function useBranch() {
|
|
1294
|
+
return useBranchContext();
|
|
1295
|
+
}
|
|
1296
|
+
|
|
859
1297
|
// src/components/SsoCallback.tsx
|
|
860
|
-
var
|
|
861
|
-
var
|
|
1298
|
+
var import_react8 = require("react");
|
|
1299
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
862
1300
|
function transformUser2(data) {
|
|
863
1301
|
return {
|
|
864
1302
|
id: data.id,
|
|
@@ -877,15 +1315,15 @@ function transformOrganizations2(data) {
|
|
|
877
1315
|
}));
|
|
878
1316
|
}
|
|
879
1317
|
function DefaultLoading() {
|
|
880
|
-
return /* @__PURE__ */ (0,
|
|
1318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: {
|
|
881
1319
|
display: "flex",
|
|
882
1320
|
justifyContent: "center",
|
|
883
1321
|
alignItems: "center",
|
|
884
1322
|
minHeight: "200px"
|
|
885
|
-
}, children: /* @__PURE__ */ (0,
|
|
1323
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: "Authenticating..." }) });
|
|
886
1324
|
}
|
|
887
1325
|
function DefaultError({ error }) {
|
|
888
|
-
return /* @__PURE__ */ (0,
|
|
1326
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: {
|
|
889
1327
|
display: "flex",
|
|
890
1328
|
flexDirection: "column",
|
|
891
1329
|
justifyContent: "center",
|
|
@@ -893,8 +1331,8 @@ function DefaultError({ error }) {
|
|
|
893
1331
|
minHeight: "200px",
|
|
894
1332
|
color: "red"
|
|
895
1333
|
}, children: [
|
|
896
|
-
/* @__PURE__ */ (0,
|
|
897
|
-
/* @__PURE__ */ (0,
|
|
1334
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: "Authentication Error" }),
|
|
1335
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { fontSize: "0.875rem", marginTop: "0.5rem" }, children: error.message })
|
|
898
1336
|
] });
|
|
899
1337
|
}
|
|
900
1338
|
function SsoCallback({
|
|
@@ -905,10 +1343,10 @@ function SsoCallback({
|
|
|
905
1343
|
errorComponent
|
|
906
1344
|
}) {
|
|
907
1345
|
const { config, refreshUser } = useSsoContext();
|
|
908
|
-
const [error, setError] = (0,
|
|
909
|
-
const [isProcessing, setIsProcessing] = (0,
|
|
910
|
-
const isProcessingRef = (0,
|
|
911
|
-
(0,
|
|
1346
|
+
const [error, setError] = (0, import_react8.useState)(null);
|
|
1347
|
+
const [isProcessing, setIsProcessing] = (0, import_react8.useState)(true);
|
|
1348
|
+
const isProcessingRef = (0, import_react8.useRef)(false);
|
|
1349
|
+
(0, import_react8.useEffect)(() => {
|
|
912
1350
|
if (isProcessingRef.current) {
|
|
913
1351
|
return;
|
|
914
1352
|
}
|
|
@@ -959,24 +1397,24 @@ function SsoCallback({
|
|
|
959
1397
|
}, []);
|
|
960
1398
|
if (error) {
|
|
961
1399
|
if (errorComponent) {
|
|
962
|
-
return /* @__PURE__ */ (0,
|
|
1400
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: errorComponent(error) });
|
|
963
1401
|
}
|
|
964
|
-
return /* @__PURE__ */ (0,
|
|
1402
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DefaultError, { error });
|
|
965
1403
|
}
|
|
966
1404
|
if (isProcessing) {
|
|
967
1405
|
if (loadingComponent) {
|
|
968
|
-
return /* @__PURE__ */ (0,
|
|
1406
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: loadingComponent });
|
|
969
1407
|
}
|
|
970
|
-
return /* @__PURE__ */ (0,
|
|
1408
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DefaultLoading, {});
|
|
971
1409
|
}
|
|
972
1410
|
return null;
|
|
973
1411
|
}
|
|
974
1412
|
|
|
975
1413
|
// src/components/OrganizationSwitcher.tsx
|
|
976
|
-
var import_react7 = __toESM(require("react"), 1);
|
|
977
|
-
var import_antd = require("antd");
|
|
978
1414
|
var import_icons = require("@ant-design/icons");
|
|
979
|
-
var
|
|
1415
|
+
var import_antd = require("antd");
|
|
1416
|
+
var import_react9 = __toESM(require("react"), 1);
|
|
1417
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
980
1418
|
var { Text } = import_antd.Typography;
|
|
981
1419
|
function OrganizationSwitcher({
|
|
982
1420
|
className,
|
|
@@ -985,8 +1423,8 @@ function OrganizationSwitcher({
|
|
|
985
1423
|
onChange
|
|
986
1424
|
}) {
|
|
987
1425
|
const { organizations, currentOrg, hasMultipleOrgs, switchOrg } = useOrganization();
|
|
988
|
-
const [isOpen, setIsOpen] =
|
|
989
|
-
const handleSelect = (0,
|
|
1426
|
+
const [isOpen, setIsOpen] = import_react9.default.useState(false);
|
|
1427
|
+
const handleSelect = (0, import_react9.useCallback)(
|
|
990
1428
|
(org) => {
|
|
991
1429
|
switchOrg(org.slug);
|
|
992
1430
|
setIsOpen(false);
|
|
@@ -994,23 +1432,23 @@ function OrganizationSwitcher({
|
|
|
994
1432
|
},
|
|
995
1433
|
[switchOrg, onChange]
|
|
996
1434
|
);
|
|
997
|
-
const menuItems = (0,
|
|
1435
|
+
const menuItems = (0, import_react9.useMemo)(() => {
|
|
998
1436
|
return organizations.map((org) => {
|
|
999
1437
|
const isSelected = currentOrg?.slug === org.slug;
|
|
1000
1438
|
if (renderOption) {
|
|
1001
1439
|
return {
|
|
1002
1440
|
key: org.slug,
|
|
1003
|
-
label: /* @__PURE__ */ (0,
|
|
1441
|
+
label: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { onClick: () => handleSelect(org), children: renderOption(org, isSelected) })
|
|
1004
1442
|
};
|
|
1005
1443
|
}
|
|
1006
1444
|
return {
|
|
1007
1445
|
key: org.slug,
|
|
1008
|
-
label: /* @__PURE__ */ (0,
|
|
1009
|
-
/* @__PURE__ */ (0,
|
|
1010
|
-
/* @__PURE__ */ (0,
|
|
1011
|
-
org.serviceRole && /* @__PURE__ */ (0,
|
|
1446
|
+
label: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_antd.Space, { style: { width: "100%", justifyContent: "space-between" }, children: [
|
|
1447
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_antd.Space, { direction: "vertical", size: 0, children: [
|
|
1448
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { strong: isSelected, children: org.name }),
|
|
1449
|
+
org.serviceRole && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Text, { type: "secondary", style: { fontSize: 12 }, children: org.serviceRole })
|
|
1012
1450
|
] }),
|
|
1013
|
-
isSelected && /* @__PURE__ */ (0,
|
|
1451
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons.CheckOutlined, { style: { color: "#1890ff" } })
|
|
1014
1452
|
] }),
|
|
1015
1453
|
onClick: () => handleSelect(org)
|
|
1016
1454
|
};
|
|
@@ -1020,7 +1458,7 @@ function OrganizationSwitcher({
|
|
|
1020
1458
|
return null;
|
|
1021
1459
|
}
|
|
1022
1460
|
if (renderTrigger) {
|
|
1023
|
-
return /* @__PURE__ */ (0,
|
|
1461
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1024
1462
|
import_antd.Dropdown,
|
|
1025
1463
|
{
|
|
1026
1464
|
menu: { items: menuItems },
|
|
@@ -1028,11 +1466,11 @@ function OrganizationSwitcher({
|
|
|
1028
1466
|
open: isOpen,
|
|
1029
1467
|
onOpenChange: setIsOpen,
|
|
1030
1468
|
className,
|
|
1031
|
-
children: /* @__PURE__ */ (0,
|
|
1469
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { cursor: "pointer" }, children: renderTrigger(currentOrg, isOpen) })
|
|
1032
1470
|
}
|
|
1033
1471
|
);
|
|
1034
1472
|
}
|
|
1035
|
-
return /* @__PURE__ */ (0,
|
|
1473
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1036
1474
|
import_antd.Dropdown,
|
|
1037
1475
|
{
|
|
1038
1476
|
menu: { items: menuItems },
|
|
@@ -1040,28 +1478,28 @@ function OrganizationSwitcher({
|
|
|
1040
1478
|
open: isOpen,
|
|
1041
1479
|
onOpenChange: setIsOpen,
|
|
1042
1480
|
className,
|
|
1043
|
-
children: /* @__PURE__ */ (0,
|
|
1044
|
-
/* @__PURE__ */ (0,
|
|
1045
|
-
/* @__PURE__ */ (0,
|
|
1046
|
-
/* @__PURE__ */ (0,
|
|
1481
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd.Button, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_antd.Space, { children: [
|
|
1482
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd.Badge, { status: "success" }),
|
|
1483
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: currentOrg?.name ?? "Select Organization" }),
|
|
1484
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons.SwapOutlined, {})
|
|
1047
1485
|
] }) })
|
|
1048
1486
|
}
|
|
1049
1487
|
);
|
|
1050
1488
|
}
|
|
1051
1489
|
|
|
1052
1490
|
// src/components/ProtectedRoute.tsx
|
|
1053
|
-
var
|
|
1054
|
-
var
|
|
1491
|
+
var import_react10 = require("react");
|
|
1492
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1055
1493
|
function DefaultLoading2() {
|
|
1056
|
-
return /* @__PURE__ */ (0,
|
|
1494
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
|
|
1057
1495
|
display: "flex",
|
|
1058
1496
|
justifyContent: "center",
|
|
1059
1497
|
alignItems: "center",
|
|
1060
1498
|
minHeight: "200px"
|
|
1061
|
-
}, children: /* @__PURE__ */ (0,
|
|
1499
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: "Loading..." }) });
|
|
1062
1500
|
}
|
|
1063
1501
|
function DefaultLoginFallback({ login }) {
|
|
1064
|
-
return /* @__PURE__ */ (0,
|
|
1502
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
|
|
1065
1503
|
display: "flex",
|
|
1066
1504
|
flexDirection: "column",
|
|
1067
1505
|
justifyContent: "center",
|
|
@@ -1069,8 +1507,8 @@ function DefaultLoginFallback({ login }) {
|
|
|
1069
1507
|
minHeight: "200px",
|
|
1070
1508
|
gap: "1rem"
|
|
1071
1509
|
}, children: [
|
|
1072
|
-
/* @__PURE__ */ (0,
|
|
1073
|
-
/* @__PURE__ */ (0,
|
|
1510
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: "Please log in to continue" }),
|
|
1511
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1074
1512
|
"button",
|
|
1075
1513
|
{
|
|
1076
1514
|
onClick: login,
|
|
@@ -1088,7 +1526,7 @@ function DefaultLoginFallback({ login }) {
|
|
|
1088
1526
|
] });
|
|
1089
1527
|
}
|
|
1090
1528
|
function DefaultAccessDenied({ reason }) {
|
|
1091
|
-
return /* @__PURE__ */ (0,
|
|
1529
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
|
|
1092
1530
|
display: "flex",
|
|
1093
1531
|
flexDirection: "column",
|
|
1094
1532
|
justifyContent: "center",
|
|
@@ -1096,85 +1534,1104 @@ function DefaultAccessDenied({ reason }) {
|
|
|
1096
1534
|
minHeight: "200px",
|
|
1097
1535
|
color: "#dc2626"
|
|
1098
1536
|
}, children: [
|
|
1099
|
-
/* @__PURE__ */ (0,
|
|
1100
|
-
/* @__PURE__ */ (0,
|
|
1537
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { fontSize: "1.5rem", fontWeight: 600 }, children: "Access Denied" }),
|
|
1538
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { marginTop: "0.5rem" }, children: reason })
|
|
1101
1539
|
] });
|
|
1102
1540
|
}
|
|
1103
|
-
function ProtectedRoute({
|
|
1104
|
-
children,
|
|
1105
|
-
fallback,
|
|
1106
|
-
loginFallback,
|
|
1107
|
-
requiredRole,
|
|
1108
|
-
requiredPermission,
|
|
1109
|
-
onAccessDenied
|
|
1541
|
+
function ProtectedRoute({
|
|
1542
|
+
children,
|
|
1543
|
+
fallback,
|
|
1544
|
+
loginFallback,
|
|
1545
|
+
requiredRole,
|
|
1546
|
+
requiredPermission,
|
|
1547
|
+
onAccessDenied
|
|
1548
|
+
}) {
|
|
1549
|
+
const { user, isLoading, isAuthenticated, login } = useAuth();
|
|
1550
|
+
const { hasRole, currentOrg } = useOrganization();
|
|
1551
|
+
(0, import_react10.useEffect)(() => {
|
|
1552
|
+
if (isLoading) return;
|
|
1553
|
+
if (!isAuthenticated) {
|
|
1554
|
+
onAccessDenied?.("unauthenticated");
|
|
1555
|
+
} else if (requiredRole && !hasRole(requiredRole)) {
|
|
1556
|
+
onAccessDenied?.("insufficient_role");
|
|
1557
|
+
}
|
|
1558
|
+
}, [isLoading, isAuthenticated, requiredRole, hasRole, onAccessDenied]);
|
|
1559
|
+
if (isLoading) {
|
|
1560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: fallback ?? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DefaultLoading2, {}) });
|
|
1561
|
+
}
|
|
1562
|
+
if (!isAuthenticated) {
|
|
1563
|
+
if (loginFallback) {
|
|
1564
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: loginFallback });
|
|
1565
|
+
}
|
|
1566
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DefaultLoginFallback, { login: () => login() });
|
|
1567
|
+
}
|
|
1568
|
+
if (requiredRole && !hasRole(requiredRole)) {
|
|
1569
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1570
|
+
DefaultAccessDenied,
|
|
1571
|
+
{
|
|
1572
|
+
reason: `This page requires ${requiredRole} role. Your role: ${currentOrg?.serviceRole ?? "none"}`
|
|
1573
|
+
}
|
|
1574
|
+
);
|
|
1575
|
+
}
|
|
1576
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children });
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
// src/components/OrgBranchSelectorModal.tsx
|
|
1580
|
+
var import_icons2 = require("@ant-design/icons");
|
|
1581
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
1582
|
+
var import_antd2 = require("antd");
|
|
1583
|
+
var import_react11 = require("react");
|
|
1584
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1585
|
+
var { Text: Text2, Title } = import_antd2.Typography;
|
|
1586
|
+
function OrgBranchSelectorModal({
|
|
1587
|
+
open,
|
|
1588
|
+
onClose,
|
|
1589
|
+
onConfirm,
|
|
1590
|
+
title = "Select Organization & Branch",
|
|
1591
|
+
requireBranch = true,
|
|
1592
|
+
loadingComponent
|
|
1593
|
+
}) {
|
|
1594
|
+
const { config } = useSsoContext();
|
|
1595
|
+
const { organizations, currentOrg, hasMultipleOrgs } = useOrganization();
|
|
1596
|
+
const { currentBranch } = useBranch();
|
|
1597
|
+
const [form] = import_antd2.Form.useForm();
|
|
1598
|
+
const [selectedOrgSlug, setSelectedOrgSlug] = (0, import_react11.useState)(
|
|
1599
|
+
currentOrg?.slug ?? null
|
|
1600
|
+
);
|
|
1601
|
+
const branchService = (0, import_react11.useMemo)(
|
|
1602
|
+
() => createBranchService({ apiUrl: config.apiUrl }),
|
|
1603
|
+
[config.apiUrl]
|
|
1604
|
+
);
|
|
1605
|
+
const {
|
|
1606
|
+
data: branchesData,
|
|
1607
|
+
isLoading: branchesLoading,
|
|
1608
|
+
error: branchesError
|
|
1609
|
+
} = (0, import_react_query2.useQuery)({
|
|
1610
|
+
queryKey: ssoQueryKeys.branches.list(selectedOrgSlug ?? void 0),
|
|
1611
|
+
queryFn: () => branchService.list(selectedOrgSlug ?? void 0),
|
|
1612
|
+
enabled: open && !!selectedOrgSlug
|
|
1613
|
+
});
|
|
1614
|
+
const branches = branchesData?.branches ?? [];
|
|
1615
|
+
const hasMultipleBranches = branches.length > 1;
|
|
1616
|
+
const selectedOrg = (0, import_react11.useMemo)(
|
|
1617
|
+
() => {
|
|
1618
|
+
if (selectedOrgSlug) {
|
|
1619
|
+
return organizations.find((o) => o.slug === selectedOrgSlug) ?? null;
|
|
1620
|
+
}
|
|
1621
|
+
if (organizations.length === 1) {
|
|
1622
|
+
return organizations[0];
|
|
1623
|
+
}
|
|
1624
|
+
return null;
|
|
1625
|
+
},
|
|
1626
|
+
[organizations, selectedOrgSlug]
|
|
1627
|
+
);
|
|
1628
|
+
(0, import_react11.useEffect)(() => {
|
|
1629
|
+
if (!open) return;
|
|
1630
|
+
if (selectedOrgSlug && form.getFieldValue("organization_id")) return;
|
|
1631
|
+
if (currentOrg) {
|
|
1632
|
+
setSelectedOrgSlug(currentOrg.slug);
|
|
1633
|
+
form.setFieldValue("organization_id", currentOrg.id);
|
|
1634
|
+
} else if (organizations.length === 1) {
|
|
1635
|
+
setSelectedOrgSlug(organizations[0].slug);
|
|
1636
|
+
form.setFieldValue("organization_id", organizations[0].id);
|
|
1637
|
+
}
|
|
1638
|
+
}, [open, organizations, currentOrg, selectedOrgSlug, form]);
|
|
1639
|
+
(0, import_react11.useEffect)(() => {
|
|
1640
|
+
if (!open || branchesLoading) return;
|
|
1641
|
+
if (branches.length === 1) {
|
|
1642
|
+
form.setFieldValue("branch_id", branches[0].id);
|
|
1643
|
+
} else if (branches.length > 0) {
|
|
1644
|
+
if (currentBranch && branches.some((b) => b.id === currentBranch.id)) {
|
|
1645
|
+
form.setFieldValue("branch_id", currentBranch.id);
|
|
1646
|
+
} else {
|
|
1647
|
+
const primaryId = branchesData?.primary_branch_id;
|
|
1648
|
+
if (primaryId) {
|
|
1649
|
+
form.setFieldValue("branch_id", primaryId);
|
|
1650
|
+
} else {
|
|
1651
|
+
const hq = branches.find((b) => b.is_headquarters);
|
|
1652
|
+
if (hq) {
|
|
1653
|
+
form.setFieldValue("branch_id", hq.id);
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
}, [open, branches, branchesLoading, branchesData, currentBranch, form]);
|
|
1659
|
+
(0, import_react11.useEffect)(() => {
|
|
1660
|
+
if (!open || branchesLoading) return;
|
|
1661
|
+
const orgId = form.getFieldValue("organization_id");
|
|
1662
|
+
const branchId = form.getFieldValue("branch_id");
|
|
1663
|
+
if (orgId && branchId && !hasMultipleOrgs && !hasMultipleBranches) {
|
|
1664
|
+
const timer = setTimeout(() => {
|
|
1665
|
+
onConfirm(orgId, branchId);
|
|
1666
|
+
}, 100);
|
|
1667
|
+
return () => clearTimeout(timer);
|
|
1668
|
+
}
|
|
1669
|
+
}, [open, branchesLoading, hasMultipleOrgs, hasMultipleBranches, form, onConfirm]);
|
|
1670
|
+
const handleOrgChange = (0, import_react11.useCallback)((orgId) => {
|
|
1671
|
+
const org = organizations.find((o) => o.id === orgId);
|
|
1672
|
+
if (org) {
|
|
1673
|
+
setSelectedOrgSlug(org.slug);
|
|
1674
|
+
form.setFieldValue("branch_id", void 0);
|
|
1675
|
+
}
|
|
1676
|
+
}, [organizations, form]);
|
|
1677
|
+
const handleSubmit = (0, import_react11.useCallback)(() => {
|
|
1678
|
+
form.validateFields().then((values) => {
|
|
1679
|
+
onConfirm(values.organization_id, values.branch_id);
|
|
1680
|
+
});
|
|
1681
|
+
}, [form, onConfirm]);
|
|
1682
|
+
const handleClose = (0, import_react11.useCallback)(() => {
|
|
1683
|
+
form.resetFields();
|
|
1684
|
+
setSelectedOrgSlug(currentOrg?.slug ?? null);
|
|
1685
|
+
onClose();
|
|
1686
|
+
}, [form, currentOrg, onClose]);
|
|
1687
|
+
const isInitialLoading = open && (!organizations.length || selectedOrgSlug && branchesLoading && !branches.length);
|
|
1688
|
+
const needsSelection = hasMultipleOrgs || hasMultipleBranches;
|
|
1689
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1690
|
+
import_antd2.Modal,
|
|
1691
|
+
{
|
|
1692
|
+
title: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_antd2.Space, { children: [
|
|
1693
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons2.BankOutlined, {}),
|
|
1694
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: title })
|
|
1695
|
+
] }),
|
|
1696
|
+
open,
|
|
1697
|
+
onCancel: handleClose,
|
|
1698
|
+
onOk: handleSubmit,
|
|
1699
|
+
okText: "Confirm",
|
|
1700
|
+
cancelText: "Cancel",
|
|
1701
|
+
destroyOnHidden: true,
|
|
1702
|
+
width: 480,
|
|
1703
|
+
children: isInitialLoading ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { textAlign: "center", padding: 40 }, children: [
|
|
1704
|
+
loadingComponent ?? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd2.Spin, { size: "large" }),
|
|
1705
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { marginTop: 16 }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text2, { type: "secondary", children: "Loading..." }) })
|
|
1706
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1707
|
+
import_antd2.Form,
|
|
1708
|
+
{
|
|
1709
|
+
form,
|
|
1710
|
+
layout: "vertical",
|
|
1711
|
+
style: { marginTop: 16 },
|
|
1712
|
+
children: [
|
|
1713
|
+
branchesError && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1714
|
+
import_antd2.Alert,
|
|
1715
|
+
{
|
|
1716
|
+
type: "error",
|
|
1717
|
+
message: "Failed to load branches",
|
|
1718
|
+
description: branchesError.message,
|
|
1719
|
+
style: { marginBottom: 16 }
|
|
1720
|
+
}
|
|
1721
|
+
),
|
|
1722
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1723
|
+
import_antd2.Form.Item,
|
|
1724
|
+
{
|
|
1725
|
+
name: "organization_id",
|
|
1726
|
+
label: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_antd2.Space, { children: [
|
|
1727
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons2.BankOutlined, {}),
|
|
1728
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "Organization" }),
|
|
1729
|
+
!hasMultipleOrgs && selectedOrg && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd2.Badge, { status: "success", text: "Auto-selected" })
|
|
1730
|
+
] }),
|
|
1731
|
+
rules: [{ required: true, message: "Please select an organization" }],
|
|
1732
|
+
children: hasMultipleOrgs ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1733
|
+
import_antd2.Select,
|
|
1734
|
+
{
|
|
1735
|
+
placeholder: "Select organization",
|
|
1736
|
+
onChange: handleOrgChange,
|
|
1737
|
+
size: "large",
|
|
1738
|
+
optionLabelProp: "label",
|
|
1739
|
+
children: organizations.map((org) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1740
|
+
import_antd2.Select.Option,
|
|
1741
|
+
{
|
|
1742
|
+
value: org.id,
|
|
1743
|
+
label: org.name,
|
|
1744
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_antd2.Space, { style: { width: "100%", justifyContent: "space-between" }, children: [
|
|
1745
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1746
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text2, { strong: true, children: org.name }),
|
|
1747
|
+
org.serviceRole && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text2, { type: "secondary", style: { marginLeft: 8, fontSize: 12 }, children: [
|
|
1748
|
+
"(",
|
|
1749
|
+
org.serviceRole,
|
|
1750
|
+
")"
|
|
1751
|
+
] })
|
|
1752
|
+
] }),
|
|
1753
|
+
org.slug === currentOrg?.slug && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons2.CheckCircleFilled, { style: { color: "#52c41a" } })
|
|
1754
|
+
] })
|
|
1755
|
+
},
|
|
1756
|
+
org.id
|
|
1757
|
+
))
|
|
1758
|
+
}
|
|
1759
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1760
|
+
"div",
|
|
1761
|
+
{
|
|
1762
|
+
style: {
|
|
1763
|
+
padding: "8px 12px",
|
|
1764
|
+
background: "#f5f5f5",
|
|
1765
|
+
borderRadius: 6,
|
|
1766
|
+
border: "1px solid #d9d9d9"
|
|
1767
|
+
},
|
|
1768
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_antd2.Space, { children: [
|
|
1769
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons2.BankOutlined, { style: { color: "#1677ff" } }),
|
|
1770
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text2, { strong: true, children: selectedOrg?.name })
|
|
1771
|
+
] })
|
|
1772
|
+
}
|
|
1773
|
+
)
|
|
1774
|
+
}
|
|
1775
|
+
),
|
|
1776
|
+
selectedOrgSlug && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1777
|
+
import_antd2.Form.Item,
|
|
1778
|
+
{
|
|
1779
|
+
name: "branch_id",
|
|
1780
|
+
label: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_antd2.Space, { children: [
|
|
1781
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons2.ApartmentOutlined, {}),
|
|
1782
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "Branch" }),
|
|
1783
|
+
!hasMultipleBranches && branches.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd2.Badge, { status: "success", text: "Auto-selected" })
|
|
1784
|
+
] }),
|
|
1785
|
+
rules: requireBranch ? [{ required: true, message: "Please select a branch" }] : void 0,
|
|
1786
|
+
children: branchesLoading ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { padding: "8px 12px", textAlign: "center" }, children: [
|
|
1787
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd2.Spin, { size: "small" }),
|
|
1788
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text2, { type: "secondary", style: { marginLeft: 8 }, children: "Loading branches..." })
|
|
1789
|
+
] }) : hasMultipleBranches ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1790
|
+
import_antd2.Select,
|
|
1791
|
+
{
|
|
1792
|
+
placeholder: "Select branch",
|
|
1793
|
+
size: "large",
|
|
1794
|
+
optionLabelProp: "label",
|
|
1795
|
+
children: branches.map((branch) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1796
|
+
import_antd2.Select.Option,
|
|
1797
|
+
{
|
|
1798
|
+
value: branch.id,
|
|
1799
|
+
label: branch.name,
|
|
1800
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_antd2.Space, { style: { width: "100%", justifyContent: "space-between" }, children: [
|
|
1801
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1802
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text2, { strong: true, children: branch.name }),
|
|
1803
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text2, { type: "secondary", style: { marginLeft: 8, fontSize: 12 }, children: branch.code })
|
|
1804
|
+
] }),
|
|
1805
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_antd2.Space, { size: 4, children: [
|
|
1806
|
+
branch.is_headquarters && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd2.Badge, { color: "blue", text: "HQ" }),
|
|
1807
|
+
branch.is_primary && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_antd2.Badge, { color: "green", text: "Primary" })
|
|
1808
|
+
] })
|
|
1809
|
+
] })
|
|
1810
|
+
},
|
|
1811
|
+
branch.id
|
|
1812
|
+
))
|
|
1813
|
+
}
|
|
1814
|
+
) : branches.length === 1 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1815
|
+
"div",
|
|
1816
|
+
{
|
|
1817
|
+
style: {
|
|
1818
|
+
padding: "8px 12px",
|
|
1819
|
+
background: "#f5f5f5",
|
|
1820
|
+
borderRadius: 6,
|
|
1821
|
+
border: "1px solid #d9d9d9"
|
|
1822
|
+
},
|
|
1823
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_antd2.Space, { children: [
|
|
1824
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons2.ApartmentOutlined, { style: { color: "#1677ff" } }),
|
|
1825
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Text2, { strong: true, children: branches[0].name }),
|
|
1826
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Text2, { type: "secondary", children: [
|
|
1827
|
+
"(",
|
|
1828
|
+
branches[0].code,
|
|
1829
|
+
")"
|
|
1830
|
+
] })
|
|
1831
|
+
] })
|
|
1832
|
+
}
|
|
1833
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1834
|
+
import_antd2.Alert,
|
|
1835
|
+
{
|
|
1836
|
+
type: "warning",
|
|
1837
|
+
message: "No branches available",
|
|
1838
|
+
description: "You don't have access to any branches in this organization."
|
|
1839
|
+
}
|
|
1840
|
+
)
|
|
1841
|
+
}
|
|
1842
|
+
),
|
|
1843
|
+
!needsSelection && selectedOrg && branches.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1844
|
+
import_antd2.Alert,
|
|
1845
|
+
{
|
|
1846
|
+
type: "info",
|
|
1847
|
+
message: "Auto-selected",
|
|
1848
|
+
description: `Using ${selectedOrg.name} / ${branches[0]?.name ?? "Default"}`,
|
|
1849
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons2.CheckCircleFilled, {}),
|
|
1850
|
+
showIcon: true
|
|
1851
|
+
}
|
|
1852
|
+
)
|
|
1853
|
+
]
|
|
1854
|
+
}
|
|
1855
|
+
)
|
|
1856
|
+
}
|
|
1857
|
+
);
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
// src/components/BranchGate.tsx
|
|
1861
|
+
var import_icons3 = require("@ant-design/icons");
|
|
1862
|
+
var import_react_query3 = require("@tanstack/react-query");
|
|
1863
|
+
var import_antd3 = require("antd");
|
|
1864
|
+
var import_react12 = __toESM(require("react"), 1);
|
|
1865
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1866
|
+
var { Text: Text3, Title: Title2 } = import_antd3.Typography;
|
|
1867
|
+
var DEFAULT_STORAGE_KEY2 = "omnify_branch_gate_selection";
|
|
1868
|
+
function BranchGate({
|
|
1869
|
+
children,
|
|
1870
|
+
onSelectionChange,
|
|
1871
|
+
storageKey = DEFAULT_STORAGE_KEY2,
|
|
1872
|
+
loadingComponent,
|
|
1873
|
+
title,
|
|
1874
|
+
description
|
|
1875
|
+
}) {
|
|
1876
|
+
const { config, isAuthenticated } = useSsoContext();
|
|
1877
|
+
const { organizations, currentOrg, hasMultipleOrgs } = useOrganization();
|
|
1878
|
+
const [storedSelection, setStoredSelection] = (0, import_react12.useState)(null);
|
|
1879
|
+
const [isInitialized, setIsInitialized] = (0, import_react12.useState)(false);
|
|
1880
|
+
const [tempOrgId, setTempOrgId] = (0, import_react12.useState)(null);
|
|
1881
|
+
const [tempBranchId, setTempBranchId] = (0, import_react12.useState)(null);
|
|
1882
|
+
const branchService = import_react12.default.useMemo(
|
|
1883
|
+
() => createBranchService({ apiUrl: config.apiUrl }),
|
|
1884
|
+
[config.apiUrl]
|
|
1885
|
+
);
|
|
1886
|
+
const activeOrgSlug = import_react12.default.useMemo(() => {
|
|
1887
|
+
if (tempOrgId) {
|
|
1888
|
+
return organizations.find((o) => String(o.id) === tempOrgId)?.slug;
|
|
1889
|
+
}
|
|
1890
|
+
return storedSelection?.orgSlug ?? currentOrg?.slug;
|
|
1891
|
+
}, [tempOrgId, organizations, storedSelection, currentOrg]);
|
|
1892
|
+
const { data: branchesData, isLoading: branchesLoading } = (0, import_react_query3.useQuery)({
|
|
1893
|
+
queryKey: ssoQueryKeys.branches.list(activeOrgSlug),
|
|
1894
|
+
queryFn: () => branchService.list(activeOrgSlug),
|
|
1895
|
+
enabled: isAuthenticated && !!activeOrgSlug
|
|
1896
|
+
});
|
|
1897
|
+
const branches = branchesData?.branches ?? [];
|
|
1898
|
+
const hasMultipleBranches = branches.length > 1;
|
|
1899
|
+
(0, import_react12.useEffect)(() => {
|
|
1900
|
+
if (typeof window === "undefined") return;
|
|
1901
|
+
const saved = localStorage.getItem(storageKey);
|
|
1902
|
+
if (saved) {
|
|
1903
|
+
try {
|
|
1904
|
+
const parsed = JSON.parse(saved);
|
|
1905
|
+
setStoredSelection(parsed);
|
|
1906
|
+
onSelectionChange?.(parsed);
|
|
1907
|
+
} catch {
|
|
1908
|
+
localStorage.removeItem(storageKey);
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
setIsInitialized(true);
|
|
1912
|
+
}, [storageKey, onSelectionChange]);
|
|
1913
|
+
(0, import_react12.useEffect)(() => {
|
|
1914
|
+
if (!isAuthenticated || !isInitialized || storedSelection) return;
|
|
1915
|
+
if (organizations.length === 1 && !tempOrgId) {
|
|
1916
|
+
setTempOrgId(String(organizations[0].id));
|
|
1917
|
+
}
|
|
1918
|
+
}, [isAuthenticated, isInitialized, organizations, storedSelection, tempOrgId]);
|
|
1919
|
+
(0, import_react12.useEffect)(() => {
|
|
1920
|
+
if (!tempOrgId || branchesLoading || storedSelection) return;
|
|
1921
|
+
if (branches.length === 1 && !tempBranchId) {
|
|
1922
|
+
setTempBranchId(String(branches[0].id));
|
|
1923
|
+
} else if (branches.length > 0 && !tempBranchId) {
|
|
1924
|
+
const primaryId = branchesData?.primary_branch_id;
|
|
1925
|
+
if (primaryId) {
|
|
1926
|
+
setTempBranchId(String(primaryId));
|
|
1927
|
+
} else {
|
|
1928
|
+
const hq = branches.find((b) => b.is_headquarters);
|
|
1929
|
+
if (hq) {
|
|
1930
|
+
setTempBranchId(String(hq.id));
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
}, [tempOrgId, branches, branchesLoading, branchesData, storedSelection, tempBranchId]);
|
|
1935
|
+
(0, import_react12.useEffect)(() => {
|
|
1936
|
+
if (storedSelection || !isInitialized) return;
|
|
1937
|
+
if (!tempOrgId || !tempBranchId || branchesLoading) return;
|
|
1938
|
+
if (!hasMultipleOrgs && !hasMultipleBranches) {
|
|
1939
|
+
confirmSelection();
|
|
1940
|
+
}
|
|
1941
|
+
}, [tempOrgId, tempBranchId, branchesLoading, hasMultipleOrgs, hasMultipleBranches, storedSelection, isInitialized]);
|
|
1942
|
+
const confirmSelection = import_react12.default.useCallback(() => {
|
|
1943
|
+
if (!tempOrgId || !tempBranchId) return;
|
|
1944
|
+
const org = organizations.find((o) => String(o.id) === tempOrgId);
|
|
1945
|
+
const branch = branches.find((b) => String(b.id) === tempBranchId);
|
|
1946
|
+
if (!org || !branch) return;
|
|
1947
|
+
const selection = {
|
|
1948
|
+
orgId: String(org.id),
|
|
1949
|
+
orgSlug: org.slug,
|
|
1950
|
+
orgName: org.name,
|
|
1951
|
+
branchId: String(branch.id),
|
|
1952
|
+
branchName: branch.name,
|
|
1953
|
+
branchCode: branch.code
|
|
1954
|
+
};
|
|
1955
|
+
localStorage.setItem(storageKey, JSON.stringify(selection));
|
|
1956
|
+
setStoredSelection(selection);
|
|
1957
|
+
onSelectionChange?.(selection);
|
|
1958
|
+
setTempOrgId(null);
|
|
1959
|
+
setTempBranchId(null);
|
|
1960
|
+
}, [tempOrgId, tempBranchId, organizations, branches, storageKey, onSelectionChange]);
|
|
1961
|
+
const clearSelection = import_react12.default.useCallback(() => {
|
|
1962
|
+
localStorage.removeItem(storageKey);
|
|
1963
|
+
setStoredSelection(null);
|
|
1964
|
+
onSelectionChange?.(null);
|
|
1965
|
+
}, [storageKey, onSelectionChange]);
|
|
1966
|
+
const needsSelection = isAuthenticated && isInitialized && !storedSelection && (hasMultipleOrgs || hasMultipleBranches);
|
|
1967
|
+
const isLoading = !isAuthenticated || !isInitialized || !!activeOrgSlug && branchesLoading && !storedSelection;
|
|
1968
|
+
if (isLoading && !needsSelection) {
|
|
1969
|
+
if (loadingComponent) {
|
|
1970
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: loadingComponent });
|
|
1971
|
+
}
|
|
1972
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
|
|
1973
|
+
display: "flex",
|
|
1974
|
+
justifyContent: "center",
|
|
1975
|
+
alignItems: "center",
|
|
1976
|
+
minHeight: "100vh",
|
|
1977
|
+
background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)"
|
|
1978
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_antd3.Spin, { size: "large" }) });
|
|
1979
|
+
}
|
|
1980
|
+
if (needsSelection) {
|
|
1981
|
+
const canConfirm = tempOrgId && tempBranchId;
|
|
1982
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
|
|
1983
|
+
minHeight: "100vh",
|
|
1984
|
+
background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
|
|
1985
|
+
display: "flex",
|
|
1986
|
+
alignItems: "center",
|
|
1987
|
+
justifyContent: "center",
|
|
1988
|
+
padding: 24
|
|
1989
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: {
|
|
1990
|
+
background: "#fff",
|
|
1991
|
+
borderRadius: 16,
|
|
1992
|
+
padding: 32,
|
|
1993
|
+
maxWidth: 480,
|
|
1994
|
+
width: "100%",
|
|
1995
|
+
boxShadow: "0 20px 60px rgba(0,0,0,0.3)"
|
|
1996
|
+
}, children: [
|
|
1997
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { textAlign: "center", marginBottom: 24 }, children: [
|
|
1998
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
|
|
1999
|
+
width: 64,
|
|
2000
|
+
height: 64,
|
|
2001
|
+
borderRadius: "50%",
|
|
2002
|
+
background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
|
|
2003
|
+
display: "flex",
|
|
2004
|
+
alignItems: "center",
|
|
2005
|
+
justifyContent: "center",
|
|
2006
|
+
margin: "0 auto 16px"
|
|
2007
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons3.BankOutlined, { style: { fontSize: 28, color: "#fff" } }) }),
|
|
2008
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Title2, { level: 3, style: { margin: 0 }, children: title ?? "Select Organization" }),
|
|
2009
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text3, { type: "secondary", children: description ?? "Please select your organization and branch to continue" })
|
|
2010
|
+
] }),
|
|
2011
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { marginBottom: 20 }, children: [
|
|
2012
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text3, { strong: true, style: { display: "block", marginBottom: 8 }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd3.Space, { children: [
|
|
2013
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons3.BankOutlined, {}),
|
|
2014
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "Organization" }),
|
|
2015
|
+
!hasMultipleOrgs && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_antd3.Badge, { status: "success", text: "Auto-selected" })
|
|
2016
|
+
] }) }),
|
|
2017
|
+
hasMultipleOrgs ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2018
|
+
import_antd3.Select,
|
|
2019
|
+
{
|
|
2020
|
+
value: tempOrgId,
|
|
2021
|
+
onChange: (value) => {
|
|
2022
|
+
setTempOrgId(String(value));
|
|
2023
|
+
setTempBranchId(null);
|
|
2024
|
+
},
|
|
2025
|
+
placeholder: "Select organization",
|
|
2026
|
+
size: "large",
|
|
2027
|
+
style: { width: "100%" },
|
|
2028
|
+
optionLabelProp: "label",
|
|
2029
|
+
children: organizations.map((org) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_antd3.Select.Option, { value: String(org.id), label: org.name, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_antd3.Space, { style: { width: "100%", justifyContent: "space-between" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
|
|
2030
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text3, { strong: true, children: org.name }),
|
|
2031
|
+
org.serviceRole && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text3, { type: "secondary", style: { marginLeft: 8, fontSize: 12 }, children: [
|
|
2032
|
+
"(",
|
|
2033
|
+
org.serviceRole,
|
|
2034
|
+
")"
|
|
2035
|
+
] })
|
|
2036
|
+
] }) }) }, org.id))
|
|
2037
|
+
}
|
|
2038
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
|
|
2039
|
+
padding: "8px 12px",
|
|
2040
|
+
background: "#f5f5f5",
|
|
2041
|
+
borderRadius: 6,
|
|
2042
|
+
border: "1px solid #d9d9d9"
|
|
2043
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd3.Space, { children: [
|
|
2044
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons3.BankOutlined, { style: { color: "#1677ff" } }),
|
|
2045
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text3, { strong: true, children: organizations[0]?.name })
|
|
2046
|
+
] }) })
|
|
2047
|
+
] }),
|
|
2048
|
+
tempOrgId && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { marginBottom: 24 }, children: [
|
|
2049
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text3, { strong: true, style: { display: "block", marginBottom: 8 }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd3.Space, { children: [
|
|
2050
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons3.ApartmentOutlined, {}),
|
|
2051
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "Branch" }),
|
|
2052
|
+
!hasMultipleBranches && branches.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_antd3.Badge, { status: "success", text: "Auto-selected" })
|
|
2053
|
+
] }) }),
|
|
2054
|
+
branchesLoading ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { padding: "12px", textAlign: "center" }, children: [
|
|
2055
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_antd3.Spin, { size: "small" }),
|
|
2056
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text3, { type: "secondary", style: { marginLeft: 8 }, children: "Loading..." })
|
|
2057
|
+
] }) : hasMultipleBranches ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2058
|
+
import_antd3.Select,
|
|
2059
|
+
{
|
|
2060
|
+
value: tempBranchId,
|
|
2061
|
+
onChange: (value) => setTempBranchId(String(value)),
|
|
2062
|
+
placeholder: "Select branch",
|
|
2063
|
+
size: "large",
|
|
2064
|
+
style: { width: "100%" },
|
|
2065
|
+
optionLabelProp: "label",
|
|
2066
|
+
children: branches.map((branch) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_antd3.Select.Option, { value: String(branch.id), label: branch.name, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd3.Space, { style: { width: "100%", justifyContent: "space-between" }, children: [
|
|
2067
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
|
|
2068
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text3, { strong: true, children: branch.name }),
|
|
2069
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text3, { type: "secondary", style: { marginLeft: 8, fontSize: 12 }, children: branch.code })
|
|
2070
|
+
] }),
|
|
2071
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd3.Space, { size: 4, children: [
|
|
2072
|
+
branch.is_headquarters && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_antd3.Badge, { color: "blue", text: "HQ" }),
|
|
2073
|
+
branch.is_primary && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_antd3.Badge, { color: "green", text: "Primary" })
|
|
2074
|
+
] })
|
|
2075
|
+
] }) }, branch.id))
|
|
2076
|
+
}
|
|
2077
|
+
) : branches.length === 1 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
|
|
2078
|
+
padding: "8px 12px",
|
|
2079
|
+
background: "#f5f5f5",
|
|
2080
|
+
borderRadius: 6,
|
|
2081
|
+
border: "1px solid #d9d9d9"
|
|
2082
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd3.Space, { children: [
|
|
2083
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons3.ApartmentOutlined, { style: { color: "#1677ff" } }),
|
|
2084
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text3, { strong: true, children: branches[0].name }),
|
|
2085
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text3, { type: "secondary", children: [
|
|
2086
|
+
"(",
|
|
2087
|
+
branches[0].code,
|
|
2088
|
+
")"
|
|
2089
|
+
] })
|
|
2090
|
+
] }) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2091
|
+
import_antd3.Alert,
|
|
2092
|
+
{
|
|
2093
|
+
type: "warning",
|
|
2094
|
+
message: "No branches available",
|
|
2095
|
+
description: "You don't have access to any branches in this organization."
|
|
2096
|
+
}
|
|
2097
|
+
)
|
|
2098
|
+
] }),
|
|
2099
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2100
|
+
import_antd3.Button,
|
|
2101
|
+
{
|
|
2102
|
+
type: "primary",
|
|
2103
|
+
size: "large",
|
|
2104
|
+
block: true,
|
|
2105
|
+
disabled: !canConfirm,
|
|
2106
|
+
onClick: confirmSelection,
|
|
2107
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_icons3.CheckCircleFilled, {}),
|
|
2108
|
+
style: {
|
|
2109
|
+
height: 48,
|
|
2110
|
+
fontSize: 16,
|
|
2111
|
+
background: canConfirm ? "linear-gradient(135deg, #667eea 0%, #764ba2 100%)" : void 0,
|
|
2112
|
+
border: "none"
|
|
2113
|
+
},
|
|
2114
|
+
children: "Confirm"
|
|
2115
|
+
}
|
|
2116
|
+
)
|
|
2117
|
+
] }) });
|
|
2118
|
+
}
|
|
2119
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children });
|
|
2120
|
+
}
|
|
2121
|
+
function useBranchGate(storageKey = DEFAULT_STORAGE_KEY2) {
|
|
2122
|
+
const [selection, setSelection] = (0, import_react12.useState)(null);
|
|
2123
|
+
(0, import_react12.useEffect)(() => {
|
|
2124
|
+
if (typeof window === "undefined") return;
|
|
2125
|
+
const saved = localStorage.getItem(storageKey);
|
|
2126
|
+
if (saved) {
|
|
2127
|
+
try {
|
|
2128
|
+
setSelection(JSON.parse(saved));
|
|
2129
|
+
} catch {
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
const handleStorage = (e) => {
|
|
2133
|
+
if (e.key === storageKey) {
|
|
2134
|
+
if (e.newValue) {
|
|
2135
|
+
try {
|
|
2136
|
+
setSelection(JSON.parse(e.newValue));
|
|
2137
|
+
} catch {
|
|
2138
|
+
setSelection(null);
|
|
2139
|
+
}
|
|
2140
|
+
} else {
|
|
2141
|
+
setSelection(null);
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
};
|
|
2145
|
+
window.addEventListener("storage", handleStorage);
|
|
2146
|
+
return () => window.removeEventListener("storage", handleStorage);
|
|
2147
|
+
}, [storageKey]);
|
|
2148
|
+
const clearSelection = import_react12.default.useCallback(() => {
|
|
2149
|
+
localStorage.removeItem(storageKey);
|
|
2150
|
+
setSelection(null);
|
|
2151
|
+
}, [storageKey]);
|
|
2152
|
+
return {
|
|
2153
|
+
selection,
|
|
2154
|
+
selectedOrg: selection ? { id: selection.orgId, slug: selection.orgSlug, name: selection.orgName } : null,
|
|
2155
|
+
selectedBranch: selection ? { id: selection.branchId, name: selection.branchName, code: selection.branchCode } : null,
|
|
2156
|
+
clearSelection
|
|
2157
|
+
};
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
// src/components/admin/UserTable.tsx
|
|
2161
|
+
var import_icons4 = require("@ant-design/icons");
|
|
2162
|
+
var import_antd4 = require("antd");
|
|
2163
|
+
|
|
2164
|
+
// src/i18n/translations.ts
|
|
2165
|
+
var ssoNamespace = "sso";
|
|
2166
|
+
var defaultTranslations = {
|
|
2167
|
+
en: {
|
|
2168
|
+
// Common
|
|
2169
|
+
actions: "Actions",
|
|
2170
|
+
save: "Save",
|
|
2171
|
+
cancel: "Cancel",
|
|
2172
|
+
delete: "Delete",
|
|
2173
|
+
edit: "Edit",
|
|
2174
|
+
search: "Search",
|
|
2175
|
+
loading: "Loading...",
|
|
2176
|
+
yes: "Yes",
|
|
2177
|
+
no: "No",
|
|
2178
|
+
confirmDelete: "Are you sure you want to delete?",
|
|
2179
|
+
// Users
|
|
2180
|
+
users: "Users",
|
|
2181
|
+
user: "User",
|
|
2182
|
+
name: "Name",
|
|
2183
|
+
email: "Email",
|
|
2184
|
+
ssoUser: "SSO User",
|
|
2185
|
+
localUser: "Local User",
|
|
2186
|
+
userList: "User List",
|
|
2187
|
+
userDetails: "User Details",
|
|
2188
|
+
editUser: "Edit User",
|
|
2189
|
+
deleteUser: "Delete User",
|
|
2190
|
+
searchUsers: "Search users...",
|
|
2191
|
+
noUsersFound: "No users found",
|
|
2192
|
+
userDeleted: "User deleted successfully",
|
|
2193
|
+
userUpdated: "User updated successfully",
|
|
2194
|
+
// Roles
|
|
2195
|
+
roles: "Roles",
|
|
2196
|
+
role: "Role",
|
|
2197
|
+
roleName: "Role Name",
|
|
2198
|
+
roleDescription: "Description",
|
|
2199
|
+
permissions: "Permissions",
|
|
2200
|
+
assignRole: "Assign Role",
|
|
2201
|
+
removeRole: "Remove Role",
|
|
2202
|
+
// Permissions
|
|
2203
|
+
permission: "Permission",
|
|
2204
|
+
permissionName: "Permission Name",
|
|
2205
|
+
permissionDescription: "Description",
|
|
2206
|
+
// Validation
|
|
2207
|
+
required: "{{field}} is required",
|
|
2208
|
+
maxLength: "{{field}} must be at most {{max}} characters",
|
|
2209
|
+
invalidEmail: "Please enter a valid email address",
|
|
2210
|
+
// Pagination
|
|
2211
|
+
total: "Total {{count}} items",
|
|
2212
|
+
page: "Page {{current}} of {{total}}"
|
|
2213
|
+
},
|
|
2214
|
+
ja: {
|
|
2215
|
+
// Common
|
|
2216
|
+
actions: "\u64CD\u4F5C",
|
|
2217
|
+
save: "\u4FDD\u5B58",
|
|
2218
|
+
cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
|
|
2219
|
+
delete: "\u524A\u9664",
|
|
2220
|
+
edit: "\u7DE8\u96C6",
|
|
2221
|
+
search: "\u691C\u7D22",
|
|
2222
|
+
loading: "\u8AAD\u307F\u8FBC\u307F\u4E2D...",
|
|
2223
|
+
yes: "\u306F\u3044",
|
|
2224
|
+
no: "\u3044\u3044\u3048",
|
|
2225
|
+
confirmDelete: "\u672C\u5F53\u306B\u524A\u9664\u3057\u307E\u3059\u304B\uFF1F",
|
|
2226
|
+
// Users
|
|
2227
|
+
users: "\u30E6\u30FC\u30B6\u30FC",
|
|
2228
|
+
user: "\u30E6\u30FC\u30B6\u30FC",
|
|
2229
|
+
name: "\u540D\u524D",
|
|
2230
|
+
email: "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",
|
|
2231
|
+
ssoUser: "SSO\u30E6\u30FC\u30B6\u30FC",
|
|
2232
|
+
localUser: "\u30ED\u30FC\u30AB\u30EB\u30E6\u30FC\u30B6\u30FC",
|
|
2233
|
+
userList: "\u30E6\u30FC\u30B6\u30FC\u4E00\u89A7",
|
|
2234
|
+
userDetails: "\u30E6\u30FC\u30B6\u30FC\u8A73\u7D30",
|
|
2235
|
+
editUser: "\u30E6\u30FC\u30B6\u30FC\u7DE8\u96C6",
|
|
2236
|
+
deleteUser: "\u30E6\u30FC\u30B6\u30FC\u524A\u9664",
|
|
2237
|
+
searchUsers: "\u30E6\u30FC\u30B6\u30FC\u3092\u691C\u7D22...",
|
|
2238
|
+
noUsersFound: "\u30E6\u30FC\u30B6\u30FC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093",
|
|
2239
|
+
userDeleted: "\u30E6\u30FC\u30B6\u30FC\u3092\u524A\u9664\u3057\u307E\u3057\u305F",
|
|
2240
|
+
userUpdated: "\u30E6\u30FC\u30B6\u30FC\u3092\u66F4\u65B0\u3057\u307E\u3057\u305F",
|
|
2241
|
+
// Roles
|
|
2242
|
+
roles: "\u30ED\u30FC\u30EB",
|
|
2243
|
+
role: "\u30ED\u30FC\u30EB",
|
|
2244
|
+
roleName: "\u30ED\u30FC\u30EB\u540D",
|
|
2245
|
+
roleDescription: "\u8AAC\u660E",
|
|
2246
|
+
permissions: "\u6A29\u9650",
|
|
2247
|
+
assignRole: "\u30ED\u30FC\u30EB\u3092\u5272\u308A\u5F53\u3066",
|
|
2248
|
+
removeRole: "\u30ED\u30FC\u30EB\u3092\u524A\u9664",
|
|
2249
|
+
// Permissions
|
|
2250
|
+
permission: "\u6A29\u9650",
|
|
2251
|
+
permissionName: "\u6A29\u9650\u540D",
|
|
2252
|
+
permissionDescription: "\u8AAC\u660E",
|
|
2253
|
+
// Validation
|
|
2254
|
+
required: "{{field}}\u306F\u5FC5\u9808\u3067\u3059",
|
|
2255
|
+
maxLength: "{{field}}\u306F{{max}}\u6587\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
2256
|
+
invalidEmail: "\u6709\u52B9\u306A\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
|
|
2257
|
+
// Pagination
|
|
2258
|
+
total: "\u5168{{count}}\u4EF6",
|
|
2259
|
+
page: "{{total}}\u30DA\u30FC\u30B8\u4E2D{{current}}\u30DA\u30FC\u30B8"
|
|
2260
|
+
},
|
|
2261
|
+
vi: {
|
|
2262
|
+
// Common
|
|
2263
|
+
actions: "H\xE0nh \u0111\u1ED9ng",
|
|
2264
|
+
save: "L\u01B0u",
|
|
2265
|
+
cancel: "H\u1EE7y",
|
|
2266
|
+
delete: "X\xF3a",
|
|
2267
|
+
edit: "S\u1EEDa",
|
|
2268
|
+
search: "T\xECm ki\u1EBFm",
|
|
2269
|
+
loading: "\u0110ang t\u1EA3i...",
|
|
2270
|
+
yes: "C\xF3",
|
|
2271
|
+
no: "Kh\xF4ng",
|
|
2272
|
+
confirmDelete: "B\u1EA1n c\xF3 ch\u1EAFc mu\u1ED1n x\xF3a?",
|
|
2273
|
+
// Users
|
|
2274
|
+
users: "Ng\u01B0\u1EDDi d\xF9ng",
|
|
2275
|
+
user: "Ng\u01B0\u1EDDi d\xF9ng",
|
|
2276
|
+
name: "T\xEAn",
|
|
2277
|
+
email: "Email",
|
|
2278
|
+
ssoUser: "Ng\u01B0\u1EDDi d\xF9ng SSO",
|
|
2279
|
+
localUser: "Ng\u01B0\u1EDDi d\xF9ng n\u1ED9i b\u1ED9",
|
|
2280
|
+
userList: "Danh s\xE1ch ng\u01B0\u1EDDi d\xF9ng",
|
|
2281
|
+
userDetails: "Chi ti\u1EBFt ng\u01B0\u1EDDi d\xF9ng",
|
|
2282
|
+
editUser: "S\u1EEDa ng\u01B0\u1EDDi d\xF9ng",
|
|
2283
|
+
deleteUser: "X\xF3a ng\u01B0\u1EDDi d\xF9ng",
|
|
2284
|
+
searchUsers: "T\xECm ng\u01B0\u1EDDi d\xF9ng...",
|
|
2285
|
+
noUsersFound: "Kh\xF4ng t\xECm th\u1EA5y ng\u01B0\u1EDDi d\xF9ng",
|
|
2286
|
+
userDeleted: "\u0110\xE3 x\xF3a ng\u01B0\u1EDDi d\xF9ng",
|
|
2287
|
+
userUpdated: "\u0110\xE3 c\u1EADp nh\u1EADt ng\u01B0\u1EDDi d\xF9ng",
|
|
2288
|
+
// Roles
|
|
2289
|
+
roles: "Vai tr\xF2",
|
|
2290
|
+
role: "Vai tr\xF2",
|
|
2291
|
+
roleName: "T\xEAn vai tr\xF2",
|
|
2292
|
+
roleDescription: "M\xF4 t\u1EA3",
|
|
2293
|
+
permissions: "Quy\u1EC1n",
|
|
2294
|
+
assignRole: "G\xE1n vai tr\xF2",
|
|
2295
|
+
removeRole: "X\xF3a vai tr\xF2",
|
|
2296
|
+
// Permissions
|
|
2297
|
+
permission: "Quy\u1EC1n",
|
|
2298
|
+
permissionName: "T\xEAn quy\u1EC1n",
|
|
2299
|
+
permissionDescription: "M\xF4 t\u1EA3",
|
|
2300
|
+
// Validation
|
|
2301
|
+
required: "{{field}} l\xE0 b\u1EAFt bu\u1ED9c",
|
|
2302
|
+
maxLength: "{{field}} t\u1ED1i \u0111a {{max}} k\xFD t\u1EF1",
|
|
2303
|
+
invalidEmail: "Email kh\xF4ng h\u1EE3p l\u1EC7",
|
|
2304
|
+
// Pagination
|
|
2305
|
+
total: "T\u1ED5ng {{count}} m\u1EE5c",
|
|
2306
|
+
page: "Trang {{current}}/{{total}}"
|
|
2307
|
+
}
|
|
2308
|
+
};
|
|
2309
|
+
|
|
2310
|
+
// src/i18n/useSsoTranslation.ts
|
|
2311
|
+
var import_react13 = require("react");
|
|
2312
|
+
function useSsoTranslation() {
|
|
2313
|
+
const t = (0, import_react13.useCallback)(
|
|
2314
|
+
(key, options) => {
|
|
2315
|
+
let value = defaultTranslations.en[key] || key;
|
|
2316
|
+
if (options) {
|
|
2317
|
+
Object.entries(options).forEach(([k, v]) => {
|
|
2318
|
+
value = value.replace(new RegExp(`{{${k}}}`, "g"), String(v));
|
|
2319
|
+
});
|
|
2320
|
+
}
|
|
2321
|
+
return value;
|
|
2322
|
+
},
|
|
2323
|
+
[]
|
|
2324
|
+
);
|
|
2325
|
+
return { t };
|
|
2326
|
+
}
|
|
2327
|
+
|
|
2328
|
+
// src/i18n/I18nProvider.tsx
|
|
2329
|
+
var import_i18next2 = __toESM(require("i18next"), 1);
|
|
2330
|
+
var import_i18next_browser_languagedetector = __toESM(require("i18next-browser-languagedetector"), 1);
|
|
2331
|
+
var import_react14 = require("react");
|
|
2332
|
+
var import_react_i18next = require("react-i18next");
|
|
2333
|
+
var import_react_i18next2 = require("react-i18next");
|
|
2334
|
+
|
|
2335
|
+
// src/i18n/config.ts
|
|
2336
|
+
var import_i18next = __toESM(require("i18next"), 1);
|
|
2337
|
+
var locales = ["ja", "en", "vi"];
|
|
2338
|
+
var defaultLocale2 = "ja";
|
|
2339
|
+
var localeNames = {
|
|
2340
|
+
ja: "\u65E5\u672C\u8A9E",
|
|
2341
|
+
en: "English",
|
|
2342
|
+
vi: "Ti\u1EBFng Vi\u1EC7t"
|
|
2343
|
+
};
|
|
2344
|
+
var changeLanguage = (locale) => {
|
|
2345
|
+
if (typeof window === "undefined") return;
|
|
2346
|
+
import_i18next.default.changeLanguage(locale);
|
|
2347
|
+
document.cookie = `locale=${locale};path=/;max-age=31536000`;
|
|
2348
|
+
};
|
|
2349
|
+
var getCurrentLocale = () => {
|
|
2350
|
+
if (typeof window === "undefined") return defaultLocale2;
|
|
2351
|
+
return import_i18next.default.language || defaultLocale2;
|
|
2352
|
+
};
|
|
2353
|
+
|
|
2354
|
+
// src/i18n/I18nProvider.tsx
|
|
2355
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2356
|
+
var initialized = false;
|
|
2357
|
+
function getOrCreateI18n(appTranslations, fallbackLocale2) {
|
|
2358
|
+
if (initialized) return import_i18next2.default;
|
|
2359
|
+
const resources = {
|
|
2360
|
+
en: {
|
|
2361
|
+
translation: appTranslations?.en || {},
|
|
2362
|
+
[ssoNamespace]: defaultTranslations.en
|
|
2363
|
+
},
|
|
2364
|
+
ja: {
|
|
2365
|
+
translation: appTranslations?.ja || {},
|
|
2366
|
+
[ssoNamespace]: defaultTranslations.ja
|
|
2367
|
+
},
|
|
2368
|
+
vi: {
|
|
2369
|
+
translation: appTranslations?.vi || {},
|
|
2370
|
+
[ssoNamespace]: defaultTranslations.vi
|
|
2371
|
+
}
|
|
2372
|
+
};
|
|
2373
|
+
import_i18next2.default.use(import_i18next_browser_languagedetector.default).use(import_react_i18next2.initReactI18next).init({
|
|
2374
|
+
resources,
|
|
2375
|
+
fallbackLng: fallbackLocale2 || defaultLocale2,
|
|
2376
|
+
supportedLngs: locales,
|
|
2377
|
+
detection: {
|
|
2378
|
+
order: ["cookie", "localStorage", "navigator"],
|
|
2379
|
+
caches: ["cookie", "localStorage"],
|
|
2380
|
+
lookupCookie: "locale",
|
|
2381
|
+
lookupLocalStorage: "locale"
|
|
2382
|
+
},
|
|
2383
|
+
interpolation: {
|
|
2384
|
+
escapeValue: false
|
|
2385
|
+
},
|
|
2386
|
+
defaultNS: "translation",
|
|
2387
|
+
ns: ["translation", ssoNamespace],
|
|
2388
|
+
react: {
|
|
2389
|
+
useSuspense: false
|
|
2390
|
+
}
|
|
2391
|
+
});
|
|
2392
|
+
initialized = true;
|
|
2393
|
+
return import_i18next2.default;
|
|
2394
|
+
}
|
|
2395
|
+
function I18nProvider({ children, translations, fallbackLocale: fallbackLocale2 }) {
|
|
2396
|
+
const i18nInstance = (0, import_react14.useMemo)(
|
|
2397
|
+
() => getOrCreateI18n(translations, fallbackLocale2),
|
|
2398
|
+
[translations, fallbackLocale2]
|
|
2399
|
+
);
|
|
2400
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_i18next.I18nextProvider, { i18n: i18nInstance, children });
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
// src/i18n/useTranslations.ts
|
|
2404
|
+
var import_react15 = require("react");
|
|
2405
|
+
var import_react_i18next3 = require("react-i18next");
|
|
2406
|
+
function useTranslations(namespace) {
|
|
2407
|
+
const { t: i18nT } = (0, import_react_i18next3.useTranslation)();
|
|
2408
|
+
const t = (0, import_react15.useCallback)(
|
|
2409
|
+
(key, values) => {
|
|
2410
|
+
const fullKey = namespace ? `${namespace}.${key}` : key;
|
|
2411
|
+
return i18nT(fullKey, values);
|
|
2412
|
+
},
|
|
2413
|
+
[i18nT, namespace]
|
|
2414
|
+
);
|
|
2415
|
+
return t;
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
// src/i18n/useLocale.ts
|
|
2419
|
+
var import_react_i18next4 = require("react-i18next");
|
|
2420
|
+
function useLocale() {
|
|
2421
|
+
const { i18n: i18n3 } = (0, import_react_i18next4.useTranslation)();
|
|
2422
|
+
return i18n3.language || defaultLocale2;
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
// src/components/admin/UserTable.tsx
|
|
2426
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2427
|
+
function UserTable({
|
|
2428
|
+
users,
|
|
2429
|
+
loading = false,
|
|
2430
|
+
pagination,
|
|
2431
|
+
sortField,
|
|
2432
|
+
sortOrder,
|
|
2433
|
+
onPageChange,
|
|
2434
|
+
onSortChange,
|
|
2435
|
+
onSearch,
|
|
2436
|
+
onEdit,
|
|
2437
|
+
onDelete,
|
|
2438
|
+
deleteLoading = false,
|
|
2439
|
+
showSearch = true,
|
|
2440
|
+
showActions = true
|
|
1110
2441
|
}) {
|
|
1111
|
-
const {
|
|
1112
|
-
const
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
2442
|
+
const { t } = useSsoTranslation();
|
|
2443
|
+
const columns = [
|
|
2444
|
+
{
|
|
2445
|
+
title: t("email"),
|
|
2446
|
+
dataIndex: "email",
|
|
2447
|
+
key: "email",
|
|
2448
|
+
sorter: true,
|
|
2449
|
+
sortOrder: sortField === "email" ? sortOrder === "asc" ? "ascend" : "descend" : void 0
|
|
2450
|
+
},
|
|
2451
|
+
{
|
|
2452
|
+
title: t("name"),
|
|
2453
|
+
dataIndex: "name",
|
|
2454
|
+
key: "name",
|
|
2455
|
+
sorter: true,
|
|
2456
|
+
sortOrder: sortField === "name" ? sortOrder === "asc" ? "ascend" : "descend" : void 0
|
|
2457
|
+
},
|
|
2458
|
+
{
|
|
2459
|
+
title: "SSO",
|
|
2460
|
+
dataIndex: "console_user_id",
|
|
2461
|
+
key: "sso",
|
|
2462
|
+
width: 100,
|
|
2463
|
+
render: (value) => value ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_antd4.Tag, { color: "green", children: t("ssoUser") }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_antd4.Tag, { color: "default", children: t("localUser") })
|
|
1119
2464
|
}
|
|
1120
|
-
|
|
1121
|
-
if (
|
|
1122
|
-
|
|
2465
|
+
];
|
|
2466
|
+
if (showActions && (onEdit || onDelete)) {
|
|
2467
|
+
columns.push({
|
|
2468
|
+
title: t("actions"),
|
|
2469
|
+
key: "actions",
|
|
2470
|
+
width: 120,
|
|
2471
|
+
render: (_, record) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_antd4.Space, { children: [
|
|
2472
|
+
onEdit && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2473
|
+
import_antd4.Button,
|
|
2474
|
+
{
|
|
2475
|
+
type: "text",
|
|
2476
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons4.EditOutlined, {}),
|
|
2477
|
+
size: "small",
|
|
2478
|
+
onClick: () => onEdit(record)
|
|
2479
|
+
}
|
|
2480
|
+
),
|
|
2481
|
+
onDelete && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2482
|
+
import_antd4.Popconfirm,
|
|
2483
|
+
{
|
|
2484
|
+
title: t("confirmDelete"),
|
|
2485
|
+
onConfirm: () => onDelete(record),
|
|
2486
|
+
okText: t("yes"),
|
|
2487
|
+
cancelText: t("no"),
|
|
2488
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2489
|
+
import_antd4.Button,
|
|
2490
|
+
{
|
|
2491
|
+
type: "text",
|
|
2492
|
+
danger: true,
|
|
2493
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons4.DeleteOutlined, {}),
|
|
2494
|
+
size: "small",
|
|
2495
|
+
loading: deleteLoading
|
|
2496
|
+
}
|
|
2497
|
+
)
|
|
2498
|
+
}
|
|
2499
|
+
)
|
|
2500
|
+
] })
|
|
2501
|
+
});
|
|
1123
2502
|
}
|
|
1124
|
-
|
|
1125
|
-
if (
|
|
1126
|
-
|
|
2503
|
+
const handleTableChange = (paginationConfig, _filters, sorter) => {
|
|
2504
|
+
if (onPageChange && paginationConfig.current && paginationConfig.pageSize) {
|
|
2505
|
+
onPageChange(paginationConfig.current, paginationConfig.pageSize);
|
|
1127
2506
|
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
2507
|
+
if (onSortChange) {
|
|
2508
|
+
const singleSorter = Array.isArray(sorter) ? sorter[0] : sorter;
|
|
2509
|
+
if (singleSorter?.field) {
|
|
2510
|
+
onSortChange(
|
|
2511
|
+
singleSorter.field,
|
|
2512
|
+
singleSorter.order === "ascend" ? "asc" : "desc"
|
|
2513
|
+
);
|
|
2514
|
+
} else {
|
|
2515
|
+
onSortChange(void 0, void 0);
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
};
|
|
2519
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
|
|
2520
|
+
showSearch && onSearch && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { marginBottom: 16 }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2521
|
+
import_antd4.Input,
|
|
1133
2522
|
{
|
|
1134
|
-
|
|
2523
|
+
placeholder: t("searchUsers"),
|
|
2524
|
+
prefix: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons4.SearchOutlined, {}),
|
|
2525
|
+
onChange: (e) => onSearch(e.target.value),
|
|
2526
|
+
style: { width: 300 },
|
|
2527
|
+
allowClear: true
|
|
1135
2528
|
}
|
|
1136
|
-
)
|
|
1137
|
-
|
|
1138
|
-
|
|
2529
|
+
) }),
|
|
2530
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2531
|
+
import_antd4.Table,
|
|
2532
|
+
{
|
|
2533
|
+
columns,
|
|
2534
|
+
dataSource: users,
|
|
2535
|
+
loading,
|
|
2536
|
+
rowKey: "id",
|
|
2537
|
+
onChange: handleTableChange,
|
|
2538
|
+
pagination: pagination ? {
|
|
2539
|
+
current: pagination.current_page,
|
|
2540
|
+
pageSize: pagination.per_page,
|
|
2541
|
+
total: pagination.total,
|
|
2542
|
+
showSizeChanger: true,
|
|
2543
|
+
showTotal: (total) => t("total", { count: total })
|
|
2544
|
+
} : false
|
|
2545
|
+
}
|
|
2546
|
+
)
|
|
2547
|
+
] });
|
|
1139
2548
|
}
|
|
1140
2549
|
|
|
1141
|
-
// src/
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
2550
|
+
// src/components/admin/UserForm.tsx
|
|
2551
|
+
var import_antd5 = require("antd");
|
|
2552
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2553
|
+
function UserForm({
|
|
2554
|
+
initialValues,
|
|
2555
|
+
onSubmit,
|
|
2556
|
+
onCancel,
|
|
2557
|
+
loading = false,
|
|
2558
|
+
submitText
|
|
2559
|
+
}) {
|
|
2560
|
+
const { t } = useSsoTranslation();
|
|
2561
|
+
const [form] = import_antd5.Form.useForm();
|
|
2562
|
+
const handleFinish = (values) => {
|
|
2563
|
+
onSubmit(values);
|
|
1150
2564
|
};
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
2565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
2566
|
+
import_antd5.Form,
|
|
2567
|
+
{
|
|
2568
|
+
form,
|
|
2569
|
+
layout: "vertical",
|
|
2570
|
+
initialValues,
|
|
2571
|
+
onFinish: handleFinish,
|
|
2572
|
+
style: { maxWidth: 600 },
|
|
2573
|
+
children: [
|
|
2574
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2575
|
+
import_antd5.Form.Item,
|
|
2576
|
+
{
|
|
2577
|
+
label: t("name"),
|
|
2578
|
+
name: "name",
|
|
2579
|
+
rules: [
|
|
2580
|
+
{ required: true, message: t("required", { field: t("name") }) },
|
|
2581
|
+
{ max: 255, message: t("maxLength", { field: t("name"), max: 255 }) }
|
|
2582
|
+
],
|
|
2583
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd5.Input, {})
|
|
2584
|
+
}
|
|
2585
|
+
),
|
|
2586
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2587
|
+
import_antd5.Form.Item,
|
|
2588
|
+
{
|
|
2589
|
+
label: t("email"),
|
|
2590
|
+
name: "email",
|
|
2591
|
+
rules: [
|
|
2592
|
+
{ required: true, message: t("required", { field: t("email") }) },
|
|
2593
|
+
{ type: "email", message: t("invalidEmail") }
|
|
2594
|
+
],
|
|
2595
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd5.Input, { type: "email" })
|
|
2596
|
+
}
|
|
2597
|
+
),
|
|
2598
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd5.Form.Item, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_antd5.Space, { children: [
|
|
2599
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd5.Button, { type: "primary", htmlType: "submit", loading, children: submitText || t("save") }),
|
|
2600
|
+
onCancel && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_antd5.Button, { onClick: onCancel, children: t("cancel") })
|
|
2601
|
+
] }) })
|
|
2602
|
+
]
|
|
2603
|
+
}
|
|
2604
|
+
);
|
|
1159
2605
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
2606
|
+
|
|
2607
|
+
// src/utils/branchHeaders.ts
|
|
2608
|
+
var BRANCH_HEADERS = {
|
|
2609
|
+
BRANCH_ID: "X-Branch-Id",
|
|
2610
|
+
ORG_ID: "X-Org-Id",
|
|
2611
|
+
BRANCH_NAME: "X-Branch-Name",
|
|
2612
|
+
BRANCH_CODE: "X-Branch-Code"
|
|
2613
|
+
};
|
|
2614
|
+
function createBranchHeaderSetter(axiosInstance) {
|
|
2615
|
+
return (selection) => {
|
|
2616
|
+
if (selection) {
|
|
2617
|
+
axiosInstance.defaults.headers.common[BRANCH_HEADERS.BRANCH_ID] = selection.branchId;
|
|
2618
|
+
axiosInstance.defaults.headers.common[BRANCH_HEADERS.ORG_ID] = selection.orgId;
|
|
2619
|
+
if (selection.branchName) {
|
|
2620
|
+
axiosInstance.defaults.headers.common[BRANCH_HEADERS.BRANCH_NAME] = selection.branchName;
|
|
2621
|
+
}
|
|
2622
|
+
if (selection.branchCode) {
|
|
2623
|
+
axiosInstance.defaults.headers.common[BRANCH_HEADERS.BRANCH_CODE] = selection.branchCode;
|
|
2624
|
+
}
|
|
2625
|
+
} else {
|
|
2626
|
+
delete axiosInstance.defaults.headers.common[BRANCH_HEADERS.BRANCH_ID];
|
|
2627
|
+
delete axiosInstance.defaults.headers.common[BRANCH_HEADERS.ORG_ID];
|
|
2628
|
+
delete axiosInstance.defaults.headers.common[BRANCH_HEADERS.BRANCH_NAME];
|
|
2629
|
+
delete axiosInstance.defaults.headers.common[BRANCH_HEADERS.BRANCH_CODE];
|
|
2630
|
+
}
|
|
2631
|
+
};
|
|
1164
2632
|
}
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
...options,
|
|
1168
|
-
credentials: "include"
|
|
1169
|
-
});
|
|
1170
|
-
if (!response.ok) {
|
|
1171
|
-
const error = await response.json().catch(() => ({}));
|
|
1172
|
-
throw new Error(error.message || `HTTP ${response.status}`);
|
|
1173
|
-
}
|
|
1174
|
-
if (response.status === 204) {
|
|
1175
|
-
return void 0;
|
|
1176
|
-
}
|
|
1177
|
-
return response.json();
|
|
2633
|
+
function setBranchHeaders(axiosInstance, selection) {
|
|
2634
|
+
createBranchHeaderSetter(axiosInstance)(selection);
|
|
1178
2635
|
}
|
|
1179
2636
|
|
|
1180
2637
|
// src/services/authService.ts
|
|
@@ -1293,8 +2750,13 @@ function createRoleService(config) {
|
|
|
1293
2750
|
* List all roles (admin)
|
|
1294
2751
|
* GET /api/admin/sso/roles
|
|
1295
2752
|
*/
|
|
1296
|
-
adminList: async (orgSlug) => {
|
|
1297
|
-
|
|
2753
|
+
adminList: async (orgSlug, params) => {
|
|
2754
|
+
const searchParams = new URLSearchParams();
|
|
2755
|
+
if (params?.["filter[scope]"]) searchParams.set("filter[scope]", params["filter[scope]"]);
|
|
2756
|
+
if (params?.["filter[org_id]"]) searchParams.set("filter[org_id]", params["filter[org_id]"]);
|
|
2757
|
+
const query = searchParams.toString();
|
|
2758
|
+
const path = query ? `/api/admin/sso/roles?${query}` : "/api/admin/sso/roles";
|
|
2759
|
+
return request(apiUrl, path, {
|
|
1298
2760
|
headers: buildHeaders(orgSlug)
|
|
1299
2761
|
});
|
|
1300
2762
|
},
|
|
@@ -1648,66 +3110,87 @@ var getEffectivePermissions = (roleAssignments, allRoles, orgId, branchId) => {
|
|
|
1648
3110
|
return Array.from(permissions);
|
|
1649
3111
|
};
|
|
1650
3112
|
|
|
1651
|
-
// src/services/
|
|
1652
|
-
function
|
|
3113
|
+
// src/services/userService.ts
|
|
3114
|
+
function createUserService(config) {
|
|
1653
3115
|
const { apiUrl } = config;
|
|
3116
|
+
const basePath = "/api/admin/sso/users";
|
|
1654
3117
|
return {
|
|
1655
3118
|
/**
|
|
1656
|
-
*
|
|
1657
|
-
|
|
3119
|
+
* List users with pagination and filtering
|
|
3120
|
+
*/
|
|
3121
|
+
async list(params, orgSlug) {
|
|
3122
|
+
const searchParams = new URLSearchParams();
|
|
3123
|
+
if (params?.page) searchParams.set("page", String(params.page));
|
|
3124
|
+
if (params?.per_page) searchParams.set("per_page", String(params.per_page));
|
|
3125
|
+
if (params?.["filter[search]"]) searchParams.set("filter[search]", params["filter[search]"]);
|
|
3126
|
+
if (params?.["filter[org_id]"]) searchParams.set("filter[org_id]", params["filter[org_id]"]);
|
|
3127
|
+
if (params?.sort) searchParams.set("sort", params.sort);
|
|
3128
|
+
const query = searchParams.toString();
|
|
3129
|
+
const path = query ? `${basePath}?${query}` : basePath;
|
|
3130
|
+
return request(apiUrl, path, {
|
|
3131
|
+
method: "GET",
|
|
3132
|
+
headers: buildHeaders(orgSlug)
|
|
3133
|
+
});
|
|
3134
|
+
},
|
|
3135
|
+
/**
|
|
3136
|
+
* Get user by ID
|
|
1658
3137
|
*/
|
|
1659
|
-
|
|
1660
|
-
const
|
|
1661
|
-
|
|
1662
|
-
headers: buildHeaders()
|
|
3138
|
+
async get(id, orgSlug) {
|
|
3139
|
+
const response = await request(apiUrl, `${basePath}/${id}`, {
|
|
3140
|
+
method: "GET",
|
|
3141
|
+
headers: buildHeaders(orgSlug)
|
|
1663
3142
|
});
|
|
3143
|
+
return response.data;
|
|
1664
3144
|
},
|
|
1665
3145
|
/**
|
|
1666
|
-
*
|
|
1667
|
-
* GET /api/sso/branches/{id}
|
|
3146
|
+
* Update a user
|
|
1668
3147
|
*/
|
|
1669
|
-
|
|
1670
|
-
const response = await request(
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
);
|
|
1675
|
-
return
|
|
3148
|
+
async update(id, input, orgSlug) {
|
|
3149
|
+
const response = await request(apiUrl, `${basePath}/${id}`, {
|
|
3150
|
+
method: "PUT",
|
|
3151
|
+
headers: buildHeaders(orgSlug),
|
|
3152
|
+
body: JSON.stringify(input)
|
|
3153
|
+
});
|
|
3154
|
+
return response.data;
|
|
1676
3155
|
},
|
|
1677
3156
|
/**
|
|
1678
|
-
*
|
|
3157
|
+
* Delete a user
|
|
1679
3158
|
*/
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
`/api/sso/branches${params}`,
|
|
1686
|
-
{ headers: buildHeaders() }
|
|
1687
|
-
);
|
|
1688
|
-
return data.branches.find((b) => b.is_headquarters) ?? null;
|
|
1689
|
-
} catch {
|
|
1690
|
-
return null;
|
|
1691
|
-
}
|
|
3159
|
+
async delete(id, orgSlug) {
|
|
3160
|
+
await request(apiUrl, `${basePath}/${id}`, {
|
|
3161
|
+
method: "DELETE",
|
|
3162
|
+
headers: buildHeaders(orgSlug)
|
|
3163
|
+
});
|
|
1692
3164
|
},
|
|
1693
3165
|
/**
|
|
1694
|
-
*
|
|
3166
|
+
* Search users by email (autocomplete)
|
|
1695
3167
|
*/
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
if (data.primary_branch_id) {
|
|
1705
|
-
return data.branches.find((b) => b.id === data.primary_branch_id) ?? null;
|
|
3168
|
+
async search(email, orgSlug) {
|
|
3169
|
+
if (email.length < 2) return [];
|
|
3170
|
+
const response = await request(
|
|
3171
|
+
apiUrl,
|
|
3172
|
+
`${basePath}/search?email=${encodeURIComponent(email)}`,
|
|
3173
|
+
{
|
|
3174
|
+
method: "GET",
|
|
3175
|
+
headers: buildHeaders(orgSlug)
|
|
1706
3176
|
}
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
3177
|
+
);
|
|
3178
|
+
return response.data;
|
|
3179
|
+
},
|
|
3180
|
+
/**
|
|
3181
|
+
* Get user permissions breakdown
|
|
3182
|
+
* Shows roles, teams, and aggregated permissions for a user in context
|
|
3183
|
+
*/
|
|
3184
|
+
async getPermissions(userId, orgId, branchId, orgSlug) {
|
|
3185
|
+
const params = new URLSearchParams();
|
|
3186
|
+
if (orgId) params.set("org_id", orgId);
|
|
3187
|
+
if (branchId) params.set("branch_id", branchId);
|
|
3188
|
+
const query = params.toString();
|
|
3189
|
+
const path = query ? `${basePath}/${userId}/permissions?${query}` : `${basePath}/${userId}/permissions`;
|
|
3190
|
+
return request(apiUrl, path, {
|
|
3191
|
+
method: "GET",
|
|
3192
|
+
headers: buildHeaders(orgSlug)
|
|
3193
|
+
});
|
|
1711
3194
|
}
|
|
1712
3195
|
};
|
|
1713
3196
|
}
|
|
@@ -1727,7 +3210,7 @@ function buildHeaders2(orgSlug) {
|
|
|
1727
3210
|
headers["X-XSRF-TOKEN"] = decodeURIComponent(xsrfToken);
|
|
1728
3211
|
}
|
|
1729
3212
|
if (orgSlug) {
|
|
1730
|
-
headers["X-Org-
|
|
3213
|
+
headers["X-Org-Id"] = orgSlug;
|
|
1731
3214
|
}
|
|
1732
3215
|
return headers;
|
|
1733
3216
|
}
|
|
@@ -2089,111 +3572,28 @@ function createSsoService(config) {
|
|
|
2089
3572
|
}
|
|
2090
3573
|
};
|
|
2091
3574
|
}
|
|
2092
|
-
|
|
2093
|
-
// src/queryKeys.ts
|
|
2094
|
-
var ssoQueryKeys = {
|
|
2095
|
-
all: ["sso"],
|
|
2096
|
-
// =========================================================================
|
|
2097
|
-
// Auth (authService)
|
|
2098
|
-
// =========================================================================
|
|
2099
|
-
auth: {
|
|
2100
|
-
all: () => [...ssoQueryKeys.all, "auth"],
|
|
2101
|
-
user: () => [...ssoQueryKeys.auth.all(), "user"],
|
|
2102
|
-
globalLogoutUrl: (redirectUri) => [...ssoQueryKeys.auth.all(), "global-logout-url", redirectUri]
|
|
2103
|
-
},
|
|
2104
|
-
// =========================================================================
|
|
2105
|
-
// Tokens (tokenService)
|
|
2106
|
-
// =========================================================================
|
|
2107
|
-
tokens: {
|
|
2108
|
-
all: () => [...ssoQueryKeys.all, "tokens"],
|
|
2109
|
-
list: () => [...ssoQueryKeys.tokens.all(), "list"]
|
|
2110
|
-
},
|
|
2111
|
-
// =========================================================================
|
|
2112
|
-
// Roles (roleService)
|
|
2113
|
-
// =========================================================================
|
|
2114
|
-
roles: {
|
|
2115
|
-
all: () => [...ssoQueryKeys.all, "roles"],
|
|
2116
|
-
list: () => [...ssoQueryKeys.roles.all(), "list"],
|
|
2117
|
-
detail: (id) => [...ssoQueryKeys.roles.all(), "detail", id],
|
|
2118
|
-
permissions: (id) => [...ssoQueryKeys.roles.all(), id, "permissions"]
|
|
2119
|
-
},
|
|
2120
|
-
// =========================================================================
|
|
2121
|
-
// Permissions (permissionService)
|
|
2122
|
-
// =========================================================================
|
|
2123
|
-
permissions: {
|
|
2124
|
-
all: () => [...ssoQueryKeys.all, "permissions"],
|
|
2125
|
-
list: (params) => [...ssoQueryKeys.permissions.all(), "list", params],
|
|
2126
|
-
detail: (id) => [...ssoQueryKeys.permissions.all(), "detail", id],
|
|
2127
|
-
matrix: () => [...ssoQueryKeys.permissions.all(), "matrix"]
|
|
2128
|
-
},
|
|
2129
|
-
// =========================================================================
|
|
2130
|
-
// Teams (teamService)
|
|
2131
|
-
// =========================================================================
|
|
2132
|
-
teams: {
|
|
2133
|
-
all: () => [...ssoQueryKeys.all, "teams"],
|
|
2134
|
-
list: () => [...ssoQueryKeys.teams.all(), "list"],
|
|
2135
|
-
permissions: (teamId) => [...ssoQueryKeys.teams.all(), teamId, "permissions"],
|
|
2136
|
-
orphaned: () => [...ssoQueryKeys.teams.all(), "orphaned"]
|
|
2137
|
-
},
|
|
2138
|
-
// =========================================================================
|
|
2139
|
-
// User Roles (userRoleService) - Scoped Role Assignments
|
|
2140
|
-
// =========================================================================
|
|
2141
|
-
userRoles: {
|
|
2142
|
-
all: () => [...ssoQueryKeys.all, "user-roles"],
|
|
2143
|
-
list: (userId) => [...ssoQueryKeys.userRoles.all(), userId],
|
|
2144
|
-
byBranch: (userId, orgId, branchId) => [...ssoQueryKeys.userRoles.all(), userId, orgId, branchId]
|
|
2145
|
-
},
|
|
2146
|
-
// =========================================================================
|
|
2147
|
-
// Branches (branchService)
|
|
2148
|
-
// =========================================================================
|
|
2149
|
-
branches: {
|
|
2150
|
-
all: () => [...ssoQueryKeys.all, "branches"],
|
|
2151
|
-
list: (orgSlug) => [...ssoQueryKeys.branches.all(), "list", orgSlug],
|
|
2152
|
-
detail: (branchId) => [...ssoQueryKeys.branches.all(), "detail", branchId],
|
|
2153
|
-
headquarters: (orgSlug) => [...ssoQueryKeys.branches.all(), "headquarters", orgSlug],
|
|
2154
|
-
primary: (orgSlug) => [...ssoQueryKeys.branches.all(), "primary", orgSlug]
|
|
2155
|
-
},
|
|
2156
|
-
// =========================================================================
|
|
2157
|
-
// Admin variants (with org context)
|
|
2158
|
-
// =========================================================================
|
|
2159
|
-
admin: {
|
|
2160
|
-
roles: {
|
|
2161
|
-
all: (orgSlug) => [...ssoQueryKeys.all, "admin", orgSlug, "roles"],
|
|
2162
|
-
list: (orgSlug) => [...ssoQueryKeys.admin.roles.all(orgSlug), "list"],
|
|
2163
|
-
detail: (orgSlug, id) => [...ssoQueryKeys.admin.roles.all(orgSlug), "detail", id],
|
|
2164
|
-
permissions: (orgSlug, id) => [...ssoQueryKeys.admin.roles.all(orgSlug), id, "permissions"]
|
|
2165
|
-
},
|
|
2166
|
-
permissions: {
|
|
2167
|
-
all: (orgSlug) => [...ssoQueryKeys.all, "admin", orgSlug, "permissions"],
|
|
2168
|
-
list: (orgSlug, params) => [...ssoQueryKeys.admin.permissions.all(orgSlug), "list", params],
|
|
2169
|
-
detail: (orgSlug, id) => [...ssoQueryKeys.admin.permissions.all(orgSlug), "detail", id],
|
|
2170
|
-
matrix: (orgSlug) => [...ssoQueryKeys.admin.permissions.all(orgSlug), "matrix"]
|
|
2171
|
-
},
|
|
2172
|
-
teams: {
|
|
2173
|
-
all: (orgSlug) => [...ssoQueryKeys.all, "admin", orgSlug, "teams"],
|
|
2174
|
-
list: (orgSlug) => [...ssoQueryKeys.admin.teams.all(orgSlug), "list"],
|
|
2175
|
-
permissions: (orgSlug, teamId) => [...ssoQueryKeys.admin.teams.all(orgSlug), teamId, "permissions"],
|
|
2176
|
-
orphaned: (orgSlug) => [...ssoQueryKeys.admin.teams.all(orgSlug), "orphaned"]
|
|
2177
|
-
},
|
|
2178
|
-
userRoles: {
|
|
2179
|
-
all: (orgSlug) => [...ssoQueryKeys.all, "admin", orgSlug, "user-roles"],
|
|
2180
|
-
list: (orgSlug, userId) => [...ssoQueryKeys.admin.userRoles.all(orgSlug), userId],
|
|
2181
|
-
byBranch: (orgSlug, userId, orgId, branchId) => [...ssoQueryKeys.admin.userRoles.all(orgSlug), userId, orgId, branchId]
|
|
2182
|
-
}
|
|
2183
|
-
}
|
|
2184
|
-
};
|
|
2185
3575
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2186
3576
|
0 && (module.exports = {
|
|
3577
|
+
BRANCH_HEADERS,
|
|
3578
|
+
BranchContext,
|
|
3579
|
+
BranchGate,
|
|
3580
|
+
BranchProvider,
|
|
3581
|
+
I18nProvider,
|
|
3582
|
+
OrgBranchSelectorModal,
|
|
2187
3583
|
OrganizationSwitcher,
|
|
2188
3584
|
ProtectedRoute,
|
|
2189
3585
|
SsoCallback,
|
|
2190
3586
|
SsoContext,
|
|
2191
3587
|
SsoProvider,
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
3588
|
+
UserForm,
|
|
3589
|
+
UserTable,
|
|
3590
|
+
branchCacheCreateSchema,
|
|
3591
|
+
branchCacheI18n,
|
|
3592
|
+
branchCacheSchemas,
|
|
3593
|
+
branchCacheUpdateSchema,
|
|
3594
|
+
changeLanguage,
|
|
2196
3595
|
createAuthService,
|
|
3596
|
+
createBranchHeaderSetter,
|
|
2197
3597
|
createBranchService,
|
|
2198
3598
|
createPermissionService,
|
|
2199
3599
|
createRoleService,
|
|
@@ -2201,14 +3601,20 @@ var ssoQueryKeys = {
|
|
|
2201
3601
|
createTeamService,
|
|
2202
3602
|
createTokenService,
|
|
2203
3603
|
createUserRoleService,
|
|
3604
|
+
createUserService,
|
|
2204
3605
|
defaultLocale,
|
|
3606
|
+
defaultTranslations,
|
|
2205
3607
|
fallbackLocale,
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
3608
|
+
getBranchCacheFieldLabel,
|
|
3609
|
+
getBranchCacheFieldPlaceholder,
|
|
3610
|
+
getBranchCacheLabel,
|
|
3611
|
+
getCurrentLocale,
|
|
2209
3612
|
getEffectivePermissions,
|
|
2210
3613
|
getMessage,
|
|
2211
3614
|
getMessages,
|
|
3615
|
+
getOrganizationCacheFieldLabel,
|
|
3616
|
+
getOrganizationCacheFieldPlaceholder,
|
|
3617
|
+
getOrganizationCacheLabel,
|
|
2212
3618
|
getPermissionFieldLabel,
|
|
2213
3619
|
getPermissionFieldPlaceholder,
|
|
2214
3620
|
getPermissionLabel,
|
|
@@ -2219,15 +3625,21 @@ var ssoQueryKeys = {
|
|
|
2219
3625
|
getRolePermissionFieldPlaceholder,
|
|
2220
3626
|
getRolePermissionLabel,
|
|
2221
3627
|
getScopeLabel,
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
3628
|
+
getTeamCacheFieldLabel,
|
|
3629
|
+
getTeamCacheFieldPlaceholder,
|
|
3630
|
+
getTeamCacheLabel,
|
|
2225
3631
|
getTeamPermissionFieldLabel,
|
|
2226
3632
|
getTeamPermissionFieldPlaceholder,
|
|
2227
3633
|
getTeamPermissionLabel,
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
3634
|
+
getUserCacheFieldLabel,
|
|
3635
|
+
getUserCacheFieldPlaceholder,
|
|
3636
|
+
getUserCacheLabel,
|
|
3637
|
+
localeNames,
|
|
3638
|
+
locales,
|
|
3639
|
+
organizationCacheCreateSchema,
|
|
3640
|
+
organizationCacheI18n,
|
|
3641
|
+
organizationCacheSchemas,
|
|
3642
|
+
organizationCacheUpdateSchema,
|
|
2231
3643
|
permissionCreateSchema,
|
|
2232
3644
|
permissionI18n,
|
|
2233
3645
|
permissionSchemas,
|
|
@@ -2240,23 +3652,30 @@ var ssoQueryKeys = {
|
|
|
2240
3652
|
rolePermissionUpdateSchema,
|
|
2241
3653
|
roleSchemas,
|
|
2242
3654
|
roleUpdateSchema,
|
|
3655
|
+
setBranchHeaders,
|
|
3656
|
+
ssoNamespace,
|
|
2243
3657
|
ssoQueryKeys,
|
|
2244
3658
|
supportedLocales,
|
|
2245
|
-
|
|
2246
|
-
|
|
3659
|
+
teamCacheCreateSchema,
|
|
3660
|
+
teamCacheI18n,
|
|
3661
|
+
teamCacheSchemas,
|
|
3662
|
+
teamCacheUpdateSchema,
|
|
2247
3663
|
teamPermissionCreateSchema,
|
|
2248
3664
|
teamPermissionI18n,
|
|
2249
3665
|
teamPermissionSchemas,
|
|
2250
3666
|
teamPermissionUpdateSchema,
|
|
2251
|
-
teamSchemas,
|
|
2252
|
-
teamUpdateSchema,
|
|
2253
3667
|
useAuth,
|
|
3668
|
+
useBranch,
|
|
3669
|
+
useBranchGate,
|
|
3670
|
+
useLocale,
|
|
2254
3671
|
useOrganization,
|
|
2255
3672
|
useSso,
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
3673
|
+
useSsoTranslation,
|
|
3674
|
+
useTranslations,
|
|
3675
|
+
userCacheCreateSchema,
|
|
3676
|
+
userCacheI18n,
|
|
3677
|
+
userCacheSchemas,
|
|
3678
|
+
userCacheUpdateSchema,
|
|
2260
3679
|
validationMessages
|
|
2261
3680
|
});
|
|
2262
3681
|
//# sourceMappingURL=index.cjs.map
|