@campxdev/shared 1.8.25 → 1.8.27

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.8.25",
3
+ "version": "1.8.27",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -1,4 +1,4 @@
1
- import { Box, Menu, Typography } from '@mui/material'
1
+ import { Box, Menu, Typography, styled } from '@mui/material'
2
2
  import Cookies from 'js-cookie'
3
3
  import { useState } from 'react'
4
4
  import { applications } from './applications'
@@ -12,13 +12,16 @@ import {
12
12
  StyledImageBox,
13
13
  } from './styles'
14
14
  import { PermissionsStore } from '../../../shared-state'
15
-
15
+ import AppsOutageIcon from '@mui/icons-material/AppsOutage'
16
16
  export const campxTenantKey = Cookies.get('campx_tenant')
17
17
 
18
18
  const AppsMenu = () => {
19
19
  const permissionState = PermissionsStore.useState((s) => s)
20
20
  const [anchorEl, setAnchorEl] = useState<any>(null)
21
21
  const open = Boolean(anchorEl)
22
+ const applicationList = applications?.filter((item) =>
23
+ permissionState.applications.includes(item.key),
24
+ )
22
25
 
23
26
  const handleClick = (event) => {
24
27
  setAnchorEl(event.currentTarget)
@@ -62,33 +65,40 @@ const AppsMenu = () => {
62
65
  },
63
66
  }}
64
67
  >
65
- <Box sx={{ padding: '0.3rem 1rem' }}>
66
- <Typography variant="body2">Switch to</Typography>
67
- </Box>
68
- <Box>
69
- {applications.map((item, index) => {
70
- if (permissionState.applications.includes(item.key)) {
71
- return (
72
- <StyledLink
73
- href={item.path + `/${campxTenantKey ?? ''}`}
74
- key={index}
75
- >
76
- <StyledMenuItemContainer
68
+ {applicationList.length != 0 ? (
69
+ <>
70
+ <Box sx={{ padding: '0.3rem 1rem' }}>
71
+ <Typography variant="body2">Switch to</Typography>
72
+ </Box>
73
+ <Box>
74
+ {applicationList.map((item, index) => {
75
+ return (
76
+ <StyledLink
77
+ href={item.path + `/${campxTenantKey ?? ''}`}
77
78
  key={index}
78
- onClick={() => {
79
- window.location.href = item.path
80
- handleClose()
81
- }}
82
79
  >
83
- <MenuItem data={item} />
84
- </StyledMenuItemContainer>
85
- </StyledLink>
86
- )
87
- } else {
88
- return null
89
- }
90
- })}
91
- </Box>
80
+ <StyledMenuItemContainer
81
+ key={index}
82
+ onClick={() => {
83
+ window.location.href = item.path
84
+ handleClose()
85
+ }}
86
+ >
87
+ <MenuItem data={item} />
88
+ </StyledMenuItemContainer>
89
+ </StyledLink>
90
+ )
91
+ })}
92
+ </Box>
93
+ </>
94
+ ) : (
95
+ <StyledNoAppContainer>
96
+ <AppsOutageIcon sx={{ width: '40px', height: '40px' }} />
97
+ <Typography variant="subtitle1">
98
+ No Application have been assigned
99
+ </Typography>
100
+ </StyledNoAppContainer>
101
+ )}
92
102
  </Menu>
93
103
  </>
94
104
  )
@@ -111,3 +121,13 @@ const MenuItem = ({ data }) => {
111
121
  </StyledMenuItem>
112
122
  )
113
123
  }
124
+
125
+ const StyledNoAppContainer = styled(Box)({
126
+ width: '300px',
127
+ height: '300px',
128
+ display: 'flex',
129
+ alignItems: 'center',
130
+ flexDirection: 'column',
131
+ justifyContent: 'center',
132
+ gap: '10px',
133
+ })
@@ -35,6 +35,7 @@ import { CustomDialog } from './ModalButtons/DialogButton'
35
35
  import { CustomDrawer } from './ModalButtons/DrawerButton'
36
36
  import ExcelJsonUpload from './ExcelToJsonInput/ExcelJsonUpload'
37
37
  import ExcelToJsonInput from './ExcelToJsonInput'
38
+ import ApplicationProfile from './ApplicationProfile'
38
39
  export { default as Image } from './Image'
39
40
  export { default as PageHeader } from './PageHeader'
