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.
- package/.github/workflows/publish.yml +29 -0
- package/README.md +317 -2
- package/package.json +45 -4
- package/scripts/postbuild.js +17 -0
- package/src/config/rbac.config.ts +206 -0
- package/src/constants/actions.constants.ts +21 -0
- package/src/constants/apiKeys.constants.ts +25 -0
- package/src/constants/auth.constants.ts +39 -0
- package/src/constants/endpoints.constants.ts +66 -0
- package/src/constants/i18n.constants.ts +82 -0
- package/src/constants/index.ts +70 -0
- package/src/constants/masters.constants.ts +68 -0
- package/src/constants/permissions/index.ts +44 -0
- package/src/constants/permissions/masterPermissions.constants.ts +44 -0
- package/src/constants/permissions/rolePermissions.constants.ts +18 -0
- package/src/constants/permissions.constants.ts +34 -0
- package/src/constants/roles.constants.ts +34 -0
- package/src/core/adapters/authAdapter.ts +89 -0
- package/src/core/adapters/index.ts +17 -0
- package/src/core/adapters/mastersAdapter.ts +132 -0
- package/src/core/adapters/permissionsAdapter.ts +90 -0
- package/src/core/adapters/rolesAdapter.ts +115 -0
- package/src/core/api/httpClient.ts +296 -0
- package/src/core/context/PermissionContext.tsx +232 -0
- package/src/core/context/RBACConfigContext.tsx +52 -0
- package/src/core/guards/Can.tsx +98 -0
- package/src/core/guards/RouteGuard.tsx +42 -0
- package/src/core/hooks/useMaster.ts +99 -0
- package/src/core/hooks/usePermissions.ts +114 -0
- package/src/core/hooks/useRoles.ts +120 -0
- package/src/core/types/adapter.types.ts +54 -0
- package/src/core/types/auth.types.ts +44 -0
- package/src/core/types/index.ts +7 -0
- package/src/core/types/masters.types.ts +63 -0
- package/src/core/types/pagination.types.ts +37 -0
- package/src/core/types/rbac.types.ts +69 -0
- package/src/core/types/router.types.ts +43 -0
- package/src/core/types/style.types.ts +53 -0
- package/src/core/utils/permissionResolver.ts +44 -0
- package/src/index.ts +44 -0
- package/src/modules/masters/DepartmentMasterView.tsx +126 -0
- package/src/modules/masters/DesignationMasterView.tsx +97 -0
- package/src/modules/masters/EmployeeMasterView.tsx +107 -0
- package/src/modules/masters/EntityMasterView.tsx +102 -0
- package/src/modules/masters/ModuleMasterView.tsx +104 -0
- package/src/modules/masters/SubModuleMasterView.tsx +106 -0
- package/src/modules/masters/components/MasterDataTable.tsx +684 -0
- package/src/modules/masters/index.ts +7 -0
- package/src/modules/roles-and-permissions/components/PermissionMatrix.tsx +289 -0
- package/src/modules/roles-and-permissions/components/PermissionRegistry.tsx +108 -0
- package/src/modules/roles-and-permissions/components/RoleListTable.tsx +568 -0
- package/src/modules/roles-and-permissions/components/RoleModal.tsx +213 -0
- package/src/modules/roles-and-permissions/index.ts +4 -0
- package/src/shared/components/Badge.tsx +24 -0
- package/src/shared/components/Button.tsx +75 -0
- package/src/shared/components/DynamicSidebar.tsx +181 -0
- package/src/shared/components/Input.tsx +48 -0
- package/src/shared/components/Modal.tsx +70 -0
- package/src/shared/components/Table.tsx +345 -0
- package/src/styles/standalone.css +51 -0
- package/src/theme/ThemeContext.tsx +74 -0
- package/src/theme/defaultTheme.ts +81 -0
- package/src/theme/index.ts +3 -0
- package/src/theme/theme.types.ts +106 -0
- package/tsconfig.cjs.json +10 -0
- package/tsconfig.esm.json +10 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MasterDataTable, FormField, CustomAction } from './components/MasterDataTable';
|
|
3
|
+
import { useMaster } from '../../core/hooks/useMaster';
|
|
4
|
+
import { useRBACConfig } from '../../core/context/RBACConfigContext';
|
|
5
|
+
import { StandardDepartmentMaster } from '../../core/types';
|
|
6
|
+
import { Column, TableProps } from '../../shared/components/Table';
|
|
7
|
+
import { Badge } from '../../shared/components/Badge';
|
|
8
|
+
import { MasterDataTableClassNames } from '../../core/types/style.types';
|
|
9
|
+
|
|
10
|
+
export interface DepartmentMasterViewProps {
|
|
11
|
+
allowAdd?: boolean;
|
|
12
|
+
allowEdit?: boolean;
|
|
13
|
+
allowDelete?: boolean;
|
|
14
|
+
allowSearch?: boolean;
|
|
15
|
+
columns?: Column<StandardDepartmentMaster>[];
|
|
16
|
+
extendColumns?: Column<StandardDepartmentMaster>[];
|
|
17
|
+
omitColumns?: string[];
|
|
18
|
+
formFields?: FormField[];
|
|
19
|
+
extendFormFields?: FormField[];
|
|
20
|
+
omitFormFields?: string[];
|
|
21
|
+
customActions?: CustomAction<StandardDepartmentMaster>[];
|
|
22
|
+
title?: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
|
|
25
|
+
// Complete Style Overrides
|
|
26
|
+
classNames?: MasterDataTableClassNames;
|
|
27
|
+
unstyled?: boolean;
|
|
28
|
+
|
|
29
|
+
// Slot / Render Props
|
|
30
|
+
renderHeader?: (props: {
|
|
31
|
+
title: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
canAdd: boolean;
|
|
34
|
+
onOpenCreate: () => void;
|
|
35
|
+
}) => React.ReactNode;
|
|
36
|
+
renderSearch?: (props: {
|
|
37
|
+
search: string;
|
|
38
|
+
onSearchChange: (value: string) => void;
|
|
39
|
+
placeholder: string;
|
|
40
|
+
}) => React.ReactNode;
|
|
41
|
+
renderTable?: (props: TableProps<StandardDepartmentMaster>) => React.ReactNode;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const DepartmentMasterView: React.FC<DepartmentMasterViewProps> = ({
|
|
45
|
+
allowAdd,
|
|
46
|
+
allowEdit,
|
|
47
|
+
allowDelete,
|
|
48
|
+
allowSearch,
|
|
49
|
+
columns: customColumns,
|
|
50
|
+
extendColumns,
|
|
51
|
+
omitColumns,
|
|
52
|
+
formFields: customFormFields,
|
|
53
|
+
extendFormFields,
|
|
54
|
+
omitFormFields,
|
|
55
|
+
customActions,
|
|
56
|
+
title = 'Department Master',
|
|
57
|
+
description = 'Manage corporate and branch departments.',
|
|
58
|
+
classNames,
|
|
59
|
+
unstyled = false,
|
|
60
|
+
renderHeader,
|
|
61
|
+
renderSearch,
|
|
62
|
+
renderTable,
|
|
63
|
+
}) => {
|
|
64
|
+
const { config } = useRBACConfig();
|
|
65
|
+
|
|
66
|
+
const useDeptHook = () =>
|
|
67
|
+
useMaster<StandardDepartmentMaster>({
|
|
68
|
+
listEndpoint: config.endpoints.DEPARTMENT_LIST,
|
|
69
|
+
createEndpoint: config.endpoints.DEPARTMENT_CREATE,
|
|
70
|
+
editEndpoint: config.endpoints.DEPARTMENT_EDIT,
|
|
71
|
+
deleteEndpoint: config.endpoints.DEPARTMENT_DELETE,
|
|
72
|
+
transformer: config.adapters.masters.transformDepartmentListResponse,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const defaultColumns: Column<StandardDepartmentMaster>[] = [
|
|
76
|
+
{
|
|
77
|
+
key: 'name',
|
|
78
|
+
header: 'Department Name',
|
|
79
|
+
render: (item) => <span className="font-semibold text-gray-900">{item.name}</span>,
|
|
80
|
+
},
|
|
81
|
+
{ key: 'code', header: 'Department Code' },
|
|
82
|
+
{ key: 'entityName', header: 'Entity' },
|
|
83
|
+
{
|
|
84
|
+
key: 'status',
|
|
85
|
+
header: 'Status',
|
|
86
|
+
align: 'center',
|
|
87
|
+
render: (item) => (
|
|
88
|
+
<Badge variant={item.isActive ? 'success' : 'neutral'}>
|
|
89
|
+
{item.isActive ? 'Active' : 'Inactive'}
|
|
90
|
+
</Badge>
|
|
91
|
+
),
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
const defaultFormFields: FormField[] = [
|
|
96
|
+
{ name: 'department_name', label: 'Department Name', required: true, placeholder: 'e.g. Human Resource' },
|
|
97
|
+
{ name: 'department_code', label: 'Department Code', placeholder: 'e.g. HR-01' },
|
|
98
|
+
{ name: 'is_active', label: 'Active', type: 'checkbox', defaultValue: true },
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<MasterDataTable
|
|
103
|
+
title={title}
|
|
104
|
+
description={description}
|
|
105
|
+
permissionPrefix="department_master"
|
|
106
|
+
featureKey="department"
|
|
107
|
+
allowAdd={allowAdd}
|
|
108
|
+
allowEdit={allowEdit}
|
|
109
|
+
allowDelete={allowDelete}
|
|
110
|
+
allowSearch={allowSearch}
|
|
111
|
+
columns={customColumns || defaultColumns}
|
|
112
|
+
extendColumns={extendColumns}
|
|
113
|
+
omitColumns={omitColumns}
|
|
114
|
+
formFields={customFormFields || defaultFormFields}
|
|
115
|
+
extendFormFields={extendFormFields}
|
|
116
|
+
omitFormFields={omitFormFields}
|
|
117
|
+
customActions={customActions}
|
|
118
|
+
classNames={classNames}
|
|
119
|
+
unstyled={unstyled}
|
|
120
|
+
renderHeader={renderHeader}
|
|
121
|
+
renderSearch={renderSearch}
|
|
122
|
+
renderTable={renderTable}
|
|
123
|
+
useMasterHook={useDeptHook}
|
|
124
|
+
/>
|
|
125
|
+
);
|
|
126
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MasterDataTable, FormField, CustomAction } from './components/MasterDataTable';
|
|
3
|
+
import { useMaster } from '../../core/hooks/useMaster';
|
|
4
|
+
import { useRBACConfig } from '../../core/context/RBACConfigContext';
|
|
5
|
+
import { StandardDesignationMaster } from '../../core/types';
|
|
6
|
+
import { Column } from '../../shared/components/Table';
|
|
7
|
+
import { Badge } from '../../shared/components/Badge';
|
|
8
|
+
|
|
9
|
+
export interface DesignationMasterViewProps {
|
|
10
|
+
allowAdd?: boolean;
|
|
11
|
+
allowEdit?: boolean;
|
|
12
|
+
allowDelete?: boolean;
|
|
13
|
+
allowSearch?: boolean;
|
|
14
|
+
columns?: Column<StandardDesignationMaster>[];
|
|
15
|
+
extendColumns?: Column<StandardDesignationMaster>[];
|
|
16
|
+
omitColumns?: string[];
|
|
17
|
+
formFields?: FormField[];
|
|
18
|
+
extendFormFields?: FormField[];
|
|
19
|
+
omitFormFields?: string[];
|
|
20
|
+
customActions?: CustomAction<StandardDesignationMaster>[];
|
|
21
|
+
title?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const DesignationMasterView: React.FC<DesignationMasterViewProps> = ({
|
|
26
|
+
allowAdd,
|
|
27
|
+
allowEdit,
|
|
28
|
+
allowDelete,
|
|
29
|
+
allowSearch,
|
|
30
|
+
columns: customColumns,
|
|
31
|
+
extendColumns,
|
|
32
|
+
omitColumns,
|
|
33
|
+
formFields: customFormFields,
|
|
34
|
+
extendFormFields,
|
|
35
|
+
omitFormFields,
|
|
36
|
+
customActions,
|
|
37
|
+
title = 'Designation Master',
|
|
38
|
+
description = 'Manage organizational job titles and designations.',
|
|
39
|
+
}) => {
|
|
40
|
+
const { config } = useRBACConfig();
|
|
41
|
+
|
|
42
|
+
const useDesigHook = () =>
|
|
43
|
+
useMaster<StandardDesignationMaster>({
|
|
44
|
+
listEndpoint: config.endpoints.DESIGNATION_LIST,
|
|
45
|
+
createEndpoint: config.endpoints.DESIGNATION_CREATE,
|
|
46
|
+
editEndpoint: config.endpoints.DESIGNATION_EDIT,
|
|
47
|
+
deleteEndpoint: config.endpoints.DESIGNATION_DELETE,
|
|
48
|
+
transformer: config.adapters.masters.transformDesignationListResponse,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const defaultColumns: Column<StandardDesignationMaster>[] = [
|
|
52
|
+
{
|
|
53
|
+
key: 'name',
|
|
54
|
+
header: 'Designation Name',
|
|
55
|
+
render: (item) => <span className="font-semibold text-gray-900">{item.name}</span>,
|
|
56
|
+
},
|
|
57
|
+
{ key: 'code', header: 'Designation Code' },
|
|
58
|
+
{ key: 'departmentName', header: 'Department' },
|
|
59
|
+
{
|
|
60
|
+
key: 'status',
|
|
61
|
+
header: 'Status',
|
|
62
|
+
align: 'center',
|
|
63
|
+
render: (item) => (
|
|
64
|
+
<Badge variant={item.isActive ? 'success' : 'neutral'}>
|
|
65
|
+
{item.isActive ? 'Active' : 'Inactive'}
|
|
66
|
+
</Badge>
|
|
67
|
+
),
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
const defaultFormFields: FormField[] = [
|
|
72
|
+
{ name: 'designation_name', label: 'Designation Name', required: true, placeholder: 'e.g. Senior Software Engineer' },
|
|
73
|
+
{ name: 'designation_code', label: 'Designation Code', placeholder: 'e.g. DES-SE-02' },
|
|
74
|
+
{ name: 'is_active', label: 'Active', type: 'checkbox', defaultValue: true },
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<MasterDataTable
|
|
79
|
+
title={title}
|
|
80
|
+
description={description}
|
|
81
|
+
permissionPrefix="designation_master"
|
|
82
|
+
featureKey="designation"
|
|
83
|
+
allowAdd={allowAdd}
|
|
84
|
+
allowEdit={allowEdit}
|
|
85
|
+
allowDelete={allowDelete}
|
|
86
|
+
allowSearch={allowSearch}
|
|
87
|
+
columns={customColumns || defaultColumns}
|
|
88
|
+
extendColumns={extendColumns}
|
|
89
|
+
omitColumns={omitColumns}
|
|
90
|
+
formFields={customFormFields || defaultFormFields}
|
|
91
|
+
extendFormFields={extendFormFields}
|
|
92
|
+
omitFormFields={omitFormFields}
|
|
93
|
+
customActions={customActions}
|
|
94
|
+
useMasterHook={useDesigHook}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MasterDataTable, FormField, CustomAction } from './components/MasterDataTable';
|
|
3
|
+
import { useMaster } from '../../core/hooks/useMaster';
|
|
4
|
+
import { useRBACConfig } from '../../core/context/RBACConfigContext';
|
|
5
|
+
import { StandardEmployeeMaster } from '../../core/types';
|
|
6
|
+
import { Column } from '../../shared/components/Table';
|
|
7
|
+
import { Badge } from '../../shared/components/Badge';
|
|
8
|
+
|
|
9
|
+
export interface EmployeeMasterViewProps {
|
|
10
|
+
allowAdd?: boolean;
|
|
11
|
+
allowEdit?: boolean;
|
|
12
|
+
allowDelete?: boolean;
|
|
13
|
+
allowSearch?: boolean;
|
|
14
|
+
columns?: Column<StandardEmployeeMaster>[];
|
|
15
|
+
extendColumns?: Column<StandardEmployeeMaster>[];
|
|
16
|
+
omitColumns?: string[];
|
|
17
|
+
formFields?: FormField[];
|
|
18
|
+
extendFormFields?: FormField[];
|
|
19
|
+
omitFormFields?: string[];
|
|
20
|
+
customActions?: CustomAction<StandardEmployeeMaster>[];
|
|
21
|
+
title?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const EmployeeMasterView: React.FC<EmployeeMasterViewProps> = ({
|
|
26
|
+
allowAdd,
|
|
27
|
+
allowEdit,
|
|
28
|
+
allowDelete,
|
|
29
|
+
allowSearch,
|
|
30
|
+
columns: customColumns,
|
|
31
|
+
extendColumns,
|
|
32
|
+
omitColumns,
|
|
33
|
+
formFields: customFormFields,
|
|
34
|
+
extendFormFields,
|
|
35
|
+
omitFormFields,
|
|
36
|
+
customActions,
|
|
37
|
+
title = 'Employee Master',
|
|
38
|
+
description = 'Manage personnel records, roles, departments, and credentials.',
|
|
39
|
+
}) => {
|
|
40
|
+
const { config } = useRBACConfig();
|
|
41
|
+
|
|
42
|
+
const useEmpHook = () =>
|
|
43
|
+
useMaster<StandardEmployeeMaster>({
|
|
44
|
+
listEndpoint: config.endpoints.EMPLOYEE_LIST,
|
|
45
|
+
createEndpoint: config.endpoints.EMPLOYEE_CREATE,
|
|
46
|
+
editEndpoint: config.endpoints.EMPLOYEE_EDIT,
|
|
47
|
+
deleteEndpoint: config.endpoints.EMPLOYEE_DELETE,
|
|
48
|
+
transformer: config.adapters.masters.transformEmployeeListResponse,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const defaultColumns: Column<StandardEmployeeMaster>[] = [
|
|
52
|
+
{
|
|
53
|
+
key: 'fullName',
|
|
54
|
+
header: 'Employee',
|
|
55
|
+
render: (item) => (
|
|
56
|
+
<div>
|
|
57
|
+
<div className="font-semibold text-gray-900">{item.fullName}</div>
|
|
58
|
+
<div className="text-xs text-gray-500">{item.email}</div>
|
|
59
|
+
</div>
|
|
60
|
+
),
|
|
61
|
+
},
|
|
62
|
+
{ key: 'employeeCode', header: 'Emp Code' },
|
|
63
|
+
{ key: 'departmentName', header: 'Department' },
|
|
64
|
+
{ key: 'designationName', header: 'Designation' },
|
|
65
|
+
{ key: 'roleName', header: 'Assigned Role' },
|
|
66
|
+
{
|
|
67
|
+
key: 'status',
|
|
68
|
+
header: 'Status',
|
|
69
|
+
align: 'center',
|
|
70
|
+
render: (item) => (
|
|
71
|
+
<Badge variant={item.isActive ? 'success' : 'neutral'}>
|
|
72
|
+
{item.isActive ? 'Active' : 'Inactive'}
|
|
73
|
+
</Badge>
|
|
74
|
+
),
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
const defaultFormFields: FormField[] = [
|
|
79
|
+
{ name: 'firstName', label: 'First Name', required: true, placeholder: 'e.g. Rahul' },
|
|
80
|
+
{ name: 'lastName', label: 'Last Name', required: true, placeholder: 'e.g. Verma' },
|
|
81
|
+
{ name: 'email', label: 'Email Address', type: 'email', required: true, placeholder: 'rahul@example.com' },
|
|
82
|
+
{ name: 'mobile_number', label: 'Mobile Number', placeholder: '9876543210' },
|
|
83
|
+
{ name: 'employee_code', label: 'Employee Code', placeholder: 'EMP-0102' },
|
|
84
|
+
{ name: 'is_active', label: 'Active', type: 'checkbox', defaultValue: true },
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<MasterDataTable
|
|
89
|
+
title={title}
|
|
90
|
+
description={description}
|
|
91
|
+
permissionPrefix="employee_master"
|
|
92
|
+
featureKey="employee"
|
|
93
|
+
allowAdd={allowAdd}
|
|
94
|
+
allowEdit={allowEdit}
|
|
95
|
+
allowDelete={allowDelete}
|
|
96
|
+
allowSearch={allowSearch}
|
|
97
|
+
columns={customColumns || defaultColumns}
|
|
98
|
+
extendColumns={extendColumns}
|
|
99
|
+
omitColumns={omitColumns}
|
|
100
|
+
formFields={customFormFields || defaultFormFields}
|
|
101
|
+
extendFormFields={extendFormFields}
|
|
102
|
+
omitFormFields={omitFormFields}
|
|
103
|
+
customActions={customActions}
|
|
104
|
+
useMasterHook={useEmpHook}
|
|
105
|
+
/>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MasterDataTable, FormField, CustomAction } from './components/MasterDataTable';
|
|
3
|
+
import { useMaster } from '../../core/hooks/useMaster';
|
|
4
|
+
import { useRBACConfig } from '../../core/context/RBACConfigContext';
|
|
5
|
+
import { StandardEntityMaster } from '../../core/types';
|
|
6
|
+
import { Column } from '../../shared/components/Table';
|
|
7
|
+
import { Badge } from '../../shared/components/Badge';
|
|
8
|
+
|
|
9
|
+
export interface EntityMasterViewProps {
|
|
10
|
+
allowAdd?: boolean;
|
|
11
|
+
allowEdit?: boolean;
|
|
12
|
+
allowDelete?: boolean;
|
|
13
|
+
allowSearch?: boolean;
|
|
14
|
+
columns?: Column<StandardEntityMaster>[];
|
|
15
|
+
extendColumns?: Column<StandardEntityMaster>[];
|
|
16
|
+
omitColumns?: string[];
|
|
17
|
+
formFields?: FormField[];
|
|
18
|
+
extendFormFields?: FormField[];
|
|
19
|
+
omitFormFields?: string[];
|
|
20
|
+
customActions?: CustomAction<StandardEntityMaster>[];
|
|
21
|
+
title?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const EntityMasterView: React.FC<EntityMasterViewProps> = ({
|
|
26
|
+
allowAdd,
|
|
27
|
+
allowEdit,
|
|
28
|
+
allowDelete,
|
|
29
|
+
allowSearch,
|
|
30
|
+
columns: customColumns,
|
|
31
|
+
extendColumns,
|
|
32
|
+
omitColumns,
|
|
33
|
+
formFields: customFormFields,
|
|
34
|
+
extendFormFields,
|
|
35
|
+
omitFormFields,
|
|
36
|
+
customActions,
|
|
37
|
+
title = 'Entity Master',
|
|
38
|
+
description = 'Manage business entities, branches, and regional distribution centers.',
|
|
39
|
+
}) => {
|
|
40
|
+
const { config } = useRBACConfig();
|
|
41
|
+
|
|
42
|
+
const useEntityHook = () =>
|
|
43
|
+
useMaster<StandardEntityMaster>({
|
|
44
|
+
listEndpoint: config.endpoints.ENTITY_LIST,
|
|
45
|
+
createEndpoint: config.endpoints.ENTITY_CREATE,
|
|
46
|
+
editEndpoint: config.endpoints.ENTITY_EDIT,
|
|
47
|
+
deleteEndpoint: config.endpoints.ENTITY_DELETE,
|
|
48
|
+
transformer: config.adapters.masters.transformEntityListResponse,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const defaultColumns: Column<StandardEntityMaster>[] = [
|
|
52
|
+
{
|
|
53
|
+
key: 'name',
|
|
54
|
+
header: 'Entity Name',
|
|
55
|
+
render: (item) => <span className="font-semibold text-gray-900">{item.name}</span>,
|
|
56
|
+
},
|
|
57
|
+
{ key: 'code', header: 'Entity Code' },
|
|
58
|
+
{ key: 'city', header: 'City' },
|
|
59
|
+
{ key: 'state', header: 'State' },
|
|
60
|
+
{ key: 'pincode', header: 'Pincode' },
|
|
61
|
+
{
|
|
62
|
+
key: 'status',
|
|
63
|
+
header: 'Status',
|
|
64
|
+
align: 'center',
|
|
65
|
+
render: (item) => (
|
|
66
|
+
<Badge variant={item.isActive ? 'success' : 'neutral'}>
|
|
67
|
+
{item.isActive ? 'Active' : 'Inactive'}
|
|
68
|
+
</Badge>
|
|
69
|
+
),
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
const defaultFormFields: FormField[] = [
|
|
74
|
+
{ name: 'entity_name', label: 'Entity Name', required: true, placeholder: 'e.g. Eastern Distribution' },
|
|
75
|
+
{ name: 'entity_code', label: 'Entity Code', placeholder: 'e.g. ENT-EAST-01' },
|
|
76
|
+
{ name: 'state', label: 'State', placeholder: 'e.g. Delhi' },
|
|
77
|
+
{ name: 'city', label: 'City', placeholder: 'e.g. New Delhi' },
|
|
78
|
+
{ name: 'pincode', label: 'Pincode', placeholder: 'e.g. 110001' },
|
|
79
|
+
{ name: 'is_active', label: 'Active', type: 'checkbox', defaultValue: true },
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<MasterDataTable
|
|
84
|
+
title={title}
|
|
85
|
+
description={description}
|
|
86
|
+
permissionPrefix="entity_master"
|
|
87
|
+
featureKey="entity"
|
|
88
|
+
allowAdd={allowAdd}
|
|
89
|
+
allowEdit={allowEdit}
|
|
90
|
+
allowDelete={allowDelete}
|
|
91
|
+
allowSearch={allowSearch}
|
|
92
|
+
columns={customColumns || defaultColumns}
|
|
93
|
+
extendColumns={extendColumns}
|
|
94
|
+
omitColumns={omitColumns}
|
|
95
|
+
formFields={customFormFields || defaultFormFields}
|
|
96
|
+
extendFormFields={extendFormFields}
|
|
97
|
+
omitFormFields={omitFormFields}
|
|
98
|
+
customActions={customActions}
|
|
99
|
+
useMasterHook={useEntityHook}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MasterDataTable, FormField, CustomAction } from './components/MasterDataTable';
|
|
3
|
+
import { useMaster } from '../../core/hooks/useMaster';
|
|
4
|
+
import { useRBACConfig } from '../../core/context/RBACConfigContext';
|
|
5
|
+
import { StandardModuleMasterItem } from '../../core/types';
|
|
6
|
+
import { Column } from '../../shared/components/Table';
|
|
7
|
+
import { Badge } from '../../shared/components/Badge';
|
|
8
|
+
|
|
9
|
+
export interface ModuleMasterViewProps {
|
|
10
|
+
allowAdd?: boolean;
|
|
11
|
+
allowEdit?: boolean;
|
|
12
|
+
allowDelete?: boolean;
|
|
13
|
+
allowSearch?: boolean;
|
|
14
|
+
columns?: Column<StandardModuleMasterItem>[];
|
|
15
|
+
extendColumns?: Column<StandardModuleMasterItem>[];
|
|
16
|
+
omitColumns?: string[];
|
|
17
|
+
formFields?: FormField[];
|
|
18
|
+
extendFormFields?: FormField[];
|
|
19
|
+
omitFormFields?: string[];
|
|
20
|
+
customActions?: CustomAction<StandardModuleMasterItem>[];
|
|
21
|
+
title?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const ModuleMasterView: React.FC<ModuleMasterViewProps> = ({
|
|
26
|
+
allowAdd,
|
|
27
|
+
allowEdit,
|
|
28
|
+
allowDelete,
|
|
29
|
+
allowSearch,
|
|
30
|
+
columns: customColumns,
|
|
31
|
+
extendColumns,
|
|
32
|
+
omitColumns,
|
|
33
|
+
formFields: customFormFields,
|
|
34
|
+
extendFormFields,
|
|
35
|
+
omitFormFields,
|
|
36
|
+
customActions,
|
|
37
|
+
title = 'Module Master',
|
|
38
|
+
description = 'Manage top-level navigation and system modules.',
|
|
39
|
+
}) => {
|
|
40
|
+
const { config } = useRBACConfig();
|
|
41
|
+
|
|
42
|
+
const useModHook = () =>
|
|
43
|
+
useMaster<StandardModuleMasterItem>({
|
|
44
|
+
listEndpoint: config.endpoints.PERMISSIONS_MODULES_PARENTS,
|
|
45
|
+
createEndpoint: config.endpoints.PERMISSIONS_MODULE_CREATE,
|
|
46
|
+
editEndpoint: config.endpoints.PERMISSIONS_MODULE_EDIT,
|
|
47
|
+
deleteEndpoint: config.endpoints.PERMISSIONS_MODULE_DELETE,
|
|
48
|
+
transformer: config.adapters.masters.transformModuleMasterListResponse,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const defaultColumns: Column<StandardModuleMasterItem>[] = [
|
|
52
|
+
{
|
|
53
|
+
key: 'name',
|
|
54
|
+
header: 'Module Name',
|
|
55
|
+
render: (item) => (
|
|
56
|
+
<div>
|
|
57
|
+
<span className="font-semibold text-gray-900">{item.name}</span>
|
|
58
|
+
<div className="text-xs text-gray-400 font-mono">{item.slug}</div>
|
|
59
|
+
</div>
|
|
60
|
+
),
|
|
61
|
+
},
|
|
62
|
+
{ key: 'routePath', header: 'Route Path' },
|
|
63
|
+
{ key: 'sortOrder', header: 'Sort Order', align: 'center' },
|
|
64
|
+
{
|
|
65
|
+
key: 'status',
|
|
66
|
+
header: 'Status',
|
|
67
|
+
align: 'center',
|
|
68
|
+
render: (item) => (
|
|
69
|
+
<Badge variant={item.isActive ? 'success' : 'neutral'}>
|
|
70
|
+
{item.isActive ? 'Active' : 'Inactive'}
|
|
71
|
+
</Badge>
|
|
72
|
+
),
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
const defaultFormFields: FormField[] = [
|
|
77
|
+
{ name: 'name', label: 'Module Name', required: true, placeholder: 'e.g. Sales Management' },
|
|
78
|
+
{ name: 'slug_name', label: 'Slug Key', required: true, placeholder: 'e.g. sales_management' },
|
|
79
|
+
{ name: 'route_path', label: 'Route Path', placeholder: '/sales' },
|
|
80
|
+
{ name: 'sort_order', label: 'Sort Order', type: 'number', defaultValue: 0 },
|
|
81
|
+
{ name: 'is_active', label: 'Active', type: 'checkbox', defaultValue: true },
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<MasterDataTable
|
|
86
|
+
title={title}
|
|
87
|
+
description={description}
|
|
88
|
+
permissionPrefix="module_master"
|
|
89
|
+
featureKey="moduleMaster"
|
|
90
|
+
allowAdd={allowAdd}
|
|
91
|
+
allowEdit={allowEdit}
|
|
92
|
+
allowDelete={allowDelete}
|
|
93
|
+
allowSearch={allowSearch}
|
|
94
|
+
columns={customColumns || defaultColumns}
|
|
95
|
+
extendColumns={extendColumns}
|
|
96
|
+
omitColumns={omitColumns}
|
|
97
|
+
formFields={customFormFields || defaultFormFields}
|
|
98
|
+
extendFormFields={extendFormFields}
|
|
99
|
+
omitFormFields={omitFormFields}
|
|
100
|
+
customActions={customActions}
|
|
101
|
+
useMasterHook={useModHook}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MasterDataTable, FormField, CustomAction } from './components/MasterDataTable';
|
|
3
|
+
import { useMaster } from '../../core/hooks/useMaster';
|
|
4
|
+
import { useRBACConfig } from '../../core/context/RBACConfigContext';
|
|
5
|
+
import { StandardModuleMasterItem } from '../../core/types';
|
|
6
|
+
import { Column } from '../../shared/components/Table';
|
|
7
|
+
import { Badge } from '../../shared/components/Badge';
|
|
8
|
+
|
|
9
|
+
export interface SubModuleMasterViewProps {
|
|
10
|
+
allowAdd?: boolean;
|
|
11
|
+
allowEdit?: boolean;
|
|
12
|
+
allowDelete?: boolean;
|
|
13
|
+
allowSearch?: boolean;
|
|
14
|
+
columns?: Column<StandardModuleMasterItem>[];
|
|
15
|
+
extendColumns?: Column<StandardModuleMasterItem>[];
|
|
16
|
+
omitColumns?: string[];
|
|
17
|
+
formFields?: FormField[];
|
|
18
|
+
extendFormFields?: FormField[];
|
|
19
|
+
omitFormFields?: string[];
|
|
20
|
+
customActions?: CustomAction<StandardModuleMasterItem>[];
|
|
21
|
+
title?: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const SubModuleMasterView: React.FC<SubModuleMasterViewProps> = ({
|
|
26
|
+
allowAdd,
|
|
27
|
+
allowEdit,
|
|
28
|
+
allowDelete,
|
|
29
|
+
allowSearch,
|
|
30
|
+
columns: customColumns,
|
|
31
|
+
extendColumns,
|
|
32
|
+
omitColumns,
|
|
33
|
+
formFields: customFormFields,
|
|
34
|
+
extendFormFields,
|
|
35
|
+
omitFormFields,
|
|
36
|
+
customActions,
|
|
37
|
+
title = 'Sub-Module Master',
|
|
38
|
+
description = 'Manage child modules and feature sections within parent modules.',
|
|
39
|
+
}) => {
|
|
40
|
+
const { config } = useRBACConfig();
|
|
41
|
+
|
|
42
|
+
const useSubModHook = () =>
|
|
43
|
+
useMaster<StandardModuleMasterItem>({
|
|
44
|
+
listEndpoint: config.endpoints.PERMISSIONS_MODULES_SUBMODULES,
|
|
45
|
+
createEndpoint: config.endpoints.PERMISSIONS_MODULE_CREATE,
|
|
46
|
+
editEndpoint: config.endpoints.PERMISSIONS_MODULE_EDIT,
|
|
47
|
+
deleteEndpoint: config.endpoints.PERMISSIONS_MODULE_DELETE,
|
|
48
|
+
transformer: config.adapters.masters.transformModuleMasterListResponse,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const defaultColumns: Column<StandardModuleMasterItem>[] = [
|
|
52
|
+
{
|
|
53
|
+
key: 'name',
|
|
54
|
+
header: 'Sub-Module Name',
|
|
55
|
+
render: (item) => (
|
|
56
|
+
<div>
|
|
57
|
+
<span className="font-semibold text-gray-900">{item.name}</span>
|
|
58
|
+
<div className="text-xs text-gray-400 font-mono">{item.slug}</div>
|
|
59
|
+
</div>
|
|
60
|
+
),
|
|
61
|
+
},
|
|
62
|
+
{ key: 'parentName', header: 'Parent Module' },
|
|
63
|
+
{ key: 'routePath', header: 'Route Path' },
|
|
64
|
+
{ key: 'sortOrder', header: 'Sort Order', align: 'center' },
|
|
65
|
+
{
|
|
66
|
+
key: 'status',
|
|
67
|
+
header: 'Status',
|
|
68
|
+
align: 'center',
|
|
69
|
+
render: (item) => (
|
|
70
|
+
<Badge variant={item.isActive ? 'success' : 'neutral'}>
|
|
71
|
+
{item.isActive ? 'Active' : 'Inactive'}
|
|
72
|
+
</Badge>
|
|
73
|
+
),
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
const defaultFormFields: FormField[] = [
|
|
78
|
+
{ name: 'name', label: 'Sub-Module Name', required: true, placeholder: 'e.g. Lead Pipeline' },
|
|
79
|
+
{ name: 'slug_name', label: 'Slug Key', required: true, placeholder: 'e.g. lead_pipeline' },
|
|
80
|
+
{ name: 'route_path', label: 'Route Path', placeholder: '/sales/leads' },
|
|
81
|
+
{ name: 'parentId', label: 'Parent Module ID', required: true, type: 'number' },
|
|
82
|
+
{ name: 'sort_order', label: 'Sort Order', type: 'number', defaultValue: 0 },
|
|
83
|
+
{ name: 'is_active', label: 'Active', type: 'checkbox', defaultValue: true },
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<MasterDataTable
|
|
88
|
+
title={title}
|
|
89
|
+
description={description}
|
|
90
|
+
permissionPrefix="sub_module_master"
|
|
91
|
+
featureKey="subModuleMaster"
|
|
92
|
+
allowAdd={allowAdd}
|
|
93
|
+
allowEdit={allowEdit}
|
|
94
|
+
allowDelete={allowDelete}
|
|
95
|
+
allowSearch={allowSearch}
|
|
96
|
+
columns={customColumns || defaultColumns}
|
|
97
|
+
extendColumns={extendColumns}
|
|
98
|
+
omitColumns={omitColumns}
|
|
99
|
+
formFields={customFormFields || defaultFormFields}
|
|
100
|
+
extendFormFields={extendFormFields}
|
|
101
|
+
omitFormFields={omitFormFields}
|
|
102
|
+
customActions={customActions}
|
|
103
|
+
useMasterHook={useSubModHook}
|
|
104
|
+
/>
|
|
105
|
+
);
|
|
106
|
+
};
|