rbac-manager 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/.github/workflows/publish.yml +29 -0
  2. package/README.md +317 -2
  3. package/package.json +45 -4
  4. package/scripts/postbuild.js +17 -0
  5. package/src/config/rbac.config.ts +206 -0
  6. package/src/constants/actions.constants.ts +21 -0
  7. package/src/constants/apiKeys.constants.ts +25 -0
  8. package/src/constants/auth.constants.ts +39 -0
  9. package/src/constants/endpoints.constants.ts +66 -0
  10. package/src/constants/i18n.constants.ts +82 -0
  11. package/src/constants/index.ts +70 -0
  12. package/src/constants/masters.constants.ts +68 -0
  13. package/src/constants/permissions/index.ts +44 -0
  14. package/src/constants/permissions/masterPermissions.constants.ts +44 -0
  15. package/src/constants/permissions/rolePermissions.constants.ts +18 -0
  16. package/src/constants/permissions.constants.ts +34 -0
  17. package/src/constants/roles.constants.ts +34 -0
  18. package/src/core/adapters/authAdapter.ts +89 -0
  19. package/src/core/adapters/index.ts +17 -0
  20. package/src/core/adapters/mastersAdapter.ts +132 -0
  21. package/src/core/adapters/permissionsAdapter.ts +90 -0
  22. package/src/core/adapters/rolesAdapter.ts +115 -0
  23. package/src/core/api/httpClient.ts +296 -0
  24. package/src/core/context/PermissionContext.tsx +232 -0
  25. package/src/core/context/RBACConfigContext.tsx +52 -0
  26. package/src/core/guards/Can.tsx +98 -0
  27. package/src/core/guards/RouteGuard.tsx +42 -0
  28. package/src/core/hooks/useMaster.ts +99 -0
  29. package/src/core/hooks/usePermissions.ts +114 -0
  30. package/src/core/hooks/useRoles.ts +120 -0
  31. package/src/core/types/adapter.types.ts +54 -0
  32. package/src/core/types/auth.types.ts +44 -0
  33. package/src/core/types/index.ts +7 -0
  34. package/src/core/types/masters.types.ts +63 -0
  35. package/src/core/types/pagination.types.ts +37 -0
  36. package/src/core/types/rbac.types.ts +69 -0
  37. package/src/core/types/router.types.ts +43 -0
  38. package/src/core/types/style.types.ts +53 -0
  39. package/src/core/utils/permissionResolver.ts +44 -0
  40. package/src/index.ts +44 -0
  41. package/src/modules/masters/DepartmentMasterView.tsx +126 -0
  42. package/src/modules/masters/DesignationMasterView.tsx +97 -0
  43. package/src/modules/masters/EmployeeMasterView.tsx +107 -0
  44. package/src/modules/masters/EntityMasterView.tsx +102 -0
  45. package/src/modules/masters/ModuleMasterView.tsx +104 -0
  46. package/src/modules/masters/SubModuleMasterView.tsx +106 -0
  47. package/src/modules/masters/components/MasterDataTable.tsx +684 -0
  48. package/src/modules/masters/index.ts +7 -0
  49. package/src/modules/roles-and-permissions/components/PermissionMatrix.tsx +289 -0
  50. package/src/modules/roles-and-permissions/components/PermissionRegistry.tsx +108 -0
  51. package/src/modules/roles-and-permissions/components/RoleListTable.tsx +568 -0
  52. package/src/modules/roles-and-permissions/components/RoleModal.tsx +213 -0
  53. package/src/modules/roles-and-permissions/index.ts +4 -0
  54. package/src/shared/components/Badge.tsx +24 -0
  55. package/src/shared/components/Button.tsx +75 -0
  56. package/src/shared/components/DynamicSidebar.tsx +181 -0
  57. package/src/shared/components/Input.tsx +48 -0
  58. package/src/shared/components/Modal.tsx +70 -0
  59. package/src/shared/components/Table.tsx +345 -0
  60. package/src/styles/standalone.css +51 -0
  61. package/src/theme/ThemeContext.tsx +74 -0
  62. package/src/theme/defaultTheme.ts +81 -0
  63. package/src/theme/index.ts +3 -0
  64. package/src/theme/theme.types.ts +106 -0
  65. package/tsconfig.cjs.json +10 -0
  66. package/tsconfig.esm.json +10 -0
  67. package/tsconfig.json +28 -0
