@campxdev/shared 1.11.5 → 1.11.7-0.alpha-20

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.
Files changed (112) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/exports.ts +4 -0
  3. package/package.json +17 -9
  4. package/src/assets/images/X.png +0 -0
  5. package/src/assets/images/active_devices.svg +3 -0
  6. package/src/assets/images/animation.gif +0 -0
  7. package/src/assets/images/change_password.svg +6 -0
  8. package/src/assets/images/clog_wheel.svg +6 -0
  9. package/src/assets/images/index.ts +28 -3
  10. package/src/assets/images/location.svg +6 -0
  11. package/src/assets/images/logout_icon.svg +6 -0
  12. package/src/assets/images/lottery.svg +22 -0
  13. package/src/assets/images/mobile.svg +7 -0
  14. package/src/assets/images/no_devices.svg +734 -0
  15. package/src/assets/images/notifications.svg +3 -0
  16. package/src/assets/images/profile.svg +6 -0
  17. package/src/assets/images/web.svg +13 -0
  18. package/src/components/ActiveDevices/ActiveDevices.tsx +60 -0
  19. package/src/components/ActiveDevices/DeviceInformationCard.tsx +97 -0
  20. package/src/components/ActiveDevices/index.ts +1 -0
  21. package/src/components/ActivityLog/ActivityLog.tsx +268 -0
  22. package/src/components/ActivityLog/Styles.tsx +35 -0
  23. package/src/components/ActivityLog/index.ts +1 -0
  24. package/src/components/ApplicationProfile/ApplicationProfile.tsx +1 -0
  25. package/src/components/ApplicationProfile/UserProfileRelation.tsx +4 -1
  26. package/src/components/DatabaseConfiguration/DatabaseConfiguration.tsx +28 -0
  27. package/src/components/DatabaseConfiguration/DatabaseConfigurationForm.tsx +87 -0
  28. package/src/components/DatabaseConfiguration/components/AddConnectionDrawerButton.tsx +30 -0
  29. package/src/components/DatabaseConfiguration/components/ConnectionCard.tsx +79 -0
  30. package/src/components/DatabaseConfiguration/index.ts +5 -0
  31. package/src/components/DatabaseConfiguration/service.ts +6 -0
  32. package/src/components/DatabaseConfiguration/styles.ts +30 -0
  33. package/src/components/DrawerWrapper/DialogTemplate.tsx +58 -0
  34. package/src/components/DrawerWrapper/DrawerWrapper.tsx +23 -7
  35. package/src/components/DrawerWrapper/ErrorTemplate.tsx +77 -0
  36. package/src/components/ErrorModal.tsx +88 -0
  37. package/src/components/ErrorModalWrapper/ErrorModalTemplate.tsx +118 -0
  38. package/src/components/ErrorModalWrapper/ErrorModalWrapper.tsx +76 -0
  39. package/src/components/FilterComponents/SearchBar.tsx +5 -2
  40. package/src/components/Form/Form.tsx +4 -1
  41. package/src/components/HookForm/AutoCompleteSearch.tsx +3 -0
  42. package/src/components/HookForm/MultiSelect.tsx +1 -0
  43. package/src/components/HookForm/SingleSelect.tsx +2 -2
  44. package/src/components/ImageUpload.tsx +4 -1
  45. package/src/components/Input/MultiSelect.tsx +1 -0
  46. package/src/components/Input/SearchSingleSelect.tsx +1 -1
  47. package/src/components/Input/SingleSelect.tsx +7 -7
  48. package/src/components/Institutions/InsititutionsDialog.tsx +2 -2
  49. package/src/components/Layout/Header/AppHeader.tsx +23 -6
  50. package/src/components/Layout/Header/HeaderActions/CogWheelMenu.tsx +2 -2
  51. package/src/components/Layout/Header/HeaderActions/HeaderActions.tsx +41 -16
  52. package/src/components/Layout/Header/HeaderActions/UserBox.tsx +48 -6
  53. package/src/components/Layout/Header/applications.ts +43 -30
  54. package/src/components/Layout/LayoutWrapper.tsx +82 -4
  55. package/src/components/Layout/SideNav.tsx +42 -9
  56. package/src/components/LoginForm.tsx +52 -1
  57. package/src/components/MongoCharts/MongoDashboard.tsx +146 -0
  58. package/src/components/MongoCharts/index.tsx +1 -0
  59. package/src/components/MyProfile/MyProfile.tsx +1 -1
  60. package/src/components/ReportHeader.tsx +13 -9
  61. package/src/components/Selectors/ClassRoomSelector.tsx +2 -2
  62. package/src/components/Selectors/CourseSelector.tsx +2 -2
  63. package/src/components/Selectors/DepartmentSelector.tsx +2 -2
  64. package/src/components/Selectors/ExamGroupSelector.tsx +19 -10
  65. package/src/components/Selectors/FacultySelector.tsx +2 -2
  66. package/src/components/Selectors/FeeTypeSelector.tsx +2 -2
  67. package/src/components/Selectors/FormSelectors/FormClassRoomSelector.tsx +2 -2
  68. package/src/components/Selectors/FormSelectors/FormCourseSelector.tsx +2 -2
  69. package/src/components/Selectors/FormSelectors/FormDepartmentSelector.tsx +2 -2
  70. package/src/components/Selectors/FormSelectors/FormExamGroupSelector.tsx +2 -2
  71. package/src/components/Selectors/FormSelectors/FormFacultySelector.tsx +2 -2
  72. package/src/components/Selectors/FormSelectors/FormFeeTypeSelector.tsx +2 -2
  73. package/src/components/Selectors/FormSelectors/FormProgramSelector.tsx +2 -2
  74. package/src/components/Selectors/FormSelectors/FormQuotaSelector.tsx +3 -3
  75. package/src/components/Selectors/FormSelectors/FormSemesterSelector.tsx +2 -2
  76. package/src/components/Selectors/FormSelectors/MultiSelect/MultiFacultySelector.tsx +2 -2
  77. package/src/components/Selectors/FormSelectors/MultiSelect/MultiFeeTypeSelector.tsx +2 -2
  78. package/src/components/Selectors/FormSelectors/MultiSelect/MultiProgramSelector.tsx +2 -2
  79. package/src/components/Selectors/FormSelectors/MultiSelect/MultiQuotaSelector.tsx +2 -2
  80. package/src/components/Selectors/ProgramSelector.tsx +3 -3
  81. package/src/components/Selectors/QuotaSelector.tsx +3 -3
  82. package/src/components/Selectors/SemesterSelector.tsx +2 -2
  83. package/src/components/SignatureFooter.tsx +35 -0
  84. package/src/components/SwitchButton.tsx +6 -1
  85. package/src/components/Tables/2DTable/Table.tsx +20 -23
  86. package/src/components/Tables/BasicTable/Table.tsx +22 -13
  87. package/src/components/Tables/BasicTable/TableFooter.tsx +35 -9
  88. package/src/components/Tables/BasicTable/styles.ts +1 -1
  89. package/src/components/Tables/ReactTable/ReactTable.tsx +42 -8
  90. package/src/components/Tables/common/types.ts +1 -0
  91. package/src/components/Tabs/TabsContainer.tsx +5 -5
  92. package/src/components/Tabs/styles.tsx +1 -0
  93. package/src/components/ToastContainer/ToastContainer.tsx +2 -3
  94. package/src/components/UploadButton/UploadButton.tsx +3 -1
  95. package/src/components/UploadButton/types.ts +2 -2
  96. package/src/components/UploadDocument.tsx +3 -0
  97. package/src/components/UploadFileDialog/UploadFileDialog.tsx +20 -9
  98. package/src/components/index.ts +5 -0
  99. package/src/config/axios.ts +5 -19
  100. package/src/constants/UIConstants.ts +65 -2
  101. package/src/constants/isDevelopment.ts +0 -1
  102. package/src/contexts/Providers.tsx +5 -43
  103. package/src/hooks/useAuth.ts +7 -0
  104. package/src/layouts/Components/styles.tsx +25 -7
  105. package/src/permissions/PermissionsStore.ts +658 -55
  106. package/src/permissions/ValidateAccess.tsx +37 -8
  107. package/src/shared-state/PermissionsStore.ts +779 -85
  108. package/src/theme/theme.d.ts +69 -35
  109. package/src/utils/debounce.ts +11 -0
  110. package/src/utils/getUrlParams.ts +13 -0
  111. package/src/utils/index.ts +6 -3
  112. package/src/utils/logout.ts +3 -8
