@famgia/omnify-react-sso 2.2.3 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/ant/index.cjs +3235 -0
  2. package/dist/ant/index.cjs.map +1 -0
  3. package/dist/ant/index.d.cts +685 -0
  4. package/dist/ant/index.d.ts +685 -0
  5. package/dist/ant/index.js +3268 -0
  6. package/dist/ant/index.js.map +1 -0
  7. package/dist/core/index.cjs +2432 -0
  8. package/dist/core/index.cjs.map +1 -0
  9. package/dist/core/index.d.cts +112 -0
  10. package/dist/core/index.d.ts +112 -0
  11. package/dist/core/index.js +2360 -0
  12. package/dist/core/index.js.map +1 -0
  13. package/dist/{testing → core/testing}/index.cjs +1 -1
  14. package/dist/core/testing/index.cjs.map +1 -0
  15. package/dist/{testing → core/testing}/index.d.cts +1 -1
  16. package/dist/{testing → core/testing}/index.d.ts +1 -1
  17. package/dist/{testing → core/testing}/index.js +1 -1
  18. package/dist/core/testing/index.js.map +1 -0
  19. package/dist/index-CHuDTvHg.d.ts +2250 -0
  20. package/dist/index-DVssHZFD.d.cts +2250 -0
  21. package/dist/index.cjs +2464 -784
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +10 -1822
  24. package/dist/index.d.ts +10 -1822
  25. package/dist/index.js +2528 -771
  26. package/dist/index.js.map +1 -1
  27. package/dist/{types-bD5deLxs.d.cts → types-BxClyvTX.d.cts} +2 -3
  28. package/dist/{types-bD5deLxs.d.ts → types-BxClyvTX.d.ts} +2 -3
  29. package/dist/userService-DH9-vPSg.d.cts +269 -0
  30. package/dist/userService-DH9-vPSg.d.ts +269 -0
  31. package/package.json +32 -53
  32. package/dist/@omnify-base/package.json +0 -16
  33. package/dist/@omnify-base/schemas/Branch.ts +0 -131
  34. package/dist/@omnify-base/schemas/BranchCache.ts +0 -131
  35. package/dist/@omnify-base/schemas/OrganizationCache.ts +0 -117
  36. package/dist/@omnify-base/schemas/Permission.ts +0 -114
  37. package/dist/@omnify-base/schemas/Role.ts +0 -128
  38. package/dist/@omnify-base/schemas/RolePermission.ts +0 -97
  39. package/dist/@omnify-base/schemas/Team.ts +0 -110
  40. package/dist/@omnify-base/schemas/TeamCache.ts +0 -110
  41. package/dist/@omnify-base/schemas/TeamPermission.ts +0 -109
  42. package/dist/@omnify-base/schemas/User.ts +0 -135
  43. package/dist/@omnify-base/schemas/UserCache.ts +0 -142
  44. package/dist/@omnify-base/schemas/common.ts +0 -47
  45. package/dist/@omnify-base/schemas/i18n.ts +0 -118
  46. package/dist/schemas/index.cjs +0 -645
  47. package/dist/schemas/index.cjs.map +0 -1
  48. package/dist/schemas/index.d.cts +0 -260
  49. package/dist/schemas/index.d.ts +0 -260
  50. package/dist/schemas/index.js +0 -557
  51. package/dist/schemas/index.js.map +0 -1
  52. package/dist/testing/index.cjs.map +0 -1
  53. package/dist/testing/index.js.map +0 -1
  54. package/scripts/build-schemas.ts +0 -191
  55. package/scripts/postinstall.cjs +0 -43
package/dist/index.cjs CHANGED
@@ -30,19 +30,31 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
+ AntdThemeProvider: () => AntdThemeProvider,
33
34
  BRANCH_HEADERS: () => BRANCH_HEADERS,
34
35
  BranchContext: () => BranchContext,
35
36
  BranchGate: () => BranchGate,
36
37
  BranchProvider: () => BranchProvider,
37
38
  I18nProvider: () => I18nProvider,
39
+ LocaleSwitcher: () => LocaleSwitcher,
38
40
  OrgBranchSelectorModal: () => OrgBranchSelectorModal,
39
41
  OrganizationSwitcher: () => OrganizationSwitcher,
42
+ PROTABLE_DEFAULT_TEXTS: () => DEFAULT_TEXTS,
43
+ PageContainer: () => PageContainer,
44
+ PermissionsListCard: () => PermissionsListCard,
45
+ ProTable: () => ProTable,
40
46
  ProtectedRoute: () => ProtectedRoute,
47
+ RoleCreateModal: () => RoleCreateModal,
48
+ RolesListCard: () => RolesListCard,
49
+ ScopeLabel: () => ScopeLabel,
50
+ ScopeTag: () => ScopeTag,
41
51
  SsoCallback: () => SsoCallback,
42
52
  SsoContext: () => SsoContext,
43
53
  SsoProvider: () => SsoProvider,
44
- UserForm: () => UserForm,
45
- UserTable: () => UserTable,
54
+ TeamsListCard: () => TeamsListCard,
55
+ UserDetailCard: () => UserDetailCard,
56
+ UserPermissionsModal: () => UserPermissionsModal,
57
+ UserRoleAssignModal: () => UserRoleAssignModal,
46
58
  branchCacheCreateSchema: () => branchCacheCreateSchema,
47
59
  branchCacheI18n: () => branchCacheI18n,
48
60
  branchCacheSchemas: () => branchCacheSchemas,