@@ -0,0 +1,568 @@
1
+ import React, { useEffect, useState, useMemo, useCallback } from 'react';
2
+ import { useRoles } from '../../../core/hooks/useRoles';
3
+ import { useRBACConfig } from '../../../core/context/RBACConfigContext';
4
+ import { isActionAllowed } from '../../../config/rbac.config';
5
+ import { StandardRole, RoleFormData } from '../../../core/types';
6
+ import { Can } from '../../../core/guards/Can';
7
+ import { Table, Column, TableProps, BatchAction } from '../../../shared/components/Table';
8
+ import { Button } from '../../../shared/components/Button';
9
+ import { Badge } from '../../../shared/components/Badge';
10
+ import { Modal } from '../../../shared/components/Modal';
11
+ import { RoleModal } from './RoleModal';
12
+ import { PermissionMatrix } from './PermissionMatrix';
13
+ import { RoleListTableClassNames } from '../../../core/types/style.types';
14
+ import { RBAC_CONSTANTS } from '../../../constants';
15
+
16
+ export interface RoleListTableProps {
17
+ title?: string;
18
+ description?: string;
19
+ entities?: Array<{ id: string | number; name: string }>;
20
+ departments?: Array<{ id: string | number; name: string }>;
21
+
22
+ // Dynamic Action Toggles
23
+ allowAdd?: boolean;
24
+ allowEdit?: boolean;
25
+ allowDelete?: boolean;
26
+ allowPermissions?: boolean;
27
+
28
+ // Custom permission key overrides (e.g. if backend uses 'roles.addition')
29
+ permissionKeys?: {
30
+ view?: string;
31
+ add?: string;
32
+ edit?: string;
33
+ delete?: string;
34
+ assign?: string;
35
+ };
36
+
37
+ // Dynamic Column Customization
38
+ columns?: Column<StandardRole>[];
39
+ extendColumns?: Column<StandardRole>[];
40
+ omitColumns?: string[];
41
+
42
+ // Custom row actions
43
+ customActions?: Array<{
44
+ key: string;
45
+ label: string;
46
+ icon?: React.ReactNode;
47
+ onClick: (role: StandardRole) => void;
48
+ }>;
49
+
50
+ // Sorting Customization (Opt-in)
51
+ defaultSortBy?: string;
52
+ defaultSortOrder?: 'asc' | 'desc';
53
+
54
+ // Bulk Row Selection & Batch Actions (Opt-in)
55
+ selectable?: boolean;
56
+ batchActions?: BatchAction<StandardRole>[];
57
+
58
+ // URL Query Sync (Deep linking - Opt-in)
59
+ syncWithUrl?: boolean;
60
+
61
+ // Complete Style Overrides
62
+ classNames?: RoleListTableClassNames;
63
+ unstyled?: boolean;
64
+
65
+ // Slot / Render Props
66
+ renderHeader?: (props: {
67
+ title: string;
68
+ description?: string;
69
+ canAdd: boolean;
70
+ onOpenCreate: () => void;
71
+ }) => React.ReactNode;
72
+ renderSearch?: (props: {
73
+ search: string;
74
+ onSearchChange: (value: string) => void;
75
+ placeholder: string;
76
+ }) => React.ReactNode;
77
+ renderTable?: (props: TableProps<StandardRole>) => React.ReactNode;
78
+ }
79
+
80
+ export const RoleListTable: React.FC<RoleListTableProps> = ({
81
+ title = 'Roles & Permissions',
82
+ description = 'Manage organizational roles, assign granular permissions, and configure access scopes.',
83
+ entities = [],
84
+ departments = [],
85
+ allowAdd: propAllowAdd,
86
+ allowEdit: propAllowEdit,
87
+ allowDelete: propAllowDelete,
88
+ allowPermissions: propAllowPermissions,
89
+ permissionKeys,
90
+ columns: customColumns,
91
+ extendColumns = [],
92
+ omitColumns = [],
93
+ customActions = [],
94
+ defaultSortBy,
95
+ defaultSortOrder,
96
+ selectable = false,
97
+ batchActions,
98
+ syncWithUrl = false,
99
+ classNames,
100
+ unstyled = false,
101
+ renderHeader,
102
+ renderSearch,
103
+ renderTable,
104
+ }) => {
105
+ const { config } = useRBACConfig();
106
+ const i18n = RBAC_CONSTANTS.i18n;
107
+ const { roles, total, page, limit, isLoading, fetchRoles, createRole, editRole, deleteRole } = useRoles();
108
+
109
+ // Resolve actions permission from props OR central config
110
+ const roleCrudConfig = config.features.rolesAndPermissions.roleCrud;
111
+ const canAdd = propAllowAdd !== undefined ? propAllowAdd : isActionAllowed(roleCrudConfig, 'add');
112
+ const canEdit = propAllowEdit !== undefined ? propAllowEdit : isActionAllowed(roleCrudConfig, 'edit');
113
+ const canDelete = propAllowDelete !== undefined ? propAllowDelete : isActionAllowed(roleCrudConfig, 'delete');
114
+ const canManagePermissions =
115
+ propAllowPermissions !== undefined
116
+ ? propAllowPermissions
117
+ : config.features.rolesAndPermissions.permissionAssignmentMatrix;
118
+
119
+ // URL query sync initialization (if syncWithUrl is active)
120
+ const initialUrlParams = useMemo(() => {
121
+ if (!syncWithUrl || typeof window === 'undefined') return {};
122
+ const sp = new URLSearchParams(window.location.search);
123
+ return {
124
+ search: sp.get('search') || '',
125
+ sortBy: sp.get('sortBy') || defaultSortBy,
126
+ sortOrder: (sp.get('sortOrder') as 'asc' | 'desc') || defaultSortOrder,
127
+ page: sp.get('page') ? Number(sp.get('page')) : undefined,
128
+ };
129
+ }, [syncWithUrl, defaultSortBy, defaultSortOrder]);
130
+
131
+ const [search, setSearch] = useState<string>(initialUrlParams.search || '');
132
+ const [sortBy, setSortBy] = useState<string | undefined>(initialUrlParams.sortBy);
133
+ const [sortOrder, setSortOrder] = useState<'asc' | 'desc' | undefined>(initialUrlParams.sortOrder);
134
+ const [selectedIds, setSelectedIds] = useState<(string | number)[]>([]);
135
+
136
+ const [isRoleModalOpen, setIsRoleModalOpen] = useState<boolean>(false);
137
+ const [editingRole, setEditingRole] = useState<StandardRole | null>(null);
138
+ const [matrixRole, setMatrixRole] = useState<StandardRole | null>(null);
139
+ const [deleteTargetRole, setDeleteTargetRole] = useState<StandardRole | null>(null);
140
+
141
+ // Synchronize state with URL query parameters when enabled
142
+ const updateUrlParams = useCallback(
143
+ (params: Record<string, string | number | undefined>) => {
144
+ if (!syncWithUrl || typeof window === 'undefined') return;
145
+ const url = new URL(window.location.href);
146
+ Object.entries(params).forEach(([k, v]) => {
147
+ if (v !== undefined && v !== '' && v !== null) {
148
+ url.searchParams.set(k, String(v));
149
+ } else {
150
+ url.searchParams.delete(k);
151
+ }
152
+ });
153
+ window.history.replaceState({}, '', url.toString());
154
+ },
155
+ [syncWithUrl]
156
+ );
157
+
158
+ useEffect(() => {
159
+ const fetchParams: Record<string, any> = {
160
+ page: initialUrlParams.page || 1,
161
+ limit: 10,
162
+ search,
163
+ };
164
+ if (sortBy) fetchParams.sortBy = sortBy;
165
+ if (sortOrder) fetchParams.sortOrder = sortOrder;
166
+
167
+ fetchRoles(fetchParams);
168
+ updateUrlParams({
169
+ search,
170
+ sortBy,
171
+ sortOrder,
172
+ page: initialUrlParams.page || 1,
173
+ });
174
+ }, [fetchRoles, search, sortBy, sortOrder, initialUrlParams.page, updateUrlParams]);
175
+
176
+ const handleCreateOrUpdate = async (formData: RoleFormData) => {
177
+ try {
178
+ if (editingRole) {
179
+ await editRole(editingRole.id, formData);
180
+ if (config.onNotification) {
181
+ config.onNotification({
182
+ type: 'success',
183
+ title: i18n.success || 'Success',
184
+ message: `Role "${formData.role_name}" updated successfully`,
185
+ });
186
+ }
187
+ } else {
188
+ await createRole(formData);
189
+ if (config.onNotification) {
190
+ config.onNotification({
191
+ type: 'success',
192
+ title: i18n.success || 'Success',
193
+ message: `Role "${formData.role_name}" created successfully`,
194
+ });
195
+ }
196
+ }
197
+ } catch (err: any) {
198
+ if (config.onNotification) {
199
+ config.onNotification({
200
+ type: 'error',
201
+ title: i18n.error || 'Error',
202
+ message: err.message || 'Failed to save role',
203
+ });
204
+ }
205
+ throw err;
206
+ }
207
+ };
208
+
209
+ const handleDeleteConfirm = async () => {
210
+ if (!deleteTargetRole) return;
211
+ try {
212
+ await deleteRole(deleteTargetRole.id);
213
+ if (config.onNotification) {
214
+ config.onNotification({
215
+ type: 'success',
216
+ title: i18n.success || 'Success',
217
+ message: `Role "${deleteTargetRole.name}" deleted successfully`,
218
+ });
219
+ }
220
+ setDeleteTargetRole(null);
221
+ setSelectedIds((prev) => prev.filter((id) => id !== deleteTargetRole.id));
222
+ } catch (err: any) {
223
+ if (config.onNotification) {
224
+ config.onNotification({
225
+ type: 'error',
226
+ title: i18n.error || 'Error',
227
+ message: err.message || 'Delete role failed',
228
+ });
229
+ }
230
+ }
231
+ };
232
+
233
+ const handleBatchDelete = async (ids: (string | number)[]) => {
234
+ if (!window.confirm(`Are you sure you want to delete ${ids.length} roles?`)) return;
235
+ try {
236
+ await Promise.all(ids.map((id) => deleteRole(id)));
237
+ if (config.onNotification) {
238
+ config.onNotification({
239
+ type: 'success',
240
+ title: i18n.success || 'Success',
241
+ message: `${ids.length} roles deleted successfully`,
242
+ });
243
+ }
244
+ setSelectedIds([]);
245
+ } catch (err: any) {
246
+ if (config.onNotification) {
247
+ config.onNotification({
248
+ type: 'error',
249
+ title: i18n.error || 'Error',
250
+ message: err.message || 'Batch delete failed',
251
+ });
252
+ }
253
+ }
254
+ };
255
+
256
+ const effectiveBatchActions: BatchAction<StandardRole>[] = useMemo(() => {
257
+ if (batchActions) return batchActions;
258
+ if (canDelete) {
259
+ return [
260
+ {
261
+ key: 'batch-delete',
262
+ label: i18n.delete || 'Delete',
263
+ variant: 'danger',
264
+ onClick: handleBatchDelete,
265
+ },
266
+ ];
267
+ }
268
+ return [];
269
+ }, [batchActions, canDelete, i18n.delete]);
270
+
271
+ const defaultColumns: Column<StandardRole>[] = [
272
+ {
273
+ key: 'name',
274
+ header: 'Role Name',
275
+ sortable: true,
276
+ render: (role) => (
277
+ <div>
278
+ <div className="font-semibold text-gray-900">{role.name}</div>
279
+ <div className="text-xs text-gray-400 font-mono">{role.key}</div>
280
+ </div>
281
+ ),
282
+ },
283
+ {
284
+ key: 'scope',
285
+ header: 'Scope',
286
+ render: (role) => (
287
+ <div className="text-xs text-gray-600">
288
+ <div>Entity: {role.entityName || 'Global'}</div>
289
+ {role.departmentName && <div>Dept: {role.departmentName}</div>}
290
+ </div>
291
+ ),
292
+ },
293
+ {
294
+ key: 'description',
295
+ header: 'Description',
296
+ render: (role) => <span className="text-xs text-gray-500">{role.description || '—'}</span>,
297
+ },
298
+ {
299
+ key: 'status',
300
+ header: 'Status',
301
+ align: 'center',
302
+ sortable: true,
303
+ render: (role) => (
304
+ <Badge variant={role.isActive ? 'success' : 'neutral'}>
305
+ {role.isActive ? 'Active' : 'Inactive'}
306
+ </Badge>
307
+ ),
308
+ },
309
+ ];
310
+
311
+ const computedColumns = useMemo<Column<StandardRole>[]>(() => {
312
+ let base = customColumns || defaultColumns;
313
+ if (omitColumns.length > 0) {
314
+ base = base.filter((c) => !omitColumns.includes(c.key));
315
+ }
316
+ const combined = [...base, ...extendColumns];
317
+
318
+ const hasActions = canEdit || canDelete || canManagePermissions || customActions.length > 0;
319
+ if (!hasActions) return combined;
320
+
321
+ return [
322
+ ...combined,
323
+ {
324
+ key: '_actions',
325
+ header: i18n.actions || 'Actions',
326
+ align: 'right',
327
+ render: (role: StandardRole) => (
328
+ <div className="flex items-center justify-end gap-1.5">
329
+ {customActions.map((ca) => (
330
+ <Button
331
+ key={ca.key}
332
+ variant="ghost"
333
+ size="sm"
334
+ onClick={() => ca.onClick(role)}
335
+ >
336
+ {ca.icon} {ca.label}
337
+ </Button>
338
+ ))}
339
+
340
+ {canManagePermissions && (
341
+ <Can
342
+ do={permissionKeys?.assign}
343
+ module={!permissionKeys?.assign ? 'roles' : undefined}
344
+ action={!permissionKeys?.assign ? 'assign' : undefined}
345
+ >
346
+ <Button
347
+ variant="outline"
348
+ size="sm"
349
+ onClick={() => setMatrixRole(role)}
350
+ >
351
+ Permissions
352
+ </Button>
353
+ </Can>
354
+ )}
355
+
356
+ {canEdit && (
357
+ <Can
358
+ do={permissionKeys?.edit}
359
+ module={!permissionKeys?.edit ? 'roles' : undefined}
360
+ action={!permissionKeys?.edit ? 'edit' : undefined}
361
+ >
362
+ <Button
363
+ variant="ghost"
364
+ size="sm"
365
+ onClick={() => {
366
+ setEditingRole(role);
367
+ setIsRoleModalOpen(true);
368
+ }}
369
+ >
370
+ {i18n.edit || 'Edit'}
371
+ </Button>
372
+ </Can>
373
+ )}
374
+
375
+ {canDelete && (
376
+ <Can
377
+ do={permissionKeys?.delete}
378
+ module={!permissionKeys?.delete ? 'roles' : undefined}
379
+ action={!permissionKeys?.delete ? 'delete' : undefined}
380
+ >
381
+ <Button
382
+ variant="ghost"
383
+ size="sm"
384
+ className="text-red-600 hover:bg-red-50"
385
+ onClick={() => setDeleteTargetRole(role)}
386
+ >
387
+ {i18n.delete || 'Delete'}
388
+ </Button>
389
+ </Can>
390
+ )}
391
+ </div>
392
+ ),
393
+ },
394
+ ];
395
+ }, [
396
+ customColumns,
397
+ defaultColumns,
398
+ omitColumns,
399
+ extendColumns,
400
+ canEdit,
401
+ canDelete,
402
+ canManagePermissions,
403
+ customActions,
404
+ permissionKeys,
405
+ i18n,
406
+ ]);
407
+
408
+ const tableProps: TableProps<StandardRole> = {
409
+ columns: computedColumns,
410
+ data: roles,
411
+ isLoading,
412
+ classNames: classNames?.table,
413
+ unstyled,
414
+ sortBy,
415
+ sortOrder,
416
+ onSortChange: (newSortBy, newSortOrder) => {
417
+ setSortBy(newSortBy);
418
+ setSortOrder(newSortOrder);
419
+ },
420
+ selectable,
421
+ selectedIds,
422
+ onSelectRow: (id) => {
423
+ setSelectedIds((prev) => (prev.includes(id) ? prev.filter((x) => x !== id) : [...prev, id]));
424
+ },
425
+ onSelectAll: (checked) => {
426
+ setSelectedIds(checked ? roles.map((r) => r.id) : []);
427
+ },
428
+ batchActions: effectiveBatchActions,
429
+ pagination: {
430
+ page,
431
+ limit,
432
+ total,
433
+ onPageChange: (newPage) => {
434
+ fetchRoles({ page: newPage, limit, search, sortBy, sortOrder });
435
+ updateUrlParams({ page: newPage });
436
+ },
437
+ },
438
+ };
439
+
440
+ return (
441
+ <div className={classNames?.root || (unstyled ? '' : 'space-y-4')}>
442
+ {/* Top Header */}
443
+ {renderHeader ? (
444
+ renderHeader({
445
+ title,
446
+ description,
447
+ canAdd,
448
+ onOpenCreate: () => {
449
+ setEditingRole(null);
450
+ setIsRoleModalOpen(true);
451
+ },
452
+ })
453
+ ) : (
454
+ <div
455
+ className={
456
+ classNames?.header?.container ||
457
+ (unstyled ? '' : 'flex flex-col sm:flex-row sm:items-center justify-between gap-4')
458
+ }
459
+ >
460
+ <div>
461
+ <h2 className={classNames?.header?.title || (unstyled ? '' : 'text-xl font-bold text-gray-900')}>
462
+ {title}
463
+ </h2>
464
+ <p className={classNames?.header?.description || (unstyled ? '' : 'text-xs text-gray-500 mt-1')}>
465
+ {description}
466
+ </p>
467
+ </div>
468
+
469
+ {canAdd && (
470
+ <Can
471
+ do={permissionKeys?.add}
472
+ module={!permissionKeys?.add ? 'roles' : undefined}
473
+ action={!permissionKeys?.add ? 'add' : undefined}
474
+ >
475
+ <Button
476
+ variant="primary"
477
+ className={classNames?.header?.createButton}
478
+ onClick={() => {
479
+ setEditingRole(null);
480
+ setIsRoleModalOpen(true);
481
+ }}
482
+ >
483
+ + {i18n.create || 'Create Role'}
484
+ </Button>
485
+ </Can>
486
+ )}
487
+ </div>
488
+ )}
489
+
490
+ {/* Filter / Search Bar */}
491
+ {renderSearch ? (
492
+ renderSearch({
493
+ search,
494
+ onSearchChange: setSearch,
495
+ placeholder: `${i18n.search || 'Search'} roles...`,
496
+ })
497
+ ) : (
498
+ <div className={classNames?.search?.container || (unstyled ? '' : 'flex items-center gap-3')}>
499
+ <input
500
+ type="text"
501
+ placeholder={`${i18n.search || 'Search'} roles...`}
502
+ value={search}
503
+ onChange={(e) => setSearch(e.target.value)}
504
+ className={
505
+ classNames?.search?.input ||
506
+ (unstyled
507
+ ? ''
508
+ : 'w-full sm:w-72 px-3.5 py-2 border border-gray-300 rounded-lg text-sm bg-white focus:outline-none focus:ring-2 focus:ring-[#28518F]')
509
+ }
510
+ />
511
+ </div>
512
+ )}
513
+
514
+ {/* Table: Slot or Default Table */}
515
+ {renderTable ? renderTable(tableProps) : <Table {...tableProps} />}
516
+
517
+ {/* Create / Edit Role Modal */}
518
+ <RoleModal
519
+ isOpen={isRoleModalOpen}
520
+ onClose={() => setIsRoleModalOpen(false)}
521
+ onSubmit={handleCreateOrUpdate}
522
+ initialData={editingRole}
523
+ entities={entities}
524
+ departments={departments}
525
+ />
526
+
527
+ {/* Permission Assignment Matrix Modal */}
528
+ <Modal
529
+ isOpen={Boolean(matrixRole)}
530
+ onClose={() => setMatrixRole(null)}
531
+ title={`Permissions Matrix: ${matrixRole?.name}`}
532
+ description="Toggle checkboxes to configure granular actions allowed for this role."
533
+ maxWidth="4xl"
534
+ >
535
+ {matrixRole && (
536
+ <PermissionMatrix
537
+ role={matrixRole}
538
+ onSuccess={() => {}}
539
+ onCancel={() => setMatrixRole(null)}
540
+ />
541
+ )}
542
+ </Modal>
543
+
544
+ {/* Delete Confirmation Modal */}
545
+ <Modal
546
+ isOpen={Boolean(deleteTargetRole)}
547
+ onClose={() => setDeleteTargetRole(null)}
548
+ title="Delete Role"
549
+ maxWidth="sm"
550
+ >
551
+ <div className="space-y-3">
552
+ <p className="text-sm text-gray-600">
553
+ Are you sure you want to delete role <strong>{deleteTargetRole?.name}</strong>? Users assigned to this
554
+ role may lose access.
555
+ </p>
556
+ <div className="flex justify-end gap-2 pt-2">
557
+ <Button variant="outline" onClick={() => setDeleteTargetRole(null)}>
558
+ {i18n.cancel || 'Cancel'}
559
+ </Button>
560
+ <Button variant="danger" onClick={handleDeleteConfirm}>
561
+ {i18n.confirm || 'Yes, Delete'}
562
+ </Button>
563
+ </div>
564
+ </div>
565
+ </Modal>
566
+ </div>
567
+ );
568
+ };