@campxdev/shared 1.10.95 → 1.10.96

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campxdev/shared",
3
- "version": "1.10.95",
3
+ "version": "1.10.96",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -223,14 +223,12 @@ function useAuth({ permissionsEndpoint, loginUrl }: AuthParams): AuthResponse {
223
223
  can_individual_pages_view: 1,
224
224
  can_analatics_view: isAdmin,
225
225
  can_admin_view: isAdmin,
226
- can_challan_registrations_view:
227
- isMasterSlave &&
228
- res.data?.permissions.can_challan_registrations_view,
229
226
  can_my_mentees_view:
230
227
  res.data?.user?.isMentor &&
231
228
  res.data?.permissions.can_my_mentees_view,
232
229
  } as any
233
230
  s.applications = res.data?.applications ?? []
231
+ s.institutionType = res.data?.institutionType
234
232
  })
235
233
  AssetsStore.update((s) => {
236
234
  s.logo = res.data?.assets.logo
@@ -4,15 +4,37 @@ import { Permission, PermissionsStore } from '../shared-state/PermissionsStore'
4
4
  export default function ValidateAccess({
5
5
  accessKey,
6
6
  children,
7
+ checkForMasterSlave = false,
7
8
  }: {
8
9
  accessKey: Permission
9
10
  children: React.ReactNode
11
+ checkForMasterSlave?: boolean
10
12
  }) {
11
- const permissions = PermissionsStore.useState((s) => s).permissions
12
- const hasAccess = accessKey ? permissions[accessKey] : true
13
+ const { permissions, institutionType } = PermissionsStore.useState((s) => s)
14
+ const hasAccess = checkHasAccess(
15
+ checkForMasterSlave,
16
+ accessKey,
17
+ institutionType,
18
+ permissions,
19
+ )
13
20
 
14
21
  if (hasAccess) {
15
22
  return <>{children}</>
16
23
  }
17
24
  return null
18
25
  }
26
+
27
+ const checkHasAccess = (
28
+ checkForMasterSlave,
29
+ accessKey,
30
+ institutionType,
31
+ permissions,
32
+ ) => {
33
+ if (checkForMasterSlave) {
34
+ return permissions[accessKey] && institutionType == 'MASTER_CHILD'
35
+ ? true
36
+ : false
37
+ } else {
38
+ return accessKey ? permissions[accessKey] : true
39
+ }
40
+ }
@@ -764,6 +764,11 @@ export enum Permission {
764
764
  STUDENTS_TRANSFER = 'can_students_transfer',
765
765
  STUDENTS_ALLOTMENT = 'can_students_allotment',
766
766
  STUDENT_INFO_VIEW = 'can_student_info_view',
767
+ STUDENT_ACADEMIC_PERFORMANCE_VIEW = 'can_student_academic_performance_view',
768
+ STUDENT_ATTENDANCE_VIEW = 'can_student_attendance_view',
769
+ STUDENT_PAYMENTS_VIEW = 'can_student_payments_view',
770
+ STUDENT_MEMOS_VIEW = 'can_student_memos_view',
771
+ STUDENT_BACKLOGS_VIEW = 'can_student_backlogs_view',
767
772
 
768
773
  // Student Certificate
769
774
  CAN_STUDENT_CERTIFICATES_VIEW = 'can_student_certificates_view',
@@ -1084,6 +1089,11 @@ export enum Permission {
1084
1089
  CAN_CHALLAN_REGISTRATION_ADD = 'can_challan_registrations_add',
1085
1090
  CAN_CHALLAN_UPLOAD_ADD = 'can_challan_upload_add',
1086
1091
 
1092
+ // Question Paper Upload
1093
+ CAN_QUESTION_PAPER_UPLOAD_VIEW = 'can_question_paper_upload_view',
1094
+ CAN_QUESTION_PAPER_UPLOAD_ADD = 'can_question_paper_upload_add',
1095
+ CAN_QUESTION_PAPER_UPLOAD_EDIT = 'can_question_paper_upload_edit',
1096
+
1087
1097
  //settings
1088
1098
  CAN_EXAMS_SETTINGS_VIEW = 'can_exams_settings_view',
1089
1099
 
@@ -1427,9 +1437,11 @@ export interface IPermissions {
1427
1437
  interface IPermissionsStore {
1428
1438
  permissions: IPermissions
1429
1439
  applications: string[]
1440
+ institutionType: 'MASTER_CHILD' | 'INDIVIDUAL'
1430
1441
  }
1431
1442
 
1432
1443
  export const PermissionsStore = new Store<IPermissionsStore>({
1433
1444
  permissions: null,
1434
1445
  applications: [],
1446
+ institutionType: null,
1435
1447
  })
File without changes