@@ -80,6 +92,8 @@ __export(src_exports, {
80
92
  getRolePermissionFieldLabel: () => getRolePermissionFieldLabel,
81
93
  getRolePermissionFieldPlaceholder: () => getRolePermissionFieldPlaceholder,
82
94
  getRolePermissionLabel: () => getRolePermissionLabel,
95
+ getScopeColor: () => getScopeColor,
96
+ getScopeIcon: () => getScopeIcon,
83
97
  getScopeLabel: () => getScopeLabel,
84
98
  getTeamCacheFieldLabel: () => getTeamCacheFieldLabel,
85
99
  getTeamCacheFieldPlaceholder: () => getTeamCacheFieldPlaceholder,
@@ -136,7 +150,7 @@ __export(src_exports, {
136
150
  });
137
151
  module.exports = __toCommonJS(src_exports);
138
152
 
139
- // node_modules/@omnify-base/schemas/i18n.ts
153
+ // src/core/schemas/base/i18n.ts
140
154
  var defaultLocale = "ja";
141
155
  var fallbackLocale = "en";
142
156
  var supportedLocales = ["ja", "en"];
@@ -191,7 +205,7 @@ function getMessages(locale) {
191
205
  return result;
192
206
  }
193
207
 
194
- // node_modules/@omnify-base/schemas/BranchCache.ts
208
+ // src/core/schemas/base/BranchCache.ts
195
209
  var import_zod = require("zod");
196
210
  var branchCacheI18n = {
197
211
  /** Model display name */
@@ -250,12 +264,12 @@ function getBranchCacheFieldPlaceholder(field, locale) {
250
264
  return placeholder[locale] ?? placeholder["en"] ?? "";
251
265
  }
252
266
 
253
- // src/schemas/BranchCache.ts
267
+ // src/core/schemas/BranchCache.ts
254
268
  var branchCacheSchemas = { ...baseBranchCacheSchemas };
255
269
  var branchCacheCreateSchema = baseBranchCacheCreateSchema;
256
270
  var branchCacheUpdateSchema = baseBranchCacheUpdateSchema;
257
271
 
258
- // node_modules/@omnify-base/schemas/OrganizationCache.ts
272
+ // src/core/schemas/base/OrganizationCache.ts
259
273
  var import_zod2 = require("zod");
260
274
  var organizationCacheI18n = {
261
275
  /** Model display name */
@@ -304,12 +318,12 @@ function getOrganizationCacheFieldPlaceholder(field, locale) {
304
318
  return placeholder[locale] ?? placeholder["en"] ?? "";
305
319
  }
306
320
 
307
- // src/schemas/OrganizationCache.ts
321
+ // src/core/schemas/OrganizationCache.ts
308
322
  var organizationCacheSchemas = { ...baseOrganizationCacheSchemas };
309
323
  var organizationCacheCreateSchema = baseOrganizationCacheCreateSchema;
310
324
  var organizationCacheUpdateSchema = baseOrganizationCacheUpdateSchema;
311
325
 
312
- // node_modules/@omnify-base/schemas/Permission.ts
326
+ // src/core/schemas/base/Permission.ts
313
327
  var import_zod3 = require("zod");
314
328
  var permissionI18n = {
315
329
  /** Model display name */
@@ -356,12 +370,12 @@ function getPermissionFieldPlaceholder(field, locale) {
356
370
  return placeholder[locale] ?? placeholder["en"] ?? "";
357
371
  }
358
372
 
359
- // src/schemas/Permission.ts
373
+ // src/core/schemas/Permission.ts
360
374
  var permissionSchemas = { ...basePermissionSchemas };
361
375
  var permissionCreateSchema = basePermissionCreateSchema;
362
376
  var permissionUpdateSchema = basePermissionUpdateSchema;
363
377
 
364
- // node_modules/@omnify-base/schemas/Role.ts
378
+ // src/core/schemas/base/Role.ts
365
379
  var import_zod4 = require("zod");
366
380
  var roleI18n = {
367
381
  /** Model display name */
@@ -418,12 +432,12 @@ function getRoleFieldPlaceholder(field, locale) {
418
432
  return placeholder[locale] ?? placeholder["en"] ?? "";
419
433
  }
420
434
 
421
- // src/schemas/Role.ts
435
+ // src/core/schemas/Role.ts
422
436
  var roleSchemas = { ...baseRoleSchemas };
423
437
  var roleCreateSchema = baseRoleCreateSchema;
424
438
  var roleUpdateSchema = baseRoleUpdateSchema;
425
439
 
426
- // node_modules/@omnify-base/schemas/RolePermission.ts
440
+ // src/core/schemas/base/RolePermission.ts
427
441
  var import_zod5 = require("zod");
428
442
  var rolePermissionI18n = {
429
443
  /** Model display name */
@@ -456,12 +470,12 @@ function getRolePermissionFieldPlaceholder(field, locale) {
456
470
  return placeholder[locale] ?? placeholder["en"] ?? "";
457
471
  }
458
472
 
459
- // src/schemas/RolePermission.ts
473
+ // src/core/schemas/RolePermission.ts
460
474
  var rolePermissionSchemas = { ...baseRolePermissionSchemas };
461
475
  var rolePermissionCreateSchema = baseRolePermissionCreateSchema;
462
476
  var rolePermissionUpdateSchema = baseRolePermissionUpdateSchema;
463
477
 
464
- // node_modules/@omnify-base/schemas/TeamCache.ts
478
+ // src/core/schemas/base/TeamCache.ts
465
479
  var import_zod6 = require("zod");
466
480
  var teamCacheI18n = {
467
481
  /** Model display name */
@@ -505,12 +519,12 @@ function getTeamCacheFieldPlaceholder(field, locale) {
505
519
  return placeholder[locale] ?? placeholder["en"] ?? "";
506
520
  }
507
521
 
508
- // src/schemas/TeamCache.ts
522
+ // src/core/schemas/TeamCache.ts
509
523
  var teamCacheSchemas = { ...baseTeamCacheSchemas };
510
524
  var teamCacheCreateSchema = baseTeamCacheCreateSchema;
511
525
  var teamCacheUpdateSchema = baseTeamCacheUpdateSchema;
512
526
 
513
- // node_modules/@omnify-base/schemas/TeamPermission.ts
527
+ // src/core/schemas/base/TeamPermission.ts
514
528
  var import_zod7 = require("zod");
515
529
  var teamPermissionI18n = {
516
530
  /** Model display name */
@@ -552,12 +566,12 @@ function getTeamPermissionFieldPlaceholder(field, locale) {
552
566
  return placeholder[locale] ?? placeholder["en"] ?? "";
553
567
  }
554
568
 
555
- // src/schemas/TeamPermission.ts
569
+ // src/core/schemas/TeamPermission.ts
556
570
  var teamPermissionSchemas = { ...baseTeamPermissionSchemas };
557
571
  var teamPermissionCreateSchema = baseTeamPermissionCreateSchema;
558
572
  var teamPermissionUpdateSchema = baseTeamPermissionUpdateSchema;
559
573
 
560
- // node_modules/@omnify-base/schemas/UserCache.ts
574
+ // src/core/schemas/base/UserCache.ts
561
575
  var import_zod8 = require("zod");
562
576
  var userCacheI18n = {
563
577
  /** Model display name */
@@ -624,12 +638,12 @@ function getUserCacheFieldPlaceholder(field, locale) {
624
638
  return placeholder[locale] ?? placeholder["en"] ?? "";
625
639
  }
626
640
 
627
- // src/schemas/UserCache.ts
641
+ // src/core/schemas/UserCache.ts
628
642
  var userCacheSchemas = { ...baseUserCacheSchemas };
629
643
  var userCacheCreateSchema = baseUserCacheCreateSchema;
630
644
  var userCacheUpdateSchema = baseUserCacheUpdateSchema;
631
645
 
632
- // src/context/SsoContext.tsx
646
+ // src/core/context/SsoContext.tsx
633
647
  var import_react = require("react");
634
648
  var SsoContext = (0, import_react.createContext)(null);
635
649
  function useSsoContext() {
@@ -640,7 +654,7 @@ function useSsoContext() {
640
654
  return context;
641
655
  }
642
656
 
643
- // src/context/SsoProvider.tsx
657
+ // src/core/context/SsoProvider.tsx
644
658
  var import_react2 = require("react");
645
659
  var import_jsx_runtime = require("react/jsx-runtime");
646
660
  function transformUser(data) {
@@ -791,8 +805,8 @@ function SsoProvider({ children, config, onAuthChange }) {
791
805
  [logout, config.consoleUrl]
792
806
  );
793
807
  const switchOrg = (0, import_react2.useCallback)(
794
- (orgSlug) => {
795
- const org = organizations.find((o) => o.slug === orgSlug);
808
+ (orgId) => {
809
+ const org = organizations.find((o) => o.slug === orgId);
796
810
  if (org) {
797
811
  setCurrentOrg(org);
798
812
  saveSelectedOrg(org);
@@ -817,7 +831,7 @@ function SsoProvider({ children, config, onAuthChange }) {
817
831
  const getHeaders = (0, import_react2.useCallback)(() => {
818
832
  const headers = {};
819
833
  if (currentOrg) {
820
- headers["X-Org-Id"] = currentOrg.slug;
834
+ headers["X-Organization-Id"] = currentOrg.slug;
821
835
  }
822
836
  return headers;
823
837
  }, [currentOrg]);
@@ -853,7 +867,7 @@ function SsoProvider({ children, config, onAuthChange }) {
853
867
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SsoContext.Provider, { value, children });
854
868
  }
855
869
 
856
- // src/context/BranchContext.tsx
870
+ // src/core/context/BranchContext.tsx
857
871
  var import_react3 = require("react");
858
872
  var BranchContext = (0, import_react3.createContext)(null);
859
873
  function useBranchContext() {
@@ -864,122 +878,16 @@ function useBranchContext() {
864
878
  return context;
865
879
  }
866
880
 
867
- // src/context/BranchProvider.tsx
868
- var import_react_query = require("@tanstack/react-query");
881
+ // src/core/context/BranchProvider.tsx
869
882
  var import_react4 = require("react");
883
+ var import_react_query = require("@tanstack/react-query");
870
884
 
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
885
+ // src/core/services/utils.ts
978
886
  function getXsrfToken2() {
979
887
  if (typeof document === "undefined") return void 0;
980
888
  return document.cookie.split("; ").find((row) => row.startsWith("XSRF-TOKEN="))?.split("=")[1];
981
889
  }
982
- function buildHeaders(orgSlug) {
890
+ function buildHeaders(orgId) {
983
891
  const headers = {
984
892
  "Content-Type": "application/json",
985
893
  Accept: "application/json"
@@ -988,8 +896,8 @@ function buildHeaders(orgSlug) {
988
896
  if (xsrfToken) {
989
897
  headers["X-XSRF-TOKEN"] = decodeURIComponent(xsrfToken);
990
898
  }
991
- if (orgSlug) {
992
- headers["X-Org-Id"] = orgSlug;
899
+ if (orgId) {
900
+ headers["X-Organization-Id"] = orgId;
993
901
  }
994
902
  return headers;
995
903
  }
@@ -1013,18 +921,18 @@ async function request(apiUrl, path, options = {}) {
1013
921
  return response.json();
1014
922
  }
1015
923
 
1016
- // src/services/branchService.ts
924
+ // src/core/services/branchService.ts
1017
925
  function createBranchService(config) {
1018
926
  const { apiUrl } = config;
1019
927
  return {
1020
928
  /**
1021
929
  * Get branches for current user in organization
1022
930
  * GET /api/sso/branches
931
+ * @param orgId - Organization ID or slug (sent via X-Organization-Id header)
1023
932
  */
1024
- list: async (orgSlug) => {
1025
- const params = orgSlug ? `?organization_slug=${orgSlug}` : "";
1026
- return request(apiUrl, `/api/sso/branches${params}`, {
1027
- headers: buildHeaders()
933
+ list: async (orgId) => {
934
+ return request(apiUrl, `/api/sso/branches`, {
935
+ headers: buildHeaders(orgId)
1028
936
  });
1029
937
  },
1030
938
  /**
@@ -1041,14 +949,14 @@ function createBranchService(config) {
1041
949
  },
1042
950
  /**
1043
951
  * Get headquarters branch for organization
952
+ * @param orgId - Organization ID or slug (sent via X-Organization-Id header)
1044
953
  */
1045
- getHeadquarters: async (orgSlug) => {
954
+ getHeadquarters: async (orgId) => {
1046
955
  try {
1047
- const params = orgSlug ? `?organization_slug=${orgSlug}` : "";
1048
956
  const data = await request(
1049
957
  apiUrl,
1050
- `/api/sso/branches${params}`,
1051
- { headers: buildHeaders() }
958
+ `/api/sso/branches`,
959
+ { headers: buildHeaders(orgId) }
1052
960
  );
1053
961
  return data.branches.find((b) => b.is_headquarters) ?? null;
1054
962
  } catch {
@@ -1057,14 +965,14 @@ function createBranchService(config) {
1057
965
  },
1058
966
  /**
1059
967
  * Get primary branch for current user
968
+ * @param orgId - Organization ID or slug (sent via X-Organization-Id header)
1060
969
  */
1061
- getPrimary: async (orgSlug) => {
970
+ getPrimary: async (orgId) => {
1062
971
  try {
1063
- const params = orgSlug ? `?organization_slug=${orgSlug}` : "";
1064
972
  const data = await request(
1065
973
  apiUrl,
1066
- `/api/sso/branches${params}`,
1067
- { headers: buildHeaders() }
974
+ `/api/sso/branches`,
975
+ { headers: buildHeaders(orgId) }
1068
976
  );
1069
977
  if (data.primary_branch_id) {
1070
978
  return data.branches.find((b) => b.id === data.primary_branch_id) ?? null;
@@ -1077,7 +985,106 @@ function createBranchService(config) {
1077
985
  };
1078
986
  }
1079
987
 
1080
- // src/context/BranchProvider.tsx
988
+ // src/core/queryKeys.ts
989
+ var ssoQueryKeys = {
990
+ all: ["sso"],
991
+ // =========================================================================
992
+ // Auth (authService)
993
+ // =========================================================================
994
+ auth: {
995
+ all: () => [...ssoQueryKeys.all, "auth"],
996
+ user: () => [...ssoQueryKeys.auth.all(), "user"],
997
+ globalLogoutUrl: (redirectUri) => [...ssoQueryKeys.auth.all(), "global-logout-url", redirectUri]
998
+ },
999
+ // =========================================================================
1000
+ // Tokens (tokenService)
1001
+ // =========================================================================
1002
+ tokens: {
1003
+ all: () => [...ssoQueryKeys.all, "tokens"],
1004
+ list: () => [...ssoQueryKeys.tokens.all(), "list"]
1005
+ },
1006
+ // =========================================================================
1007
+ // Roles (roleService)
1008
+ // =========================================================================
1009
+ roles: {
1010
+ all: () => [...ssoQueryKeys.all, "roles"],
1011
+ list: () => [...ssoQueryKeys.roles.all(), "list"],
1012
+ detail: (id) => [...ssoQueryKeys.roles.all(), "detail", id],
1013
+ permissions: (id) => [...ssoQueryKeys.roles.all(), id, "permissions"]
1014
+ },
1015
+ // =========================================================================
1016
+ // Permissions (permissionService)
1017
+ // =========================================================================
1018
+ permissions: {
1019
+ all: () => [...ssoQueryKeys.all, "permissions"],
1020
+ list: (params) => [...ssoQueryKeys.permissions.all(), "list", params],
1021
+ detail: (id) => [...ssoQueryKeys.permissions.all(), "detail", id],
1022
+ matrix: () => [...ssoQueryKeys.permissions.all(), "matrix"]
1023
+ },
1024
+ // =========================================================================
1025
+ // Teams (teamService)
1026
+ // =========================================================================
1027
+ teams: {
1028
+ all: () => [...ssoQueryKeys.all, "teams"],
1029
+ list: () => [...ssoQueryKeys.teams.all(), "list"],
1030
+ permissions: (teamId) => [...ssoQueryKeys.teams.all(), teamId, "permissions"],
1031
+ orphaned: () => [...ssoQueryKeys.teams.all(), "orphaned"]
1032
+ },
1033
+ // =========================================================================
1034
+ // User Roles (userRoleService) - Scoped Role Assignments
1035
+ // =========================================================================
1036
+ userRoles: {
1037
+ all: () => [...ssoQueryKeys.all, "user-roles"],
1038
+ list: (userId) => [...ssoQueryKeys.userRoles.all(), userId],
1039
+ byBranch: (userId, orgId, branchId) => [...ssoQueryKeys.userRoles.all(), userId, orgId, branchId]
1040
+ },
1041
+ // =========================================================================
1042
+ // Branches (branchService)
1043
+ // =========================================================================
1044
+ branches: {
1045
+ all: () => [...ssoQueryKeys.all, "branches"],
1046
+ list: (orgId) => [...ssoQueryKeys.branches.all(), "list", orgId],
1047
+ detail: (branchId) => [...ssoQueryKeys.branches.all(), "detail", branchId],
1048
+ headquarters: (orgId) => [...ssoQueryKeys.branches.all(), "headquarters", orgId],
1049
+ primary: (orgId) => [...ssoQueryKeys.branches.all(), "primary", orgId]
1050
+ },
1051
+ // =========================================================================
1052
+ // Admin variants (with org context)
1053
+ // =========================================================================
1054
+ admin: {
1055
+ roles: {
1056
+ all: (orgId) => [...ssoQueryKeys.all, "admin", orgId, "roles"],
1057
+ list: (orgId) => [...ssoQueryKeys.admin.roles.all(orgId), "list"],
1058
+ detail: (orgId, id) => [...ssoQueryKeys.admin.roles.all(orgId), "detail", id],
1059
+ permissions: (orgId, id) => [...ssoQueryKeys.admin.roles.all(orgId), id, "permissions"]
1060
+ },
1061
+ permissions: {
1062
+ all: (orgId) => [...ssoQueryKeys.all, "admin", orgId, "permissions"],
1063
+ list: (orgId, params) => [...ssoQueryKeys.admin.permissions.all(orgId), "list", params],
1064
+ detail: (orgId, id) => [...ssoQueryKeys.admin.permissions.all(orgId), "detail", id],
1065
+ matrix: (orgId) => [...ssoQueryKeys.admin.permissions.all(orgId), "matrix"]
1066
+ },
1067
+ teams: {
1068
+ all: (orgId) => [...ssoQueryKeys.all, "admin", orgId, "teams"],
1069
+ list: (orgId) => [...ssoQueryKeys.admin.teams.all(orgId), "list"],
1070
+ permissions: (orgId, teamId) => [...ssoQueryKeys.admin.teams.all(orgId), teamId, "permissions"],
1071
+ orphaned: (orgId) => [...ssoQueryKeys.admin.teams.all(orgId), "orphaned"]
1072
+ },
1073
+ userRoles: {
1074
+ all: (orgId) => [...ssoQueryKeys.all, "admin", orgId, "user-roles"],
1075
+ list: (orgId, userId) => [...ssoQueryKeys.admin.userRoles.all(orgId), userId],
1076
+ byBranch: (orgId, userId, consoleOrgId, branchId) => [...ssoQueryKeys.admin.userRoles.all(orgId), userId, consoleOrgId, branchId]
1077
+ },
1078
+ users: {
1079
+ all: (orgId) => [...ssoQueryKeys.all, "admin", orgId, "users"],
1080
+ list: (orgId, params) => [...ssoQueryKeys.admin.users.all(orgId), "list", params],
1081
+ detail: (orgId, id) => [...ssoQueryKeys.admin.users.all(orgId), "detail", id],
1082
+ permissions: (orgId, userId, consoleOrgId, branchId) => [...ssoQueryKeys.admin.users.all(orgId), userId, "permissions", consoleOrgId, branchId]
1083
+ }
1084
+ }
1085
+ };
1086
+
1087
+ // src/core/context/BranchProvider.tsx
1081
1088
  var import_jsx_runtime2 = require("react/jsx-runtime");
1082
1089
  var DEFAULT_STORAGE_KEY = "omnify_selected_branch";
1083
1090
  function BranchProvider({
@@ -1193,7 +1200,7 @@ function BranchProvider({
1193
1200
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BranchContext.Provider, { value: contextValue, children });
1194
1201
  }
1195
1202
 
1196
- // src/hooks/useAuth.ts
1203
+ // src/core/hooks/useAuth.ts
1197
1204
  var import_react5 = require("react");
1198
1205
  function useAuth() {
1199
1206
  const { user, isLoading, isAuthenticated, login, logout, globalLogout, refreshUser } = useSsoContext();
@@ -1223,7 +1230,7 @@ function useAuth() {
1223
1230
  };
1224
1231
  }
1225
1232
 
1226
- // src/hooks/useOrganization.ts
1233
+ // src/core/hooks/useOrganization.ts
1227
1234
  var import_react6 = require("react");
1228
1235
  var ROLE_LEVELS = {
1229
1236
  admin: 100,
@@ -1244,8 +1251,8 @@ function useOrganization() {
1244
1251
  [currentRole]
1245
1252
  );
1246
1253
  const handleSwitchOrg = (0, import_react6.useCallback)(
1247
- (orgSlug) => {
1248
- switchOrg(orgSlug);
1254
+ (orgId) => {
1255
+ switchOrg(orgId);
1249
1256
  },
1250
1257
  [switchOrg]
1251
1258
  );
@@ -1262,7 +1269,7 @@ function useOrganization() {
1262
1269
  );
1263
1270
  }
1264
1271
 
1265
- // src/hooks/useSso.ts
1272
+ // src/core/hooks/useSso.ts
1266
1273
  var import_react7 = require("react");
1267
1274
  function useSso() {
1268
1275
  const context = useSsoContext();
@@ -1289,12 +1296,12 @@ function useSso() {
1289
1296
  );
1290
1297
  }
1291
1298
 
1292
- // src/hooks/useBranch.ts
1299
+ // src/core/hooks/useBranch.ts
1293
1300
  function useBranch() {
1294
1301
  return useBranchContext();
1295
1302
  }
1296
1303
 
1297
- // src/components/SsoCallback.tsx
1304
+ // src/ant/components/SsoCallback/SsoCallback.tsx
1298
1305
  var import_react8 = require("react");
1299
1306
  var import_jsx_runtime3 = require("react/jsx-runtime");
1300
1307
  function transformUser2(data) {
@@ -1410,10 +1417,10 @@ function SsoCallback({
1410
1417
  return null;
1411
1418
  }
1412
1419
 
1413
- // src/components/OrganizationSwitcher.tsx
1414
- var import_icons = require("@ant-design/icons");
1415
- var import_antd = require("antd");
1420
+ // src/ant/components/OrganizationSwitcher/OrganizationSwitcher.tsx
1416
1421
  var import_react9 = __toESM(require("react"), 1);
1422
+ var import_antd = require("antd");
1423
+ var import_icons = require("@ant-design/icons");
1417
1424
  var import_jsx_runtime4 = require("react/jsx-runtime");
1418
1425
  var { Text } = import_antd.Typography;
1419
1426
  function OrganizationSwitcher({
@@ -1487,7 +1494,7 @@ function OrganizationSwitcher({
1487
1494
  );
1488
1495
  }
1489
1496
 
1490
- // src/components/ProtectedRoute.tsx
1497
+ // src/ant/components/ProtectedRoute/ProtectedRoute.tsx
1491
1498
  var import_react10 = require("react");
1492
1499
  var import_jsx_runtime5 = require("react/jsx-runtime");
1493
1500
  function DefaultLoading2() {
@@ -1576,11 +1583,11 @@ function ProtectedRoute({
1576
1583
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children });
1577
1584
  }
1578
1585
 
1579
- // src/components/OrgBranchSelectorModal.tsx
1586
+ // src/ant/components/OrgBranchSelectorModal/OrgBranchSelectorModal.tsx
1587
+ var import_react11 = require("react");
1588
+ var import_antd2 = require("antd");
1580
1589
  var import_icons2 = require("@ant-design/icons");
1581
1590
  var import_react_query2 = require("@tanstack/react-query");
1582
- var import_antd2 = require("antd");
1583
- var import_react11 = require("react");
1584
1591
  var import_jsx_runtime6 = require("react/jsx-runtime");
1585
1592
  var { Text: Text2, Title } = import_antd2.Typography;
1586
1593
  function OrgBranchSelectorModal({
@@ -1593,7 +1600,6 @@ function OrgBranchSelectorModal({
1593
1600
  }) {
1594
1601
  const { config } = useSsoContext();
1595
1602
  const { organizations, currentOrg, hasMultipleOrgs } = useOrganization();
1596
- const { currentBranch } = useBranch();
1597
1603
  const [form] = import_antd2.Form.useForm();
1598
1604
  const [selectedOrgSlug, setSelectedOrgSlug] = (0, import_react11.useState)(
1599
1605
  currentOrg?.slug ?? null
@@ -1614,26 +1620,17 @@ function OrgBranchSelectorModal({
1614
1620
  const branches = branchesData?.branches ?? [];
1615
1621
  const hasMultipleBranches = branches.length > 1;
1616
1622
  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
- },
1623
+ () => organizations.find((o) => o.slug === selectedOrgSlug) ?? null,
1626
1624
  [organizations, selectedOrgSlug]
1627
1625
  );
1628
1626
  (0, import_react11.useEffect)(() => {
1629
1627
  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) {
1628
+ if (organizations.length === 1 && !selectedOrgSlug) {
1635
1629
  setSelectedOrgSlug(organizations[0].slug);
1636
1630
  form.setFieldValue("organization_id", organizations[0].id);
1631
+ } else if (currentOrg && !selectedOrgSlug) {
1632
+ setSelectedOrgSlug(currentOrg.slug);
1633
+ form.setFieldValue("organization_id", currentOrg.id);
1637
1634
  }
1638
1635
  }, [open, organizations, currentOrg, selectedOrgSlug, form]);
1639
1636
  (0, import_react11.useEffect)(() => {
@@ -1641,21 +1638,17 @@ function OrgBranchSelectorModal({
1641
1638
  if (branches.length === 1) {
1642
1639
  form.setFieldValue("branch_id", branches[0].id);
1643
1640
  } else if (branches.length > 0) {
1644
- if (currentBranch && branches.some((b) => b.id === currentBranch.id)) {
1645
- form.setFieldValue("branch_id", currentBranch.id);
1641
+ const primaryId = branchesData?.primary_branch_id;
1642
+ if (primaryId) {
1643
+ form.setFieldValue("branch_id", primaryId);
1646
1644
  } 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
- }
1645
+ const hq = branches.find((b) => b.is_headquarters);
1646
+ if (hq) {
1647
+ form.setFieldValue("branch_id", hq.id);
1655
1648
  }
1656
1649
  }
1657
1650
  }
1658
- }, [open, branches, branchesLoading, branchesData, currentBranch, form]);
1651
+ }, [open, branches, branchesLoading, branchesData, form]);
1659
1652
  (0, import_react11.useEffect)(() => {
1660
1653
  if (!open || branchesLoading) return;
1661
1654
  const orgId = form.getFieldValue("organization_id");
@@ -1857,11 +1850,11 @@ function OrgBranchSelectorModal({
1857
1850
  );
1858
1851
  }
1859
1852
 
1860
- // src/components/BranchGate.tsx
1853
+ // src/ant/components/BranchGate/BranchGate.tsx
1854
+ var import_react12 = __toESM(require("react"), 1);
1855
+ var import_antd3 = require("antd");
1861
1856
  var import_icons3 = require("@ant-design/icons");
1862
1857
  var import_react_query3 = require("@tanstack/react-query");
1863
- var import_antd3 = require("antd");
1864
- var import_react12 = __toESM(require("react"), 1);
1865
1858
  var import_jsx_runtime7 = require("react/jsx-runtime");
1866
1859
  var { Text: Text3, Title: Title2 } = import_antd3.Typography;
1867
1860
  var DEFAULT_STORAGE_KEY2 = "omnify_branch_gate_selection";
@@ -1887,7 +1880,7 @@ function BranchGate({
1887
1880
  if (tempOrgId) {
1888
1881
  return organizations.find((o) => String(o.id) === tempOrgId)?.slug;
1889
1882
  }
1890
- return storedSelection?.orgSlug ?? currentOrg?.slug;
1883
+ return storedSelection?.orgId ?? currentOrg?.slug;
1891
1884
  }, [tempOrgId, organizations, storedSelection, currentOrg]);
1892
1885
  const { data: branchesData, isLoading: branchesLoading } = (0, import_react_query3.useQuery)({
1893
1886
  queryKey: ssoQueryKeys.branches.list(activeOrgSlug),
@@ -1945,8 +1938,7 @@ function BranchGate({
1945
1938
  const branch = branches.find((b) => String(b.id) === tempBranchId);
1946
1939
  if (!org || !branch) return;
1947
1940
  const selection = {
1948
- orgId: String(org.id),
1949
- orgSlug: org.slug,
1941
+ orgId: org.slug,
1950
1942
  orgName: org.name,
1951
1943
  branchId: String(branch.id),
1952
1944
  branchName: branch.name,
@@ -2151,482 +2143,2184 @@ function useBranchGate(storageKey = DEFAULT_STORAGE_KEY2) {
2151
2143
  }, [storageKey]);
2152
2144
  return {
2153
2145
  selection,
2154
- selectedOrg: selection ? { id: selection.orgId, slug: selection.orgSlug, name: selection.orgName } : null,
2146
+ selectedOrg: selection ? { id: selection.orgId, slug: selection.orgId, name: selection.orgName } : null,
2155
2147
  selectedBranch: selection ? { id: selection.branchId, name: selection.branchName, code: selection.branchCode } : null,
2156
2148
  clearSelection
2157
2149
  };
2158
2150
  }
2159
2151
 
2160
- // src/components/admin/UserTable.tsx
2152
+ // src/ant/components/ProTable/ProTable.tsx
2161
2153
  var import_icons4 = require("@ant-design/icons");
2154
+ var import_react_query4 = require("@tanstack/react-query");
2162
2155
  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
2156
  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 };
2157
+ var import_jsx_runtime8 = require("react/jsx-runtime");
2158
+ var { Link } = import_antd4.Typography;
2159
+ var { RangePicker } = import_antd4.DatePicker;
2160
+ var InertiaLink = null;
2161
+ try {
2162
+ InertiaLink = require("@inertiajs/react").Link;
2163
+ } catch {
2326
2164
  }
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"
2165
+ var DEFAULT_TEXTS = {
2166
+ search: "\u691C\u7D22",
2167
+ reset: "\u30EA\u30BB\u30C3\u30C8",
2168
+ expand: "\u5C55\u958B",
2169
+ collapse: "\u53CE\u7D0D",
2170
+ add: "\u65B0\u898F",
2171
+ refresh: "\u66F4\u65B0",
2172
+ columnSettings: "\u5217\u8A2D\u5B9A",
2173
+ actions: "\u64CD\u4F5C",
2174
+ yes: "\u306F\u3044",
2175
+ no: "\u3044\u3044\u3048",
2176
+ cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
2177
+ totalItems: (total) => `\u5168 ${total} \u4EF6`,
2178
+ selectPlaceholder: "\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044",
2179
+ inputPlaceholder: "\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
2180
+ startDate: "\u958B\u59CB\u65E5",
2181
+ endDate: "\u7D42\u4E86\u65E5"
2343
2182
  };
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;
2183
+ var DEFAULT_STATUS_CONFIG = {
2184
+ active: { color: "#52c41a", text: "\u6709\u52B9" },
2185
+ Active: { color: "#52c41a", text: "\u6709\u52B9" },
2186
+ inactive: { color: "#d9d9d9", text: "\u7121\u52B9" },
2187
+ Inactive: { color: "#d9d9d9", text: "\u7121\u52B9" },
2188
+ pending: { color: "#faad14", text: "\u4FDD\u7559\u4E2D" },
2189
+ Pending: { color: "#faad14", text: "\u4FDD\u7559\u4E2D" },
2190
+ error: { color: "#ff4d4f", text: "\u30A8\u30E9\u30FC" },
2191
+ Error: { color: "#ff4d4f", text: "\u30A8\u30E9\u30FC" },
2192
+ closed: { color: "#ff4d4f", text: "\u9589\u9396" },
2193
+ Closed: { color: "#ff4d4f", text: "\u9589\u9396" }
2352
2194
  };
2195
+ function renderSearchField(field, texts) {
2196
+ switch (field.type) {
2197
+ case "select":
2198
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2199
+ import_antd4.Select,
2200
+ {
2201
+ allowClear: true,
2202
+ placeholder: field.placeholder || texts.selectPlaceholder,
2203
+ options: field.options,
2204
+ style: { width: "100%" }
2205
+ }
2206
+ );
2207
+ case "date":
2208
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2209
+ import_antd4.DatePicker,
2210
+ {
2211
+ placeholder: field.placeholder,
2212
+ style: { width: "100%" }
2213
+ }
2214
+ );
2215
+ case "dateRange":
2216
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2217
+ RangePicker,
2218
+ {
2219
+ placeholder: [texts.startDate, texts.endDate],
2220
+ style: { width: "100%" }
2221
+ }
2222
+ );
2223
+ case "number":
2224
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2225
+ import_antd4.InputNumber,
2226
+ {
2227
+ placeholder: field.placeholder,
2228
+ style: { width: "100%" }
2229
+ }
2230
+ );
2231
+ default:
2232
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2233
+ import_antd4.Input,
2234
+ {
2235
+ allowClear: true,
2236
+ placeholder: field.placeholder || texts.inputPlaceholder
2237
+ }
2238
+ );
2239
+ }
2240
+ }
2241
+ function SmartLink({ href, children }) {
2242
+ if (InertiaLink) {
2243
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(InertiaLink, { href, children });
2244
+ }
2245
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", { href, children });
2246
+ }
2247
+ function renderValue(value, valueType, statusConfig) {
2248
+ if (value === null || value === void 0) {
2249
+ return "-";
2250
+ }
2251
+ switch (valueType) {
2252
+ case "status": {
2253
+ const config = { ...DEFAULT_STATUS_CONFIG, ...statusConfig };
2254
+ const statusValue = String(value);
2255
+ const status = config[statusValue] || { color: "#d9d9d9", text: statusValue };
2256
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_antd4.Space, { children: [
2257
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2258
+ "span",
2259
+ {
2260
+ style: {
2261
+ display: "inline-block",
2262
+ width: 6,
2263
+ height: 6,
2264
+ borderRadius: "50%",
2265
+ backgroundColor: status.color
2266
+ }
2267
+ }
2268
+ ),
2269
+ status.text
2270
+ ] });
2271
+ }
2272
+ case "date":
2273
+ return value ? new Date(String(value)).toLocaleDateString("ja-JP") : "-";
2274
+ case "datetime":
2275
+ return value ? new Date(String(value)).toLocaleString("ja-JP") : "-";
2276
+ case "number":
2277
+ return typeof value === "number" ? value.toLocaleString("ja-JP") : String(value);
2278
+ case "currency":
2279
+ return typeof value === "number" ? `\xA5${value.toLocaleString("ja-JP")}` : String(value);
2280
+ case "boolean":
2281
+ return value ? "\u306F\u3044" : "\u3044\u3044\u3048";
2282
+ default:
2283
+ return String(value);
2284
+ }
2285
+ }
2286
+ function ProTable({
2287
+ // Header
2288
+ title,
2289
+ icon,
2290
+ subTitle,
2291
+ // Search
2292
+ searchFields = [],
2293
+ defaultSearchValues = {},
2294
+ // Columns
2295
+ columns,
2296
+ // Data
2297
+ dataSource: externalDataSource,
2298
+ rowKey = "id",
2299
+ loading: externalLoading,
2300
+ // Query
2301
+ queryKey,
2302
+ queryFn,
2303
+ queryResult: externalQueryResult,
2304
+ queryEnabled = true,
2305
+ // Toolbar
2306
+ onAdd,
2307
+ addButtonLink,
2308
+ addLabel = "\u65B0\u898F",
2309
+ toolbarExtra,
2310
+ showRefresh = true,
2311
+ showColumnSettings = true,
2312
+ // Row actions
2313
+ rowActions,
2314
+ // Pagination
2315
+ pagination = true,
2316
+ defaultPageSize = 15,
2317
+ // Events
2318
+ onSearch,
2319
+ onReset,
2320
+ onChange,
2321
+ // Style
2322
+ className,
2323
+ style,
2324
+ cardStyle,
2325
+ tableProps,
2326
+ // i18n
2327
+ texts: customTexts
2328
+ }) {
2329
+ const { token } = import_antd4.theme.useToken();
2330
+ const texts = { ...DEFAULT_TEXTS, ...customTexts };
2331
+ const [searchForm] = import_antd4.Form.useForm();
2332
+ const [expanded, setExpanded] = (0, import_react13.useState)(false);
2333
+ const [queryParams, setQueryParams] = (0, import_react13.useState)({
2334
+ page: 1,
2335
+ per_page: defaultPageSize,
2336
+ ...defaultSearchValues
2337
+ });
2338
+ const visibleFields = searchFields.filter((f) => !f.hidden);
2339
+ const hiddenFields = searchFields.filter((f) => f.hidden);
2340
+ const hasHiddenFields = hiddenFields.length > 0;
2341
+ const internalQuery = (0, import_react_query4.useQuery)({
2342
+ queryKey: queryKey ? [...queryKey, queryParams] : ["proTable", queryParams],
2343
+ queryFn: () => queryFn(queryParams),
2344
+ enabled: !!queryFn && queryEnabled
2345
+ });
2346
+ const queryResult = externalQueryResult || internalQuery;
2347
+ const dataSource = externalDataSource || queryResult.data?.data || [];
2348
+ const loading = externalLoading ?? queryResult.isLoading;
2349
+ const meta = queryResult.data?.meta;
2350
+ const handleSearch = (0, import_react13.useCallback)((values) => {
2351
+ const newParams = {
2352
+ ...queryParams,
2353
+ ...values,
2354
+ page: 1
2355
+ };
2356
+ setQueryParams(newParams);
2357
+ onSearch?.(values);
2358
+ }, [queryParams, onSearch]);
2359
+ const handleReset = (0, import_react13.useCallback)(() => {
2360
+ searchForm.resetFields();
2361
+ const newParams = {
2362
+ page: 1,
2363
+ per_page: defaultPageSize
2364
+ };
2365
+ setQueryParams(newParams);
2366
+ onReset?.();
2367
+ }, [searchForm, defaultPageSize, onReset]);
2368
+ const handleTableChange = (0, import_react13.useCallback)(
2369
+ (pag, _filters, sorter, _extra) => {
2370
+ const sortInfo = Array.isArray(sorter) ? sorter[0] : sorter;
2371
+ const newParams = {
2372
+ ...queryParams,
2373
+ page: pag.current || 1,
2374
+ per_page: pag.pageSize || defaultPageSize
2375
+ };
2376
+ if (sortInfo?.field && sortInfo?.order) {
2377
+ newParams.sort = String(sortInfo.field);
2378
+ newParams.order = sortInfo.order === "ascend" ? "asc" : "desc";
2379
+ } else {
2380
+ delete newParams.sort;
2381
+ delete newParams.order;
2382
+ }
2383
+ setQueryParams(newParams);
2384
+ onChange?.(pag, _filters, sorter, _extra);
2385
+ },
2386
+ [queryParams, defaultPageSize, onChange]
2387
+ );
2388
+ const tableColumns = (0, import_react13.useMemo)(() => {
2389
+ const cols = columns.filter((col) => !col.hidden).map((col) => ({
2390
+ ...col,
2391
+ key: col.key || (Array.isArray(col.dataIndex) ? col.dataIndex.join(".") : col.dataIndex),
2392
+ sorter: col.sortable ? true : void 0,
2393
+ render: col.render ? col.render : (value) => renderValue(value, col.valueType, col.statusConfig)
2394
+ }));
2395
+ if (rowActions) {
2396
+ cols.push({
2397
+ title: texts.actions,
2398
+ key: "_actions",
2399
+ width: 150,
2400
+ render: (_, record) => {
2401
+ const actions = rowActions(record).filter(
2402
+ (a) => !a.hidden?.(record)
2403
+ );
2404
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Space, { size: 0, children: actions.map((action, idx) => {
2405
+ const isLast = idx === actions.length - 1;
2406
+ let actionElement;
2407
+ if (action.href) {
2408
+ actionElement = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SmartLink, { href: action.href, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Link, { style: action.danger ? { color: token.colorError } : void 0, children: action.label }) });
2409
+ } else {
2410
+ const linkElement = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2411
+ Link,
2412
+ {
2413
+ style: action.danger ? { color: token.colorError } : void 0,
2414
+ onClick: action.confirm ? void 0 : () => action.onClick?.(record),
2415
+ children: action.label
2416
+ }
2417
+ );
2418
+ if (action.confirm) {
2419
+ actionElement = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2420
+ import_antd4.Popconfirm,
2421
+ {
2422
+ title: typeof action.confirm === "string" ? action.confirm : `${action.label}\u3057\u307E\u3059\u304B\uFF1F`,
2423
+ onConfirm: () => action.onClick?.(record),
2424
+ okText: texts.yes,
2425
+ cancelText: texts.cancel,
2426
+ okButtonProps: action.danger ? { danger: true } : void 0,
2427
+ children: linkElement
2428
+ }
2429
+ );
2430
+ } else {
2431
+ actionElement = linkElement;
2432
+ }
2433
+ }
2434
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
2435
+ actionElement,
2436
+ !isLast && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Divider, { type: "vertical" })
2437
+ ] }, idx);
2438
+ }) });
2439
+ }
2440
+ });
2441
+ }
2442
+ return cols;
2443
+ }, [columns, rowActions, texts]);
2444
+ const paginationConfig = (0, import_react13.useMemo)(() => {
2445
+ if (pagination === false) return false;
2446
+ return {
2447
+ current: meta?.current_page || queryParams.page,
2448
+ pageSize: meta?.per_page || queryParams.per_page,
2449
+ total: meta?.total || 0,
2450
+ showSizeChanger: true,
2451
+ showTotal: texts.totalItems,
2452
+ ...typeof pagination === "object" ? pagination : {}
2453
+ };
2454
+ }, [pagination, meta, queryParams, texts]);
2455
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className, style, children: [
2456
+ searchFields.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Card, { style: { marginBottom: 24, ...cardStyle }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
2457
+ import_antd4.Form,
2458
+ {
2459
+ form: searchForm,
2460
+ layout: "horizontal",
2461
+ onFinish: handleSearch,
2462
+ labelCol: { flex: "100px" },
2463
+ wrapperCol: { flex: 1 },
2464
+ initialValues: defaultSearchValues,
2465
+ children: [
2466
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_antd4.Row, { gutter: 24, children: [
2467
+ visibleFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Col, { span: 8, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Form.Item, { name: field.name, label: field.label, children: renderSearchField(field, texts) }) }, field.name)),
2468
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Col, { span: visibleFields.length === 1 ? 16 : 8, style: { textAlign: "right" }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_antd4.Space, { children: [
2469
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Button, { onClick: handleReset, children: texts.reset }),
2470
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Button, { type: "primary", htmlType: "submit", children: texts.search }),
2471
+ hasHiddenFields && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
2472
+ import_antd4.Button,
2473
+ {
2474
+ type: "link",
2475
+ onClick: () => setExpanded(!expanded),
2476
+ children: [
2477
+ expanded ? texts.collapse : texts.expand,
2478
+ expanded ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons4.UpOutlined, {}) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons4.DownOutlined, {})
2479
+ ]
2480
+ }
2481
+ )
2482
+ ] }) })
2483
+ ] }),
2484
+ expanded && hiddenFields.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Row, { gutter: 24, style: { marginTop: 16 }, children: hiddenFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Col, { span: 8, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Form.Item, { name: field.name, label: field.label, children: renderSearchField(field, texts) }) }, field.name)) })
2485
+ ]
2486
+ }
2487
+ ) }),
2488
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2489
+ import_antd4.Card,
2490
+ {
2491
+ title: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_antd4.Space, { children: [
2492
+ icon,
2493
+ title,
2494
+ subTitle && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: {
2495
+ fontWeight: "normal",
2496
+ fontSize: 14,
2497
+ color: token.colorTextSecondary
2498
+ }, children: subTitle })
2499
+ ] }),
2500
+ extra: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_antd4.Space, { size: "small", children: [
2501
+ toolbarExtra,
2502
+ addButtonLink && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SmartLink, { href: addButtonLink, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Button, { type: "primary", icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons4.PlusOutlined, {}), children: addLabel || texts.add }) }),
2503
+ onAdd && !addButtonLink && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Button, { type: "primary", icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons4.PlusOutlined, {}), onClick: onAdd, children: addLabel || texts.add }),
2504
+ showRefresh && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Tooltip, { title: texts.refresh, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2505
+ import_antd4.Button,
2506
+ {
2507
+ icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons4.ReloadOutlined, {}),
2508
+ onClick: () => queryResult.refetch?.(),
2509
+ loading: queryResult.isFetching
2510
+ }
2511
+ ) }),
2512
+ showColumnSettings && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Tooltip, { title: texts.columnSettings, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_antd4.Button, { icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_icons4.SettingOutlined, {}) }) })
2513
+ ] }),
2514
+ style: cardStyle,
2515
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2516
+ import_antd4.Table,
2517
+ {
2518
+ ...tableProps,
2519
+ columns: tableColumns,
2520
+ dataSource,
2521
+ rowKey,
2522
+ loading,
2523
+ pagination: paginationConfig,
2524
+ onChange: handleTableChange
2525
+ }
2526
+ )
2527
+ }
2528
+ )
2529
+ ] });
2530
+ }
2353
2531
 
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");
2532
+ // src/ant/components/PageContainer/PageContainer.tsx
2533
+ var import_antd5 = require("antd");
2534
+ var import_jsx_runtime9 = require("react/jsx-runtime");
2535
+ function PageContainer({
2536
+ title,
2537
+ subTitle,
2538
+ icon,
2539
+ extra,
2540
+ breadcrumb,
2541
+ children,
2542
+ showHeader = true,
2543
+ className,
2544
+ style
2545
+ }) {
2546
+ const { token } = import_antd5.theme.useToken();
2547
+ const breadcrumbProps = breadcrumb ? Array.isArray(breadcrumb) ? { items: breadcrumb } : breadcrumb : void 0;
2548
+ const hasHeader = showHeader && (title || subTitle || breadcrumb);
2549
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className, style, children: [
2550
+ hasHeader && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2551
+ "div",
2552
+ {
2553
+ style: {
2554
+ marginBottom: 24
2555
+ },
2556
+ children: [
2557
+ breadcrumbProps && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2558
+ import_antd5.Breadcrumb,
2559
+ {
2560
+ ...breadcrumbProps,
2561
+ style: {
2562
+ marginBottom: 12,
2563
+ ...breadcrumbProps.style
2564
+ }
2565
+ }
2566
+ ),
2567
+ (title || extra) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2568
+ "div",
2569
+ {
2570
+ style: {
2571
+ display: "flex",
2572
+ justifyContent: "space-between",
2573
+ alignItems: "flex-start"
2574
+ },
2575
+ children: [
2576
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2577
+ title && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2578
+ "h1",
2579
+ {
2580
+ style: {
2581
+ margin: 0,
2582
+ fontSize: 20,
2583
+ fontWeight: 600,
2584
+ lineHeight: 1.4,
2585
+ color: token.colorText,
2586
+ display: "flex",
2587
+ alignItems: "center",
2588
+ gap: 8
2589
+ },
2590
+ children: [
2591
+ icon && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { style: { fontSize: 20 }, children: icon }),
2592
+ title
2593
+ ]
2594
+ }
2595
+ ),
2596
+ subTitle && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2597
+ "div",
2598
+ {
2599
+ style: {
2600
+ marginTop: 4,
2601
+ fontSize: 14,
2602
+ color: token.colorTextSecondary
2603
+ },
2604
+ children: subTitle
2605
+ }
2606
+ )
2607
+ ] }),
2608
+ extra && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { flexShrink: 0 }, children: extra })
2609
+ ]
2610
+ }
2611
+ )
2612
+ ]
2613
+ }
2614
+ ),
2615
+ children
2616
+ ] });
2617
+ }
2618
+
2619
+ // src/ant/components/LocaleSwitcher/LocaleSwitcher.tsx
2620
+ var import_icons5 = require("@ant-design/icons");
2621
+ var import_antd6 = require("antd");
2622
+ var import_react_i18next2 = require("react-i18next");
2623
+
2624
+ // src/core/i18n/index.tsx
2625
+ var import_react14 = require("react");
2626
+ var import_react_i18next = require("react-i18next");
2627
+ var import_i18next = __toESM(require("i18next"), 1);
2628
+ var import_jsx_runtime10 = require("react/jsx-runtime");
2629
+ var locales = ["ja", "en", "vi"];
2630
+ var localeNames = {
2631
+ ja: "\u65E5\u672C\u8A9E",
2632
+ en: "English",
2633
+ vi: "Ti\u1EBFng Vi\u1EC7t"
2634
+ };
2635
+ var defaultLocale2 = "ja";
2636
+ var I18nContext = (0, import_react14.createContext)(null);
2637
+ var i18nInitialized = false;
2638
+ function initializeI18n(initialLocale, fallbackLocale2, translations) {
2639
+ if (i18nInitialized) {
2640
+ return import_i18next.default;
2641
+ }
2642
+ const resources = {};
2643
+ for (const locale of locales) {
2644
+ resources[locale] = {
2645
+ translation: {
2646
+ ...defaultTranslations[locale],
2647
+ ...translations?.[locale] || {}
2648
+ }
2649
+ };
2650
+ }
2651
+ import_i18next.default.use(import_react_i18next.initReactI18next).init({
2652
+ resources,
2653
+ lng: initialLocale,
2654
+ fallbackLng: fallbackLocale2,
2655
+ interpolation: {
2656
+ escapeValue: false
2657
+ },
2658
+ react: {
2659
+ useSuspense: false
2660
+ }
2661
+ });
2662
+ i18nInitialized = true;
2663
+ return import_i18next.default;
2664
+ }
2665
+ function I18nProvider({
2666
+ children,
2667
+ defaultLocale: initialLocale = "ja",
2668
+ fallbackLocale: fallbackLocale2 = "ja",
2669
+ translations
2670
+ }) {
2671
+ const i18nInstance = (0, import_react14.useMemo)(
2672
+ () => initializeI18n(initialLocale, fallbackLocale2, translations),
2673
+ [initialLocale, fallbackLocale2, translations]
2674
+ );
2675
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_i18next.I18nextProvider, { i18n: i18nInstance, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(I18nProviderInner, { initialLocale, children }) });
2676
+ }
2677
+ function I18nProviderInner({
2678
+ children,
2679
+ initialLocale
2680
+ }) {
2681
+ const [locale, setLocaleState] = (0, import_react14.useState)(initialLocale);
2682
+ const { t: translate, i18n: i18nInstance } = (0, import_react_i18next.useTranslation)();
2683
+ const setLocale = (0, import_react14.useCallback)((newLocale) => {
2684
+ setLocaleState(newLocale);
2685
+ i18nInstance?.changeLanguage(newLocale);
2686
+ if (typeof document !== "undefined") {
2687
+ document.cookie = `locale=${newLocale};path=/;max-age=31536000`;
2688
+ }
2689
+ }, [i18nInstance]);
2690
+ const t = (0, import_react14.useCallback)((key, options) => {
2691
+ return String(translate(key, options));
2692
+ }, [translate]);
2693
+ (0, import_react14.useEffect)(() => {
2694
+ if (typeof document !== "undefined") {
2695
+ const cookieLocale = document.cookie.split("; ").find((row) => row.startsWith("locale="))?.split("=")[1];
2696
+ if (cookieLocale && locales.includes(cookieLocale)) {
2697
+ setLocale(cookieLocale);
2698
+ }
2699
+ }
2700
+ }, [setLocale]);
2701
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(I18nContext.Provider, { value: { locale, setLocale, t }, children });
2702
+ }
2420
2703
  function useLocale() {
2421
- const { i18n: i18n3 } = (0, import_react_i18next4.useTranslation)();
2422
- return i18n3.language || defaultLocale2;
2704
+ const context = (0, import_react14.useContext)(I18nContext);
2705
+ const { i18n: i18nInstance } = (0, import_react_i18next.useTranslation)();
2706
+ if (context) {
2707
+ return context.locale;
2708
+ }
2709
+ return i18nInstance?.language || defaultLocale2;
2710
+ }
2711
+ function useTranslations() {
2712
+ const { t } = (0, import_react_i18next.useTranslation)();
2713
+ return t;
2714
+ }
2715
+ function useSsoTranslation() {
2716
+ return (0, import_react_i18next.useTranslation)("sso");
2717
+ }
2718
+ function getCurrentLocale() {
2719
+ if (typeof document !== "undefined") {
2720
+ const cookieLocale = document.cookie.split("; ").find((row) => row.startsWith("locale="))?.split("=")[1];
2721
+ if (cookieLocale && locales.includes(cookieLocale)) {
2722
+ return cookieLocale;
2723
+ }
2724
+ }
2725
+ return defaultLocale2;
2726
+ }
2727
+ function changeLanguage(locale) {
2728
+ import_i18next.default.changeLanguage(locale);
2729
+ if (typeof document !== "undefined") {
2730
+ document.cookie = `locale=${locale};path=/;max-age=31536000`;
2731
+ }
2423
2732
  }
