@campxdev/shared 1.11.51 → 1.11.53

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.11.51",
3
+ "version": "1.11.53",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -8,6 +8,7 @@ import { Box, SxProps, Typography } from '@mui/material'
8
8
  import moment from 'moment'
9
9
  import { useCallback, useRef } from 'react'
10
10
  import { useInfiniteQuery } from 'react-query'
11
+ import { NoDataIllustration } from '..'
11
12
  import axios from '../../config/axios'
12
13
  import { useErrorModal } from '../ErrorModalWrapper/ErrorModalWrapper'
13
14
  import Spinner from '../Spinner'
@@ -22,19 +23,22 @@ import {
22
23
  interface Props {
23
24
  endPoint: string
24
25
  tableView: boolean
26
+ enableTitle?: boolean
27
+ params: any
25
28
  sx?: SxProps
26
29
  }
27
30
 
28
- export default function ActivityLog({ endPoint, tableView, sx }: Props) {
31
+ export default function ActivityLog({
32
+ endPoint,
33
+ tableView,
34
+ enableTitle,
35
+ params,
36
+ sx,
37
+ }: Props) {
29
38
  const errorModal = useErrorModal()
30
39
  const fetchActivities = async ({ pageParam = 0 }) => {
31
40
  try {
32
- const response = await axios.get(endPoint, {
33
- params: {
34
- limit: 30,
35
- // nextToken: pageParam,
36
- },
37
- })
41
+ const response = await axios.get(endPoint, { params: { ...params } })
38
42
  return response.data
39
43
  } catch (error) {
40
44
  // eslint-disable-next-line no-console
@@ -46,17 +50,33 @@ export default function ActivityLog({ endPoint, tableView, sx }: Props) {
46
50
  const { data, fetchNextPage, hasNextPage, isFetchingNextPage, isLoading } =
47
51
  useInfiniteQuery('activities', fetchActivities, {
48
52
  getNextPageParam: (lastPage) => {
49
- return lastPage.length ? lastPage[lastPage.length - 1].id : null
53
+ return lastPage?.length ? lastPage[lastPage?.length - 1].id : null
50
54
  },
51
55
  })
52
56
 
53
- const activitesData = data ? data.pages.flatMap((page) => page) : []
57
+ const activitesData = data ? data?.pages.flatMap((page) => page) : []
54
58
 
55
59
  if (isLoading) return <Spinner />
56
60
 
61
+ if (data.pages.length === 0 || !activitesData.length) {
62
+ return (
63
+ <NoDataIllustration
64
+ imageSrc=""
65
+ message={
66
+ <Typography
67
+ variant="h6"
68
+ style={{ textAlign: 'center', marginTop: '20px' }}
69
+ >
70
+ {'No data found'}
71
+ </Typography>
72
+ }
73
+ />
74
+ )
75
+ }
76
+
57
77
  return (
58
78
  <Box>
59
- {!tableView && (
79
+ {enableTitle && (
60
80
  <Typography
61
81
  variant="h1"
62
82
  sx={{ fontSize: '18px', fontWeight: 700, margin: '20px' }}
@@ -134,7 +154,7 @@ export const TimeLineComponent = ({
134
154
 
135
155
  return (
136
156
  <Timeline sx={{ padding: 0, margin: 0 }}>
137
- {activitesData.map((item, index, items) => (
157
+ {activitesData?.map((item, index, items) => (
138
158
  <Box
139
159
  key={index}
140
160
  ref={items.length - 1 === index ? lastItemRef : null}
@@ -167,12 +187,23 @@ export const TimeLineComponent = ({
167
187
  <Box>
168
188
  <Typography variant="subtitle2" sx={{ fontSize: '14px' }}>
169
189
  {moment
170
- .utc(item.timestamp)
190
+ .utc(item?.timestamp)
171
191
  .local()
172
192
  .format('DD MMM YYYY - hh:mm A')}
173
193
  </Typography>
174
- <Typography sx={{ fontSize: '16px' }} variant="body1">
175
- {item.message}
194
+ <Typography sx={{ fontSize: '16px' }} variant="subtitle1">
195
+ {item?.message.split("'").map((text: string, index: number) =>
196
+ index % 2 === 0 ? (
197
+ <span key={index}>{text}</span>
198
+ ) : (
199
+ <Typography
200
+ key={index}
201
+ sx={{ display: 'inline', fontWeight: 900 }}
202
+ >
203
+ {text}
204
+ </Typography>
205
+ ),
206
+ )}
176
207
  </Typography>
177
208
  <Typography
178
209
  style={{
@@ -182,10 +213,10 @@ export const TimeLineComponent = ({
182
213
  }}
183
214
  >
184
215
  <StyledAvatar>
185
- {item.userName.charAt(0).toUpperCase()}
216
+ {item?.userName.charAt(0).toUpperCase()}
186
217
  </StyledAvatar>
187
218
  <Typography sx={{ fontSize: '13px', fontWeight: 900 }}>
188
- {item.userName}
219
+ {item?.userName}
189
220
  </Typography>
190
221
  </Typography>
191
222
  </Box>
@@ -6,6 +6,7 @@ interface SwicthButtonProps {
6
6
  checked: boolean
7
7
  onChange: (v: any) => void
8
8
  subtitle?: ReactNode
9
+ disabled?: boolean
9
10
  }
10
11
 
11
12
  export default function SwitchButton({
@@ -13,13 +14,17 @@ export default function SwitchButton({
13
14
  checked,
14
15
  onChange,
15
16
  subtitle,
17
+ disabled,
16
18
  }: SwicthButtonProps) {
17
19
  return (
18
20
  <StyledBox>
19
21
  <Box sx={{ display: 'flex', alignItems: 'center', gap: '1rem' }}>
20
- <Typography variant="body1">{label}</Typography>
22
+ <Typography variant="body1" color={disabled ? 'grey' : 'black'}>
23
+ {label}
24
+ </Typography>
21
25
  <Switch
22
26
  checked={checked}
27
+ disabled={disabled}
23
28
  onChange={(e, checked) => onChange(checked)}
24
29
  />
25
30
  </Box>
@@ -1215,6 +1215,18 @@ export enum Permission {
1215
1215
  CAN_RESULTS_PROCESSING_PUBLISH_RESULTS = 'can_results_processing_publish_results',
1216
1216
  CAN_RESULTS_PROCESSING_UPDATE_INTERNAL_MARKS = 'can_results_processing_update_internal_marks',
1217
1217
 
1218
+ //Blocked Students
1219
+ CAN_BLOCKED_STUDENTS_VIEW = 'can_blocked_students_view',
1220
+ CAN_BLOCKED_STUDENTS_ADD = 'can_blocked_students_add',
1221
+ CAN_BLOCKED_STUDENTS_IMPORT = 'can_blocked_students_import',
1222
+ CAN_BLOCKED_STUDENTS_DELETE = 'can_blocked_students_delete',
1223
+ //student grades
1224
+ CAN_STUDENTS_GRADES_VIEW = 'can_students_grades_view',
1225
+ CAN_STUDENTS_GRADES_IMPORT = 'can_students_grades_import',
1226
+ //student memos
1227
+ CAN_STUDENTS_MEMOS_VIEW = 'can_students_memos_view',
1228
+ CAN_STUDENTS_MEMOS_GENERATE = 'can_students_memos_generate',
1229
+
1218
1230
  // Revaluation Fee Configuration
1219
1231
  CAN_REVALUATION_FEE_CONFIGURATION_VIEW = 'can_revaluation_fee_configuration_view',
1220
1232
  CAN_REVALUATION_FEE_CONFIGURATION_ADD = 'can_revaluation_fee_configuration_add',
@@ -1264,6 +1276,12 @@ export enum Permission {
1264
1276
  CAN_EVALUATORS_EDIT = 'can_evaluators_edit',
1265
1277
  CAN_EVALUATORS_DELETE = 'can_evaluators_delete',
1266
1278
 
1279
+ //Grade Templates
1280
+ CAN_GRADE_TEMPLATES_VIEW = 'can_grade_templates_view',
1281
+ CAN_GRADE_TEMPLATES_ADD = 'can_grade_templates_add',
1282
+ CAN_GRADE_TEMPLATES_EDIT = 'can_grade_templates_edit',
1283
+ CAN_GRADE_TEMPLATES_DELETE = 'can_grade_templates_delete',
1284
+
1267
1285
  // Grades
1268
1286
  CAN_GRADES_ADD = 'can_grades_add',
1269
1287
  CAN_GRADES_EDIT = 'can_grades_edit',