@campxdev/shared 1.10.94 → 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
|
-
import { Box, CircularProgress, Stack, styled, Typography } from '@mui/material'
|
|
2
|
-
import { ReactNode, useRef, useState } from 'react'
|
|
3
1
|
import AttachFileIcon from '@mui/icons-material/AttachFile'
|
|
2
|
+
import { CircularProgress, styled, Typography } from '@mui/material'
|
|
3
|
+
import { ReactNode, useRef, useState } from 'react'
|
|
4
4
|
import { toast } from 'react-toastify'
|
|
5
5
|
import axios from '../config/axios'
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ export default function UploadDocument({
|
|
|
10
10
|
postUrl,
|
|
11
11
|
postBody,
|
|
12
12
|
styleProps,
|
|
13
|
-
|
|
13
|
+
onSuccess,
|
|
14
14
|
width,
|
|
15
15
|
height,
|
|
16
16
|
}: {
|
|
@@ -18,7 +18,7 @@ export default function UploadDocument({
|
|
|
18
18
|
styledUpload?: ReactNode
|
|
19
19
|
postUrl: string
|
|
20
20
|
postBody?: object
|
|
21
|
-
|
|
21
|
+
onSuccess?: (res: any) => void
|
|
22
22
|
styleProps?: any
|
|
23
23
|
width?: string
|
|
24
24
|
height?: string
|
|
@@ -41,7 +41,7 @@ export default function UploadDocument({
|
|
|
41
41
|
.post(postUrl, formData)
|
|
42
42
|
.then((res) => {
|
|
43
43
|
setLoading(false)
|
|
44
|
-
|
|
44
|
+
onSuccess(res?.data)
|
|
45
45
|
})
|
|
46
46
|
.catch((err) => {
|
|
47
47
|
setLoading(false)
|
package/src/hooks/useAuth.ts
CHANGED
|
@@ -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)
|
|
12
|
-
const hasAccess =
|
|
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
|
})
|