2733
+ var ssoNamespace = "sso";
2734
+ var defaultTranslations = {
2735
+ ja: {
2736
+ login: "\u30ED\u30B0\u30A4\u30F3",
2737
+ logout: "\u30ED\u30B0\u30A2\u30A6\u30C8",
2738
+ loading: "\u8AAD\u307F\u8FBC\u307F\u4E2D...",
2739
+ error: "\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F",
2740
+ retry: "\u518D\u8A66\u884C",
2741
+ cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
2742
+ save: "\u4FDD\u5B58",
2743
+ delete: "\u524A\u9664",
2744
+ edit: "\u7DE8\u96C6",
2745
+ create: "\u65B0\u898F\u4F5C\u6210",
2746
+ search: "\u691C\u7D22",
2747
+ reset: "\u30EA\u30BB\u30C3\u30C8",
2748
+ noData: "\u30C7\u30FC\u30BF\u304C\u3042\u308A\u307E\u305B\u3093",
2749
+ confirmDelete: "\u524A\u9664\u3057\u3066\u3082\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F"
2750
+ },
2751
+ en: {
2752
+ login: "Login",
2753
+ logout: "Logout",
2754
+ loading: "Loading...",
2755
+ error: "An error occurred",
2756
+ retry: "Retry",
2757
+ cancel: "Cancel",
2758
+ save: "Save",
2759
+ delete: "Delete",
2760
+ edit: "Edit",
2761
+ create: "Create",
2762
+ search: "Search",
2763
+ reset: "Reset",
2764
+ noData: "No data",
2765
+ confirmDelete: "Are you sure you want to delete?"
2766
+ },
2767
+ vi: {
2768
+ login: "\u0110\u0103ng nh\u1EADp",
2769
+ logout: "\u0110\u0103ng xu\u1EA5t",
2770
+ loading: "\u0110ang t\u1EA3i...",
2771
+ error: "\u0110\xE3 x\u1EA3y ra l\u1ED7i",
2772
+ retry: "Th\u1EED l\u1EA1i",
2773
+ cancel: "H\u1EE7y",
2774
+ save: "L\u01B0u",
2775
+ delete: "X\xF3a",
2776
+ edit: "S\u1EEDa",
2777
+ create: "T\u1EA1o m\u1EDBi",
2778
+ search: "T\xECm ki\u1EBFm",
2779
+ reset: "\u0110\u1EB7t l\u1EA1i",
2780
+ noData: "Kh\xF4ng c\xF3 d\u1EEF li\u1EC7u",
2781
+ confirmDelete: "B\u1EA1n c\xF3 ch\u1EAFc ch\u1EAFn mu\u1ED1n x\xF3a?"
2782
+ }
2783
+ };
2424
2784
 