@@ -9,7 +9,7 @@ import {
9
9
  import { Store } from 'pullstate'
10
10
  import { ReactNode, memo } from 'react'
11
11
  import { Link, useMatch, useResolvedPath } from 'react-router-dom'
12
- import { PermissionsStore } from '../../shared-state'
12
+ import { PermissionsStore, UserStore } from '../../shared-state'
13
13
  import {
14
14
  ListItemButton,
15
15
  StyledChevronIcon,
@@ -23,14 +23,24 @@ const checkHasAccess = (
23
23
  permissionKey,
24
24
  institutionType,
25
25
  permissions,
26
+ checkIsMasterInstitution,
27
+ masterInstitutionUniqueId,
28
+ isMasterInstitution,
29
+ user,
26
30
  ) => {
27
31
  if (checkForMasterSlave) {
28
- return permissions[permissionKey] && institutionType == 'MASTER_CHILD'
29
- ? true
30
- : false
31
- } else {
32
- return permissionKey ? permissions[permissionKey] : true
32
+ if (institutionType == 'MASTER_CHILD') {
33
+ if (checkIsMasterInstitution) {
34
+ return (
35
+ permissions[permissionKey] &&
36
+ user.institutionIds.includes(masterInstitutionUniqueId) &&
37
+ isMasterInstitution
38
+ )
39
+ }
40
+ return permissionKey ? permissions[permissionKey] : true
41
+ }
33
42
  }
43
+ return permissionKey ? permissions[permissionKey] : true
34
44
  }
35
45
 
36
46
  const sideNavStore = new Store({
@@ -73,17 +83,30 @@ const RenderMenuItem = ({ menuItem }) => {
73
83
  title,
74
84
  icon,
75
85
  permissionKey,
76
- checkForMasterSlave = false,
86
+ checkForMasterSlave,
87
+ checkIsMasterInstitution,
77
88
  } = menuItem
89
+
78
90
  let resolved = useResolvedPath(path)
79
91
  let match = useMatch({ path: resolved.pathname, end: false })
80
92
 
81
- const { permissions, institutionType } = PermissionsStore.useState((s) => s)
93
+ const {
94
+ permissions,
95
+ institutionType,
96
+ masterInstitutionUniqueId,
97
+ isMasterInstitution,
98
+ } = PermissionsStore.useState((s) => s)
99
+ const { user } = UserStore.useState((s) => s)
100
+
82
101
  const hasAccess = checkHasAccess(
83
102
  checkForMasterSlave,
84
103
  permissionKey,
85
104
  institutionType,
86
105
  permissions,
106
+ checkIsMasterInstitution,
107
+ masterInstitutionUniqueId,
108
+ isMasterInstitution,
109
+ user,
87
110
  )
88
111
 
89
112
  if (children?.length)
@@ -126,7 +149,13 @@ const RenderMenuItem = ({ menuItem }) => {
126
149
 
127
150
  const DropDownMenu = ({ path, title, icon, menuItems }) => {
128
151
  const { activeKey } = sideNavStore.useState((s) => s)
129
- const { permissions, institutionType } = PermissionsStore.useState((s) => s)
152
+ const {
153
+ permissions,
154
+ institutionType,
155
+ masterInstitutionUniqueId,
156
+ isMasterInstitution,
157
+ } = PermissionsStore.useState((s) => s)
158
+ const { user } = UserStore.useState((s) => s)
130
159
 
131
160
  const validateDropdownAccess = () => {
132
161
  if (process.env.NODE_ENV === 'development' && !permissions) return true
@@ -138,6 +167,10 @@ const DropDownMenu = ({ path, title, icon, menuItems }) => {
138
167
  item?.permissionKey,
139
168
  institutionType,
140
169
  permissions,
170
+ item?.checkIsMasterInstitution,
171
+ masterInstitutionUniqueId,
172
+ isMasterInstitution,
173
+ user,
141
174
  )
142
175
  : accessIfNoKey,
143
176
  )
@@ -11,6 +11,7 @@ import {
11
11
  styled,
12
12
  } from '@mui/material'
13
13
  import axiosBase from 'axios'
14
+ import DeviceDetector from 'device-detector-js'
14
15
  import Cookies from 'js-cookie'
15
16
  import { useEffect, useState } from 'react'
16
17
  import { useForm } from 'react-hook-form'
@@ -36,6 +37,18 @@ export function LoginForm({
36
37
  const [resetPassword, setResetPassword] = useState(false)
37
38
  const { handleSubmit, control } = useForm()
38
39
  const [error, setError] = useState('')
40
+ const [deviceState, setDeviceState] = useState({
41
+ deviceInformation: {
42
+ deviceType: 'browser',
43
+ clientName: 'unknown',
44
+ os: 'unknown',
45
+ osVersion: 'unknown',
46
+ latitude: null,
47
+ longitude: null,
48
+ tokenType: 'WEB',
49
+ },
50
+ isLocationAllowed: true,
51
+ })
39
52
 
40
53
  const onSubmit = async (values) => {
41
54
  try {
@@ -45,7 +58,7 @@ export function LoginForm({
45
58
  url: loginUrl ? loginUrl : `/auth-server/auth/login`,
46
59
  data: {
47
60
  ...values,
48
- type: 'WEB',
61
+ ...deviceState.deviceInformation,
49
62
  },
50
63
  })
51
64
  Cookies.set('campx_tenant', res?.data?.subDomain)
@@ -83,6 +96,39 @@ export function LoginForm({
83
96
  }
84
97
 
85
98
  useEffect(() => {
99
+ navigator.geolocation.getCurrentPosition((position) => {
100
+ setDeviceState((s) => ({
101
+ ...s,
102
+ deviceInformation: {
103
+ ...s.deviceInformation,
104
+ latitude: position.coords.latitude,
105
+ longitude: position.coords.longitude,
106
+ },
107
+ }))
108
+ })
109
+ navigator.permissions
110
+ .query({ name: 'geolocation' })
111
+ .then((permissionStatus) => {
112
+ if (permissionStatus.state === 'denied') {
113
+ setDeviceState((s) => ({
114
+ ...s,
115
+ isLocationAllowed: false,
116
+ }))
117
+ }
118
+ })
119
+
120
+ const detector = new DeviceDetector()
121
+ const deviceInfo = detector.parse(navigator.userAgent)
122
+ setDeviceState((s) => ({
123
+ ...s,
124
+ deviceInformation: {
125
+ ...s.deviceInformation,
126
+ clientName: deviceInfo.client?.name || s.deviceInformation.clientName,
127
+ os: deviceInfo.os?.name || s.deviceInformation.os,
128
+ osVersion: deviceInfo.os?.version || s.deviceInformation.osVersion,
129
+ },
130
+ }))
131
+
86
132
  const restLink = window.location.pathname.split('/')[1]
87
133
  if (restLink == 'reset-password') {
88
134
  setResetPassword(true)
@@ -138,6 +184,11 @@ export function LoginForm({
138
184
  ),
139
185
  }}
140
186
  />
187
+ {!deviceState.isLocationAllowed && (
188
+ <Alert severity="warning" sx={{ marginTop: '20px' }}>
189
+ Please Enable Location Services
190
+ </Alert>
191
+ )}
141
192
  <ActionButton type="submit">Login</ActionButton>
142
193
  <Typography
143
194
  variant="h6"
@@ -0,0 +1,146 @@
1
+ import ChartsEmbedSDK from '@mongodb-js/charts-embed-dom'
2
+ import { useEffect, useRef, useState } from 'react'
3
+
4
+ interface DashboardProps {
5
+ token: any
6
+ dashboardId: string
7
+ charts: any
8
+ chartFilters: any
9
+ sx?: any
10
+ }
11
+
12
+ const MongoDashboard: React.FC<DashboardProps> = ({
13
+ token,
14
+ dashboardId,
15
+ charts,
16
+ chartFilters,
17
+ sx = {},
18
+ }) => {
19
+ const [rendered, setRendered] = useState<Boolean>(false)
20
+ const [dashboard, setDashboard] = useState<any>(null)
21
+ const chartDiv = useRef(null)
22
+
23
+ const sdk = new ChartsEmbedSDK({
24
+ baseUrl: 'https://charts.mongodb.com/charts-project-0-cnovv',
25
+ getUserToken: () => token,
26
+ })
27
+
28
+ useEffect(() => {
29
+ const initDashboard = async () => {
30
+ const dashboard = sdk.createDashboard({
31
+ dashboardId: dashboardId,
32
+ showAttribution: false,
33
+ background: 'transparent',
34
+ widthMode: 'scale',
35
+ heightMode: 'scale',
36
+ })
37
+
38
+ setDashboard(dashboard)
39
+ try {
40
+ await dashboard.render(chartDiv.current)
41
+
42
+ setRendered(true)
43
+ } catch (err) {
44
+ console.log('Error during Charts rendering:', err)
45
+ }
46
+ }
47
+
48
+ initDashboard()
49
+ }, [])
50
+
51
+ useEffect(() => {
52
+ if (dashboard && rendered) {
53
+ const applyFiltersToChart = async () => {
54
+ charts.map((chartGroup, index) => {
55
+ chartGroup.map(async (chartId) => {
56
+ const chart = await dashboard.getChart(chartId)
57
+ console.log(chartFilters[index], chart)
58
+ try {
59
+ await chart.setFilter(chartFilters[index])
60
+ } catch (err) {
61
+ console.log(
62
+ 'Error while applying filters to specific chart.',
63
+ err,
64
+ )
65
+ }
66
+ })
67
+ })
68
+
69
+ // charts.default.map(async (chartId) => {
70
+ // const chart = await dashboard.getChart(chartId)
71
+
72
+ // try {
73
+ // await chart.setFilter(filters)
74
+ // } catch (err) {
75
+ // console.log('Error while applying filters to specific chart.', err)
76
+ // }
77
+ // })
78
+
79
+ // charts.lessThanAcademicYear.map(async (chartId) => {
80
+ // const chart = await dashboard.getChart(chartId)
81
+
82
+ // try {
83
+ // await chart.setFilter({
84
+ // ...filters,
85
+ // academicYear: { $lt: filters.academicYear },
86
+ // })
87
+ // } catch (err) {
88
+ // console.log('Error while applying filters to specific chart.', err)
89
+ // }
90
+ // })
91
+
92
+ // charts.lessThanOrEqualAcademicYear.map(async (chartId) => {
93
+ // const chart = await dashboard.getChart(chartId)
94
+
95
+ // try {
96
+ // await chart.setFilter({
97
+ // ...filters,
98
+ // academicYear: { $lte: filters.academicYear },
99
+ // })
100
+ // } catch (err) {
101
+ // console.log('Error while applying filters to specific chart.', err)
102
+ // }
103
+ // })
104
+
105
+ // charts.dateRangeByAcademicYear.map(async (chartId) => {
106
+ // const chart = await dashboard.getChart(chartId)
107
+
108
+ // try {
109
+ // await chart.setFilter({
110
+ // 'admissionSubValue.tenantId':
111
+ // filters['admissionSubValue.tenantId'],
112
+ // 'admissionSubValue.institutionId':
113
+ // filters['admissionSubValue.institutionId'],
114
+ // 'feeTypeObject.feeType': filters['feeTypeObject.feeType'],
115
+ // createdAt: {
116
+ // $gte: startDate,
117
+ // $lte: endDate,
118
+ // },
119
+ // })
120
+ // } catch (err) {
121
+ // console.log('Error while applying filters to specific chart.', err)
122
+ // }
123
+ // })
124
+ }
125
+
126
+ applyFiltersToChart()
127
+ }
128
+ }, [dashboard, chartFilters, rendered])
129
+
130
+ return (
131
+ <div
132
+ className="chart"
133
+ ref={chartDiv}
134
+ style={{
135
+ height: '200vh',
136
+ margin: '25px 10px',
137
+ backgroundColor: '#EEEE',
138
+ padding: '15px 0px',
139
+ borderRadius: '10px',
140
+ ...sx,
141
+ }}
142
+ />
143
+ )
144
+ }
145
+
146
+ export default MongoDashboard
@@ -0,0 +1 @@
1
+ export { default } from './MongoDashboard'
@@ -111,7 +111,7 @@ const MyProfile = ({ close }) => {
111
111
  <Box
112
112
  sx={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}
113
113
  >
114
- <StyledAvatar>
114
+ <StyledAvatar src={userProfile?.picture?.url}>
115
115
  <Typography
116
116
  sx={{
117
117
  fontSize: '50px',
@@ -118,7 +118,7 @@ export default function ReportHeader({
118
118
  src={
119
119
  reportHeaderImageUrl ||
120
120
  current?.reportHeader?.url ||
121
- masterInstitution.reportHeader?.url
121
+ masterInstitution?.reportHeader?.url
122
122
  }
123
123
  />
124
124
  </>
@@ -132,8 +132,8 @@ export default function ReportHeader({
132
132
  }}
133
133
  src={
134
134
  logoImageUrl ||
135
- current?.images?.url ||
136
- masterInstitution?.images?.url
135
+ current?.image?.url ||
136
+ masterInstitution?.image?.url
137
137
  }
138
138
  />
139
139
  {!hideRecognitionDetails && (
@@ -142,19 +142,23 @@ export default function ReportHeader({
142
142
  sx={recognitionDetailsSx}
143
143
  >
144
144
  {recognitionDetailsText ||
145
- current.recognitionDetails ||
146
- masterInstitution.recognitionDetails}
145
+ current?.recognitionDetails ||
146
+ masterInstitution?.recognitionDetails ||
147
+ ''}
147
148
  </Typography>
148
149
  )}
149
150
  {!hideAddress && (
150
151
  <Typography variant={addressVariant} sx={addressSx}>
151
- {addressText || current.address || masterInstitution.address}
152
+ {addressText ||
153
+ current?.address ||
154
+ masterInstitution?.address ||
155
+ ''}
152
156
  </Typography>
153
157
  )}
154
158
  {!hidePhone && (
155
159
  <Typography variant={phoneVariant} sx={phoneSx}>
156
160
  {'Phone: ' +
157
- (phoneText || current.phone || masterInstitution.phone)}
161
+ (phoneText || current?.phone || masterInstitution?.phone)}
158
162
  </Typography>
159
163
  )}
160
164
  </>
@@ -168,8 +172,8 @@ export default function ReportHeader({
168
172
  />
169
173
  )}
170
174
  {typographyList &&
171
- typographyList.map((s) => (
172
- <Typography variant={s.variant || 'body1'} sx={s.sx}>
175
+ typographyList.map((s, index) => (
176
+ <Typography key={index} variant={s.variant || 'body1'} sx={s.sx}>
173
177
  {s.text}
174
178
  </Typography>
175
179
  ))}
@@ -1,4 +1,4 @@
1
- import { SelectProps } from '@mui/material'
1
+ import { BaseSelectProps } from '@mui/material'
2
2
  import { useEffect, useState } from 'react'
3
3
  import axios from '../../config/axios'
4
4
  import { SingleSelect } from '../Input'
@@ -13,7 +13,7 @@ type ClassRoomSelectorProps = {
13
13
  error?: boolean
14
14
  helperText?: string
15
15
  api?: string
16
- } & SelectProps
16
+ } & BaseSelectProps
17
17
  const ClassRoomSelector = (props: ClassRoomSelectorProps) => {
18
18
  const {
19
19
  name,
@@ -1,4 +1,4 @@
1
- import { SelectProps } from '@mui/material'
1
+ import { BaseSelectProps } from '@mui/material'
2
2
  import { useEffect, useState } from 'react'
3
3
  import axios from '../../config/axios'
4
4
  import { SingleSelect } from '../Input'
@@ -13,7 +13,7 @@ type CourseSelectorProps = {
13
13
  helperText?: string
14
14
  api?: string
15
15
  valueByUniqueId?: boolean
16
- } & SelectProps
16
+ } & BaseSelectProps
17
17
  export default function CourseSelector(props: CourseSelectorProps) {
18
18
  const {
19
19
  name,
@@ -1,4 +1,4 @@
1
- import { SelectProps } from '@mui/material'
1
+ import { BaseSelectProps } from '@mui/material'
2
2
  import { useEffect, useState } from 'react'
3
3
  import axios from '../../config/axios'
4
4
  import { SingleSelect } from '../Input'
@@ -12,7 +12,7 @@ type DepartmentSelectorProps = {
12
12
  error?: boolean
13
13
  helperText?: string
14
14
  api?: string
15
- } & SelectProps
15
+ } & BaseSelectProps
16
16
  export default function DepartmentSelector(props: DepartmentSelectorProps) {
17
17
  const {
18
18
  name,
@@ -1,4 +1,4 @@
1
- import { SelectProps } from '@mui/material'
1
+ import { BaseSelectProps } from '@mui/material'
2
2
  import { useEffect, useState } from 'react'
3
3
  import axios from '../../config/axios'
4
4
  import { SingleSelect } from '../Input'
@@ -12,7 +12,7 @@ type ExamGroupSelectorProps = {
12
12
  allowAll?: boolean
13
13
  error?: boolean
14
14
  helperText?: string
15
- } & SelectProps
15
+ } & BaseSelectProps
16
16
  const ExamGroupSelector = (props: ExamGroupSelectorProps) => {
17
17
  const {
18
18
  name,
@@ -26,13 +26,13 @@ const ExamGroupSelector = (props: ExamGroupSelectorProps) => {
26
26
  const [prevExamType, setPrevExamType] = useState(null)
27
27
  const [prevCourseId, setPrevCourseId] = useState(null)
28
28
  let api =
29
- filters.examType !== 'internal'
29
+ filters?.examType !== 'internal'
30
30
  ? '/exams/exams/exam-groups'
31
31
  : '/exams/internal-exams'
32
32
  const handleOpen = () => {
33
33
  if (filters) {
34
34
  if (
35
- (filters.examType && filters.examType !== prevExamType) ||
35
+ (filters?.examType && filters?.examType !== prevExamType) ||
36
36
  (filters?.courseId && filters?.courseId !== prevCourseId)
37
37
  ) {
38
38
  setOptions([])
@@ -46,12 +46,12 @@ const ExamGroupSelector = (props: ExamGroupSelectorProps) => {
46
46
  })
47
47
  .then((response) => {
48
48
  setOptions(
49
- filters.examType !== 'internal'
49
+ filters?.examType !== 'internal'
50
50
  ? response.data?.examGroups
51
51
  : response.data?.exams,
52
52
  )
53
- setPrevExamType(filters.examType)
54
- setPrevCourseId(filters.courseId)
53
+ setPrevExamType(filters?.examType)
54
+ setPrevCourseId(filters?.courseId)
55
55
  })
56
56
  .catch((error) => {
57
57
  console.error('Error fetching data from the API:', error)
@@ -59,9 +59,18 @@ const ExamGroupSelector = (props: ExamGroupSelectorProps) => {
59
59
  }
60
60
  } else if (options.length === 0) {
61
61
  axios
62
- .get(api)
62
+ .get(api, {
63
+ params: {
64
+ isArchived: 'false',
65
+ isExamPublished: 'true',
66
+ },
67
+ })
63
68
  .then((response) => {
64
- setOptions(response.data)
69
+ setOptions(
70
+ filters?.examType !== 'internal'
71
+ ? response.data?.examGroups
72
+ : response.data?.exams,
73
+ )
65
74
  })
66
75
  .catch((error) => {
67
76
  console.error('Error fetching data from the API:', error)
@@ -80,7 +89,7 @@ const ExamGroupSelector = (props: ExamGroupSelectorProps) => {
80
89
  ...(allowAll ? [{ value: 'all', label: 'All' }] : []),
81
90
  ...options.map((item) => ({
82
91
  label:
83
- filters.examType != 'internal'
92
+ filters?.examType != 'internal'
84
93
  ? item?.groupName
85
94
  : item?.displayName,
86
95
  value: item?.id,
@@ -1,4 +1,4 @@
1
- import { SelectProps } from '@mui/material'
1
+ import { BaseSelectProps } from '@mui/material'
2
2
  import { useEffect, useState } from 'react'
3
3
  import axios from '../../config/axios'
4
4
  import { SingleSelect } from '../Input'
@@ -18,7 +18,7 @@ type FacultySelectorProps = {
18
18
  error?: boolean
19
19
  helperText?: string
20
20
  api?: string
21
- } & SelectProps
21
+ } & BaseSelectProps
22
22
  const FacultySelector = (props: FacultySelectorProps) => {
23
23
  const {
24
24
  name,
@@ -1,4 +1,4 @@
1
- import { SelectProps } from '@mui/material'
1
+ import { BaseSelectProps } from '@mui/material'
2
2
  import { useEffect, useState } from 'react'
3
3
  import axios from '../../config/axios'
4
4
  import { SingleSelect } from '../Input'
@@ -11,7 +11,7 @@ type FeeTypeSelectorProps = {
11
11
  onChange?: (value: any) => void
12
12
  error?: boolean
13
13
  helperText?: string
14
- } & SelectProps
14
+ } & BaseSelectProps
15
15
  export default function FeeTypeSelector(props: FeeTypeSelectorProps) {
16
16
  const { name, required = false, label, onChange, allowAll = true } = props
17
17
  const [options, setOptions] = useState([])
@@ -1,4 +1,4 @@
1
- import { SelectProps } from '@mui/material'
1
+ import { BaseSelectProps } from '@mui/material'
2
2
  import { Controller } from 'react-hook-form'
3
3
  import ClassRoomSelector from '../ClassRoomSelector'
4
4
 
@@ -12,7 +12,7 @@ type ClassRoomSelectorProps = {
12
12
  filters?: { programId: number; courseId: number; batch: string }
13
13
  onChange?: (value: any) => void
14
14
  api?: string
15
- } & SelectProps
15
+ } & BaseSelectProps
16
16
  export default function FormClassRoomSelector(props: ClassRoomSelectorProps) {
17
17
  const {
18
18
  name,
@@ -1,4 +1,4 @@
1
- import { SelectProps } from '@mui/material'
1
+ import { BaseSelectProps } from '@mui/material'
2
2
  import { Controller } from 'react-hook-form'
3
3
  import CourseSelector from '../CourseSelector'
4
4
 
@@ -12,7 +12,7 @@ type FormCourseSelectorProps = {
12
12
  onChange?: (value: any) => void
13
13
  api?: string
14
14
  valueByUniqueId?: boolean
15
- } & SelectProps
15
+ } & BaseSelectProps
16
16
  export default function FormCourseSelector(props: FormCourseSelectorProps) {
17
17
  const {
18
18
  name,
@@ -1,4 +1,4 @@
1
- import { SelectProps } from '@mui/material'
1
+ import { BaseSelectProps } from '@mui/material'
2
2
  import { Controller } from 'react-hook-form'
3
3
  import DepartmentSelector from '../DepartmentSelector'
4
4
 
@@ -11,7 +11,7 @@ type FormDepartmentSelectorProps = {
11
11
  allowAll?: boolean
12
12
  onChange?: (value: any) => void
13
13
  api?: string
14
- } & SelectProps
14
+ } & BaseSelectProps
15
15
  export default function FormDepartmentSelector(
16
16
  props: FormDepartmentSelectorProps,
17
17
  ) {
@@ -1,4 +1,4 @@
1
- import { SelectProps } from '@mui/material'
1
+ import { BaseSelectProps } from '@mui/material'
2
2
  import { Controller } from 'react-hook-form'
3
3
  import ExamGroupSelector from '../ExamGroupSelector'
4
4
 
@@ -11,7 +11,7 @@ type ExamGroupSelectorProps = {
11
11
  allowAll?: boolean
12
12
  filters?: { courseId: number; examType: string }
13
13
  onChange?: (value: any) => void
14
- } & SelectProps
14
+ } & BaseSelectProps
15
15
  export default function FormExamGroupSelector(props: ExamGroupSelectorProps) {
16
16
  const {
17
17
  name,
@@ -1,4 +1,4 @@
1
- import { SelectProps } from '@mui/material'
1
+ import { BaseSelectProps } from '@mui/material'
2
2
  import { Controller } from 'react-hook-form'
3
3
  import FacultySelector from '../FacultySelector'
4
4
 
@@ -17,7 +17,7 @@ type FacultySelectorProps = {
17
17
  }
18
18
  onChange?: (value: any) => void
19
19
  api?: string
20
- } & SelectProps
20
+ } & BaseSelectProps
21
21
  export default function FormFacultySelector(props: FacultySelectorProps) {
22
22
  const {
23
23
  name,
@@ -1,4 +1,4 @@
1
- import { SelectProps } from '@mui/material'
1
+ import { BaseSelectProps } from '@mui/material'
2
2
  import { Controller } from 'react-hook-form'
3
3
  import FeeTypeSelector from '../FeeTypeSelector'
4
4
 
@@ -11,7 +11,7 @@ type FormFeeTypeSelectorProps = {
11
11
  allowAll?: boolean
12
12
  onChange?: (value: any) => void
13
13
  api?: string
14
- } & SelectProps
14
+ } & BaseSelectProps
15
15
  export default function FormFeeTypeSelector(props: FormFeeTypeSelectorProps) {
16
16
  const {
17
17
  name,
@@ -1,4 +1,4 @@
1
- import { SelectProps } from '@mui/material'
1
+ import { BaseSelectProps } from '@mui/material'
2
2
  import { Controller } from 'react-hook-form'
3
3
  import ProgramSelector from '../ProgramSelector'
4
4
 
@@ -13,7 +13,7 @@ type ProgramSelectorProps = {
13
13
  onChange?: (value: any) => void
14
14
  api?: string
15
15
  valueByBranchCode?: boolean
16
- } & SelectProps
16
+ } & BaseSelectProps
17
17
  export default function FormProgramSelector(props: ProgramSelectorProps) {
18
18
  const {
19
19
  name,