40
41
  export { PageContent } from './PageContent'
@@ -58,7 +59,7 @@ export { default as ReactTable } from './Tables/ReactTable'
58
59
  export { default as TableFooter } from './Tables/BasicTable/TableFooter'
59
60
  export { default as DropDownButton } from './DropDownButton'
60
61
  export { default as useConfirm } from './PopupConfirm/useConfirm'
61
- export { default } from './ApplicationProfile'
62
+
62
63
  export {
63
64
  UploadFileDialog,
64
65
  Chips,
@@ -98,6 +99,7 @@ export {
98
99
  UserBox,
99
100
  ExcelJsonUpload,
100
101
  ExcelToJsonInput,
102
+ ApplicationProfile,
101
103
  }
102
104
 
103
105
  export * from './UploadButton/types'
@@ -95,3 +95,30 @@ export function getRandomColor(name) {
95
95
  character: firstAlphabet?.toUpperCase(),
96
96
  }
97
97
  }
98
+
99
+ export const ProfileApplicationType = [
100
+ {
101
+ label: 'Square',
102
+ value: 'square',
103
+ },
104
+ {
105
+ label: 'Exams',
106
+ value: 'exams',
107
+ },
108
+ {
109
+ label: 'Payments',
110
+ value: 'payments',
111
+ },
112
+ {
113
+ label: 'EnrollX',
114
+ value: 'enroll_x',
115
+ },
116
+ {
117
+ label: 'Hostels',
118
+ value: 'hostels',
119
+ },
120
+ {
121
+ label: 'Commute',
122
+ value: 'commute',
123
+ },
124
+ ]
@@ -38,20 +38,20 @@ function useAuth({ permissionsEndpoint, loginUrl }: AuthParams): AuthResponse {
38
38
  axios
39
39
  .get(permissionsEndpoint)
40
40
  .then((res) => {
41
- const origin = window.location.origin
42
- const domain = origin.split('campx')[0].split('//')[1]
41
+ // const origin = window.location.origin
42
+ // const domain = origin.split('campx')[0].split('//')[1]
43
43
 
44
- const isStaging = origin.split('campx')[1] === '.dev'
45
- if (!isDevelopment) {
46
- if (!res.data.applications.includes(domain) && domain !== 'ums') {
47
- if (isStaging) {
48
- window.location.replace(`https://www.ums.campx.dev`)
49
- } else {
50
- window.location.replace(`https://www.ums.campx.in`)
51
- }
52
- }
53
- return
54
- }
44
+ // const isStaging = origin.split('campx')[1] === '.dev'
45
+ // if (!isDevelopment) {
46
+ // if (!res.data.applications.includes(domain) && domain !== 'ums') {
47
+ // if (isStaging) {
48
+ // window.location.replace(`https://www.ums.campx.dev`)
49
+ // } else {
50
+ // window.location.replace(`https://www.ums.campx.in`)
51
+ // }
52
+ // }
53
+ // return
54
+ // }
55
55
 
56
56
  setLoading(false)
57
57
  setData(res.data)
@@ -28,6 +28,7 @@ const useExternalScript = (url) => {
28
28
  return () => {
29
29
  script.removeEventListener('load', handleScript)
30
30
  script.removeEventListener('error', handleScript)
31
+ document.body.removeChild(script)
31
32
  }
32
33
  }, [url])
33
34
 
@@ -3,6 +3,13 @@ import { Store } from 'pullstate'
3
3
  export enum Permission {
4
4
  // Square
5
5
  // manage
6
+
7
+ // manage square profile_permissions
8
+ CAN_MANAGE_SQUARE_PROFILE_PERMISSIONS_VIEW = 'can_manage_square_profile_permissions_view',
9
+ CAN_MANAGE_SQUARE_PROFILE_PERMISSIONS_ADD = 'can_manage_square_profile_permissions_add',
10
+ CAN_MANAGE_SQUARE_PROFILE_PERMISSIONS_EDIT = 'can_manage_square_profile_permissions_edit',
11
+ CAN_MANAGE_SQUARE_PROFILE_PERMISSIONS_DELETE = 'can_manage_square_profile_permissions_delete',
12
+
6
13
  MANAGE_ROLES_AND_PROFILES = 'can_manage_roles_and_profiles',
7
14
  VIEW_AUDIT_LOGS = 'can_view_audit_logs',
8
15
  MANAGE_SETTINGS = 'can_manage_settings',
@@ -157,6 +164,13 @@ export enum Permission {
157
164
  DESIGNATIONS_VIEW = 'can_designations_view',
158
165
 
159
166
  // Enroll X
167
+
168
+ // manage exams profile_permissions
169
+ CAN_MANAGE_ENROLL_X_PROFILE_PERMISSIONS_VIEW = 'can_manage_enrol_x_profile_permissions_view',
170
+ CAN_MANAGE_ENROLL_X_PROFILE_PERMISSIONS_ADD = 'can_manage_enrol_x_profile_permissions_add',
171
+ CAN_MANAGE_ENROLL_X_PROFILE_PERMISSIONS_EDIT = 'can_manage_enrol_x_profile_permissions_edit',
172
+ CAN_MANAGE_ENROLL_X_PROFILE_PERMISSIONS_DELETE = 'can_manage_enrol_x_profile_permissions_delete',
173
+
160
174
  // Admissions
161
175
  ADMISSIONS_ADD = 'can_admissions_add',
162
176
  ADMISSIONS_EDIT = 'can_admissions_edit',
@@ -218,15 +232,22 @@ export enum Permission {
218
232
  CAN_HOSTELERS_SETTINGS_AMENITIES_DELETE = 'can_hosteler_settings_amenities_delete',
219
233
 
220
234
  // Exams
235
+
236
+ // manage exams profile_permissions
237
+ CAN_MANAGE_EXAMS_PROFILE_PERMISSIONS_VIEW = 'can_manage_exams_profile_permissions_view',
238
+ CAN_MANAGE_EXAMS_PROFILE_PERMISSIONS_ADD = 'can_manage_exams_profile_permissions_add',
239
+ CAN_MANAGE_EXAMS_PROFILE_PERMISSIONS_EDIT = 'can_manage_exams_profile_permissions_edit',
240
+ CAN_MANAGE_EXAMS_PROFILE_PERMISSIONS_DELETE = 'can_manage_exams_profile_permissions_delete',
241
+
221
242
  // End Semester Examination
222
- END_SEMESTER_EXAMINATIONS_VIEW = 'can_end_semester_examinations_view',
223
- END_SEMESTER_EXAMINATIONS_ADD = 'can_end_semester_examinations_add',
224
- END_SEMESTER_EXAMINATIONS_EDIT = 'can_end_semester_examinations_edit',
225
- END_SEMESTER_EXAMINATIONS_DELETE = 'can_end_semester_examinations_delete',
243
+ CAN_END_SEMESTER_EXAMINATIONS_VIEW = 'can_end_semester_examinations_view',
244
+ CAN_END_SEMESTER_EXAMINATIONS_ADD = 'can_end_semester_examinations_add',
245
+ CAN_END_SEMESTER_EXAMINATIONS_EDIT = 'can_end_semester_examinations_edit',
246
+ CAN_END_SEMESTER_EXAMINATIONS_DELETE = 'can_end_semester_examinations_delete',
226
247
 
227
248
  // Registrations
228
- CAN_REGISTARTIONS_VIEW = 'can_exam_registrations_view',
229
- CAN_REGISTARTIONS_ADD = 'can_exam_registrations_add',
249
+ CAN_EXAM_REGISTARTIONS_VIEW = 'can_exam_registrations_view',
250
+ CAN_EXAM_REGISTARTIONS_ADD = 'can_exam_registrations_add',
230
251
 
231
252
  // Fee configuration
232
253
  EXAM_FEE_CONFIGURATION_VIEW = 'can_exam_fee_configuration_view',
@@ -244,6 +265,7 @@ export enum Permission {
244
265
  // OMRS
245
266
  CAN_OMRS_VIEW = 'can_omrs_view',
246
267
  CAN_OMRS_UPDATE = 'can_omrs_update',
268
+ CAN_OMRS_GENERATE = 'can_omrs_generate',
247
269
 
248
270
  // Paper Configuration
249
271
  CAN_PAPER_CONFIGURATION_VIEW = 'can_paper_configuration_view',
@@ -256,15 +278,14 @@ export enum Permission {
256
278
  CAN_D_FORM_ADD = 'can_d_forms_add',
257
279
 
258
280
  // Bundling
259
- VIEW_ANSWER_SHEET_REPORT = 'can_view_answer_sheet_report',
260
-
261
- BUNDLING_VIEW = 'can_bundling_view',
262
- BUNDLING_ADD = 'can_bundling_add',
263
- BUNDLING_EDIT = 'can_bundling_edit',
264
- BUNDLING_DELETE = 'can_bundling_delete',
265
- BUNDLING_UPDATE_BUNDLE_STATUS = 'can_bundling_update_bundle_status',
266
- BUNDLING_BUNDLE_SHEETS_ADD = 'can_bundling_bundle_sheets_add',
267
- BUNDLING_BUNDLE_SHEETS_REMOVE = 'can_bundling_bundle_sheets_remove',
281
+ CAN_VIEW_ANSWER_SHEET_REPORT = 'can_view_answer_sheet_report',
282
+ CAN_BUNDLING_VIEW = 'can_bundling_view',
283
+ CAN_BUNDLING_ADD = 'can_bundling_add',
284
+ CAN_BUNDLING_EDIT = 'can_bundling_edit',
285
+ CAN_BUNDLING_DELETE = 'can_bundling_delete',
286
+ CAN_BUNDLING_UPDATE_BUNDLE_STATUS = 'can_bundling_update_bundle_status',
287
+ CAN_BUNDLING_BUNDLE_SHEETS_ADD = 'can_bundling_bundle_sheets_add',
288
+ CAN_BUNDLING_BUNDLE_SHEETS_REMOVE = 'can_bundling_bundle_sheets_remove',
268
289
 
269
290
  // Internal Marks
270
291
  CAN_INTERNAL_MARKS_VIEW = 'can_internal_marks_view',
@@ -301,11 +322,11 @@ export enum Permission {
301
322
  CAN_REVALUATION_GENERATE_MEMOS = 'can_revaluation_generate_memos',
302
323
 
303
324
  // Internal Examinations
304
- INTERNAL_EXAMINATIONS_VIEW = 'can_internal_examinations_view',
305
- INTERNAL_EXAMINATIONS_ADD = 'can_internal_examinations_add',
306
- INTERNAL_EXAMINATIONS_EDIT = 'can_internal_examinations_edit',
307
- INTERNAL_EXAMINATIONS_DELETE = 'can_internal_examinations_delete',
308
- INTERNAL_EXAMINATIONS_MANAGE_EXAM_FEE = 'can_internal_examinations_manage_exam_fee',
325
+ CAN_INTERNAL_EXAMINATIONS_VIEW = 'can_internal_examinations_view',
326
+ CAN_INTERNAL_EXAMINATIONS_ADD = 'can_internal_examinations_add',
327
+ CAN_INTERNAL_EXAMINATIONS_EDIT = 'can_internal_examinations_edit',
328
+ CAN_INTERNAL_EXAMINATIONS_DELETE = 'can_internal_examinations_delete',
329
+ CAN_INTERNAL_EXAMINATIONS_MANAGE_EXAM_FEE = 'can_internal_examinations_manage_exam_fee',
309
330
 
310
331
  // Seating Plan
311
332
  SEATING_PLAN = 'can_examinations_seating_plan',
@@ -351,6 +372,13 @@ export enum Permission {
351
372
  CAN_SETTINGS_VIEW = 'can_settings_view',
352
373
  CAN_DASHBOARD_VIEW = 'can_dashboard_view',
353
374
 
375
+ // Payments
376
+ // manage payments profile_permissions
377
+ CAN_MANAGE_PAYMENTS_PROFILE_PERMISSIONS_VIEW = 'can_manage_payments_profile_permissions_view',
378
+ CAN_MANAGE_PAYMENTS_PROFILE_PERMISSIONS_ADD = 'can_manage_payments_profile_permissions_add',
379
+ CAN_MANAGE_PAYMENTS_PROFILE_PERMISSIONS_EDIT = 'can_manage_payments_profile_permissions_edit',
380
+ CAN_MANAGE_PAYMENTS_PROFILE_PERMISSIONS_DELETE = 'can_manage_payments_profile_permissions_delete',
381
+
354
382
  // MANAGE_USER_GROUPS = 'can_manage_user_groups',
355
383
  // MANAGE_ASSESSMENTS = 'can_manage_assessments',
356
384
  // EDIT_ANSWER_SHEET_MARKS = 'can_edit_answer_sheet_marks',