2425
- // src/components/admin/UserTable.tsx
2426
- var import_jsx_runtime9 = require("react/jsx-runtime");
2427
- function UserTable({
2428
- users,
2785
+ // src/ant/components/LocaleSwitcher/LocaleSwitcher.tsx
2786
+ var import_jsx_runtime11 = require("react/jsx-runtime");
2787
+ function LocaleSwitcher() {
2788
+ const { i18n: i18n2 } = (0, import_react_i18next2.useTranslation)();
2789
+ const locale = i18n2.language || "ja";
2790
+ const handleChange = (newLocale) => {
2791
+ i18n2.changeLanguage(newLocale);
2792
+ document.cookie = `locale=${newLocale};path=/;max-age=31536000`;
2793
+ };
2794
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2795
+ import_antd6.Select,
2796
+ {
2797
+ value: locale,
2798
+ onChange: handleChange,
2799
+ style: { width: 100 },
2800
+ size: "small",
2801
+ suffixIcon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons5.GlobalOutlined, {}),
2802
+ options: locales.map((l) => ({
2803
+ value: l,
2804
+ label: localeNames[l]
2805
+ }))
2806
+ }
2807
+ );
2808
+ }
2809
+
2810
+ // src/ant/components/UserRoleAssignModal/UserRoleAssignModal.tsx
2811
+ var import_icons7 = require("@ant-design/icons");
2812
+ var import_antd8 = require("antd");
2813
+ var import_react15 = require("react");
2814
+
2815
+ // src/ant/components/ScopeUtils/ScopeUtils.tsx
2816
+ var import_icons6 = require("@ant-design/icons");
2817
+ var import_antd7 = require("antd");
2818
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2819
+ function getScopeIcon(scope) {
2820
+ switch (scope) {
2821
+ case "global":
2822
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons6.GlobalOutlined, {});
2823
+ case "org-wide":
2824
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons6.BankOutlined, {});
2825
+ case "branch":
2826
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons6.BranchesOutlined, {});
2827
+ default:
2828
+ return null;
2829
+ }
2830
+ }
2831
+ function getScopeColor(scope) {
2832
+ switch (scope) {
2833
+ case "global":
2834
+ return "purple";
2835
+ case "org-wide":
2836
+ return "blue";
2837
+ case "branch":
2838
+ return "green";
2839
+ default:
2840
+ return "default";
2841
+ }
2842
+ }
2843
+ function ScopeTag({ scope, label, showIcon = true }) {
2844
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_antd7.Tag, { color: getScopeColor(scope), icon: showIcon ? getScopeIcon(scope) : void 0, children: label || scope });
2845
+ }
2846
+ function ScopeLabel({ scope, label }) {
2847
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_antd7.Space, { children: [
2848
+ getScopeIcon(scope),
2849
+ label
2850
+ ] });
2851
+ }
2852
+
2853
+ // src/ant/components/UserRoleAssignModal/UserRoleAssignModal.tsx
2854
+ var import_jsx_runtime13 = require("react/jsx-runtime");
2855
+ var { Text: Text4 } = import_antd8.Typography;
2856
+ var defaultTranslations2 = {
2857
+ title: "\u30ED\u30FC\u30EB\u5272\u308A\u5F53\u3066",
2858
+ selectRole: "\u30ED\u30FC\u30EB\u3092\u9078\u629E",
2859
+ scope: "\u30B9\u30B3\u30FC\u30D7",
2860
+ global: "\u30B0\u30ED\u30FC\u30D0\u30EB",
2861
+ orgWide: "\u7D44\u7E54\u5168\u4F53",
2862
+ branchSpecific: "\u62E0\u70B9\u9650\u5B9A",
2863
+ organization: "\u7D44\u7E54",
2864
+ selectBranches: "\u62E0\u70B9\u3092\u9078\u629E",
2865
+ assign: "\u5272\u308A\u5F53\u3066",
2866
+ cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
2867
+ assignRole: "\u30ED\u30FC\u30EB\u5272\u308A\u5F53\u3066",
2868
+ required: "\u5FC5\u9808\u9805\u76EE\u3067\u3059"
2869
+ };
2870
+ function UserRoleAssignModal({
2871
+ open,
2872
+ userName,
2873
+ roles,
2874
+ organizations,
2875
+ branches,
2876
+ currentOrgId,
2429
2877
  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
2878
+ onAssign,
2879
+ onCancel,
2880
+ translations: t = {}
2441
2881
  }) {
2442
- const { t } = useSsoTranslation();
2443
- const columns = [
2882
+ const [form] = import_antd8.Form.useForm();
2883
+ const [isSubmitting, setIsSubmitting] = (0, import_react15.useState)(false);
2884
+ const labels = { ...defaultTranslations2, ...t };
2885
+ const handleFinish = async (values) => {
2886
+ setIsSubmitting(true);
2887
+ try {
2888
+ await onAssign(values);
2889
+ form.resetFields();
2890
+ } finally {
2891
+ setIsSubmitting(false);
2892
+ }
2893
+ };
2894
+ const handleCancel = () => {
2895
+ form.resetFields();
2896
+ onCancel();
2897
+ };
2898
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2899
+ import_antd8.Modal,
2444
2900
  {
2445
- title: t("email"),
2446
- dataIndex: "email",
2447
- key: "email",
2448
- sorter: true,
2449
- sortOrder: sortField === "email" ? sortOrder === "asc" ? "ascend" : "descend" : void 0
2450
- },
2901
+ title: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_antd8.Space, { children: [
2902
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons7.SafetyOutlined, {}),
2903
+ labels.title,
2904
+ " ",
2905
+ userName ? `- ${userName}` : ""
2906
+ ] }),
2907
+ open,
2908
+ onCancel: handleCancel,
2909
+ footer: null,
2910
+ destroyOnHidden: true,
2911
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2912
+ import_antd8.Form,
2913
+ {
2914
+ form,
2915
+ layout: "vertical",
2916
+ onFinish: handleFinish,
2917
+ initialValues: { scope: "org-wide", org_id: currentOrgId },
2918
+ children: [
2919
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2920
+ import_antd8.Form.Item,
2921
+ {
2922
+ name: "role_id",
2923
+ label: labels.selectRole,
2924
+ rules: [{ required: true, message: labels.required }],
2925
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Select, { placeholder: labels.selectRole, children: roles.map((role) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Select.Option, { value: role.id, children: role.name }, role.id)) })
2926
+ }
2927
+ ),
2928
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Form.Item, { name: "scope", label: labels.scope, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_antd8.Radio.Group, { children: [
2929
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Radio, { value: "global", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ScopeLabel, { scope: "global", label: labels.global }) }),
2930
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Radio, { value: "org-wide", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ScopeLabel, { scope: "org-wide", label: labels.orgWide }) }),
2931
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Radio, { value: "branch", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ScopeLabel, { scope: "branch", label: labels.branchSpecific }) })
2932
+ ] }) }),
2933
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Form.Item, { noStyle: true, shouldUpdate: (prev, curr) => prev.scope !== curr.scope, children: ({ getFieldValue }) => (getFieldValue("scope") === "org-wide" || getFieldValue("scope") === "branch") && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2934
+ import_antd8.Form.Item,
2935
+ {
2936
+ name: "org_id",
2937
+ label: labels.organization,
2938
+ rules: [{ required: true, message: labels.required }],
2939
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Select, { placeholder: labels.organization, children: organizations.map((org) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Select.Option, { value: String(org.id), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_antd8.Space, { children: [
2940
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons7.BankOutlined, {}),
2941
+ org.name
2942
+ ] }) }, org.id)) })
2943
+ }
2944
+ ) }),
2945
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Form.Item, { noStyle: true, shouldUpdate: (prev, curr) => prev.scope !== curr.scope, children: ({ getFieldValue }) => getFieldValue("scope") === "branch" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2946
+ import_antd8.Form.Item,
2947
+ {
2948
+ name: "branch_ids",
2949
+ label: labels.selectBranches,
2950
+ rules: [{ required: true, message: labels.required }],
2951
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Select, { mode: "multiple", placeholder: labels.selectBranches, children: branches?.map((branch) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Select.Option, { value: String(branch.id), children: branch.name }, branch.id)) })
2952
+ }
2953
+ ) }),
2954
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Form.Item, { noStyle: true, shouldUpdate: true, children: ({ getFieldValue }) => {
2955
+ const scope = getFieldValue("scope");
2956
+ const selectedOrgId = getFieldValue("org_id");
2957
+ const selectedBranchIds = getFieldValue("branch_ids") || [];
2958
+ const selectedRole = roles.find((r) => r.id === getFieldValue("role_id"));
2959
+ const selectedOrg = organizations.find((o) => String(o.id) === selectedOrgId);
2960
+ const selectedBranches = branches?.filter((b) => selectedBranchIds.includes(String(b.id))) || [];
2961
+ if (!selectedRole) return null;
2962
+ let scopeText = "";
2963
+ if (scope === "global") {
2964
+ scopeText = labels.global;
2965
+ } else if (scope === "org-wide" && selectedOrg) {
2966
+ scopeText = `${selectedOrg.name} (${labels.orgWide})`;
2967
+ } else if (scope === "branch" && selectedBranches.length > 0) {
2968
+ scopeText = selectedBranches.map((b) => b.name).join(", ");
2969
+ }
2970
+ return scopeText ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2971
+ "div",
2972
+ {
2973
+ style: {
2974
+ padding: "8px 12px",
2975
+ background: "#f5f5f5",
2976
+ borderRadius: 4,
2977
+ marginBottom: 16
2978
+ },
2979
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Text4, { type: "secondary", children: [
2980
+ labels.assignRole,
2981
+ ": ",
2982
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Text4, { strong: true, children: selectedRole.name }),
2983
+ " \u2192 ",
2984
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Tag, { color: getScopeColor(scope), children: scopeText })
2985
+ ] })
2986
+ }
2987
+ ) : null;
2988
+ } }),
2989
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Form.Item, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_antd8.Space, { children: [
2990
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Button, { type: "primary", htmlType: "submit", loading: loading || isSubmitting, children: labels.assign }),
2991
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_antd8.Button, { onClick: handleCancel, children: labels.cancel })
2992
+ ] }) })
2993
+ ]
2994
+ }
2995
+ )
2996
+ }
2997
+ );
2998
+ }
2999
+
3000
+ // src/ant/components/UserPermissionsModal/UserPermissionsModal.tsx
3001
+ var import_icons8 = require("@ant-design/icons");
3002
+ var import_antd9 = require("antd");
3003
+ var import_jsx_runtime14 = require("react/jsx-runtime");
3004
+ var { Text: Text5 } = import_antd9.Typography;
3005
+ var defaultTranslations3 = {
3006
+ permissionBreakdown: "\u6A29\u9650\u30D6\u30EC\u30FC\u30AF\u30C0\u30A6\u30F3",
3007
+ userInfo: "\u30E6\u30FC\u30B6\u30FC\u60C5\u5831",
3008
+ email: "\u30E1\u30FC\u30EB",
3009
+ primaryOrganization: "\u6240\u5C5E\u7D44\u7E54",
3010
+ global: "\u30B0\u30ED\u30FC\u30D0\u30EB",
3011
+ currentContext: "\u73FE\u5728\u306E\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8",
3012
+ roleAssignments: "\u30ED\u30FC\u30EB\u5272\u308A\u5F53\u3066",
3013
+ noRolesAssigned: "\u30ED\u30FC\u30EB\u304C\u5272\u308A\u5F53\u3066\u3089\u308C\u3066\u3044\u307E\u305B\u3093",
3014
+ add: "\u8FFD\u52A0",
3015
+ permissions: "\u6A29\u9650",
3016
+ teamMemberships: "\u30C1\u30FC\u30E0\u30E1\u30F3\u30D0\u30FC\u30B7\u30C3\u30D7",
3017
+ noTeamMemberships: "\u30C1\u30FC\u30E0\u306B\u6240\u5C5E\u3057\u3066\u3044\u307E\u305B\u3093",
3018
+ teamLeader: "\u30EA\u30FC\u30C0\u30FC",
3019
+ teamsFromConsole: "\u30C1\u30FC\u30E0\u306F\u30B3\u30F3\u30BD\u30FC\u30EB\u304B\u3089\u7BA1\u7406\u3057\u307E\u3059",
3020
+ aggregatedPermissions: "\u96C6\u7D04\u3055\u308C\u305F\u6A29\u9650",
3021
+ noData: "\u30C7\u30FC\u30BF\u304C\u3042\u308A\u307E\u305B\u3093",
3022
+ ungrouped: "\u672A\u5206\u985E",
3023
+ orgWide: "\u7D44\u7E54\u5168\u4F53",
3024
+ confirmRemoveRole: "\u3053\u306E\u30ED\u30FC\u30EB\u3092\u524A\u9664\u3057\u3066\u3082\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F"
3025
+ };
3026
+ function UserPermissionsModal({
3027
+ open,
3028
+ userName,
3029
+ permissions,
3030
+ loading = false,
3031
+ currentOrg,
3032
+ currentBranch,
3033
+ branches,
3034
+ onClose,
3035
+ onAddRole,
3036
+ onAddTeam,
3037
+ onRemoveRole,
3038
+ translations: t = {}
3039
+ }) {
3040
+ const labels = { ...defaultTranslations3, ...t };
3041
+ const getBranchName = (branchId) => {
3042
+ if (!branchId || !branches) return "";
3043
+ const branch = branches.find((b) => String(b.id) === branchId);
3044
+ return branch?.name || branchId;
3045
+ };
3046
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3047
+ import_antd9.Modal,
2451
3048
  {
2452
- title: t("name"),
2453
- dataIndex: "name",
2454
- key: "name",
2455
- sorter: true,
2456
- sortOrder: sortField === "name" ? sortOrder === "asc" ? "ascend" : "descend" : void 0
3049
+ title: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_antd9.Space, { children: [
3050
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons8.UserOutlined, {}),
3051
+ userName,
3052
+ " - ",
3053
+ labels.permissionBreakdown
3054
+ ] }),
3055
+ open,
3056
+ onCancel: onClose,
3057
+ footer: null,
3058
+ width: 800,
3059
+ destroyOnHidden: true,
3060
+ children: loading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { textAlign: "center", padding: 40 }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Spin, { size: "large" }) }) : permissions ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 16 }, children: [
3061
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Card, { size: "small", title: labels.userInfo, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
3062
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { children: [
3063
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Text5, { type: "secondary", children: [
3064
+ labels.email,
3065
+ ": "
3066
+ ] }),
3067
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text5, { children: permissions.user?.email })
3068
+ ] }),
3069
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { children: [
3070
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Text5, { type: "secondary", children: [
3071
+ labels.primaryOrganization,
3072
+ ": "
3073
+ ] }),
3074
+ permissions.user?.organization ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Tag, { icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons8.BankOutlined, {}), color: "blue", children: permissions.user.organization.name }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Tag, { icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons8.GlobalOutlined, {}), color: "purple", children: labels.global })
3075
+ ] })
3076
+ ] }) }),
3077
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Card, { size: "small", title: labels.currentContext, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_antd9.Space, { wrap: true, children: [
3078
+ currentOrg && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Tag, { icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons8.BankOutlined, {}), color: "blue", children: currentOrg.name }),
3079
+ currentBranch && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Tag, { icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons8.BranchesOutlined, {}), color: "green", children: currentBranch.name })
3080
+ ] }) }),
3081
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3082
+ import_antd9.Card,
3083
+ {
3084
+ size: "small",
3085
+ title: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_antd9.Space, { children: [
3086
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons8.SafetyOutlined, {}),
3087
+ labels.roleAssignments,
3088
+ " (",
3089
+ permissions.role_assignments.length,
3090
+ ")"
3091
+ ] }),
3092
+ extra: onAddRole && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Button, { type: "primary", size: "small", icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons8.PlusOutlined, {}), onClick: onAddRole, children: labels.add }),
3093
+ children: permissions.role_assignments.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Empty, { description: labels.noRolesAssigned }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Collapse, { ghost: true, children: permissions.role_assignments.map((assignment, index) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3094
+ import_antd9.Collapse.Panel,
3095
+ {
3096
+ header: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_antd9.Space, { wrap: true, children: [
3097
+ getScopeIcon(assignment.scope),
3098
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text5, { strong: true, children: assignment.role.name }),
3099
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Tag, { color: getScopeColor(assignment.scope), children: assignment.scope === "global" ? labels.global : assignment.scope === "org-wide" ? assignment.org_name || labels.orgWide : assignment.branch_name || getBranchName(assignment.console_branch_id) }),
3100
+ assignment.scope === "branch" && assignment.org_name && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Tag, { color: "blue", icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons8.BankOutlined, {}), children: assignment.org_name }),
3101
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_antd9.Tag, { children: [
3102
+ assignment.permissions.length,
3103
+ " ",
3104
+ labels.permissions
3105
+ ] }),
3106
+ onRemoveRole && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3107
+ import_antd9.Popconfirm,
3108
+ {
3109
+ title: labels.confirmRemoveRole,
3110
+ onConfirm: () => {
3111
+ onRemoveRole(
3112
+ assignment.role.id,
3113
+ assignment.console_org_id,
3114
+ assignment.console_branch_id
3115
+ );
3116
+ },
3117
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3118
+ import_antd9.Button,
3119
+ {
3120
+ size: "small",
3121
+ danger: true,
3122
+ icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons8.DeleteOutlined, {}),
3123
+ onClick: (e) => e.stopPropagation()
3124
+ }
3125
+ )
3126
+ }
3127
+ )
3128
+ ] }),
3129
+ children: Object.entries(
3130
+ assignment.permissions.reduce(
3131
+ (groups, perm) => {
3132
+ const group = perm.group || labels.ungrouped;
3133
+ if (!groups[group]) groups[group] = [];
3134
+ groups[group].push({ slug: perm.slug, name: perm.name });
3135
+ return groups;
3136
+ },
3137
+ {}
3138
+ )
3139
+ ).map(([group, perms]) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: { marginBottom: 8 }, children: [
3140
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text5, { type: "secondary", style: { fontSize: 12 }, children: group }),
3141
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: 4, marginTop: 4 }, children: perms.map((perm) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Tag, { color: "blue", children: perm.name }, perm.slug)) })
3142
+ ] }, group))
3143
+ },
3144
+ index
3145
+ )) })
3146
+ }
3147
+ ),
3148
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3149
+ import_antd9.Card,
3150
+ {
3151
+ size: "small",
3152
+ title: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_antd9.Space, { children: [
3153
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons8.TeamOutlined, {}),
3154
+ labels.teamMemberships,
3155
+ " (",
3156
+ permissions.team_memberships.length,
3157
+ ")"
3158
+ ] }),
3159
+ extra: onAddTeam && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Button, { size: "small", icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons8.PlusOutlined, {}), onClick: onAddTeam, children: labels.add }),
3160
+ children: permissions.team_memberships.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Empty, { description: labels.noTeamMemberships }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Collapse, { ghost: true, children: permissions.team_memberships.map((membership, index) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3161
+ import_antd9.Collapse.Panel,
3162
+ {
3163
+ header: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_antd9.Space, { children: [
3164
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons8.TeamOutlined, {}),
3165
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text5, { strong: true, children: membership.team.name }),
3166
+ membership.is_leader && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Tag, { color: "gold", children: labels.teamLeader }),
3167
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_antd9.Tag, { children: [
3168
+ membership.permissions.length,
3169
+ " ",
3170
+ labels.permissions
3171
+ ] })
3172
+ ] }),
3173
+ children: Object.entries(
3174
+ membership.permissions.reduce(
3175
+ (groups, perm) => {
3176
+ const group = perm.group || labels.ungrouped;
3177
+ if (!groups[group]) groups[group] = [];
3178
+ groups[group].push({ slug: perm.slug, name: perm.name });
3179
+ return groups;
3180
+ },
3181
+ {}
3182
+ )
3183
+ ).map(([group, perms]) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { style: { marginBottom: 8 }, children: [
3184
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text5, { type: "secondary", style: { fontSize: 12 }, children: group }),
3185
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: 4, marginTop: 4 }, children: perms.map((perm) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Tag, { color: "cyan", children: perm.name }, perm.slug)) })
3186
+ ] }, group))
3187
+ },
3188
+ index
3189
+ )) })
3190
+ }
3191
+ ),
3192
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3193
+ import_antd9.Card,
3194
+ {
3195
+ size: "small",
3196
+ title: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_antd9.Space, { children: [
3197
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons8.SafetyOutlined, {}),
3198
+ labels.aggregatedPermissions,
3199
+ " (",
3200
+ permissions.aggregated_permissions.length,
3201
+ ")"
3202
+ ] }),
3203
+ children: permissions.aggregated_permissions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Empty, { description: labels.noData }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Collapse, { ghost: true, children: Object.entries(
3204
+ permissions.aggregated_permissions.reduce(
3205
+ (groups, perm) => {
3206
+ const parts = perm.split(".");
3207
+ const group = parts.length > 1 ? parts.slice(0, -1).join(".") : labels.ungrouped;
3208
+ if (!groups[group]) groups[group] = [];
3209
+ groups[group].push(perm);
3210
+ return groups;
3211
+ },
3212
+ {}
3213
+ )
3214
+ ).map(([group, perms]) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3215
+ import_antd9.Collapse.Panel,
3216
+ {
3217
+ header: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_antd9.Space, { children: [
3218
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons8.SafetyOutlined, {}),
3219
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text5, { strong: true, children: group }),
3220
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Tag, { color: "green", children: perms.length })
3221
+ ] }),
3222
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: 4 }, children: perms.map((perm) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_antd9.Tag, { color: "green", children: perm.split(".").pop() }, perm)) })
3223
+ },
3224
+ group
3225
+ )) })
3226
+ }
3227
+ )
3228
+ ] }) : null
3229
+ }
3230
+ );
3231
+ }
3232
+
3233
+ // src/ant/components/UserDetailCard/UserDetailCard.tsx
3234
+ var import_icons9 = require("@ant-design/icons");
3235
+ var import_antd10 = require("antd");
3236
+ var import_react16 = require("react");
3237
+ var import_jsx_runtime15 = require("react/jsx-runtime");
3238
+ var { Title: Title3, Text: Text6, Link: AntLink } = import_antd10.Typography;
3239
+ var defaultTranslations4 = {
3240
+ email: "\u30E1\u30FC\u30EB",
3241
+ primaryOrganization: "\u6240\u5C5E\u7D44\u7E54",
3242
+ currentContext: "\u73FE\u5728\u306E\u30B3\u30F3\u30C6\u30AD\u30B9\u30C8",
3243
+ global: "\u30B0\u30ED\u30FC\u30D0\u30EB",
3244
+ created: "\u4F5C\u6210\u65E5",
3245
+ lastSignIn: "\u6700\u7D42\u30B5\u30A4\u30F3\u30A4\u30F3",
3246
+ roleAssignments: "\u30ED\u30FC\u30EB\u5272\u308A\u5F53\u3066",
3247
+ roles: "\u30ED\u30FC\u30EB",
3248
+ permissions: "\u6A29\u9650",
3249
+ teams: "\u30C1\u30FC\u30E0",
3250
+ aggregatedPermissions: "\u96C6\u7D04\u3055\u308C\u305F\u6A29\u9650",
3251
+ permissionPolicies: "\u6A29\u9650\u30DD\u30EA\u30B7\u30FC",
3252
+ permissionsDescription: "\u6A29\u9650\u306E\u8AAC\u660E",
3253
+ searchPermissions: "\u6A29\u9650\u3092\u691C\u7D22",
3254
+ allTypes: "\u3059\u3079\u3066\u306E\u30BF\u30A4\u30D7",
3255
+ viaRole: "\u30ED\u30FC\u30EB\u7D4C\u7531",
3256
+ viaTeam: "\u30C1\u30FC\u30E0\u7D4C\u7531",
3257
+ attachedVia: "\u4ED8\u4E0E\u5143",
3258
+ filterByType: "\u30BF\u30A4\u30D7\u3067\u30D5\u30A3\u30EB\u30BF",
3259
+ remove: "\u524A\u9664",
3260
+ addPermissions: "\u6A29\u9650\u3092\u8FFD\u52A0",
3261
+ assignRole: "\u30ED\u30FC\u30EB\u5272\u308A\u5F53\u3066",
3262
+ noRolesAssigned: "\u30ED\u30FC\u30EB\u304C\u5272\u308A\u5F53\u3066\u3089\u308C\u3066\u3044\u307E\u305B\u3093",
3263
+ level: "\u30EC\u30D9\u30EB",
3264
+ actions: "\u64CD\u4F5C",
3265
+ confirmRemoveRole: "\u3053\u306E\u30ED\u30FC\u30EB\u3092\u524A\u9664\u3057\u3066\u3082\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F",
3266
+ teamMemberships: "\u30C1\u30FC\u30E0\u30E1\u30F3\u30D0\u30FC\u30B7\u30C3\u30D7",
3267
+ noTeamMemberships: "\u30C1\u30FC\u30E0\u306B\u6240\u5C5E\u3057\u3066\u3044\u307E\u305B\u3093",
3268
+ teamLeader: "\u30EA\u30FC\u30C0\u30FC",
3269
+ noPermissions: "\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093",
3270
+ group: "\u30B0\u30EB\u30FC\u30D7"
3271
+ };
3272
+ function UserDetailCard({
3273
+ user,
3274
+ roleAssignments,
3275
+ teamMemberships,
3276
+ aggregatedPermissions,
3277
+ currentOrg,
3278
+ currentBranch,
3279
+ onRefresh,
3280
+ onAssignRole,
3281
+ onRemoveRole,
3282
+ onRoleClick,
3283
+ removeLoading = false,
3284
+ translations: t = {}
3285
+ }) {
3286
+ const labels = { ...defaultTranslations4, ...t };
3287
+ const [permissionSearch, setPermissionSearch] = (0, import_react16.useState)("");
3288
+ const [permissionTypeFilter, setPermissionTypeFilter] = (0, import_react16.useState)("all");
3289
+ const getScopeLabel2 = (assignment) => {
3290
+ if (assignment.scope === "global") return labels.global;
3291
+ if (assignment.scope === "org-wide") return assignment.org_name || labels.global;
3292
+ return assignment.branch_name || labels.global;
3293
+ };
3294
+ const permissionsTableData = roleAssignments.flatMap(
3295
+ (assignment) => assignment.permissions.map((perm) => ({
3296
+ key: `${assignment.role.id}-${perm.slug}`,
3297
+ permission: perm.slug,
3298
+ permissionName: perm.name,
3299
+ permissionGroup: perm.group,
3300
+ type: "role",
3301
+ attachedVia: assignment.role.name,
3302
+ scope: assignment.scope,
3303
+ roleId: assignment.role.id,
3304
+ consoleOrgId: assignment.console_org_id,
3305
+ consoleBranchId: assignment.console_branch_id
3306
+ }))
3307
+ );
3308
+ const teamPermissionsData = teamMemberships.flatMap(
3309
+ (membership) => membership.permissions.map((perm) => ({
3310
+ key: `team-${membership.team.id}-${perm.slug}`,
3311
+ permission: perm.slug,
3312
+ permissionName: perm.name,
3313
+ permissionGroup: perm.group,
3314
+ type: "team",
3315
+ attachedVia: membership.team.name,
3316
+ scope: "team"
3317
+ }))
3318
+ );
3319
+ const allPermissionsData = [...permissionsTableData, ...teamPermissionsData];
3320
+ const filteredPermissions = allPermissionsData.filter((p) => {
3321
+ const matchesSearch = !permissionSearch || p.permission.toLowerCase().includes(permissionSearch.toLowerCase());
3322
+ const matchesType = permissionTypeFilter === "all" || p.type === permissionTypeFilter;
3323
+ return matchesSearch && matchesType;
3324
+ });
3325
+ const groupedAggregatedPermissions = (0, import_react16.useMemo)(
3326
+ () => aggregatedPermissions.reduce((acc, perm) => {
3327
+ const group = perm.split(".").slice(0, -1).join(".") || "other";
3328
+ if (!acc[group]) acc[group] = [];
3329
+ acc[group].push(perm);
3330
+ return acc;
3331
+ }, {}),
3332
+ [aggregatedPermissions]
3333
+ );
3334
+ const tabItems = [
3335
+ {
3336
+ key: "permissions",
3337
+ label: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { children: [
3338
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.KeyOutlined, {}),
3339
+ " ",
3340
+ labels.permissions
3341
+ ] }),
3342
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
3343
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
3344
+ "div",
3345
+ {
3346
+ style: {
3347
+ display: "flex",
3348
+ justifyContent: "space-between",
3349
+ alignItems: "center",
3350
+ marginBottom: 16
3351
+ },
3352
+ children: [
3353
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
3354
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Title3, { level: 5, style: { margin: 0 }, children: [
3355
+ labels.permissionPolicies,
3356
+ " (",
3357
+ allPermissionsData.length,
3358
+ ")"
3359
+ ] }),
3360
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { type: "secondary", style: { fontSize: 12 }, children: labels.permissionsDescription })
3361
+ ] }),
3362
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_antd10.Space, { children: [
3363
+ onRefresh && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Button, { icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.ReloadOutlined, {}), onClick: onRefresh }),
3364
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Button, { type: "default", children: labels.remove }),
3365
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Button, { type: "primary", icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.PlusOutlined, {}), children: labels.addPermissions })
3366
+ ] })
3367
+ ]
3368
+ }
3369
+ ),
3370
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { display: "flex", gap: 16, marginBottom: 16 }, children: [
3371
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3372
+ import_antd10.Input,
3373
+ {
3374
+ placeholder: labels.searchPermissions,
3375
+ prefix: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.KeyOutlined, {}),
3376
+ value: permissionSearch,
3377
+ onChange: (e) => setPermissionSearch(e.target.value),
3378
+ style: { width: 300 }
3379
+ }
3380
+ ),
3381
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3382
+ import_antd10.Select,
3383
+ {
3384
+ value: permissionTypeFilter,
3385
+ onChange: setPermissionTypeFilter,
3386
+ style: { width: 200 },
3387
+ options: [
3388
+ { value: "all", label: labels.allTypes },
3389
+ { value: "role", label: labels.viaRole },
3390
+ { value: "team", label: labels.viaTeam }
3391
+ ]
3392
+ }
3393
+ )
3394
+ ] }),
3395
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3396
+ import_antd10.Table,
3397
+ {
3398
+ dataSource: filteredPermissions,
3399
+ pagination: { pageSize: 10 },
3400
+ columns: [
3401
+ {
3402
+ title: labels.permissions,
3403
+ dataIndex: "permission",
3404
+ key: "permission",
3405
+ render: (perm) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_antd10.Space, { children: [
3406
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.KeyOutlined, { style: { color: "#faad14" } }),
3407
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(AntLink, { children: perm })
3408
+ ] })
3409
+ },
3410
+ {
3411
+ title: labels.filterByType,
3412
+ dataIndex: "type",
3413
+ key: "type",
3414
+ width: 150,
3415
+ render: (type) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Tag, { color: type === "role" ? "blue" : "green", children: type === "role" ? labels.viaRole : labels.viaTeam })
3416
+ },
3417
+ {
3418
+ title: labels.attachedVia,
3419
+ dataIndex: "attachedVia",
3420
+ key: "attachedVia",
3421
+ width: 200,
3422
+ render: (via, record) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_antd10.Space, { children: [
3423
+ record.type === "role" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.SafetyOutlined, {}) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.TeamOutlined, {}),
3424
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { children: via }),
3425
+ record.scope && record.scope !== "team" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Tag, { color: getScopeColor(record.scope), style: { fontSize: 12 }, children: record.scope })
3426
+ ] })
3427
+ }
3428
+ ]
3429
+ }
3430
+ )
3431
+ ] })
2457
3432
  },
