@campxdev/shared 1.10.96 → 1.10.97
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/package.json
CHANGED
|
@@ -18,6 +18,21 @@ import {
|
|
|
18
18
|
|
|
19
19
|
const accessIfNoKey = process.env.NODE_ENV === 'development' ? true : false
|
|
20
20
|
|
|
21
|
+
const checkHasAccess = (
|
|
22
|
+
checkForMasterSlave,
|
|
23
|
+
permissionKey,
|
|
24
|
+
institutionType,
|
|
25
|
+
permissions,
|
|
26
|
+
) => {
|
|
27
|
+
if (checkForMasterSlave) {
|
|
28
|
+
return permissions[permissionKey] && institutionType == 'MASTER_CHILD'
|
|
29
|
+
? true
|
|
30
|
+
: false
|
|
31
|
+
} else {
|
|
32
|
+
return permissionKey ? permissions[permissionKey] : true
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
21
36
|
const sideNavStore = new Store({
|
|
22
37
|
activeKey: '',
|
|
23
38
|
})
|
|
@@ -52,12 +67,24 @@ const SideNav = ({
|
|
|
52
67
|
export default memo(SideNav)
|
|
53
68
|
|
|
54
69
|
const RenderMenuItem = ({ menuItem }) => {
|
|
55
|
-
const {
|
|
70
|
+
const {
|
|
71
|
+
path,
|
|
72
|
+
children,
|
|
73
|
+
title,
|
|
74
|
+
icon,
|
|
75
|
+
permissionKey,
|
|
76
|
+
checkForMasterSlave = false,
|
|
77
|
+
} = menuItem
|
|
56
78
|
let resolved = useResolvedPath(path)
|
|
57
79
|
let match = useMatch({ path: resolved.pathname, end: false })
|
|
58
80
|
|
|
59
|
-
const permissions = PermissionsStore.useState((s) => s)
|
|
60
|
-
const hasAccess =
|
|
81
|
+
const { permissions, institutionType } = PermissionsStore.useState((s) => s)
|
|
82
|
+
const hasAccess = checkHasAccess(
|
|
83
|
+
checkForMasterSlave,
|
|
84
|
+
permissionKey,
|
|
85
|
+
institutionType,
|
|
86
|
+
permissions,
|
|
87
|
+
)
|
|
61
88
|
|
|
62
89
|
if (children?.length)
|
|
63
90
|
return (
|
|
@@ -99,13 +126,20 @@ const RenderMenuItem = ({ menuItem }) => {
|
|
|
99
126
|
|
|
100
127
|
const DropDownMenu = ({ path, title, icon, menuItems }) => {
|
|
101
128
|
const { activeKey } = sideNavStore.useState((s) => s)
|
|
102
|
-
const permissions = PermissionsStore.useState((s) => s)
|
|
129
|
+
const { permissions, institutionType } = PermissionsStore.useState((s) => s)
|
|
103
130
|
|
|
104
131
|
const validateDropdownAccess = () => {
|
|
105
132
|
if (process.env.NODE_ENV === 'development' && !permissions) return true
|
|
106
133
|
|
|
107
134
|
return menuItems?.some((item) =>
|
|
108
|
-
item?.permissionKey
|
|
135
|
+
item?.permissionKey
|
|
136
|
+
? checkHasAccess(
|
|
137
|
+
item?.checkForMasterSlave,
|
|
138
|
+
item?.permissionKey,
|
|
139
|
+
institutionType,
|
|
140
|
+
permissions,
|
|
141
|
+
)
|
|
142
|
+
: accessIfNoKey,
|
|
109
143
|
)
|
|
110
144
|
}
|
|
111
145
|
|
|
@@ -1432,6 +1432,12 @@ export interface IPermissions {
|
|
|
1432
1432
|
can_assessment_templates_edit: boolean
|
|
1433
1433
|
can_assessment_templates_view: boolean
|
|
1434
1434
|
can_assessment_templates_delete: boolean
|
|
1435
|
+
|
|
1436
|
+
//
|
|
1437
|
+
can_student_academic_performance_view: boolean
|
|
1438
|
+
can_student_permissions_add: boolean
|
|
1439
|
+
can_student_permissions_edit: boolean
|
|
1440
|
+
can_student_permissions_delete: boolean
|
|
1435
1441
|
}
|
|
1436
1442
|
|
|
1437
1443
|
interface IPermissionsStore {
|