2458
3433
  {
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") })
2464
- }
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,
3434
+ key: "roles",
3435
+ label: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { children: [
3436
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.SafetyOutlined, {}),
3437
+ " ",
3438
+ labels.roles,
3439
+ " (",
3440
+ roleAssignments.length,
3441
+ ")"
3442
+ ] }),
3443
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
3444
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
3445
+ "div",
2474
3446
  {
2475
- type: "text",
2476
- icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons4.EditOutlined, {}),
2477
- size: "small",
2478
- onClick: () => onEdit(record)
3447
+ style: {
3448
+ display: "flex",
3449
+ justifyContent: "space-between",
3450
+ alignItems: "center",
3451
+ marginBottom: 16
3452
+ },
3453
+ children: [
3454
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Title3, { level: 5, style: { margin: 0 }, children: labels.roleAssignments }),
3455
+ onAssignRole && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Button, { type: "primary", icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.PlusOutlined, {}), onClick: onAssignRole, children: labels.assignRole })
3456
+ ]
2479
3457
  }
2480
3458
  ),
2481
- onDelete && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2482
- import_antd4.Popconfirm,
3459
+ roleAssignments.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Empty, { description: labels.noRolesAssigned }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3460
+ import_antd10.Table,
2483
3461
  {
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,
3462
+ dataSource: roleAssignments,
3463
+ rowKey: (r) => `${r.role.id}-${r.console_org_id}-${r.console_branch_id}`,
3464
+ columns: [
3465
+ {
3466
+ title: labels.roles,
3467
+ key: "role",
3468
+ render: (_, record) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_antd10.Space, { children: [
3469
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.SafetyOutlined, { style: { color: "#1890ff" } }),
3470
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3471
+ Text6,
3472
+ {
3473
+ strong: true,
3474
+ style: { color: "#1890ff", cursor: onRoleClick ? "pointer" : "default" },
3475
+ onClick: () => onRoleClick?.(record.role.id),
3476
+ children: record.role.name
3477
+ }
3478
+ ),
3479
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Tag, { color: "default", children: record.role.slug })
3480
+ ] })
3481
+ },
2490
3482
  {
2491
- type: "text",
2492
- danger: true,
2493
- icon: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_icons4.DeleteOutlined, {}),
2494
- size: "small",
2495
- loading: deleteLoading
3483
+ title: labels.global,
3484
+ key: "scope",
3485
+ width: 200,
3486
+ render: (_, record) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Tag, { color: getScopeColor(record.scope), children: getScopeLabel2(record) })
3487
+ },
3488
+ {
3489
+ title: labels.level,
3490
+ dataIndex: ["role", "level"],
3491
+ key: "level",
3492
+ width: 100
3493
+ },
3494
+ {
3495
+ title: labels.permissions,
3496
+ key: "permissions",
3497
+ width: 150,
3498
+ render: (_, record) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Text6, { children: [
3499
+ record.permissions.length,
3500
+ " ",
3501
+ labels.permissions.toLowerCase()
3502
+ ] })
3503
+ },
3504
+ {
3505
+ title: labels.actions,
3506
+ key: "actions",
3507
+ width: 100,
3508
+ render: (_, record) => onRemoveRole && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3509
+ import_antd10.Popconfirm,
3510
+ {
3511
+ title: labels.confirmRemoveRole,
3512
+ onConfirm: () => onRemoveRole(
3513
+ record.role.id,
3514
+ record.console_org_id,
3515
+ record.console_branch_id
3516
+ ),
3517
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3518
+ import_antd10.Button,
3519
+ {
3520
+ type: "text",
3521
+ danger: true,
3522
+ icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.DeleteOutlined, {}),
3523
+ loading: removeLoading
3524
+ }
3525
+ )
3526
+ }
3527
+ )
2496
3528
  }
2497
- )
3529
+ ]
3530
+ }
3531
+ )
3532
+ ] })
3533
+ },
3534
+ {
3535
+ key: "teams",
3536
+ label: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { children: [
3537
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.TeamOutlined, {}),
3538
+ " ",
3539
+ labels.teams,
3540
+ " (",
3541
+ teamMemberships.length,
3542
+ ")"
3543
+ ] }),
3544
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
3545
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Title3, { level: 5, style: { marginBottom: 16 }, children: labels.teamMemberships }),
3546
+ teamMemberships.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Empty, { description: labels.noTeamMemberships }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3547
+ import_antd10.Table,
3548
+ {
3549
+ dataSource: teamMemberships,
3550
+ rowKey: (m) => m.team.id,
3551
+ columns: [
3552
+ {
3553
+ title: labels.teams,
3554
+ key: "team",
3555
+ render: (_, record) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_antd10.Space, { children: [
3556
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.TeamOutlined, { style: { color: "#52c41a" } }),
3557
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { strong: true, children: record.team.name }),
3558
+ record.team.path && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Text6, { type: "secondary", children: [
3559
+ "(",
3560
+ record.team.path,
3561
+ ")"
3562
+ ] })
3563
+ ] })
3564
+ },
3565
+ {
3566
+ title: labels.teamLeader,
3567
+ key: "leader",
3568
+ width: 150,
3569
+ render: (_, record) => record.is_leader ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Tag, { color: "gold", children: labels.teamLeader }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { type: "secondary", children: "-" })
3570
+ },
3571
+ {
3572
+ title: labels.permissions,
3573
+ key: "permissions",
3574
+ width: 150,
3575
+ render: (_, record) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Text6, { children: [
3576
+ record.permissions.length,
3577
+ " ",
3578
+ labels.permissions.toLowerCase()
3579
+ ] })
3580
+ }
3581
+ ]
3582
+ }
3583
+ )
3584
+ ] })
3585
+ },
3586
+ {
3587
+ key: "aggregated",
3588
+ label: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { children: [
3589
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.SafetyOutlined, {}),
3590
+ " ",
3591
+ labels.aggregatedPermissions,
3592
+ " (",
3593
+ aggregatedPermissions.length,
3594
+ ")"
3595
+ ] }),
3596
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
3597
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Title3, { level: 5, style: { marginBottom: 16 }, children: labels.aggregatedPermissions }),
3598
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { type: "secondary", style: { display: "block", marginBottom: 16 }, children: "\u3059\u3079\u3066\u306E\u30ED\u30FC\u30EB\u3068\u30C1\u30FC\u30E0\u304B\u3089\u96C6\u7D04\u3055\u308C\u305F\u6A29\u9650\u306E\u4E00\u89A7\u3067\u3059\u3002" }),
3599
+ aggregatedPermissions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Empty, { description: labels.noPermissions }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3600
+ import_antd10.Table,
3601
+ {
3602
+ dataSource: aggregatedPermissions.map((perm) => ({
3603
+ key: perm,
3604
+ permission: perm,
3605
+ group: perm.split(".").slice(0, -1).join(".") || "other",
3606
+ action: perm.split(".").pop() || perm
3607
+ })),
3608
+ pagination: { pageSize: 20 },
3609
+ size: "small",
3610
+ columns: [
3611
+ {
3612
+ title: labels.group,
3613
+ dataIndex: "group",
3614
+ key: "group",
3615
+ width: 200,
3616
+ filters: Object.keys(groupedAggregatedPermissions).map((g) => ({
3617
+ text: g,
3618
+ value: g
3619
+ })),
3620
+ onFilter: (value, record) => record.group === value,
3621
+ render: (group) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Tag, { icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.SafetyOutlined, {}), color: "blue", children: group })
3622
+ },
3623
+ {
3624
+ title: labels.permissions,
3625
+ dataIndex: "permission",
3626
+ key: "permission",
3627
+ render: (perm) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_antd10.Space, { children: [
3628
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.KeyOutlined, { style: { color: "#faad14" } }),
3629
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { children: perm })
3630
+ ] })
3631
+ },
3632
+ {
3633
+ title: "Action",
3634
+ dataIndex: "action",
3635
+ key: "action",
3636
+ width: 150,
3637
+ render: (action) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Tag, { color: "green", children: action })
3638
+ }
3639
+ ]
2498
3640
  }
2499
3641
  )
2500
3642
  ] })
2501
- });
2502
- }
2503
- const handleTableChange = (paginationConfig, _filters, sorter) => {
2504
- if (onPageChange && paginationConfig.current && paginationConfig.pageSize) {
2505
- onPageChange(paginationConfig.current, paginationConfig.pageSize);
2506
- }
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
3643
  }
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,
3644
+ ];
3645
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
3646
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Card, { size: "small", style: { marginBottom: 24 }, styles: { body: { padding: "16px 24px" } }, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
3647
+ "div",
2522
3648
  {
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
3649
+ style: {
3650
+ display: "grid",
3651
+ gridTemplateColumns: "repeat(3, 1fr)",
3652
+ gap: "20px 48px"
3653
+ },
3654
+ children: [
3655
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
3656
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { type: "secondary", style: { fontSize: 12, display: "block", marginBottom: 4 }, children: labels.email }),
3657
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { copyable: true, style: { fontSize: 14 }, children: user?.email || "-" })
3658
+ ] }),
3659
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
3660
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { type: "secondary", style: { fontSize: 12, display: "block", marginBottom: 4 }, children: labels.primaryOrganization }),
3661
+ user?.organization ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_antd10.Space, { size: 4, children: [
3662
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.BankOutlined, { style: { color: "#1890ff" } }),
3663
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { style: { fontSize: 14 }, children: user.organization.name })
3664
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_antd10.Space, { size: 4, children: [
3665
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.GlobalOutlined, { style: { color: "#722ed1" } }),
3666
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { style: { fontSize: 14 }, children: labels.global })
3667
+ ] })
3668
+ ] }),
3669
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
3670
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { type: "secondary", style: { fontSize: 12, display: "block", marginBottom: 4 }, children: labels.currentContext }),
3671
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_antd10.Space, { size: 16, wrap: true, children: [
3672
+ currentOrg && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_antd10.Space, { size: 4, children: [
3673
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.BankOutlined, { style: { color: "#1890ff" } }),
3674
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { style: { fontSize: 14 }, children: currentOrg.name })
3675
+ ] }),
3676
+ currentBranch && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_antd10.Space, { size: 4, children: [
3677
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons9.BranchesOutlined, { style: { color: "#52c41a" } }),
3678
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { style: { fontSize: 14 }, children: currentBranch.name })
3679
+ ] })
3680
+ ] })
3681
+ ] }),
3682
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
3683
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { type: "secondary", style: { fontSize: 12, display: "block", marginBottom: 4 }, children: labels.created }),
3684
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { style: { fontSize: 14 }, children: user?.created_at ? new Date(user.created_at).toLocaleDateString() : "-" })
3685
+ ] }),
3686
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
3687
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { type: "secondary", style: { fontSize: 12, display: "block", marginBottom: 4 }, children: labels.lastSignIn }),
3688
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { style: { fontSize: 14 }, children: "-" })
3689
+ ] }),
3690
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { children: [
3691
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { type: "secondary", style: { fontSize: 12, display: "block", marginBottom: 4 }, children: labels.roleAssignments }),
3692
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Text6, { style: { fontSize: 14 }, children: [
3693
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text6, { strong: true, children: roleAssignments.length }),
3694
+ " ",
3695
+ labels.roles.toLowerCase()
3696
+ ] })
3697
+ ] })
3698
+ ]
2528
3699
  }
2529
3700
  ) }),
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
- )
3701
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Card, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_antd10.Tabs, { defaultActiveKey: "permissions", items: tabItems }) })
2547
3702
  ] });
2548
3703
  }
2549
3704
 
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,
3705
+ // src/ant/components/RoleCreateModal/RoleCreateModal.tsx
3706
+ var import_icons10 = require("@ant-design/icons");
3707
+ var import_antd11 = require("antd");
3708
+ var import_jsx_runtime16 = require("react/jsx-runtime");
3709
+ var defaultTranslations5 = {
3710
+ title: "\u30ED\u30FC\u30EB\u4F5C\u6210",
3711
+ name: "\u540D\u524D",
3712
+ slug: "\u30B9\u30E9\u30C3\u30B0",
3713
+ description: "\u8AAC\u660E",
3714
+ level: "\u30EC\u30D9\u30EB",
3715
+ scope: "\u30B9\u30B3\u30FC\u30D7",
3716
+ global: "\u30B0\u30ED\u30FC\u30D0\u30EB",
3717
+ orgRole: "\u7D44\u7E54\u30ED\u30FC\u30EB",
3718
+ organization: "\u7D44\u7E54",
3719
+ create: "\u4F5C\u6210",
3720
+ cancel: "\u30AD\u30E3\u30F3\u30BB\u30EB",
3721
+ required: "\u5FC5\u9808\u9805\u76EE\u3067\u3059"
3722
+ };
3723
+ function RoleCreateModal({
3724
+ open,
3725
+ organizations,
3726
+ currentOrgId,
3727
+ loading = false,
2555
3728
  onSubmit,
2556
3729
  onCancel,
2557
- loading = false,
2558
- submitText
3730
+ translations: t = {}
2559
3731
  }) {
2560
- const { t } = useSsoTranslation();
2561
- const [form] = import_antd5.Form.useForm();
2562
- const handleFinish = (values) => {
2563
- onSubmit(values);
3732
+ const [form] = import_antd11.Form.useForm();
3733
+ const labels = { ...defaultTranslations5, ...t };
3734
+ const handleFinish = async (values) => {
3735
+ await onSubmit(values);
3736
+ form.resetFields();
2564
3737
  };
2565
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
2566
- import_antd5.Form,
3738
+ const handleCancel = () => {
3739
+ form.resetFields();
3740
+ onCancel();
3741
+ };
3742
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3743
+ import_antd11.Modal,
3744
+ {
3745
+ title: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_antd11.Space, { children: [
3746
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_icons10.PlusOutlined, {}),
3747
+ labels.title
3748
+ ] }),
3749
+ open,
3750
+ onCancel: handleCancel,
3751
+ footer: null,
3752
+ destroyOnHidden: true,
3753
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
3754
+ import_antd11.Form,
3755
+ {
3756
+ form,
3757
+ layout: "vertical",
3758
+ onFinish: handleFinish,
3759
+ initialValues: { level: 50, scope: "org", org_id: currentOrgId },
3760
+ children: [
3761
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3762
+ import_antd11.Form.Item,
3763
+ {
3764
+ name: "scope",
3765
+ label: labels.scope,
3766
+ rules: [{ required: true, message: labels.required }],
3767
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_antd11.Radio.Group, { children: [
3768
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_antd11.Radio, { value: "global", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_antd11.Space, { children: [
3769
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_icons10.GlobalOutlined, {}),
3770
+ labels.global
3771
+ ] }) }),
3772
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_antd11.Radio, { value: "org", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_antd11.Space, { children: [
3773
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_icons10.BankOutlined, {}),
3774
+ labels.orgRole
3775
+ ] }) })
3776
+ ] })
3777
+ }
3778
+ ),
3779
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_antd11.Form.Item, { noStyle: true, shouldUpdate: (prev, curr) => prev.scope !== curr.scope, children: ({ getFieldValue }) => getFieldValue("scope") === "org" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3780
+ import_antd11.Form.Item,
3781
+ {
3782
+ name: "org_id",
3783
+ label: labels.organization,
3784
+ rules: [{ required: true, message: labels.required }],
3785
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_antd11.Select, { placeholder: labels.organization, children: organizations.map((org) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_antd11.Select.Option, { value: String(org.id), children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_antd11.Space, { children: [
3786
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_icons10.BankOutlined, {}),
3787
+ org.name
3788
+ ] }) }, org.id)) })
3789
+ }
3790
+ ) }),
3791
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3792
+ import_antd11.Form.Item,
3793
+ {
3794
+ name: "name",
3795
+ label: labels.name,
3796
+ rules: [{ required: true, message: labels.required }],
3797
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_antd11.Input, {})
3798
+ }
3799
+ ),
3800
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3801
+ import_antd11.Form.Item,
3802
+ {
3803
+ name: "slug",
3804
+ label: labels.slug,
3805
+ rules: [{ required: true, message: labels.required }],
3806
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_antd11.Input, {})
3807
+ }
3808
+ ),
3809
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_antd11.Form.Item, { name: "description", label: labels.description, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_antd11.Input.TextArea, { rows: 3 }) }),
3810
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3811
+ import_antd11.Form.Item,
3812
+ {
3813
+ name: "level",
3814
+ label: labels.level,
3815
+ rules: [{ required: true, message: labels.required }],
3816
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_antd11.InputNumber, { min: 1, max: 100, style: { width: "100%" } })
3817
+ }
3818
+ ),
3819
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_antd11.Form.Item, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_antd11.Space, { children: [
3820
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_antd11.Button, { type: "primary", htmlType: "submit", loading, children: labels.create }),
3821
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_antd11.Button, { onClick: handleCancel, children: labels.cancel })
3822
+ ] }) })
3823
+ ]
3824
+ }
3825
+ )
3826
+ }
3827
+ );
3828
+ }
3829
+
3830
+ // src/ant/components/RolesListCard/RolesListCard.tsx
3831
+ var import_icons11 = require("@ant-design/icons");
3832
+ var import_antd12 = require("antd");
3833
+ var import_jsx_runtime17 = require("react/jsx-runtime");
3834
+ var { Text: Text7 } = import_antd12.Typography;
3835
+ var defaultTranslations6 = {
3836
+ name: "\u540D\u524D",
3837
+ scope: "\u30B9\u30B3\u30FC\u30D7",
3838
+ level: "\u30EC\u30D9\u30EB",
3839
+ description: "\u8AAC\u660E",
3840
+ actions: "\u64CD\u4F5C",
3841
+ detail: "\u8A73\u7D30",
3842
+ global: "\u30B0\u30ED\u30FC\u30D0\u30EB",
3843
+ orgRole: "\u7D44\u7E54\u30ED\u30FC\u30EB",
3844
+ all: "\u3059\u3079\u3066",
3845
+ confirmDeleteRole: "\u3053\u306E\u30ED\u30FC\u30EB\u3092\u524A\u9664\u3057\u3066\u3082\u3088\u308D\u3057\u3044\u3067\u3059\u304B\uFF1F"
3846
+ };
3847
+ function RolesListCard({
3848
+ roles,
3849
+ loading = false,
3850
+ scopeFilter,
3851
+ onScopeFilterChange,
3852
+ onCreateClick,
3853
+ onViewClick,
3854
+ onDeleteClick,
3855
+ translations: t = {}
3856
+ }) {
3857
+ const labels = { ...defaultTranslations6, ...t };
3858
+ const columns = [
2567
3859
  {
2568
- form,
2569
- layout: "vertical",
2570
- initialValues,
2571
- onFinish: handleFinish,
2572
- style: { maxWidth: 600 },
3860
+ title: labels.name,
3861
+ dataIndex: "name",
3862
+ key: "name",
3863
+ render: (name, record) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { children: [
3864
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_icons11.SafetyOutlined, { style: { color: "#1890ff" } }),
3865
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Text7, { strong: true, children: name }),
3866
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Tag, { children: record.slug })
3867
+ ] })
3868
+ },
3869
+ {
3870
+ title: labels.scope,
3871
+ dataIndex: "console_org_id",
3872
+ key: "scope",
3873
+ width: 180,
3874
+ render: (_, record) => record.console_org_id ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Tag, { icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_icons11.BankOutlined, {}), color: "blue", children: record.organization?.name || record.console_org_id }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Tag, { icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_icons11.GlobalOutlined, {}), color: "purple", children: labels.global })
3875
+ },
3876
+ {
3877
+ title: labels.level,
3878
+ dataIndex: "level",
3879
+ key: "level",
3880
+ width: 100,
3881
+ render: (level) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Tag, { color: "blue", children: level })
3882
+ },
3883
+ {
3884
+ title: labels.description,
3885
+ dataIndex: "description",
3886
+ key: "description",
3887
+ ellipsis: true
3888
+ },
3889
+ {
3890
+ title: labels.actions,
3891
+ key: "actions",
3892
+ width: 180,
3893
+ render: (_, record) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { children: [
3894
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Button, { size: "small", icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_icons11.EyeOutlined, {}), onClick: () => onViewClick(record), children: labels.detail }),
3895
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Popconfirm, { title: labels.confirmDeleteRole, onConfirm: () => onDeleteClick(record), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Button, { size: "small", danger: true, icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_icons11.DeleteOutlined, {}) }) })
3896
+ ] })
3897
+ }
3898
+ ];
3899
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
3900
+ import_antd12.Card,
3901
+ {
3902
+ title: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { children: [
3903
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_icons11.SafetyOutlined, {}),
3904
+ "Roles"
3905
+ ] }),
3906
+ extra: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Button, { type: "primary", icon: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_icons11.PlusOutlined, {}), onClick: onCreateClick, children: "Create" }),
2573
3907
  children: [
2574
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2575
- import_antd5.Form.Item,
3908
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { marginBottom: 16, display: "flex", gap: 16 }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
3909
+ import_antd12.Select,
2576
3910
  {
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, {})
3911
+ value: scopeFilter,
3912
+ onChange: onScopeFilterChange,
3913
+ style: { minWidth: 200 },
3914
+ children: [
3915
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Select.Option, { value: "all", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { children: [
3916
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_icons11.SafetyOutlined, {}),
3917
+ labels.all
3918
+ ] }) }),
3919
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Select.Option, { value: "global", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { children: [
3920
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_icons11.GlobalOutlined, {}),
3921
+ labels.global
3922
+ ] }) }),
3923
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Select.Option, { value: "org", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { children: [
3924
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_icons11.BankOutlined, {}),
3925
+ labels.orgRole
3926
+ ] }) })
3927
+ ]
2584
3928
  }
2585
- ),
2586
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2587
- import_antd5.Form.Item,
3929
+ ) }),
3930
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
3931
+ import_antd12.Table,
2588
3932
  {
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" })
3933
+ columns,
3934
+ dataSource: roles,
3935
+ rowKey: "id",
3936
+ loading,
3937
+ pagination: { pageSize: 10 }
2596
3938
  }
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
- ] }) })
3939
+ )
2602
3940
  ]
2603
3941
  }
2604
3942
  );
2605
3943
  }
2606
3944
 
2607
- // src/utils/branchHeaders.ts
3945
+ // src/ant/components/PermissionsListCard/PermissionsListCard.tsx
3946
+ var import_icons12 = require("@ant-design/icons");
3947
+ var import_antd13 = require("antd");
3948
+ var import_react17 = require("react");
3949
+ var import_jsx_runtime18 = require("react/jsx-runtime");
3950
+ var { Text: Text8 } = import_antd13.Typography;
3951
+ var defaultTranslations7 = {
3952
+ searchPermissions: "\u6A29\u9650\u3092\u691C\u7D22",
3953
+ name: "\u540D\u524D",
3954
+ slug: "\u30B9\u30E9\u30C3\u30B0",
3955
+ group: "\u30B0\u30EB\u30FC\u30D7",
3956
+ noData: "\u30C7\u30FC\u30BF\u304C\u3042\u308A\u307E\u305B\u3093"
3957
+ };
3958
+ function PermissionsListCard({
3959
+ permissions,
3960
+ groups,
3961
+ loading = false,
3962
+ translations: t = {},
3963
+ onGroupLabelRender
3964
+ }) {
3965
+ const [search, setSearch] = (0, import_react17.useState)("");
3966
+ const labels = { ...defaultTranslations7, ...t };
3967
+ const filteredPermissions = (0, import_react17.useMemo)(() => {
3968
+ if (!search) return permissions;
3969
+ const lowerSearch = search.toLowerCase();
3970
+ return permissions.filter(
3971
+ (p) => p.name.toLowerCase().includes(lowerSearch) || p.slug.toLowerCase().includes(lowerSearch) || (p.group || "").toLowerCase().includes(lowerSearch)
3972
+ );
3973
+ }, [permissions, search]);
3974
+ const groupedPermissions = (0, import_react17.useMemo)(() => {
3975
+ const grouped = {};
3976
+ filteredPermissions.forEach((perm) => {
3977
+ const group = perm.group || "other";
3978
+ if (!grouped[group]) grouped[group] = [];
3979
+ grouped[group].push(perm);
3980
+ });
3981
+ return grouped;
3982
+ }, [filteredPermissions]);
3983
+ const getGroupLabel = (group) => {
3984
+ if (onGroupLabelRender) return onGroupLabelRender(group);
3985
+ return group;
3986
+ };
3987
+ const columns = [
3988
+ {
3989
+ title: labels.name,
3990
+ dataIndex: "name",
3991
+ key: "name",
3992
+ render: (name) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_antd13.Space, { children: [
3993
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_icons12.KeyOutlined, { style: { color: "#52c41a" } }),
3994
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Text8, { strong: true, children: name })
3995
+ ] })
3996
+ },
3997
+ {
3998
+ title: labels.slug,
3999
+ dataIndex: "slug",
4000
+ key: "slug",
4001
+ render: (slug) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_antd13.Tag, { color: "blue", children: slug })
4002
+ },
4003
+ {
4004
+ title: labels.group,
4005
+ dataIndex: "group",
4006
+ key: "group",
4007
+ render: (group) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_antd13.Tag, { icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_icons12.AppstoreOutlined, {}), color: "purple", children: getGroupLabel(group || "other") })
4008
+ }
4009
+ ];
4010
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_antd13.Card, { children: [
4011
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { marginBottom: 16 }, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4012
+ import_antd13.Input.Search,
4013
+ {
4014
+ placeholder: labels.searchPermissions,
4015
+ allowClear: true,
4016
+ onSearch: setSearch,
4017
+ onChange: (e) => !e.target.value && setSearch(""),
4018
+ style: { maxWidth: 300 }
4019
+ }
4020
+ ) }),
4021
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_antd13.Collapse, { defaultActiveKey: groups, ghost: true, children: Object.entries(groupedPermissions).map(([group, perms]) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4022
+ import_antd13.Collapse.Panel,
4023
+ {
4024
+ header: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_antd13.Space, { children: [
4025
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_icons12.AppstoreOutlined, { style: { color: "#722ed1" } }),
4026
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Text8, { strong: true, children: getGroupLabel(group) }),
4027
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_antd13.Tag, { children: perms.length })
4028
+ ] }),
4029
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
4030
+ import_antd13.Table,
4031
+ {
4032
+ columns,
4033
+ dataSource: perms,
4034
+ rowKey: "id",
4035
+ loading,
4036
+ pagination: false,
4037
+ size: "small"
4038
+ }
4039
+ )
4040
+ },
4041
+ group
4042
+ )) }),
4043
+ filteredPermissions.length === 0 && !loading && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { style: { textAlign: "center", padding: 40 }, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Text8, { type: "secondary", children: labels.noData }) })
4044
+ ] });
4045
+ }
4046
+
4047
+ // src/ant/components/TeamsListCard/TeamsListCard.tsx
4048
+ var import_icons13 = require("@ant-design/icons");
4049
+ var import_antd14 = require("antd");
4050
+ var import_jsx_runtime19 = require("react/jsx-runtime");
4051
+ var { Text: Text9 } = import_antd14.Typography;
4052
+ var defaultTranslations8 = {
4053
+ name: "\u540D\u524D",
4054
+ memberCount: "\u30E1\u30F3\u30D0\u30FC\u6570",
4055
+ permissions: "\u6A29\u9650",
4056
+ noTeams: "\u30C1\u30FC\u30E0\u304C\u3042\u308A\u307E\u305B\u3093",
4057
+ teamsFromConsole: "\u30C1\u30FC\u30E0\u306F\u30B3\u30F3\u30BD\u30FC\u30EB\u304B\u3089\u7BA1\u7406\u3055\u308C\u307E\u3059",
4058
+ teamPermissions: "\u30C1\u30FC\u30E0\u6A29\u9650",
4059
+ noData: "\u30C7\u30FC\u30BF\u304C\u3042\u308A\u307E\u305B\u3093"
4060
+ };
4061
+ function TeamsListCard({
4062
+ teams,
4063
+ loading = false,
4064
+ translations: t = {}
4065
+ }) {
4066
+ const labels = { ...defaultTranslations8, ...t };
4067
+ const columns = [
4068
+ {
4069
+ title: labels.name,
4070
+ dataIndex: "name",
4071
+ key: "name",
4072
+ render: (name) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { children: [
4073
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_icons13.TeamOutlined, { style: { marginRight: 8, color: "#1890ff" } }),
4074
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Text9, { strong: true, children: name })
4075
+ ] })
4076
+ },
4077
+ {
4078
+ title: labels.memberCount,
4079
+ dataIndex: "member_count",
4080
+ key: "member_count",
4081
+ width: 120,
4082
+ render: (count) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_antd14.Tag, { icon: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_icons13.UserOutlined, {}), children: count })
4083
+ },
4084
+ {
4085
+ title: labels.permissions,
4086
+ dataIndex: "permissions",
4087
+ key: "permissions",
4088
+ render: (permissions) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: permissions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_antd14.Tag, { color: "blue", children: [
4089
+ permissions.length,
4090
+ " ",
4091
+ labels.permissions
4092
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_antd14.Tag, { children: [
4093
+ "0 ",
4094
+ labels.permissions
4095
+ ] }) })
4096
+ }
4097
+ ];
4098
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_antd14.Card, { children: teams.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4099
+ import_antd14.Empty,
4100
+ {
4101
+ description: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { children: [
4102
+ labels.noTeams,
4103
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("br", {}),
4104
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Text9, { type: "secondary", style: { fontSize: 12 }, children: labels.teamsFromConsole })
4105
+ ] })
4106
+ }
4107
+ ) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
4108
+ import_antd14.Table,
4109
+ {
4110
+ columns,
4111
+ dataSource: teams,
4112
+ rowKey: "id",
4113
+ loading,
4114
+ pagination: { pageSize: 10 },
4115
+ expandable: {
4116
+ expandedRowRender: (record) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { style: { padding: "8px 0" }, children: [
4117
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(Text9, { strong: true, style: { marginBottom: 8, display: "block" }, children: [
4118
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_icons13.KeyOutlined, { style: { marginRight: 4 } }),
4119
+ labels.teamPermissions,
4120
+ ":"
4121
+ ] }),
4122
+ record.permissions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Text9, { type: "secondary", children: labels.noData }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: 4 }, children: record.permissions.map((perm) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_antd14.Tag, { color: "cyan", children: perm }, perm)) })
4123
+ ] })
4124
+ }
4125
+ }
4126
+ ) });
4127
+ }
4128
+
4129
+ // src/ant/theme/AntdThemeProvider.tsx
4130
+ var import_antd15 = require("antd");
4131
+ var import_en_US = __toESM(require("antd/locale/en_US"), 1);
4132
+ var import_ja_JP = __toESM(require("antd/locale/ja_JP"), 1);
4133
+ var import_vi_VN = __toESM(require("antd/locale/vi_VN"), 1);
4134
+ var import_react18 = require("react");
4135
+ var import_jsx_runtime20 = require("react/jsx-runtime");
4136
+ var antdLocales = {
4137
+ ja: import_ja_JP.default,
4138
+ en: import_en_US.default,
4139
+ vi: import_vi_VN.default
4140
+ };
4141
+ var fontFamilies = {
4142
+ // Japanese - CJK optimized fonts
4143
+ ja: "'Noto Sans JP', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif",
4144
+ // English - Modern western fonts
4145
+ en: "'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
4146
+ // Vietnamese - Light, clean font with good diacritics
4147
+ vi: "'Inter', 'Nunito Sans', -apple-system, BlinkMacSystemFont, sans-serif"
4148
+ };
4149
+ var themeColors = {
4150
+ dashboard: {
4151
+ primary: "#7C3AED",
4152
+ // Violet
4153
+ siderBg: "#7C3AED",
4154
+ menuDarkItemBg: "#7C3AED",
4155
+ menuDarkSubMenuItemBg: "#6D28D9",
4156
+ menuDarkItemSelectedBg: "#9061F9",
4157
+ menuDarkItemHoverBg: "rgba(144, 97, 249, 0.6)"
4158
+ },
4159
+ admin: {
4160
+ primary: "#64748B",
4161
+ // Slate gray - professional admin look
4162
+ siderBg: "#475569",
4163
+ menuDarkItemBg: "#475569",
4164
+ menuDarkSubMenuItemBg: "#334155",
4165
+ menuDarkItemSelectedBg: "#64748B",
4166
+ menuDarkItemHoverBg: "rgba(100, 116, 139, 0.6)"
4167
+ }
4168
+ };
4169
+ function AntdThemeProvider({ children, variant = "dashboard", setDayjsLocale }) {
4170
+ const locale = useLocale();
4171
+ const antdLocale = antdLocales[locale] ?? import_ja_JP.default;
4172
+ const fontFamily = fontFamilies[locale] ?? fontFamilies.ja;
4173
+ const colors = themeColors[variant];
4174
+ (0, import_react18.useEffect)(() => {
4175
+ setDayjsLocale?.(locale);
4176
+ }, [locale, setDayjsLocale]);
4177
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4178
+ import_antd15.ConfigProvider,
4179
+ {
4180
+ locale: antdLocale,
4181
+ theme: {
4182
+ algorithm: import_antd15.theme.defaultAlgorithm,
4183
+ token: {
4184
+ // ===========================================
4185
+ // Tempofast Design System (HSL-based harmony)
4186
+ // ===========================================
4187
+ // Primary - Dynamic based on variant
4188
+ colorPrimary: colors.primary,
4189
+ colorInfo: colors.primary,
4190
+ // Semantic Colors (Complementary harmony)
4191
+ colorSuccess: "#10B981",
4192
+ // HSL(160, 84%, 39%) - Teal-green, cool tone
4193
+ colorWarning: "#F59E0B",
4194
+ // HSL(38, 92%, 50%) - Amber, warm accent
4195
+ colorError: "#EF4444",
4196
+ // HSL(0, 84%, 60%) - Red, same saturation
4197
+ // Text - Neutral with slight violet undertone
4198
+ colorText: "#1E1B2E",
4199
+ // Near black with violet tint
4200
+ colorTextSecondary: "#4B5563",
4201
+ // Cool gray
4202
+ colorTextTertiary: "#9CA3AF",
4203
+ // Light cool gray
4204
+ // Background - Cool neutrals
4205
+ colorBgLayout: "#F8F7FA",
4206
+ // Very light violet-gray
4207
+ colorBgContainer: "#FFFFFF",
4208
+ colorBgElevated: "#FFFFFF",
4209
+ // Border - Subtle
4210
+ colorBorder: "#E5E7EB",
4211
+ colorBorderSecondary: "#F3F4F6",
4212
+ // Border Radius - Compact
4213
+ borderRadius: 4,
4214
+ borderRadiusSM: 2,
4215
+ borderRadiusLG: 6,
4216
+ // Control Heights - Compact
4217
+ controlHeight: 32,
4218
+ controlHeightLG: 36,
4219
+ controlHeightSM: 28,
4220
+ // Font - Dynamic based on locale
4221
+ fontFamily,
4222
+ fontSize: 13,
4223
+ fontSizeLG: 14,
4224
+ fontSizeHeading1: 24,
4225
+ fontSizeHeading2: 20,
4226
+ fontSizeHeading3: 16,
4227
+ fontSizeHeading4: 14,
4228
+ fontSizeHeading5: 13,
4229
+ // Spacing - Tight
4230
+ padding: 12,
4231
+ paddingLG: 16,
4232
+ paddingSM: 8,
4233
+ paddingXS: 4,
4234
+ margin: 12,
4235
+ marginLG: 16,
4236
+ marginSM: 8,
4237
+ marginXS: 4,
4238
+ // Shadows - Almost flat (Japanese style)
4239
+ boxShadow: "0 1px 2px rgba(0, 0, 0, 0.03)",
4240
+ boxShadowSecondary: "0 1px 3px rgba(0, 0, 0, 0.04)",
4241
+ // Line Height
4242
+ lineHeight: 1.5
4243
+ },
4244
+ components: {
4245
+ // Global icon margin in Space component
4246
+ Space: {
4247
+ marginXS: 6
4248
+ },
4249
+ Button: {
4250
+ controlHeight: 32,
4251
+ paddingInline: 12,
4252
+ fontWeight: 500
4253
+ },
4254
+ Statistic: {
4255
+ contentFontSize: 24,
4256
+ titleFontSize: 13
4257
+ },
4258
+ Input: {
4259
+ controlHeight: 32,
4260
+ paddingInline: 8
4261
+ },
4262
+ Select: {
4263
+ controlHeight: 32
4264
+ },
4265
+ Table: {
4266
+ cellPaddingBlock: 8,
4267
+ cellPaddingInline: 8,
4268
+ headerBg: "#F8F7FA"
4269
+ },
4270
+ Card: {
4271
+ paddingLG: 16
4272
+ },
4273
+ Form: {
4274
+ itemMarginBottom: 16,
4275
+ verticalLabelPadding: "0 0 4px"
4276
+ },
4277
+ Menu: {
4278
+ itemHeight: 36,
4279
+ itemMarginBlock: 2,
4280
+ itemMarginInline: 4,
4281
+ darkItemBg: colors.menuDarkItemBg,
4282
+ darkSubMenuItemBg: colors.menuDarkSubMenuItemBg,
4283
+ darkItemSelectedBg: colors.menuDarkItemSelectedBg,
4284
+ darkItemSelectedColor: "#FFFFFF",
4285
+ darkItemColor: "rgba(255, 255, 255, 0.9)",
4286
+ darkItemHoverBg: colors.menuDarkItemHoverBg,
4287
+ darkItemHoverColor: "#FFFFFF"
4288
+ },
4289
+ Layout: {
4290
+ siderBg: colors.siderBg,
4291
+ headerPadding: "0 16px",
4292
+ headerHeight: 48
4293
+ },
4294
+ Typography: {
4295
+ titleMarginBottom: 8,
4296
+ titleMarginTop: 0
4297
+ },
4298
+ Modal: {
4299
+ paddingContentHorizontalLG: 16
4300
+ },
4301
+ Descriptions: {
4302
+ itemPaddingBottom: 8
4303
+ }
4304
+ }
4305
+ },
4306
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_antd15.App, { children })
4307
+ }
4308
+ );
4309
+ }
4310
+
4311
+ // src/core/utils/branchHeaders.ts
2608
4312
  var BRANCH_HEADERS = {
2609
4313
  BRANCH_ID: "X-Branch-Id",
2610
- ORG_ID: "X-Org-Id",
2611
- BRANCH_NAME: "X-Branch-Name",
2612
- BRANCH_CODE: "X-Branch-Code"
4314
+ ORG_ID: "X-Organization-Id"
2613
4315
  };
2614
4316
  function createBranchHeaderSetter(axiosInstance) {
2615
4317
  return (selection) => {
2616
4318
  if (selection) {
2617
4319
  axiosInstance.defaults.headers.common[BRANCH_HEADERS.BRANCH_ID] = selection.branchId;
2618
4320
  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
4321
  } else {
2626
4322
  delete axiosInstance.defaults.headers.common[BRANCH_HEADERS.BRANCH_ID];
2627
4323
  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
4324
  }
2631
4325
  };
2632
4326
  }
@@ -2634,7 +4328,7 @@ function setBranchHeaders(axiosInstance, selection) {
2634
4328
  createBranchHeaderSetter(axiosInstance)(selection);
2635
4329
  }
2636
4330
 
2637
- // src/services/authService.ts
4331
+ // src/core/services/authService.ts
2638
4332
  function createAuthService(config) {
2639
4333
  const { apiUrl } = config;
2640
4334
  return {
@@ -2682,7 +4376,7 @@ function createAuthService(config) {
2682
4376
  };
2683
4377
  }
2684
4378
 
2685
- // src/services/tokenService.ts
4379
+ // src/core/services/tokenService.ts
2686
4380
  function createTokenService(config) {
2687
4381
  const { apiUrl } = config;
2688
4382
  return {
@@ -2718,7 +4412,7 @@ function createTokenService(config) {
2718
4412
  };
2719
4413
  }
2720
4414
 
2721
- // src/services/roleService.ts
4415
+ // src/core/services/roleService.ts
2722
4416
  function createRoleService(config) {
2723
4417
  const { apiUrl } = config;
2724
4418
  return {
@@ -2750,33 +4444,38 @@ function createRoleService(config) {
2750
4444
  * List all roles (admin)
2751
4445
  * GET /api/admin/sso/roles
2752
4446
  */
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, {
2760
- headers: buildHeaders(orgSlug)
4447
+ adminList: async (orgId, params) => {
4448
+ const queryParams = new URLSearchParams();
4449
+ if (params) {
4450
+ Object.entries(params).forEach(([key, value]) => {
4451
+ if (value !== void 0 && value !== null) {
4452
+ queryParams.append(key, String(value));
4453
+ }
4454
+ });
4455
+ }
4456
+ const query = queryParams.toString();
4457
+ const url = `/api/admin/sso/roles${query ? `?${query}` : ""}`;
4458
+ return request(apiUrl, url, {
4459
+ headers: buildHeaders(orgId)
2761
4460
  });
2762
4461
  },
2763
4462
  /**
2764
4463
  * Get single role (admin)
2765
4464
  * GET /api/admin/sso/roles/{id}
2766
4465
  */
2767
- adminGet: async (id, orgSlug) => {
4466
+ adminGet: async (id, orgId) => {
2768
4467
  return request(apiUrl, `/api/admin/sso/roles/${id}`, {
2769
- headers: buildHeaders(orgSlug)
4468
+ headers: buildHeaders(orgId)
2770
4469
  });
2771
4470
  },
2772
4471
  /**
2773
4472
  * Create role (admin only)
2774
4473
  * POST /api/admin/sso/roles
2775
4474
  */
2776
- create: async (input, orgSlug) => {
4475
+ create: async (input, orgId) => {
2777
4476
  return request(apiUrl, "/api/admin/sso/roles", {
2778
4477
  method: "POST",
2779
- headers: buildHeaders(orgSlug),
4478
+ headers: buildHeaders(orgId),
2780
4479
  body: JSON.stringify(input)
2781
4480
  });
2782
4481
  },
@@ -2784,10 +4483,10 @@ function createRoleService(config) {
2784
4483
  * Update role (admin only)
2785
4484
  * PUT /api/admin/sso/roles/{id}
2786
4485
  */
2787
- update: async (id, input, orgSlug) => {
4486
+ update: async (id, input, orgId) => {
2788
4487
  return request(apiUrl, `/api/admin/sso/roles/${id}`, {
2789
4488
  method: "PUT",
2790
- headers: buildHeaders(orgSlug),
4489
+ headers: buildHeaders(orgId),
2791
4490
  body: JSON.stringify(input)
2792
4491
  });
2793
4492
  },
@@ -2795,36 +4494,36 @@ function createRoleService(config) {
2795
4494
  * Delete role (admin only)
2796
4495
  * DELETE /api/admin/sso/roles/{id}
2797
4496
  */
2798
- delete: async (id, orgSlug) => {
4497
+ delete: async (id, orgId) => {
2799
4498
  return request(apiUrl, `/api/admin/sso/roles/${id}`, {
2800
4499
  method: "DELETE",
2801
- headers: buildHeaders(orgSlug)
4500
+ headers: buildHeaders(orgId)
2802
4501
  });
2803
4502
  },
2804
4503
  /**
2805
4504
  * Get role's permissions (admin)
2806
4505
  * GET /api/admin/sso/roles/{id}/permissions
2807
4506
  */
2808
- getPermissions: async (id, orgSlug) => {
4507
+ getPermissions: async (id, orgId) => {
2809
4508
  return request(apiUrl, `/api/admin/sso/roles/${id}/permissions`, {
2810
- headers: buildHeaders(orgSlug)
4509
+ headers: buildHeaders(orgId)
2811
4510
  });
2812
4511
  },
2813
4512
  /**
2814
4513
  * Sync role's permissions (admin)
2815
4514
  * PUT /api/admin/sso/roles/{id}/permissions
2816
4515
  */
2817
- syncPermissions: async (id, input, orgSlug) => {
4516
+ syncPermissions: async (id, input, orgId) => {
2818
4517
  return request(apiUrl, `/api/admin/sso/roles/${id}/permissions`, {
2819
4518
  method: "PUT",
2820
- headers: buildHeaders(orgSlug),
4519
+ headers: buildHeaders(orgId),
2821
4520
  body: JSON.stringify(input)
2822
4521
  });
2823
4522
  }
2824
4523
  };
2825
4524
  }
2826
4525
 
2827
- // src/services/permissionService.ts
4526
+ // src/core/services/permissionService.ts
2828
4527
  function createPermissionService(config) {
2829
4528
  const { apiUrl } = config;
2830
4529
  return {
@@ -2859,31 +4558,31 @@ function createPermissionService(config) {
2859
4558
  * List all permissions (admin)
2860
4559
  * GET /api/admin/sso/permissions
2861
4560
  */
2862
- adminList: async (orgSlug, params) => {
4561
+ adminList: async (orgId, params) => {
2863
4562
  const queryString = params ? `?${new URLSearchParams(
2864
4563
  Object.entries(params).filter(([, v]) => v !== void 0).map(([k, v]) => [k, String(v)])
2865
4564
  )}` : "";
2866
4565
  return request(apiUrl, `/api/admin/sso/permissions${queryString}`, {
2867
- headers: buildHeaders(orgSlug)
4566
+ headers: buildHeaders(orgId)
2868
4567
  });
2869
4568
  },
2870
4569
  /**
2871
4570
  * Get single permission (admin)
2872
4571
  * GET /api/admin/sso/permissions/{id}
2873
4572
  */
2874
- adminGet: async (id, orgSlug) => {
4573
+ adminGet: async (id, orgId) => {
2875
4574
  return request(apiUrl, `/api/admin/sso/permissions/${id}`, {
2876
- headers: buildHeaders(orgSlug)
4575
+ headers: buildHeaders(orgId)
2877
4576
  });
2878
4577
  },
2879
4578
  /**
2880
4579
  * Create permission (admin only)
2881
4580
  * POST /api/admin/sso/permissions
2882
4581
  */
2883
- create: async (input, orgSlug) => {
4582
+ create: async (input, orgId) => {
2884
4583
  return request(apiUrl, "/api/admin/sso/permissions", {
2885
4584
  method: "POST",
2886
- headers: buildHeaders(orgSlug),
4585
+ headers: buildHeaders(orgId),
2887
4586
  body: JSON.stringify(input)
2888
4587
  });
2889
4588
  },
@@ -2891,10 +4590,10 @@ function createPermissionService(config) {
2891
4590
  * Update permission (admin only)
2892
4591
  * PUT /api/admin/sso/permissions/{id}
2893
4592
  */
2894
- update: async (id, input, orgSlug) => {
4593
+ update: async (id, input, orgId) => {
2895
4594
  return request(apiUrl, `/api/admin/sso/permissions/${id}`, {
2896
4595
  method: "PUT",
2897
- headers: buildHeaders(orgSlug),
4596
+ headers: buildHeaders(orgId),
2898
4597
  body: JSON.stringify(input)
2899
4598
  });
2900
4599
  },
@@ -2902,25 +4601,25 @@ function createPermissionService(config) {
2902
4601
  * Delete permission (admin only)
2903
4602
  * DELETE /api/admin/sso/permissions/{id}
2904
4603
  */
2905
- delete: async (id, orgSlug) => {
4604
+ delete: async (id, orgId) => {
2906
4605
  return request(apiUrl, `/api/admin/sso/permissions/${id}`, {
2907
4606
  method: "DELETE",
2908
- headers: buildHeaders(orgSlug)
4607
+ headers: buildHeaders(orgId)
2909
4608
  });
2910
4609
  },
2911
4610
  /**
2912
4611
  * Get permission matrix (admin)
2913
4612
  * GET /api/admin/sso/permission-matrix
2914
4613
  */
2915
- adminGetMatrix: async (orgSlug) => {
4614
+ adminGetMatrix: async (orgId) => {
2916
4615
  return request(apiUrl, "/api/admin/sso/permission-matrix", {
2917
- headers: buildHeaders(orgSlug)
4616
+ headers: buildHeaders(orgId)
2918
4617
  });
2919
4618
  }
2920
4619
  };
2921
4620
  }
2922
4621
 
2923
- // src/services/teamService.ts
4622
+ // src/core/services/teamService.ts
2924
4623
  function createTeamService(config) {
2925
4624
  const { apiUrl } = config;
2926
4625
  return {
@@ -2928,28 +4627,28 @@ function createTeamService(config) {
2928
4627
  * Get all teams with their permissions (admin only)
2929
4628
  * GET /api/admin/sso/teams/permissions
2930
4629
  */
2931
- list: async (orgSlug) => {
4630
+ list: async (orgId) => {
2932
4631
  return request(apiUrl, "/api/admin/sso/teams/permissions", {
2933
- headers: buildHeaders(orgSlug)
4632
+ headers: buildHeaders(orgId)
2934
4633
  });
2935
4634
  },
2936
4635
  /**
2937
4636
  * Get specific team permissions (admin only)
2938
4637
  * GET /api/admin/sso/teams/{teamId}/permissions
2939
4638
  */
2940
- getPermissions: async (teamId, orgSlug) => {
4639
+ getPermissions: async (teamId, orgId) => {
2941
4640
  return request(apiUrl, `/api/admin/sso/teams/${teamId}/permissions`, {
2942
- headers: buildHeaders(orgSlug)
4641
+ headers: buildHeaders(orgId)
2943
4642
  });
2944
4643
  },
2945
4644
  /**
2946
4645
  * Sync team permissions (admin only)
2947
4646
  * PUT /api/admin/sso/teams/{teamId}/permissions
2948
4647
  */
2949
- syncPermissions: async (teamId, input, orgSlug) => {
4648
+ syncPermissions: async (teamId, input, orgId) => {
2950
4649
  return request(apiUrl, `/api/admin/sso/teams/${teamId}/permissions`, {
2951
4650
  method: "PUT",
2952
- headers: buildHeaders(orgSlug),
4651
+ headers: buildHeaders(orgId),
2953
4652
  body: JSON.stringify(input)
2954
4653
  });
2955
4654
  },
@@ -2957,46 +4656,46 @@ function createTeamService(config) {
2957
4656
  * Remove all permissions for a team (admin only)
2958
4657
  * DELETE /api/admin/sso/teams/{teamId}/permissions
2959
4658
  */
2960
- removePermissions: async (teamId, orgSlug) => {
4659
+ removePermissions: async (teamId, orgId) => {
2961
4660
  return request(apiUrl, `/api/admin/sso/teams/${teamId}/permissions`, {
2962
4661
  method: "DELETE",
2963
- headers: buildHeaders(orgSlug)
4662
+ headers: buildHeaders(orgId)
2964
4663
  });
2965
4664
  },
2966
4665
  /**
2967
4666
  * List orphaned team permissions (admin only)
2968
4667
  * GET /api/admin/sso/teams/orphaned
2969
4668
  */
2970
- listOrphaned: async (orgSlug) => {
4669
+ listOrphaned: async (orgId) => {
2971
4670
  return request(apiUrl, "/api/admin/sso/teams/orphaned", {
2972
- headers: buildHeaders(orgSlug)
4671
+ headers: buildHeaders(orgId)
2973
4672
  });
2974
4673
  },
2975
4674
  /**
2976
4675
  * Restore orphaned team permissions (admin only)
2977
4676
  * POST /api/admin/sso/teams/orphaned/{teamId}/restore
2978
4677
  */
2979
- restoreOrphaned: async (teamId, orgSlug) => {
4678
+ restoreOrphaned: async (teamId, orgId) => {
2980
4679
  return request(apiUrl, `/api/admin/sso/teams/orphaned/${teamId}/restore`, {
2981
4680
  method: "POST",
2982
- headers: buildHeaders(orgSlug)
4681
+ headers: buildHeaders(orgId)
2983
4682
  });
2984
4683
  },
2985
4684
  /**
2986
4685
  * Cleanup orphaned team permissions (admin only)
2987
4686
  * DELETE /api/admin/sso/teams/orphaned
2988
4687
  */
2989
- cleanupOrphaned: async (orgSlug, input) => {
4688
+ cleanupOrphaned: async (orgId, input) => {
2990
4689
  return request(apiUrl, "/api/admin/sso/teams/orphaned", {
2991
4690
  method: "DELETE",
2992
- headers: buildHeaders(orgSlug),
4691
+ headers: buildHeaders(orgId),
2993
4692
  body: input ? JSON.stringify(input) : void 0
2994
4693
  });
2995
4694
  }
2996
4695
  };
2997
4696
  }
2998
4697
 
2999
- // src/services/userRoleService.ts
4698
+ // src/core/services/userRoleService.ts
3000
4699
  function createUserRoleService(config) {
3001
4700
  const { apiUrl } = config;
3002
4701
  return {
@@ -3004,11 +4703,11 @@ function createUserRoleService(config) {
3004
4703
  * List user's role assignments with scope information
3005
4704
  * GET /api/admin/sso/users/{userId}/roles
3006
4705
  */
3007
- list: async (userId, orgSlug) => {
4706
+ list: async (userId, orgId) => {
3008
4707
  const response = await request(
3009
4708
  apiUrl,
3010
4709
  `/api/admin/sso/users/${userId}/roles`,
3011
- { headers: buildHeaders(orgSlug) }
4710
+ { headers: buildHeaders(orgId) }
3012
4711
  );
3013
4712
  return response.data;
3014
4713
  },
@@ -3016,15 +4715,15 @@ function createUserRoleService(config) {
3016
4715
  * List user's role assignments filtered by branch context
3017
4716
  * Returns roles applicable to the given org/branch
3018
4717
  */
3019
- listByBranch: async (userId, orgId, branchId, orgSlug) => {
4718
+ listByBranch: async (userId, consoleOrgId, branchId, orgId) => {
3020
4719
  const all = await request(
3021
4720
  apiUrl,
3022
4721
  `/api/admin/sso/users/${userId}/roles`,
3023
- { headers: buildHeaders(orgSlug) }
4722
+ { headers: buildHeaders(orgId) }
3024
4723
  );
3025
4724
  return all.data.filter((a) => {
3026
4725
  if (a.console_org_id === null) return true;
3027
- if (a.console_org_id !== orgId) return false;
4726
+ if (a.console_org_id !== consoleOrgId) return false;
3028
4727
  if (a.console_branch_id === null) return true;
3029
4728
  return a.console_branch_id === branchId;
3030
4729
  });
@@ -3033,13 +4732,13 @@ function createUserRoleService(config) {
3033
4732
  * Assign a role to user with scope
3034
4733
  * POST /api/admin/sso/users/{userId}/roles
3035
4734
  */
3036
- assign: async (userId, input, orgSlug) => {
4735
+ assign: async (userId, input, orgId) => {
3037
4736
  return request(
3038
4737
  apiUrl,
3039
4738
  `/api/admin/sso/users/${userId}/roles`,
3040
4739
  {
3041
4740
  method: "POST",
3042
- headers: buildHeaders(orgSlug),
4741
+ headers: buildHeaders(orgId),
3043
4742
  body: JSON.stringify(input)
3044
4743
  }
3045
4744
  );
@@ -3048,15 +4747,15 @@ function createUserRoleService(config) {
3048
4747
  * Remove a role assignment from user
3049
4748
  * DELETE /api/admin/sso/users/{userId}/roles/{roleId}
3050
4749
  */
3051
- remove: async (userId, roleId, orgId, branchId, orgSlug) => {
4750
+ remove: async (userId, roleId, consoleOrgId, branchId, orgId) => {
3052
4751
  return request(
3053
4752
  apiUrl,
3054
4753
  `/api/admin/sso/users/${userId}/roles/${roleId}`,
3055
4754
  {
3056
4755
  method: "DELETE",
3057
- headers: buildHeaders(orgSlug),
4756
+ headers: buildHeaders(orgId),
3058
4757
  body: JSON.stringify({
3059
- console_org_id: orgId ?? null,
4758
+ console_org_id: consoleOrgId ?? null,
3060
4759
  console_branch_id: branchId ?? null
3061
4760
  })
3062
4761
  }
@@ -3066,13 +4765,13 @@ function createUserRoleService(config) {
3066
4765
  * Sync roles for user in a specific scope
3067
4766
  * PUT /api/admin/sso/users/{userId}/roles/sync
3068
4767
  */
3069
- sync: async (userId, input, orgSlug) => {
4768
+ sync: async (userId, input, orgId) => {
3070
4769
  return request(
3071
4770
  apiUrl,
3072
4771
  `/api/admin/sso/users/${userId}/roles/sync`,
3073
4772
  {
3074
4773
  method: "PUT",
3075
- headers: buildHeaders(orgSlug),
4774
+ headers: buildHeaders(orgId),
3076
4775
  body: JSON.stringify(input)
3077
4776
  }
3078
4777
  );
@@ -3110,97 +4809,64 @@ var getEffectivePermissions = (roleAssignments, allRoles, orgId, branchId) => {
3110
4809
  return Array.from(permissions);
3111
4810
  };
3112
4811
 
3113
- // src/services/userService.ts
4812
+ // src/core/services/userService.ts
3114
4813
  function createUserService(config) {
3115
4814
  const { apiUrl } = config;
3116
- const basePath = "/api/admin/sso/users";
3117
4815
  return {
3118
4816
  /**
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
4817
+ * List users with optional filters
4818
+ * GET /api/admin/sso/users
3137
4819
  */
3138
- async get(id, orgSlug) {
3139
- const response = await request(apiUrl, `${basePath}/${id}`, {
3140
- method: "GET",
3141
- headers: buildHeaders(orgSlug)
3142
- });
3143
- return response.data;
3144
- },
3145
- /**
3146
- * Update a user
3147
- */
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;
3155
- },
3156
- /**
3157
- * Delete a user
3158
- */
3159
- async delete(id, orgSlug) {
3160
- await request(apiUrl, `${basePath}/${id}`, {
3161
- method: "DELETE",
3162
- headers: buildHeaders(orgSlug)
4820
+ list: async (params, orgId) => {
4821
+ const queryParams = new URLSearchParams();
4822
+ if (params) {
4823
+ Object.entries(params).forEach(([key, value]) => {
4824
+ if (value !== void 0 && value !== null) {
4825
+ queryParams.append(key, String(value));
4826
+ }
4827
+ });
4828
+ }
4829
+ const query = queryParams.toString();
4830
+ const url = `/api/admin/sso/users${query ? `?${query}` : ""}`;
4831
+ return request(apiUrl, url, {
4832
+ headers: buildHeaders(orgId)
3163
4833
  });
3164
4834
  },
3165
4835
  /**
3166
- * Search users by email (autocomplete)
4836
+ * Get single user by ID
4837
+ * GET /api/admin/sso/users/{userId}
3167
4838
  */
3168
- async search(email, orgSlug) {
3169
- if (email.length < 2) return [];
4839
+ get: async (userId, orgId) => {
3170
4840
  const response = await request(
3171
4841
  apiUrl,
3172
- `${basePath}/search?email=${encodeURIComponent(email)}`,
3173
- {
3174
- method: "GET",
3175
- headers: buildHeaders(orgSlug)
3176
- }
4842
+ `/api/admin/sso/users/${userId}`,
4843
+ { headers: buildHeaders(orgId) }
3177
4844
  );
3178
4845
  return response.data;
3179
4846
  },
3180
4847
  /**
3181
- * Get user permissions breakdown
3182
- * Shows roles, teams, and aggregated permissions for a user in context
4848
+ * Get user permissions breakdown for specific org/branch context
4849
+ * GET /api/admin/sso/users/{userId}/permissions
3183
4850
  */
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)
4851
+ getPermissions: async (userId, consoleOrgId, branchId, orgId) => {
4852
+ const queryParams = new URLSearchParams();
4853
+ if (consoleOrgId) queryParams.append("org_id", consoleOrgId);
4854
+ if (branchId) queryParams.append("branch_id", branchId);
4855
+ const query = queryParams.toString();
4856
+ const url = `/api/admin/sso/users/${userId}/permissions${query ? `?${query}` : ""}`;
4857
+ return request(apiUrl, url, {
4858
+ headers: buildHeaders(orgId)
3193
4859
  });
3194
4860
  }
3195
4861
  };
3196
4862
  }
3197
4863
 
3198
- // src/services/ssoService.ts
4864
+ // src/core/services/ssoService.ts
3199
4865
  function getXsrfToken3() {
3200
4866
  if (typeof document === "undefined") return void 0;
3201
4867
  return document.cookie.split("; ").find((row) => row.startsWith("XSRF-TOKEN="))?.split("=")[1];
3202
4868
  }
3203
- function buildHeaders2(orgSlug) {
4869
+ function buildHeaders2(orgId) {
3204
4870
  const headers = {
3205
4871
  "Content-Type": "application/json",
3206
4872
  Accept: "application/json"
@@ -3209,8 +4875,8 @@ function buildHeaders2(orgSlug) {
3209
4875
  if (xsrfToken) {
3210
4876
  headers["X-XSRF-TOKEN"] = decodeURIComponent(xsrfToken);
3211
4877
  }
3212
- if (orgSlug) {
3213
- headers["X-Org-Id"] = orgSlug;
4878
+ if (orgId) {
4879
+ headers["X-Organization-Id"] = orgId;
3214
4880
  }
3215
4881
  return headers;
3216
4882
  }
@@ -3364,28 +5030,28 @@ function createSsoService(config) {
3364
5030
  * List all roles (admin)
3365
5031
  * GET /api/admin/sso/roles
3366
5032
  */
3367
- adminGetRoles: async (orgSlug) => {
5033
+ adminGetRoles: async (orgId) => {
3368
5034
  return request2(apiUrl, "/api/admin/sso/roles", {
3369
- headers: buildHeaders2(orgSlug)
5035
+ headers: buildHeaders2(orgId)
3370
5036
  });
3371
5037
  },
3372
5038
  /**
3373
5039
  * Get single role (admin)
3374
5040
  * GET /api/admin/sso/roles/{id}
3375
5041
  */
3376
- adminGetRole: async (id, orgSlug) => {
5042
+ adminGetRole: async (id, orgId) => {
3377
5043
  return request2(apiUrl, `/api/admin/sso/roles/${id}`, {
3378
- headers: buildHeaders2(orgSlug)
5044
+ headers: buildHeaders2(orgId)
3379
5045
  });
3380
5046
  },
3381
5047
  /**
3382
5048
  * Create role (admin only)
3383
5049
  * POST /api/admin/sso/roles
3384
5050
  */
3385
- createRole: async (input, orgSlug) => {
5051
+ createRole: async (input, orgId) => {
3386
5052
  return request2(apiUrl, "/api/admin/sso/roles", {
3387
5053
  method: "POST",
3388
- headers: buildHeaders2(orgSlug),
5054
+ headers: buildHeaders2(orgId),
3389
5055
  body: JSON.stringify(input)
3390
5056
  });
3391
5057
  },
@@ -3393,10 +5059,10 @@ function createSsoService(config) {
3393
5059
  * Update role (admin only)
3394
5060
  * PUT /api/admin/sso/roles/{id}
3395
5061
  */
3396
- updateRole: async (id, input, orgSlug) => {
5062
+ updateRole: async (id, input, orgId) => {
3397
5063
  return request2(apiUrl, `/api/admin/sso/roles/${id}`, {
3398
5064
  method: "PUT",
3399
- headers: buildHeaders2(orgSlug),
5065
+ headers: buildHeaders2(orgId),
3400
5066
  body: JSON.stringify(input)
3401
5067
  });
3402
5068
  },
@@ -3404,29 +5070,29 @@ function createSsoService(config) {
3404
5070
  * Delete role (admin only)
3405
5071
  * DELETE /api/admin/sso/roles/{id}
3406
5072
  */
3407
- deleteRole: async (id, orgSlug) => {
5073
+ deleteRole: async (id, orgId) => {
3408
5074
  return request2(apiUrl, `/api/admin/sso/roles/${id}`, {
3409
5075
  method: "DELETE",
3410
- headers: buildHeaders2(orgSlug)
5076
+ headers: buildHeaders2(orgId)
3411
5077
  });
3412
5078
  },
3413
5079
  /**
3414
5080
  * Get role's permissions (admin)
3415
5081
  * GET /api/admin/sso/roles/{id}/permissions
3416
5082
  */
3417
- getRolePermissions: async (id, orgSlug) => {
5083
+ getRolePermissions: async (id, orgId) => {
3418
5084
  return request2(apiUrl, `/api/admin/sso/roles/${id}/permissions`, {
3419
- headers: buildHeaders2(orgSlug)
5085
+ headers: buildHeaders2(orgId)
3420
5086
  });
3421
5087
  },
3422
5088
  /**
3423
5089
  * Sync role's permissions (admin)
3424
5090
  * PUT /api/admin/sso/roles/{id}/permissions
3425
5091
  */
3426
- syncRolePermissions: async (id, input, orgSlug) => {
5092
+ syncRolePermissions: async (id, input, orgId) => {
3427
5093
  return request2(apiUrl, `/api/admin/sso/roles/${id}/permissions`, {
3428
5094
  method: "PUT",
3429
- headers: buildHeaders2(orgSlug),
5095
+ headers: buildHeaders2(orgId),
3430
5096
  body: JSON.stringify(input)
3431
5097
  });
3432
5098
  },
@@ -3437,31 +5103,31 @@ function createSsoService(config) {
3437
5103
  * List all permissions (admin)
3438
5104
  * GET /api/admin/sso/permissions
3439
5105
  */
3440
- adminGetPermissions: async (orgSlug, params) => {
5106
+ adminGetPermissions: async (orgId, params) => {
3441
5107
  const queryString = params ? `?${new URLSearchParams(
3442
5108
  Object.entries(params).filter(([, v]) => v !== void 0).map(([k, v]) => [k, String(v)])
3443
5109
  )}` : "";
3444
5110
  return request2(apiUrl, `/api/admin/sso/permissions${queryString}`, {
3445
- headers: buildHeaders2(orgSlug)
5111
+ headers: buildHeaders2(orgId)
3446
5112
  });
3447
5113
  },
3448
5114
  /**
3449
5115
  * Get single permission (admin)
3450
5116
  * GET /api/admin/sso/permissions/{id}
3451
5117
  */
3452
- adminGetPermission: async (id, orgSlug) => {
5118
+ adminGetPermission: async (id, orgId) => {
3453
5119
  return request2(apiUrl, `/api/admin/sso/permissions/${id}`, {
3454
- headers: buildHeaders2(orgSlug)
5120
+ headers: buildHeaders2(orgId)
3455
5121
  });
3456
5122
  },
3457
5123
  /**
3458
5124
  * Create permission (admin only)
3459
5125
  * POST /api/admin/sso/permissions
3460
5126
  */
3461
- createPermission: async (input, orgSlug) => {
5127
+ createPermission: async (input, orgId) => {
3462
5128
  return request2(apiUrl, "/api/admin/sso/permissions", {
3463
5129
  method: "POST",
3464
- headers: buildHeaders2(orgSlug),
5130
+ headers: buildHeaders2(orgId),
3465
5131
  body: JSON.stringify(input)
3466
5132
  });
3467
5133
  },
@@ -3469,10 +5135,10 @@ function createSsoService(config) {
3469
5135
  * Update permission (admin only)
3470
5136
  * PUT /api/admin/sso/permissions/{id}
3471
5137
  */
3472
- updatePermission: async (id, input, orgSlug) => {
5138
+ updatePermission: async (id, input, orgId) => {
3473
5139
  return request2(apiUrl, `/api/admin/sso/permissions/${id}`, {
3474
5140
  method: "PUT",
3475
- headers: buildHeaders2(orgSlug),
5141
+ headers: buildHeaders2(orgId),
3476
5142
  body: JSON.stringify(input)
3477
5143
  });
3478
5144
  },
@@ -3480,19 +5146,19 @@ function createSsoService(config) {
3480
5146
  * Delete permission (admin only)
3481
5147
  * DELETE /api/admin/sso/permissions/{id}
3482
5148
  */
3483
- deletePermission: async (id, orgSlug) => {
5149
+ deletePermission: async (id, orgId) => {
3484
5150
  return request2(apiUrl, `/api/admin/sso/permissions/${id}`, {
3485
5151
  method: "DELETE",
3486
- headers: buildHeaders2(orgSlug)
5152
+ headers: buildHeaders2(orgId)
3487
5153
  });
3488
5154
  },
3489
5155
  /**
3490
5156
  * Get permission matrix (admin)
3491
5157
  * GET /api/admin/sso/permission-matrix
3492
5158
  */
3493
- adminGetPermissionMatrix: async (orgSlug) => {
5159
+ adminGetPermissionMatrix: async (orgId) => {
3494
5160
  return request2(apiUrl, "/api/admin/sso/permission-matrix", {
3495
- headers: buildHeaders2(orgSlug)
5161
+ headers: buildHeaders2(orgId)
3496
5162
  });
3497
5163
  },
3498
5164
  // =========================================================================
@@ -3502,28 +5168,28 @@ function createSsoService(config) {
3502
5168
  * Get all teams with their permissions (admin only)
3503
5169
  * GET /api/admin/sso/teams/permissions
3504
5170
  */
3505
- getTeamPermissions: async (orgSlug) => {
5171
+ getTeamPermissions: async (orgId) => {
3506
5172
  return request2(apiUrl, "/api/admin/sso/teams/permissions", {
3507
- headers: buildHeaders2(orgSlug)
5173
+ headers: buildHeaders2(orgId)
3508
5174
  });
3509
5175
  },
3510
5176
  /**
3511
5177
  * Get specific team permissions (admin only)
3512
5178
  * GET /api/admin/sso/teams/{teamId}/permissions
3513
5179
  */
3514
- getTeamPermission: async (teamId, orgSlug) => {
5180
+ getTeamPermission: async (teamId, orgId) => {
3515
5181
  return request2(apiUrl, `/api/admin/sso/teams/${teamId}/permissions`, {
3516
- headers: buildHeaders2(orgSlug)
5182
+ headers: buildHeaders2(orgId)
3517
5183
  });
3518
5184
  },
3519
5185
  /**
3520
5186
  * Sync team permissions (admin only)
3521
5187
  * PUT /api/admin/sso/teams/{teamId}/permissions
3522
5188
  */
3523
- syncTeamPermissions: async (teamId, input, orgSlug) => {
5189
+ syncTeamPermissions: async (teamId, input, orgId) => {
3524
5190
  return request2(apiUrl, `/api/admin/sso/teams/${teamId}/permissions`, {
3525
5191
  method: "PUT",
3526
- headers: buildHeaders2(orgSlug),
5192
+ headers: buildHeaders2(orgId),
3527
5193
  body: JSON.stringify(input)
3528
5194
  });
3529
5195
  },
@@ -3531,10 +5197,10 @@ function createSsoService(config) {
3531
5197
  * Remove all permissions for a team (admin only)
3532
5198
  * DELETE /api/admin/sso/teams/{teamId}/permissions
3533
5199
  */
3534
- removeTeamPermissions: async (teamId, orgSlug) => {
5200
+ removeTeamPermissions: async (teamId, orgId) => {
3535
5201
  return request2(apiUrl, `/api/admin/sso/teams/${teamId}/permissions`, {
3536
5202
  method: "DELETE",
3537
- headers: buildHeaders2(orgSlug)
5203
+ headers: buildHeaders2(orgId)
3538
5204
  });
3539
5205
  },
3540
5206
  // =========================================================================
@@ -3544,29 +5210,29 @@ function createSsoService(config) {
3544
5210
  * List orphaned team permissions (admin only)
3545
5211
  * GET /api/admin/sso/teams/orphaned
3546
5212
  */
3547
- getOrphanedTeamPermissions: async (orgSlug) => {
5213
+ getOrphanedTeamPermissions: async (orgId) => {
3548
5214
  return request2(apiUrl, "/api/admin/sso/teams/orphaned", {
3549
- headers: buildHeaders2(orgSlug)
5215
+ headers: buildHeaders2(orgId)
3550
5216
  });
3551
5217
  },
3552
5218
  /**
3553
5219
  * Restore orphaned team permissions (admin only)
3554
5220
  * POST /api/admin/sso/teams/orphaned/{teamId}/restore
3555
5221
  */
3556
- restoreOrphanedTeamPermissions: async (teamId, orgSlug) => {
5222
+ restoreOrphanedTeamPermissions: async (teamId, orgId) => {
3557
5223
  return request2(apiUrl, `/api/admin/sso/teams/orphaned/${teamId}/restore`, {
3558
5224
  method: "POST",
3559
- headers: buildHeaders2(orgSlug)
5225
+ headers: buildHeaders2(orgId)
3560
5226
  });
3561
5227
  },
3562
5228
  /**
3563
5229
  * Cleanup orphaned team permissions (admin only)
3564
5230
  * DELETE /api/admin/sso/teams/orphaned
3565
5231
  */
3566
- cleanupOrphanedTeamPermissions: async (orgSlug, input) => {
5232
+ cleanupOrphanedTeamPermissions: async (orgId, input) => {
3567
5233
  return request2(apiUrl, "/api/admin/sso/teams/orphaned", {
3568
5234
  method: "DELETE",
3569
- headers: buildHeaders2(orgSlug),
5235
+ headers: buildHeaders2(orgId),
3570
5236
  body: input ? JSON.stringify(input) : void 0
3571
5237
  });
3572
5238
  }
@@ -3574,19 +5240,31 @@ function createSsoService(config) {
3574
5240
  }
3575
5241
  // Annotate the CommonJS export names for ESM import in node:
3576
5242
  0 && (module.exports = {
5243
+ AntdThemeProvider,
3577
5244
  BRANCH_HEADERS,
3578
5245
  BranchContext,
3579
5246
  BranchGate,
3580
5247
  BranchProvider,
3581
5248
  I18nProvider,
5249
+ LocaleSwitcher,
3582
5250
  OrgBranchSelectorModal,
3583
5251
  OrganizationSwitcher,
5252
+ PROTABLE_DEFAULT_TEXTS,
5253
+ PageContainer,
5254
+ PermissionsListCard,
5255
+ ProTable,
3584
5256
  ProtectedRoute,
5257
+ RoleCreateModal,
5258
+ RolesListCard,
5259
+ ScopeLabel,
5260
+ ScopeTag,
3585
5261
  SsoCallback,
3586
5262
  SsoContext,
3587
5263
  SsoProvider,
3588
- UserForm,
3589
- UserTable,
5264
+ TeamsListCard,
5265
+ UserDetailCard,
5266
+ UserPermissionsModal,
5267
+ UserRoleAssignModal,
3590
5268
  branchCacheCreateSchema,
3591
5269
  branchCacheI18n,
3592
5270
  branchCacheSchemas,
@@ -3624,6 +5302,8 @@ function createSsoService(config) {
3624
5302
  getRolePermissionFieldLabel,
3625
5303
  getRolePermissionFieldPlaceholder,
3626
5304
  getRolePermissionLabel,
5305
+ getScopeColor,
5306
+ getScopeIcon,
3627
5307
  getScopeLabel,
3628
5308
  getTeamCacheFieldLabel,
3629
5309
  getTeamCacheFieldPlaceholder,